@react-fabric/chart 1.0.0-beta.9 → 1.0.2

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 (82) hide show
  1. package/{src/wrapper/Chart.module.css → css/_chart.css} +11 -11
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/charts/ActivityMap.js +70 -36
  4. package/dist/cjs/charts/CountSeries.js +67 -35
  5. package/dist/cjs/charts/DataSeries.js +75 -40
  6. package/dist/cjs/charts/Generic.js +41 -19
  7. package/dist/cjs/charts/MapSeries.js +41 -17
  8. package/dist/cjs/charts/TimeSeries.js +73 -40
  9. package/dist/cjs/charts/TimeSlider.js +40 -21
  10. package/dist/cjs/charts/WordBubble.js +65 -29
  11. package/dist/cjs/index.js +28 -0
  12. package/dist/cjs/theme/darkBase.js +13 -10
  13. package/dist/cjs/theme/index.js +43 -23
  14. package/dist/cjs/theme/lightBase.js +18 -15
  15. package/dist/cjs/theme/palettes.js +5 -54
  16. package/dist/cjs/types/charts.js +4 -2
  17. package/dist/cjs/types/utils.js +6 -9
  18. package/dist/cjs/wrapper/ChartContainer.js +26 -18
  19. package/dist/cjs/wrapper/ChartToolbar.js +4 -5
  20. package/dist/cjs/wrapper/ChartWrapper.js +4 -5
  21. package/dist/cjs/wrapper/PaletteSelect.js +31 -18
  22. package/dist/esm/charts/ActivityMap.js +71 -37
  23. package/dist/esm/charts/CountSeries.js +68 -36
  24. package/dist/esm/charts/DataSeries.js +76 -41
  25. package/dist/esm/charts/Generic.js +43 -21
  26. package/dist/esm/charts/MapSeries.js +41 -17
  27. package/dist/esm/charts/TimeSeries.js +74 -41
  28. package/dist/esm/charts/TimeSlider.js +41 -22
  29. package/dist/esm/charts/WordBubble.js +67 -31
  30. package/dist/esm/index.js +30 -0
  31. package/dist/esm/theme/darkBase.js +13 -10
  32. package/dist/esm/theme/index.js +43 -23
  33. package/dist/esm/theme/lightBase.js +18 -15
  34. package/dist/esm/theme/palettes.js +5 -54
  35. package/dist/esm/types/charts.js +4 -2
  36. package/dist/esm/types/utils.js +6 -9
  37. package/dist/esm/wrapper/ChartContainer.js +27 -19
  38. package/dist/esm/wrapper/ChartToolbar.js +4 -5
  39. package/dist/esm/wrapper/ChartWrapper.js +4 -5
  40. package/dist/esm/wrapper/PaletteSelect.js +32 -19
  41. package/dist/types/charts/ActivityMap.d.ts +20 -4
  42. package/dist/types/charts/CountSeries.d.ts +25 -3
  43. package/dist/types/charts/DataSeries.d.ts +26 -1
  44. package/dist/types/charts/Generic.d.ts +36 -52
  45. package/dist/types/charts/MapSeries.d.ts +31 -3
  46. package/dist/types/charts/TimeSeries.d.ts +24 -1
  47. package/dist/types/charts/TimeSlider.d.ts +19 -5
  48. package/dist/types/charts/WordBubble.d.ts +28 -5
  49. package/dist/types/index.d.ts +26 -0
  50. package/dist/types/theme/darkBase.d.ts +8 -5
  51. package/dist/types/theme/index.d.ts +3 -2
  52. package/dist/types/theme/lightBase.d.ts +8 -5
  53. package/dist/types/types/charts.d.ts +2 -1
  54. package/dist/types/types/index.d.ts +30 -12
  55. package/dist/types/types/world.svg.d.ts +1 -1
  56. package/dist/types/wrapper/ChartContainer.d.ts +7 -7
  57. package/dist/types/wrapper/ChartToolbar.d.ts +2 -3
  58. package/dist/types/wrapper/ChartWrapper.d.ts +3 -5
  59. package/dist/types/wrapper/PaletteSelect.d.ts +6 -1
  60. package/package.json +17 -21
  61. package/src/charts/ActivityMap.tsx +95 -94
  62. package/src/charts/CountSeries.tsx +73 -65
  63. package/src/charts/DataSeries.tsx +104 -98
  64. package/src/charts/Generic.tsx +56 -86
  65. package/src/charts/MapSeries.tsx +153 -151
  66. package/src/charts/TimeSeries.tsx +96 -79
  67. package/src/charts/TimeSlider.tsx +194 -195
  68. package/src/charts/WordBubble.tsx +97 -62
  69. package/src/index.ts +22 -17
  70. package/src/theme/darkBase.ts +12 -9
  71. package/src/theme/index.ts +92 -30
  72. package/src/theme/lightBase.ts +17 -14
  73. package/src/theme/palettes.ts +1 -52
  74. package/src/types/charts.ts +6 -2
  75. package/src/types/index.ts +40 -4
  76. package/src/types/utils.ts +18 -30
  77. package/src/wrapper/ChartContainer.tsx +48 -79
  78. package/src/wrapper/ChartToolbar.tsx +5 -12
  79. package/src/wrapper/ChartWrapper.tsx +5 -10
  80. package/src/wrapper/PaletteSelect.tsx +43 -40
  81. package/dist/cjs/wrapper/Chart.module.css +0 -1
  82. package/dist/esm/wrapper/Chart.module.css +0 -1
@@ -21,194 +21,196 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import {
25
- compareValues,
26
- Countries,
27
- Format,
28
- isEmpty,
29
- } from "@react-fabric/utilities";
24
+ import { Button, ToggleButtonGroup, useMemoDebugger } from "@react-fabric/core";
25
+ import { compareValues, Countries, Format, isEmpty } from "@react-fabric/utilities";
30
26
  import * as echarts from "echarts";
31
- import { type EChartOption, type EChartsType } from "echarts";
27
+ import { type EChartsOption, type EChartsType } from "echarts";
32
28
  import { memo, useEffect, useRef, useState, type FC } from "react";
33
29
  import { ChartPalette } from "../theme/palettes";
34
- import { type BaseChart, type CountType } from "../types";
30
+ import { type BaseChart } from "../types";
35
31
  import { countRenderer } from "../types/utils";
36
32
  import { ChartContainer } from "../wrapper/ChartContainer";
37
33
  import { ChartWrapper } from "../wrapper/ChartWrapper";
38
34
 
39
- import {
40
- Button,
41
- CoreIcons,
42
- ToggleButtonGroup,
43
- useMemoDebugger,
44
- } from "@react-fabric/core";
45
35
  import WorldMap from "../types/world.svg";
46
36
  echarts.registerMap("world", { svg: WorldMap });
47
37
 
48
- export interface MapSeriesProps extends BaseChart, CountType {
38
+ export interface MapSeriesProps extends BaseChart {
39
+ series: Array<{ id: string; label?: string; count: number }>;
49
40
  onClick?: (key: string) => void;
50
41
  }
51
42
 
52
- const MapSeriesChart: FC<MapSeriesProps> = memo(
53
- ({ data, onExport, theme: chartTheme, title, onClick }: MapSeriesProps) => {
54
- const chartRef = useRef<EChartsType>(null);
55
- const [type, setType] = useState("map");
56
- const [zoom, setZoom] = useState(1.25);
43
+ const MapSeriesChart: FC<MapSeriesProps> = memo(({ series, onExport, showTypeSelector, title, onClick }: MapSeriesProps) => {
44
+ const chartRef = useRef<EChartsType>(null);
45
+ const [type, setType] = useState("map");
46
+ const [zoom, setZoom] = useState(1.25);
57
47
 
58
- const options = useMemoDebugger<EChartOption>(
59
- () => {
60
- if (isEmpty(data)) return {};
48
+ const options = useMemoDebugger<EChartsOption>(
49
+ () => {
50
+ if (isEmpty(series)) return {};
61
51
 
62
- const sorted = data
63
- .map((d) => ({
64
- ...d,
65
- label: d.label ?? Countries.name(d.id),
66
- }))
67
- .sort(compareValues("desc", "count"));
68
- const valueMap = data.map((d) => d.count);
52
+ const sorted = series
53
+ .map((d) => ({
54
+ ...d,
55
+ label: d.label ?? Countries.name(d.id),
56
+ }))
57
+ .sort(compareValues("desc", "count"));
58
+ const valueMap = series.map((d) => d.count);
69
59
 
70
- if (type === "column") {
71
- return {
72
- xAxis: {
73
- type: "category",
74
- nameLocation: "center",
75
- axisTick: {
76
- show: false,
77
- },
78
- axisLabel: {
79
- rotate: 30,
80
- },
81
- data: [],
60
+ if (type === "column") {
61
+ return {
62
+ xAxis: {
63
+ type: "category",
64
+ nameLocation: "center",
65
+ axisTick: {
66
+ show: false,
82
67
  },
83
- yAxis: {
84
- type: "value",
85
- axisLabel: {
86
- formatter: (val: AnyObject) => Format.number(val),
87
- },
68
+ axisLabel: {
69
+ rotate: 30,
88
70
  },
89
- series: sorted.map((item, index) => ({
90
- id: item.id + index,
91
- type: "bar",
92
- label: {
93
- show: true,
94
- rotate: 90,
95
- formatter: "{a}",
96
- position: "inside",
97
- color: "#fff",
98
- },
99
- data: [
100
- {
101
- value: item.count,
102
- },
103
- ],
104
- name: item.label ?? item.id,
105
- universalTransition: true,
106
- })),
107
- } as AnyObject;
108
- }
109
-
110
- return {
111
- legend: {
112
- show: false,
71
+ data: [],
113
72
  },
114
- visualMap: {
115
- type: "piecewise",
116
- min: Math.min(...valueMap) - 1,
117
- max: Math.max(...valueMap) + 1,
118
- show: false,
119
- color: [...ChartPalette.Heatmap],
120
- calculable: true,
121
- orient: "horizontal",
122
- left: "center",
123
- bottom: 48,
124
- } as AnyObject,
125
- series: [
126
- {
127
- id: "mapseries",
128
- name: title ?? "Map Series",
129
- type: "map",
130
- map: "world",
131
- aspectScale: 1,
132
- roam: "move",
133
- colorBy: "data",
134
- nameProperty: "name",
135
- universalTransition: true,
136
- emphasis: {
137
- label: { show: false },
138
- },
139
- select: {
140
- disabled: true,
141
- },
142
- data: sorted.map(({ id, label: name, count: value }) => ({
143
- id,
144
- name,
145
- value,
146
- })),
73
+ yAxis: {
74
+ type: "value",
75
+ axisLabel: {
76
+ formatter: (val) => Format.number(val),
147
77
  },
148
- ],
78
+ },
79
+ series: sorted.map((item, index) => ({
80
+ id: item.id + index,
81
+ type: "bar",
82
+ label: {
83
+ show: true,
84
+ rotate: 90,
85
+ formatter: "{a}",
86
+ position: "inside",
87
+ color: "#fff",
88
+ },
89
+ data: [
90
+ {
91
+ value: item.count,
92
+ },
93
+ ],
94
+ name: item.label ?? item.id,
95
+ universalTransition: true,
96
+ })),
149
97
  };
150
- },
151
- [data, title, type],
152
- "MapChart options",
153
- );
154
-
155
- useEffect(() => {
156
- setZoom(1.25);
157
- }, [data, type]);
98
+ }
158
99
 
159
- useEffect(() => {
160
- chartRef.current?.setOption({
100
+ return {
101
+ legend: {
102
+ show: false,
103
+ },
104
+ visualMap: {
105
+ type: "piecewise",
106
+ min: Math.min(...valueMap) - 1,
107
+ max: Math.max(...valueMap) + 1,
108
+ show: false,
109
+ color: [...ChartPalette.Heatmap],
110
+ calculable: true,
111
+ orient: "horizontal",
112
+ left: "center",
113
+ bottom: 48,
114
+ },
161
115
  series: [
162
116
  {
163
- zoom,
117
+ id: "mapseries",
118
+ name: title ?? "Map Series",
119
+ type: "map",
120
+ map: "world",
121
+ aspectScale: 1,
122
+ roam: "move",
123
+ colorBy: "data",
124
+ nameProperty: "name",
125
+ universalTransition: true,
126
+ emphasis: {
127
+ label: { show: false },
128
+ },
129
+ select: {
130
+ disabled: true,
131
+ },
132
+ data: sorted.map(({ id, label: name, count: value }) => ({
133
+ id,
134
+ name,
135
+ value,
136
+ })),
164
137
  },
165
138
  ],
166
- });
167
- }, [zoom]);
139
+ };
140
+ },
141
+ [series, title, type],
142
+ "MapChart options",
143
+ );
168
144
 
169
- return (
170
- <ChartContainer
171
- title={title}
172
- onExport={onExport}
173
- chartRef={chartRef}
174
- options={options}
175
- dataTableRenderer={countRenderer}
176
- onClick={(e) => e.data && onClick?.(e?.data?.id ?? "")}
177
- >
178
- {type === "map" && (
179
- <input
180
- type="range"
181
- min={1.25}
182
- max={24}
183
- step={0.25}
184
- value={zoom}
185
- onChange={(e) => setZoom(e.target.valueAsNumber)}
186
- />
187
- )}
188
- <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
189
- <Button
190
- size="sm"
191
- variant="link"
192
- icon={CoreIcons.map}
193
- aria-label="map"
194
- value="map"
195
- />
145
+ useEffect(() => {
146
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
147
+ setZoom(1.25);
148
+ }, [series, type]);
149
+
150
+ useEffect(() => {
151
+ chartRef.current?.setOption({
152
+ series: [
153
+ {
154
+ zoom,
155
+ },
156
+ ],
157
+ });
158
+ }, [zoom]);
159
+
160
+ return (
161
+ <ChartContainer
162
+ title={title}
163
+ onExport={onExport}
164
+ chartRef={chartRef}
165
+ options={options}
166
+ dataTableRenderer={countRenderer}
167
+ onClick={(e) => e.data && onClick?.((e?.data as KeyValue<string>)?.id ?? "")}
168
+ >
169
+ {type === "map" && (
170
+ <input type="range" min={1.25} max={24} step={0.25} value={zoom} onChange={(e) => setZoom(e.target.valueAsNumber)} />
171
+ )}
172
+ {showTypeSelector && (
173
+ <ToggleButtonGroup value={type} onChange={setType}>
174
+ <Button size="sm" variant="link" icon="icon-[mdi--map]" aria-label="map" value="map" />
196
175
  <Button
197
176
  size="sm"
198
177
  variant="link"
199
- icon={CoreIcons.chartColumn}
178
+ icon="icon-[mdi--chart-bar] rotate-90 -scale-x-100"
200
179
  aria-label="column"
201
180
  value="column"
202
181
  />
203
182
  </ToggleButtonGroup>
204
- </ChartContainer>
205
- );
206
- },
207
- );
183
+ )}
184
+ </ChartContainer>
185
+ );
186
+ });
208
187
  MapSeriesChart.displayName = "MapSeriesChart";
209
188
 
210
189
  /**
211
- * Chart to display simple map data series
190
+ * MapSeries component renders a map chart using ECharts.
191
+ * It displays data on a world map, allowing users to visualize counts or other metrics by country.
192
+ * It supports zooming and switching between map and column views.
193
+ *
194
+ * @param {MapSeriesProps} props - The properties for the MapSeries component.
195
+ * @returns {React.ReactElement} The rendered MapSeries component.
196
+ *
197
+ * @example
198
+ * ```jsx
199
+ * <MapSeries
200
+ * data={[
201
+ * { id: "US", label: "United States", count: 100 },
202
+ * { id: "IN", label: "India", count: 200 },
203
+ * { id: "CN", label: "China", count: 300 },
204
+ * ]}
205
+ * onExport={() => console.log("Exporting chart")}
206
+ * title="World Map Series"
207
+ * onClick={(key) => console.log("Clicked country:", key)}
208
+ * theme="light"
209
+ * />
210
+ * ```
211
+ *
212
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-mapseries--docs} for more details on the properties.
213
+ * @see {@link https://echarts.apache.org/en/option.html#series-map} for ECharts map series options documentation.
212
214
  */
213
215
  export const MapSeries: FC<MapSeriesProps> = (props) => (
214
216
  <ChartWrapper>
@@ -21,15 +21,9 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import {
25
- Button,
26
- CoreIcons,
27
- Divider,
28
- ToggleButtonGroup,
29
- useMemoDebugger,
30
- } from "@react-fabric/core";
24
+ import { Button, Divider, ToggleButtonGroup, useMemoDebugger } from "@react-fabric/core";
31
25
  import { isEmpty } from "@react-fabric/utilities";
32
- import { type EChartOption, type EChartsType } from "echarts";
26
+ import { type ECharts, type EChartsOption } from "echarts";
33
27
  import { memo, useCallback, useEffect, useRef, useState, type FC } from "react";
34
28
  import { type BaseChart, type TimeSeriesType } from "../types";
35
29
  import { timeSeriesRenderer } from "../types/utils";
@@ -45,24 +39,29 @@ export interface TimeSeriesProps extends BaseChart, TimeSeriesType {
45
39
 
46
40
  const TimeSeriesChart: FC<TimeSeriesProps> = memo(
47
41
  ({
48
- data,
42
+ series: _series,
49
43
  onExport,
50
44
  categoryAxisName,
51
45
  valueAxisName,
52
46
  title,
47
+ showThemeSelector,
48
+ showTypeSelector,
53
49
  theme: chartTheme,
54
50
  type: chartType = "column",
51
+ options: optionOverride,
55
52
  onClick,
56
53
  onBrush,
57
54
  }: TimeSeriesProps) => {
58
- const chartRef = useRef<EChartsType>(null);
55
+ const chartRef = useRef<ECharts>(null);
59
56
  const [type, setType] = useState(chartType);
60
57
  const [theme, setTheme] = useState(chartTheme);
61
58
 
62
59
  useEffect(() => {
60
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
63
61
  setType(chartType);
64
62
  }, [chartType]);
65
63
  useEffect(() => {
64
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
66
65
  setTheme(chartTheme);
67
66
  }, [chartTheme]);
68
67
 
@@ -90,7 +89,8 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
90
89
  if (chart && !chart?.isDisposed()) {
91
90
  enableBrush();
92
91
  let range = [0, 0];
93
- chart.on("brushselected", (e: KeyValue) => {
92
+ chart.on("brushselected", (e: AnyObject) => {
93
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
94
94
  range = e.batch?.[0]?.areas?.[0]?.coordRange;
95
95
  });
96
96
  chart.on("brushEnd", () => {
@@ -98,15 +98,18 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
98
98
  enableBrush();
99
99
  });
100
100
  return () => {
101
- !chart.isDisposed() && chart.off("brushEnd");
102
- !chart.isDisposed() && chart.off("brushselected");
101
+ if (!chart.isDisposed()) {
102
+ chart.off("brushEnd");
103
+ chart.off("brushselected");
104
+ }
103
105
  };
104
106
  }
105
- }, [chartRef.current, onBrush]);
107
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
108
+ }, [enableBrush, onBrush, chartRef.current]);
106
109
 
107
- const options = useMemoDebugger<EChartOption>(
110
+ const options = useMemoDebugger<EChartsOption>(
108
111
  () => {
109
- if (isEmpty(data)) {
112
+ if (isEmpty(_series)) {
110
113
  chartRef.current?.clear();
111
114
  return {};
112
115
  }
@@ -114,7 +117,7 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
114
117
  const stack = type.includes("stacked") ? "stack" : undefined;
115
118
 
116
119
  const [_type, stacked] = type.split("-");
117
- const categoryAxis: AnyObject = {
120
+ const categoryAxis = Object.assign({}, optionOverride?.xAxis, {
118
121
  name: categoryAxisName,
119
122
  type: "time",
120
123
  nameGap: 32,
@@ -132,47 +135,48 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
132
135
  second: "{HH}:{mm}:{ss}",
133
136
  millisecond: "{hh}:{mm}:{ss} {SSS}",
134
137
  none: "{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}",
135
- } as AnyObject,
138
+ },
136
139
  },
137
- } as EChartOption.XAxis;
138
- const valueAxis: AnyObject = {
140
+ } as EChartsOption["xAxis"]);
141
+ const valueAxis = Object.assign({}, optionOverride?.yAxis, {
139
142
  name: valueAxisName,
140
143
  type: "value",
141
144
  nameGap: 32,
142
145
  nameLocation: "center",
143
- } as EChartOption.YAxis;
146
+ } as EChartsOption["yAxis"]);
144
147
 
145
- const series = data?.map(
146
- (item) =>
147
- ({
148
- id: item.id,
149
- stack,
150
- areaStyle: stacked ? {} : undefined,
151
- symbol: "none",
152
- type: _type === "column" ? "bar" : _type,
153
- name: item.label ?? item.id,
154
- data: item.values,
155
- universalTransition: true,
156
- }) as AnyObject,
157
- );
148
+ const series = _series?.map((item) => ({
149
+ ...item,
150
+ stack: item.stack ?? stack,
151
+ areaStyle: stacked ? {} : undefined,
152
+ symbol: "none",
153
+ type: _type === "column" ? "bar" : _type,
154
+ name: item.name ?? item.id,
155
+ universalTransition: true,
156
+ }));
158
157
 
159
158
  return {
160
- xAxis: categoryAxis,
161
- yAxis: valueAxis,
162
- series,
163
159
  brush: {
164
160
  toolbox: ["lineX", "clear"],
165
161
  brushType: "lineX",
166
162
  xAxisIndex: 0,
167
163
  },
168
- tooltip: {
169
- trigger: "axis",
170
- confine: true,
171
- position: "top",
172
- } as AnyObject,
164
+ ...optionOverride,
165
+ tooltip: Object.assign(
166
+ {
167
+ trigger: "axis",
168
+ confine: true,
169
+ position: "top",
170
+ appendTo: "body",
171
+ },
172
+ optionOverride?.tooltip,
173
+ ),
174
+ xAxis: categoryAxis,
175
+ yAxis: valueAxis,
176
+ series,
173
177
  };
174
178
  },
175
- [data, type, categoryAxisName, valueAxisName],
179
+ [_series, type, categoryAxisName, valueAxisName, optionOverride],
176
180
  "TimeChart options",
177
181
  );
178
182
 
@@ -183,43 +187,33 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
183
187
  theme={theme}
184
188
  options={options}
185
189
  chartRef={chartRef}
186
- isEmpty={isEmpty(data)}
187
- emptyIcon={CoreIcons.chartColumn}
190
+ isEmpty={isEmpty(_series)}
191
+ emptyIcon="icon-[mdi--chart-bar] rotate-90 -scale-x-100"
188
192
  dataTableRenderer={timeSeriesRenderer}
189
- onClick={(e) => onClick?.({ category: e.data[0], series: e.seriesId })}
193
+ onClick={(e) => onClick?.({ category: (e?.data as KeyValue<string>)?.[0] ?? "", series: e.seriesId ?? "" })}
190
194
  >
191
- <ToggleButtonGroup value={type} onChange={setType as AnyObject}>
192
- <Button
193
- size="sm"
194
- variant="link"
195
- icon={CoreIcons.chartLine}
196
- value="line"
197
- aria-label="line"
198
- />
199
- <Button
200
- size="sm"
201
- variant="link"
202
- icon={CoreIcons.chartColumn}
203
- value="column"
204
- aria-label="column"
205
- />
206
- <Button
207
- size="sm"
208
- variant="link"
209
- icon={CoreIcons.chartLineStacked}
210
- value="line-stacked"
211
- aria-label="line-stacked"
212
- />
213
- <Button
214
- size="sm"
215
- variant="link"
216
- icon={CoreIcons.chartColumnStacked}
217
- value="column-stacked"
218
- aria-label="column-stacked"
219
- />
220
- </ToggleButtonGroup>
221
- <Divider vertical />
222
- <PaletteSelect theme={theme} onClick={setTheme} />
195
+ {showTypeSelector && (
196
+ <ToggleButtonGroup value={type} onChange={setType}>
197
+ <Button size="sm" variant="link" icon="icon-[mdi--chart-line]" value="line" aria-label="line" />
198
+ <Button size="sm" variant="link" icon="icon-[mdi--chart-bar]" value="column" aria-label="column" />
199
+ <Button
200
+ size="sm"
201
+ variant="link"
202
+ icon="icon-[mdi--chart-line-stacked]"
203
+ value="line-stacked"
204
+ aria-label="line-stacked"
205
+ />
206
+ <Button
207
+ size="sm"
208
+ variant="link"
209
+ icon="icon-[mdi--chart-bar-stacked]"
210
+ value="column-stacked"
211
+ aria-label="column-stacked"
212
+ />
213
+ </ToggleButtonGroup>
214
+ )}
215
+ {showTypeSelector && showThemeSelector && <Divider vertical />}
216
+ {showThemeSelector && <PaletteSelect theme={theme} onClick={setTheme} />}
223
217
  </ChartContainer>
224
218
  );
225
219
  },
@@ -227,7 +221,30 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
227
221
  TimeSeriesChart.displayName = "TimeSeriesChart";
228
222
 
229
223
  /**
230
- * Chart to display simple data time series
224
+ * TimeSeries component renders a time series chart using the provided data and options.
225
+ * It supports different chart types such as line, column, and stacked variants.
226
+ * It also allows for interaction through click and brush events.
227
+ *
228
+ * @param {TimeSeriesProps} props - The properties for the TimeSeries component.
229
+ * @returns {React.ReactElement} The rendered TimeSeries component.
230
+ *
231
+ * @example
232
+ * ```jsx
233
+ * <TimeSeries
234
+ * data={data}
235
+ * onExport={handleExport}
236
+ * categoryAxisName="Time"
237
+ * valueAxisName="Value"
238
+ * title="Time Series Chart"
239
+ * type="line"
240
+ * onClick={(data) => console.log(data)}
241
+ * onBrush={(range) => console.log(range)}
242
+ * />
243
+ * ```
244
+ *
245
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-timeseries--docs} for more details on the properties.
246
+ * @see {@link https://echarts.apache.org/en/option.html#series-line} for more details on the ECharts line series options.
247
+ * @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
231
248
  */
232
249
  export const TimeSeries: FC<TimeSeriesProps> = (props) => (
233
250
  <ChartWrapper>