We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a57ec0 commit 39b7d00Copy full SHA for 39b7d00
packages/solid-charts/src/lib/utils.ts
@@ -2,10 +2,12 @@ import type { ChartContextType } from '@src/components/context'
2
import { scaleBand } from 'd3-scale'
3
4
const accessData = <T>(data: unknown, dataKey: string | undefined): T[] => {
5
- return (
6
- dataKey
7
- ? (data as Record<string, unknown>[]).map((entry) => entry[dataKey])
8
- : data
+ if (!dataKey) return data as T[]
+
+ const keys = dataKey.split('.')
9
+ return (data as Record<string, any>[]).map((entry) =>
10
+ keys.reduce((acc, key) => acc?.[key], entry),
11
) as T[]
12
}
13
0 commit comments