({
value,
onChange,
isNotChartComponent,
columns,
}: ChartSeriesProps)
| 14 | } |
| 15 | |
| 16 | export default function ChartSeries({ |
| 17 | value, |
| 18 | onChange, |
| 19 | isNotChartComponent, |
| 20 | columns, |
| 21 | }: ChartSeriesProps) { |
| 22 | const { forcedTheme, resolvedTheme } = useTheme(); |
| 23 | if (isNotChartComponent) return null; |
| 24 | |
| 25 | return ( |
| 26 | <div className="pt-4"> |
| 27 | <div className="flex items-center justify-between pb-2"> |
| 28 | <p className="mb-1.5 text-sm font-bold opacity-70">Series</p> |
| 29 | <ButtonGroupItem |
| 30 | onClick={() => { |
| 31 | if (!value.params.options?.yAxisKeys) return; |
| 32 | if (value.params.options?.yAxisKeys.length === columns.length) |
| 33 | return; |
| 34 | |
| 35 | onChange((prev) => { |
| 36 | return produce(prev, (draft) => { |
| 37 | if (!draft.params.options.yAxisKeys) return; |
| 38 | draft.params.options.yAxisKeys.push( |
| 39 | columns.filter( |
| 40 | (key) => !draft.params.options.yAxisKeys?.includes(key) |
| 41 | )[0] |
| 42 | ); |
| 43 | }); |
| 44 | }); |
| 45 | }} |
| 46 | > |
| 47 | <p className="text-xs">Add Series</p> |
| 48 | </ButtonGroupItem> |
| 49 | </div> |
| 50 | |
| 51 | <div className="flex flex-col gap-2"> |
| 52 | {value.params.options?.yAxisKeys?.map((key, index) => { |
| 53 | const color = value.params.options?.yAxisKeyColors |
| 54 | ? value.params.options?.yAxisKeyColors[key] |
| 55 | : undefined; |
| 56 | return ( |
| 57 | <ChartSeriesCombobox |
| 58 | color={color} |
| 59 | key={index} |
| 60 | values={ |
| 61 | columns.map((s) => { |
| 62 | return { |
| 63 | value: s, |
| 64 | label: s, |
| 65 | }; |
| 66 | }) ?? [] |
| 67 | } |
| 68 | selected={key ?? ""} |
| 69 | placeholder="Select axis key..." |
| 70 | onChange={function (v: string): void { |
| 71 | onChange((prev) => { |
| 72 | return produce(prev, (draft) => { |
| 73 | if (!draft.params.options.yAxisKeys) return; |
nothing calls this directly
no test coverage detected