@react-fabric/chart 1.0.0-beta.52 → 1.0.0-beta.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cjs/charts/ActivityMap.js +36 -26
  2. package/dist/cjs/charts/CountSeries.js +17 -14
  3. package/dist/cjs/charts/DataSeries.js +30 -27
  4. package/dist/cjs/charts/Generic.js +15 -5
  5. package/dist/cjs/charts/MapSeries.js +9 -8
  6. package/dist/cjs/charts/TimeSeries.js +31 -28
  7. package/dist/cjs/charts/TimeSlider.js +9 -9
  8. package/dist/cjs/charts/WordBubble.js +11 -5
  9. package/dist/cjs/theme/darkBase.js +13 -10
  10. package/dist/cjs/theme/index.js +38 -18
  11. package/dist/cjs/theme/lightBase.js +18 -15
  12. package/dist/cjs/theme/palettes.js +27 -27
  13. package/dist/cjs/types/charts.js +2 -2
  14. package/dist/cjs/wrapper/ChartContainer.js +2 -1
  15. package/dist/cjs/wrapper/ChartToolbar.js +1 -1
  16. package/dist/esm/charts/ActivityMap.js +36 -26
  17. package/dist/esm/charts/CountSeries.js +17 -14
  18. package/dist/esm/charts/DataSeries.js +30 -27
  19. package/dist/esm/charts/Generic.js +17 -7
  20. package/dist/esm/charts/MapSeries.js +9 -8
  21. package/dist/esm/charts/TimeSeries.js +31 -28
  22. package/dist/esm/charts/TimeSlider.js +9 -9
  23. package/dist/esm/charts/WordBubble.js +11 -5
  24. package/dist/esm/theme/darkBase.js +13 -10
  25. package/dist/esm/theme/index.js +38 -18
  26. package/dist/esm/theme/lightBase.js +18 -15
  27. package/dist/esm/theme/palettes.js +27 -27
  28. package/dist/esm/types/charts.js +2 -2
  29. package/dist/esm/wrapper/ChartContainer.js +2 -1
  30. package/dist/esm/wrapper/ChartToolbar.js +1 -1
  31. package/dist/types/charts/ActivityMap.d.ts +1 -1
  32. package/dist/types/charts/MapSeries.d.ts +7 -2
  33. package/dist/types/charts/TimeSlider.d.ts +1 -1
  34. package/dist/types/charts/WordBubble.d.ts +7 -2
  35. package/dist/types/theme/darkBase.d.ts +8 -5
  36. package/dist/types/theme/index.d.ts +1 -1
  37. package/dist/types/theme/lightBase.d.ts +8 -5
  38. package/dist/types/types/charts.d.ts +1 -1
  39. package/dist/types/types/index.d.ts +30 -12
  40. package/package.json +3 -3
  41. package/src/charts/ActivityMap.tsx +75 -55
  42. package/src/charts/CountSeries.tsx +53 -41
  43. package/src/charts/DataSeries.tsx +98 -73
  44. package/src/charts/Generic.tsx +11 -4
  45. package/src/charts/MapSeries.tsx +33 -23
  46. package/src/charts/TimeSeries.tsx +87 -72
  47. package/src/charts/TimeSlider.tsx +12 -9
  48. package/src/charts/WordBubble.tsx +14 -7
  49. package/src/theme/darkBase.ts +12 -9
  50. package/src/theme/index.ts +94 -20
  51. package/src/theme/lightBase.ts +17 -14
  52. package/src/theme/palettes.ts +1 -52
  53. package/src/types/charts.ts +6 -2
  54. package/src/types/index.ts +40 -4
  55. package/src/wrapper/ChartContainer.tsx +1 -0
  56. package/src/wrapper/ChartToolbar.tsx +1 -1
@@ -31,7 +31,6 @@ import {
31
31
  import { isArray, isEmpty } from "@react-fabric/utilities";
32
32
  import { type EChartOption, type EChartsType } from "echarts";
33
33
  import { memo, useEffect, useRef, useState, type FC } from "react";
34
- import { ChartPalette } from "../theme/palettes";
35
34
  import { type BaseChart } from "../types";
36
35
  import { activityRenderer } from "../types/utils";
37
36
  import { ChartContainer } from "../wrapper/ChartContainer";
@@ -40,7 +39,7 @@ import { PaletteSelect } from "../wrapper/PaletteSelect";
40
39
 
41
40
  export interface ActivityMapProps extends BaseChart {
42
41
  heatmapPalette?: string[];
43
- data: Array<Array<[low: number, high: number, count: number]>>;
42
+ series: Array<Array<[low: number, high: number, count: number]>>;
44
43
  time?: "day-hour" | "month-day";
45
44
  type?: "scatter" | "heatmap";
46
45
  /**
@@ -135,13 +134,16 @@ const MONTH_DAY = {
135
134
 
136
135
  const ActivityMapChart = memo(
137
136
  ({
138
- data = [],
137
+ series = [],
139
138
  title,
140
139
  onExport,
140
+ options: optionOverride,
141
141
  theme: chartTheme = "activity",
142
142
  heatmapPalette,
143
143
  highLabels,
144
144
  lowLabels,
145
+ showThemeSelector,
146
+ showTypeSelector,
145
147
  time = "day-hour",
146
148
  type: chartType = "scatter",
147
149
  onClick,
@@ -161,13 +163,13 @@ const ActivityMapChart = memo(
161
163
  () => {
162
164
  const defaultMap = time === "day-hour" ? DAY_HOUR : MONTH_DAY;
163
165
 
164
- const options: KeyValue = {
166
+ const options: EChartOption = {
165
167
  series: [],
166
168
  };
167
169
 
168
- if (isEmpty(data)) return {};
170
+ if (isEmpty(series)) return {};
169
171
 
170
- options.xAxis = {
172
+ options.xAxis = Object.assign({}, optionOverride?.xAxis, {
171
173
  type: "category",
172
174
  data: lowLabels ?? defaultMap.low,
173
175
  boundaryGap: type === "heatmap",
@@ -177,8 +179,8 @@ const ActivityMapChart = memo(
177
179
  axisLine: {
178
180
  show: false,
179
181
  },
180
- };
181
- options.yAxis = {
182
+ });
183
+ options.yAxis = Object.assign({}, optionOverride?.yAxis, {
182
184
  type: "category",
183
185
  axisLabel: {
184
186
  margin: 16,
@@ -187,11 +189,11 @@ const ActivityMapChart = memo(
187
189
  axisLine: {
188
190
  show: false,
189
191
  },
190
- };
191
- options.series = data.map((points, index) => {
192
+ });
193
+ options.series = series.map((points, index) => {
192
194
  const total = points.reduce((t, p) => t + p[2], 0);
193
195
  return {
194
- id: index,
196
+ id: `${index}`,
195
197
  name: defaultMap.high[index],
196
198
  type,
197
199
  symbolSize: function (dataItem: number[]) {
@@ -201,28 +203,37 @@ const ActivityMapChart = memo(
201
203
  },
202
204
  data: points,
203
205
  universalTransition: true,
204
- };
206
+ } as EChartOption.SeriesScatter;
205
207
  });
206
208
 
207
209
  if (type === "heatmap") {
208
- const dataPoints = data.map((points) =>
210
+ const dataPoints = series.map((points) =>
209
211
  Math.max(...points.map((pt) => pt[2])),
210
212
  );
211
213
  options.grid = {
212
214
  top: 32,
213
- bottom: 128,
215
+ bottom: 64,
214
216
  };
215
- options.visualMap = {
216
- type: "piecewise",
217
- min: 1,
218
- show: type === "heatmap",
219
- color: heatmapPalette ?? [...ChartPalette.Heatmap],
220
- max: Math.max(...dataPoints),
221
- calculable: true,
222
- orient: "horizontal",
223
- left: "center",
224
- bottom: 48,
217
+ options.legend = {
218
+ show: false,
225
219
  };
220
+ options.visualMap = [
221
+ {
222
+ type: "piecewise",
223
+ min: 1,
224
+ show: type === "heatmap",
225
+ max: Math.max(...dataPoints),
226
+ // calculable: true,inRange:
227
+ orient: "horizontal",
228
+ left: "center",
229
+ bottom: 4,
230
+ },
231
+ ];
232
+ if (heatmapPalette) {
233
+ options.visualMap[0].inRange = {
234
+ color: heatmapPalette,
235
+ };
236
+ }
226
237
  }
227
238
 
228
239
  return {
@@ -230,18 +241,23 @@ const ActivityMapChart = memo(
230
241
  top: 32,
231
242
  bottom: 64,
232
243
  },
233
- tooltip: {
234
- trigger: "item",
235
- confine: true,
236
- position: "top",
237
- valueFormatter: (c: AnyObject) => {
238
- return isArray(c) ? c[2] : c;
239
- },
240
- } as AnyObject,
244
+ tooltip: Object.assign(
245
+ {
246
+ trigger: "item",
247
+ confine: true,
248
+ position: "top",
249
+ appendToBody: true,
250
+ valueFormatter: (c: AnyObject) => {
251
+ return isArray(c) ? c[2] : c;
252
+ },
253
+ } as AnyObject,
254
+ optionOverride?.tooltip,
255
+ ),
256
+ ...optionOverride,
241
257
  ...options,
242
258
  };
243
259
  },
244
- [data, title, type],
260
+ [series, title, type, heatmapPalette, optionOverride],
245
261
  "ActivityChart options",
246
262
  );
247
263
 
@@ -252,33 +268,37 @@ const ActivityMapChart = memo(
252
268
  theme={theme}
253
269
  options={options}
254
270
  chartRef={chartRef}
255
- isEmpty={isEmpty(data)}
271
+ isEmpty={isEmpty(series)}
256
272
  emptyIcon={CoreIcons.chartActivityScatter}
257
273
  dataTableRenderer={activityRenderer}
258
274
  onClick={(e) => onClick?.(e.seriesIndex, e.dataIndex)}
259
275
  >
260
- <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
261
- <Button
262
- size="sm"
263
- variant="link"
264
- value="scatter"
265
- aria-label="scatter"
266
- icon={CoreIcons.chartActivityScatter}
267
- />
268
- <Button
269
- size="sm"
270
- variant="link"
271
- value="heatmap"
272
- aria-label="heatmap"
273
- icon={CoreIcons.chartActivityCalendar}
276
+ {showTypeSelector && (
277
+ <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
278
+ <Button
279
+ size="sm"
280
+ variant="link"
281
+ value="scatter"
282
+ aria-label="scatter"
283
+ icon={CoreIcons.chartActivityScatter}
284
+ />
285
+ <Button
286
+ size="sm"
287
+ variant="link"
288
+ value="heatmap"
289
+ aria-label="heatmap"
290
+ icon={CoreIcons.chartActivityCalendar}
291
+ />
292
+ </ToggleButtonGroup>
293
+ )}
294
+ {showTypeSelector && showThemeSelector && <Divider vertical />}
295
+ {showThemeSelector && (
296
+ <PaletteSelect
297
+ theme={theme}
298
+ onClick={setTheme}
299
+ defaultTheme="activity"
274
300
  />
275
- </ToggleButtonGroup>
276
- <Divider vertical />
277
- <PaletteSelect
278
- theme={theme}
279
- onClick={setTheme}
280
- defaultTheme="activity"
281
- />
301
+ )}
282
302
  </ChartContainer>
283
303
  );
284
304
  },
@@ -44,11 +44,14 @@ export interface CountSeriesProps extends BaseChart, CountType {
44
44
 
45
45
  const CountSeriesChart: FC<CountSeriesProps> = memo(
46
46
  ({
47
- data,
47
+ series: _series,
48
48
  title,
49
49
  onExport,
50
50
  theme: chartTheme,
51
51
  type: chartType = "pie",
52
+ options: optionOverride,
53
+ showThemeSelector,
54
+ showTypeSelector,
52
55
  onClick,
53
56
  }: CountSeriesProps) => {
54
57
  const chartRef = useRef<EChartsType>(null);
@@ -64,28 +67,32 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
64
67
 
65
68
  const options = useMemoDebugger<EChartOption>(
66
69
  () => {
67
- if (isEmpty(data)) {
70
+ if (isEmpty(_series)) {
68
71
  chartRef.current?.clear();
69
72
  return {};
70
73
  }
71
74
 
72
- const sorted = data?.sort(compareValues("desc", "count"));
75
+ const sorted = _series?.sort(compareValues("desc", "count"));
73
76
 
74
- const categoryAxis: AnyObject = {
75
- type: "category",
76
- name: title ?? "Count Series",
77
- nameLocation: "center",
78
- axisTick: {
79
- show: false,
80
- },
81
- data: [],
82
- } as EChartOption.XAxis;
83
- const valueAxis: AnyObject = {
77
+ const categoryAxis: AnyObject = Object.assign(
78
+ {},
79
+ optionOverride?.xAxis,
80
+ {
81
+ type: "category",
82
+ name: title ?? "Count Series",
83
+ nameLocation: "center",
84
+ axisTick: {
85
+ show: false,
86
+ },
87
+ data: [],
88
+ } as EChartOption.XAxis,
89
+ );
90
+ const valueAxis: AnyObject = Object.assign({}, optionOverride?.yAxis, {
84
91
  type: "value",
85
92
  axisLabel: {
86
93
  formatter: (val: AnyObject) => Format.number(val),
87
94
  },
88
- } as EChartOption.YAxis;
95
+ } as EChartOption.YAxis);
89
96
 
90
97
  const series =
91
98
  type === "pie"
@@ -121,6 +128,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
121
128
  universalTransition: true,
122
129
  }));
123
130
  return {
131
+ ...optionOverride,
124
132
  series,
125
133
  countSeries: true,
126
134
  xAxis:
@@ -129,7 +137,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
129
137
  type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis,
130
138
  };
131
139
  },
132
- [data, title, type],
140
+ [_series, title, type, optionOverride],
133
141
  "CountChart options",
134
142
  );
135
143
 
@@ -140,36 +148,40 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
140
148
  theme={theme}
141
149
  options={options}
142
150
  chartRef={chartRef}
143
- isEmpty={isEmpty(data)}
151
+ isEmpty={isEmpty(_series)}
144
152
  emptyIcon={CoreIcons.chartPie}
145
153
  dataTableRenderer={countRenderer}
146
154
  onClick={(e) => onClick?.(e.data.id ?? e.seriesId)}
147
155
  >
148
- <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
149
- <Button
150
- size="sm"
151
- variant="link"
152
- value="pie"
153
- aria-label="pie"
154
- icon={CoreIcons.chartPie}
155
- />
156
- <Button
157
- size="sm"
158
- variant="link"
159
- value="column"
160
- aria-label="column"
161
- icon={CoreIcons.chartColumn}
162
- />
163
- <Button
164
- size="sm"
165
- variant="link"
166
- value="bar"
167
- aria-label="bar"
168
- icon={CoreIcons.chartBar}
169
- />
170
- </ToggleButtonGroup>
171
- <Divider vertical />
172
- <PaletteSelect theme={theme} onClick={setTheme} />
156
+ {showTypeSelector && (
157
+ <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
158
+ <Button
159
+ size="sm"
160
+ variant="link"
161
+ value="pie"
162
+ aria-label="pie"
163
+ icon={CoreIcons.chartPie}
164
+ />
165
+ <Button
166
+ size="sm"
167
+ variant="link"
168
+ value="column"
169
+ aria-label="column"
170
+ icon={CoreIcons.chartColumn}
171
+ />
172
+ <Button
173
+ size="sm"
174
+ variant="link"
175
+ value="bar"
176
+ aria-label="bar"
177
+ icon={CoreIcons.chartBar}
178
+ />
179
+ </ToggleButtonGroup>
180
+ )}
181
+ {showTypeSelector && showThemeSelector && <Divider vertical />}
182
+ {showThemeSelector && (
183
+ <PaletteSelect theme={theme} onClick={setTheme} />
184
+ )}
173
185
  </ChartContainer>
174
186
  );
175
187
  },
@@ -51,12 +51,15 @@ export interface DataSeriesProps extends BaseChart, SeriesType {
51
51
 
52
52
  const DataSeriesChart: FC<DataSeriesProps> = memo(
53
53
  ({
54
- data,
54
+ series: _series,
55
55
  onExport,
56
56
  categories,
57
57
  categoryAxisName,
58
58
  valueAxisName,
59
59
  title,
60
+ options: optionOverride,
61
+ showThemeSelector,
62
+ showTypeSelector,
60
63
  theme: chartTheme,
61
64
  type: chartType = "column",
62
65
  onClick,
@@ -74,7 +77,7 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
74
77
 
75
78
  const options = useMemoDebugger<EChartOption>(
76
79
  () => {
77
- if (isEmpty(data)) {
80
+ if (isEmpty(_series)) {
78
81
  chartRef.current?.clear();
79
82
  return {};
80
83
  }
@@ -82,7 +85,9 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
82
85
  const stack = type.includes("stacked") ? "stack" : undefined;
83
86
 
84
87
  const [_type, stacked] = type.split("-");
85
- const categoryAxis: AnyObject =
88
+ const categoryAxis: AnyObject = Object.assign(
89
+ {},
90
+ optionOverride?.xAxis,
86
91
  _type === "radar"
87
92
  ? undefined
88
93
  : ({
@@ -94,8 +99,11 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
94
99
  show: false,
95
100
  },
96
101
  data: categories,
97
- } as EChartOption.XAxis);
98
- const valueAxis: AnyObject =
102
+ } as EChartOption.XAxis),
103
+ );
104
+ const valueAxis: AnyObject = Object.assign(
105
+ {},
106
+ optionOverride?.yAxis,
99
107
  _type === "radar"
100
108
  ? undefined
101
109
  : ({
@@ -103,18 +111,19 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
103
111
  type: "value",
104
112
  nameGap: 32,
105
113
  nameLocation: "center",
106
- } as EChartOption.YAxis);
114
+ } as EChartOption.YAxis),
115
+ );
107
116
  const radar =
108
117
  _type !== "radar"
109
118
  ? undefined
110
- : ({
119
+ : Object.assign({}, optionOverride?.radar, {
111
120
  shape: "circle",
112
121
  indicator: categories?.map((c) => ({ name: c })),
113
122
  } as AnyObject);
114
123
 
115
- const series = data?.map((item, index) => ({
116
- id: item.id,
117
- stack,
124
+ const series = _series?.map((item, index) => ({
125
+ ...item,
126
+ stack: item.stack ?? stack,
118
127
  areaStyle: stacked ? {} : undefined,
119
128
  type: _type === "column" ? "bar" : _type,
120
129
  name: item.label ?? item.id,
@@ -123,27 +132,39 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
123
132
  _type === "radar"
124
133
  ? [
125
134
  {
126
- value: item.values,
135
+ value: item.data,
127
136
  id: item.id,
128
- name: item.label ?? item.id,
137
+ name: item.name ?? item.id,
129
138
  },
130
139
  ]
131
- : item.values,
140
+ : item.data,
132
141
  }));
133
142
 
134
143
  return {
144
+ ...optionOverride,
135
145
  xAxis: type.startsWith("bar") ? valueAxis : categoryAxis,
136
146
  yAxis: type.startsWith("bar") ? categoryAxis : valueAxis,
137
147
  radar,
138
148
  series,
139
- tooltip: {
140
- trigger: _type === "radar" ? "item" : "axis",
141
- confine: true,
142
- position: "top",
143
- } as AnyObject,
149
+ tooltip: Object.assign(
150
+ {
151
+ trigger: _type === "radar" ? "item" : "axis",
152
+ confine: true,
153
+ position: "top",
154
+ appendToBody: true,
155
+ } as AnyObject,
156
+ optionOverride?.tooltip,
157
+ ),
144
158
  };
145
159
  },
146
- [data, type, categories, categoryAxisName, valueAxisName],
160
+ [
161
+ _series,
162
+ type,
163
+ categories,
164
+ categoryAxisName,
165
+ valueAxisName,
166
+ optionOverride,
167
+ ],
147
168
  "DataChart options",
148
169
  );
149
170
 
@@ -154,64 +175,68 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
154
175
  theme={theme}
155
176
  options={options}
156
177
  chartRef={chartRef}
157
- isEmpty={isEmpty(data)}
178
+ isEmpty={isEmpty(_series)}
158
179
  emptyIcon={CoreIcons.chartColumn}
159
180
  dataTableRenderer={seriesRenderer}
160
181
  onClick={(e) => onClick?.({ category: e.name, series: e.seriesId })}
161
182
  >
162
- <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
163
- <Button
164
- size="sm"
165
- variant="link"
166
- icon={CoreIcons.chartLine}
167
- aria-label="line"
168
- value="line"
169
- />
170
- <Button
171
- size="sm"
172
- variant="link"
173
- icon={CoreIcons.chartColumn}
174
- aria-label="column"
175
- value="column"
176
- />
177
- <Button
178
- size="sm"
179
- variant="link"
180
- icon={CoreIcons.chartBar}
181
- aria-label="bar"
182
- value="bar"
183
- />
184
- <Button
185
- size="sm"
186
- variant="link"
187
- icon={CoreIcons.chartRadar}
188
- aria-label="radar"
189
- value="radar"
190
- />
191
- <Button
192
- size="sm"
193
- variant="link"
194
- icon={CoreIcons.chartLineStacked}
195
- aria-label="line-stacked"
196
- value="line-stacked"
197
- />
198
- <Button
199
- size="sm"
200
- variant="link"
201
- icon={CoreIcons.chartColumnStacked}
202
- aria-label="column-stacked"
203
- value="column-stacked"
204
- />
205
- <Button
206
- size="sm"
207
- variant="link"
208
- icon={CoreIcons.chartBarStacked}
209
- aria-label="bar-stacked"
210
- value="bar-stacked"
211
- />
212
- </ToggleButtonGroup>
213
- <Divider vertical />
214
- <PaletteSelect theme={theme} onClick={setTheme} />
183
+ {showTypeSelector && (
184
+ <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
185
+ <Button
186
+ size="sm"
187
+ variant="link"
188
+ icon={CoreIcons.chartLine}
189
+ aria-label="line"
190
+ value="line"
191
+ />
192
+ <Button
193
+ size="sm"
194
+ variant="link"
195
+ icon={CoreIcons.chartColumn}
196
+ aria-label="column"
197
+ value="column"
198
+ />
199
+ <Button
200
+ size="sm"
201
+ variant="link"
202
+ icon={CoreIcons.chartBar}
203
+ aria-label="bar"
204
+ value="bar"
205
+ />
206
+ <Button
207
+ size="sm"
208
+ variant="link"
209
+ icon={CoreIcons.chartRadar}
210
+ aria-label="radar"
211
+ value="radar"
212
+ />
213
+ <Button
214
+ size="sm"
215
+ variant="link"
216
+ icon={CoreIcons.chartLineStacked}
217
+ aria-label="line-stacked"
218
+ value="line-stacked"
219
+ />
220
+ <Button
221
+ size="sm"
222
+ variant="link"
223
+ icon={CoreIcons.chartColumnStacked}
224
+ aria-label="column-stacked"
225
+ value="column-stacked"
226
+ />
227
+ <Button
228
+ size="sm"
229
+ variant="link"
230
+ icon={CoreIcons.chartBarStacked}
231
+ aria-label="bar-stacked"
232
+ value="bar-stacked"
233
+ />
234
+ </ToggleButtonGroup>
235
+ )}
236
+ {showTypeSelector && showThemeSelector && <Divider vertical />}
237
+ {showThemeSelector && (
238
+ <PaletteSelect theme={theme} onClick={setTheme} />
239
+ )}
215
240
  </ChartContainer>
216
241
  );
217
242
  },
@@ -27,12 +27,14 @@ import {
27
27
  useEffect,
28
28
  useImperativeHandle,
29
29
  useRef,
30
+ useState,
30
31
  type FC,
31
32
  type Ref,
32
33
  } from "react";
33
34
  import { type BaseChart } from "../types";
34
35
  import { ChartContainer } from "../wrapper/ChartContainer";
35
36
  import { ChartWrapper } from "../wrapper/ChartWrapper";
37
+ import { PaletteSelect } from "../wrapper/PaletteSelect";
36
38
 
37
39
  export interface GenericProps extends BaseChart {
38
40
  chartRef?: Ref<EChartsType>;
@@ -96,7 +98,7 @@ export interface GenericProps extends BaseChart {
96
98
  dataTableRenderer?: (chartOption: EChartOption) => string;
97
99
  }
98
100
 
99
- const GenericChartBase: FC<GenericProps> = memo(
101
+ const GenericChartBase = memo(
100
102
  ({
101
103
  chartRef: _ref,
102
104
  onBrush,
@@ -105,12 +107,14 @@ const GenericChartBase: FC<GenericProps> = memo(
105
107
  dataTableRenderer,
106
108
  onClick,
107
109
  onRendered,
110
+ showThemeSelector,
108
111
  actions,
109
112
  title,
110
- theme,
113
+ theme: chartTheme,
111
114
  ...options
112
- }: GenericProps) => {
115
+ }: Omit<GenericProps, "showTypeSelector">) => {
113
116
  const chartRef = useRef<EChartsType>(null);
117
+ const [theme, setTheme] = useState(chartTheme);
114
118
 
115
119
  useImperativeHandle<EChartsType | null, EChartsType | null>(
116
120
  _ref,
@@ -170,13 +174,16 @@ const GenericChartBase: FC<GenericProps> = memo(
170
174
 
171
175
  return (
172
176
  <ChartContainer
173
- theme={theme}
174
177
  options={options}
175
178
  chartRef={chartRef}
179
+ theme={theme}
176
180
  title={title}
177
181
  dataTableRenderer={dataTableRenderer}
178
182
  >
179
183
  {actions}
184
+ {showThemeSelector && (
185
+ <PaletteSelect theme={theme} onClick={setTheme} />
186
+ )}
180
187
  </ChartContainer>
181
188
  );
182
189
  },