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

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
- import { useMemoDebugger, CoreIcons, ToggleButtonGroup, Button, Divider } from '@react-fabric/core';
5
+ import { useMemoDebugger, ToggleButtonGroup, Button, Divider } from '@react-fabric/core';
6
6
  import { isEmpty } from '@react-fabric/utilities';
7
7
  import { memo, useRef, useState, useEffect } from 'react';
8
8
  import { seriesRenderer } from '../types/utils.js';
@@ -12,35 +12,44 @@ import { PaletteSelect } from '../wrapper/PaletteSelect.js';
12
12
  import { jsxs, jsx } from 'react/jsx-runtime';
13
13
 
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
17
- var data = _ref.data,
17
+ var _series = _ref.series,
18
18
  onExport = _ref.onExport,
19
19
  categories = _ref.categories,
20
20
  categoryAxisName = _ref.categoryAxisName,
21
21
  valueAxisName = _ref.valueAxisName,
22
22
  title = _ref.title,
23
+ optionOverride = _ref.options,
24
+ showThemeSelector = _ref.showThemeSelector,
25
+ showTypeSelector = _ref.showTypeSelector,
23
26
  chartTheme = _ref.theme,
24
27
  _ref$type = _ref.type,
25
28
  chartType = _ref$type === void 0 ? "column" : _ref$type,
26
29
  _onClick = _ref.onClick;
27
30
  var chartRef = useRef(null);
28
- var _useState = useState(chartType),
31
+ var _useState = useState(function () {
32
+ return chartType;
33
+ }),
29
34
  _useState2 = _slicedToArray(_useState, 2),
30
35
  type = _useState2[0],
31
36
  setType = _useState2[1];
32
- var _useState3 = useState(chartTheme),
37
+ var _useState3 = useState(function () {
38
+ return chartTheme;
39
+ }),
33
40
  _useState4 = _slicedToArray(_useState3, 2),
34
41
  theme = _useState4[0],
35
42
  setTheme = _useState4[1];
36
43
  useEffect(function () {
44
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
37
45
  setType(chartType);
38
46
  }, [chartType]);
39
47
  useEffect(function () {
48
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
40
49
  setTheme(chartTheme);
41
50
  }, [chartTheme]);
42
51
  var options = useMemoDebugger(function () {
43
- if (isEmpty(data)) {
52
+ if (isEmpty(_series)) {
44
53
  var _chartRef$current;
45
54
  (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 || _chartRef$current.clear();
46
55
  return {};
@@ -50,7 +59,7 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
50
59
  _type$split2 = _slicedToArray(_type$split, 2),
51
60
  _type = _type$split2[0],
52
61
  stacked = _type$split2[1];
53
- var categoryAxis = _type === "radar" ? undefined : {
62
+ var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, _type === "radar" ? undefined : {
54
63
  name: categoryAxisName,
55
64
  type: "category",
56
65
  nameGap: 32,
@@ -59,113 +68,114 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
59
68
  show: false
60
69
  },
61
70
  data: categories
62
- };
63
- var valueAxis = _type === "radar" ? undefined : {
71
+ });
72
+ var valueAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, _type === "radar" ? undefined : {
64
73
  name: valueAxisName,
65
74
  type: "value",
66
75
  nameGap: 32,
67
76
  nameLocation: "center"
68
- };
69
- var radar = _type !== "radar" ? undefined : {
77
+ });
78
+ var radar = _type !== "radar" ? undefined : Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.radar, {
70
79
  shape: "circle",
71
80
  indicator: categories === null || categories === void 0 ? void 0 : categories.map(function (c) {
72
81
  return {
73
82
  name: c
74
83
  };
75
84
  })
76
- };
77
- var series = data === null || data === void 0 ? void 0 : data.map(function (item, index) {
78
- var _item$label, _item$label2;
79
- return {
80
- id: item.id,
81
- stack: stack,
85
+ });
86
+ var series = _series === null || _series === void 0 ? void 0 : _series.map(function (item) {
87
+ var _item$stack, _item$label, _item$name;
88
+ return _objectSpread(_objectSpread({}, item), {}, {
89
+ stack: (_item$stack = item.stack) !== null && _item$stack !== void 0 ? _item$stack : stack,
82
90
  areaStyle: stacked ? {} : undefined,
83
91
  type: _type === "column" ? "bar" : _type,
84
92
  name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id,
85
93
  universalTransition: true,
86
94
  data: _type === "radar" ? [{
87
- value: item.values,
95
+ value: item.data,
88
96
  id: item.id,
89
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id
90
- }] : item.values
91
- };
97
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
98
+ }] : item.data
99
+ });
92
100
  });
93
- return {
101
+ return _objectSpread(_objectSpread({}, optionOverride), {}, {
94
102
  xAxis: type.startsWith("bar") ? valueAxis : categoryAxis,
95
103
  yAxis: type.startsWith("bar") ? categoryAxis : valueAxis,
96
104
  radar: radar,
97
105
  series: series,
98
- tooltip: {
106
+ tooltip: Object.assign({
99
107
  trigger: _type === "radar" ? "item" : "axis",
100
108
  confine: true,
101
- position: "top"
102
- }
103
- };
104
- }, [data, type, categories, categoryAxisName, valueAxisName], "DataChart options");
109
+ position: "top",
110
+ appendToBody: true
111
+ }, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip)
112
+ });
113
+ }, [_series, type, categories, categoryAxisName, valueAxisName, optionOverride], "DataChart options");
105
114
  return /*#__PURE__*/jsxs(ChartContainer, {
106
115
  title: title,
107
116
  onExport: onExport,
108
117
  theme: theme,
109
118
  options: options,
110
119
  chartRef: chartRef,
111
- isEmpty: isEmpty(data),
112
- emptyIcon: CoreIcons.chartColumn,
120
+ isEmpty: isEmpty(_series),
121
+ emptyIcon: "icon-[mdi--chart-bar]",
113
122
  dataTableRenderer: seriesRenderer,
114
123
  onClick: function onClick(e) {
124
+ var _e$seriesId;
115
125
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick({
116
126
  category: e.name,
117
- series: e.seriesId
127
+ series: (_e$seriesId = e.seriesId) !== null && _e$seriesId !== void 0 ? _e$seriesId : ""
118
128
  });
119
129
  },
120
- children: [/*#__PURE__*/jsxs(ToggleButtonGroup, {
130
+ children: [showTypeSelector && /*#__PURE__*/jsxs(ToggleButtonGroup, {
121
131
  value: type,
122
132
  onChange: setType,
123
133
  children: [/*#__PURE__*/jsx(Button, {
124
134
  size: "sm",
125
135
  variant: "link",
126
- icon: CoreIcons.chartLine,
136
+ icon: "icon-[mdi--chart-line]",
127
137
  "aria-label": "line",
128
138
  value: "line"
129
139
  }), /*#__PURE__*/jsx(Button, {
130
140
  size: "sm",
131
141
  variant: "link",
132
- icon: CoreIcons.chartColumn,
142
+ icon: "icon-[mdi--chart-bar]",
133
143
  "aria-label": "column",
134
144
  value: "column"
135
145
  }), /*#__PURE__*/jsx(Button, {
136
146
  size: "sm",
137
147
  variant: "link",
138
- icon: CoreIcons.chartBar,
148
+ icon: "icon-[mdi--chart-bar] rotate-90 -scale-x-100",
139
149
  "aria-label": "bar",
140
150
  value: "bar"
141
151
  }), /*#__PURE__*/jsx(Button, {
142
152
  size: "sm",
143
153
  variant: "link",
144
- icon: CoreIcons.chartRadar,
154
+ icon: "icon-[mdi--radar]",
145
155
  "aria-label": "radar",
146
156
  value: "radar"
147
157
  }), /*#__PURE__*/jsx(Button, {
148
158
  size: "sm",
149
159
  variant: "link",
150
- icon: CoreIcons.chartLineStacked,
160
+ icon: "icon-[mdi--chart-line-stacked]",
151
161
  "aria-label": "line-stacked",
152
162
  value: "line-stacked"
153
163
  }), /*#__PURE__*/jsx(Button, {
154
164
  size: "sm",
155
165
  variant: "link",
156
- icon: CoreIcons.chartColumnStacked,
166
+ icon: "icon-[mdi--chart-bar-stacked]",
157
167
  "aria-label": "column-stacked",
158
168
  value: "column-stacked"
159
169
  }), /*#__PURE__*/jsx(Button, {
160
170
  size: "sm",
161
171
  variant: "link",
162
- icon: CoreIcons.chartBarStacked,
172
+ icon: "icon-[mdi--chart-bar-stacked] rotate-90 -scale-x-100",
163
173
  "aria-label": "bar-stacked",
164
174
  value: "bar-stacked"
165
175
  })]
166
- }), /*#__PURE__*/jsx(Divider, {
176
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsx(Divider, {
167
177
  vertical: true
168
- }), /*#__PURE__*/jsx(PaletteSelect, {
178
+ }), showThemeSelector && /*#__PURE__*/jsx(PaletteSelect, {
169
179
  theme: theme,
170
180
  onClick: setTheme
171
181
  })]
@@ -174,7 +184,32 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
174
184
  DataSeriesChart.displayName = "DataSeriesChart";
175
185
 
176
186
  /**
177
- * Chart to display simple data category series
187
+ * DataSeries component renders a chart for visualizing data series.
188
+ * It supports various chart types such as column, line, bar, radar, and stacked variants.
189
+ * It allows users to click on data points to trigger custom actions.
190
+ *
191
+ * @param {DataSeriesProps} props - The properties for the DataSeries component.
192
+ * @returns {React.ReactElement} The rendered DataSeries component.
193
+ *
194
+ * @example
195
+ * ```jsx
196
+ * <DataSeries
197
+ * data={[{ id: "1", label: "Series 1", values: [10, 20, 30] }]}
198
+ * categories={["Category 1", "Category 2", "Category 3"]}
199
+ * categoryAxisName="Categories"
200
+ * valueAxisName="Values"
201
+ * title="Data Series Example"
202
+ * type="column"
203
+ * onClick={(data) => console.log("Clicked data:", data)}
204
+ * onExport={() => console.log("Exporting chart data")}
205
+ * theme="light"
206
+ * />
207
+ * ```
208
+ *
209
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-dataseries--docs} for more details on the properties.
210
+ * @see {@link https://echarts.apache.org/en/option.html#series-bar} for ECharts bar series options.
211
+ * @see {@link https://echarts.apache.org/en/option.html#series-line} for ECharts line series options.
212
+ * @see {@link https://echarts.apache.org/en/option.html#series-radar} for ECharts radar series options.
178
213
  */
179
214
  var DataSeries = function DataSeries(props) {
180
215
  return /*#__PURE__*/jsx(ChartWrapper, {
@@ -1,15 +1,17 @@
1
1
  'use client';
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
- import { memo, useRef, useImperativeHandle, useEffect } from 'react';
6
+ import { memo, useRef, useState, useImperativeHandle, useEffect } from 'react';
6
7
  import { ChartContainer } from '../wrapper/ChartContainer.js';
7
8
  import { ChartWrapper } from '../wrapper/ChartWrapper.js';
8
- import { jsx } from 'react/jsx-runtime';
9
+ import { PaletteSelect } from '../wrapper/PaletteSelect.js';
10
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
11
 
10
- var _excluded = ["chartRef", "onBrush", "onBrushEnd", "onBrushSelected", "dataTableRenderer", "onClick", "onRendered", "actions", "title", "theme"];
12
+ var _excluded = ["chartRef", "onBrush", "onBrushEnd", "onBrushSelected", "dataTableRenderer", "onClick", "onRendered", "showThemeSelector", "actions", "title", "theme"];
11
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
15
  var GenericChartBase = /*#__PURE__*/memo(function (_ref2) {
14
16
  var _ref = _ref2.chartRef,
15
17
  onBrush = _ref2.onBrush,
@@ -18,73 +20,93 @@ var GenericChartBase = /*#__PURE__*/memo(function (_ref2) {
18
20
  dataTableRenderer = _ref2.dataTableRenderer,
19
21
  onClick = _ref2.onClick,
20
22
  onRendered = _ref2.onRendered,
23
+ showThemeSelector = _ref2.showThemeSelector,
21
24
  actions = _ref2.actions,
22
25
  title = _ref2.title,
23
- theme = _ref2.theme,
26
+ chartTheme = _ref2.theme,
24
27
  options = _objectWithoutProperties(_ref2, _excluded);
25
28
  var chartRef = useRef(null);
29
+ var _useState = useState(function () {
30
+ return chartTheme;
31
+ }),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ theme = _useState2[0],
34
+ setTheme = _useState2[1];
26
35
  useImperativeHandle(_ref, function () {
27
36
  return chartRef.current;
28
- }, [chartRef.current]);
37
+ }, []);
29
38
  useEffect(function () {
30
39
  var chart = chartRef.current;
31
40
  if (chart && onRendered) {
32
41
  chart.on("finished", onRendered);
33
42
  return function () {
34
- !chart.isDisposed() && chart.off("finished");
43
+ if (!chart.isDisposed()) chart.off("finished");
35
44
  };
36
45
  }
37
- }, [chartRef.current, onRendered]);
46
+ }, [onRendered]);
38
47
  useEffect(function () {
39
48
  var chart = chartRef.current;
40
49
  if (chart && onClick) {
41
50
  chart.on("click", onClick);
42
51
  return function () {
43
- !chart.isDisposed() && chart.off("click");
52
+ if (!chart.isDisposed()) chart.off("click");
44
53
  };
45
54
  }
46
- }, [chartRef.current, onClick]);
55
+ }, [onClick]);
47
56
  useEffect(function () {
48
57
  var chart = chartRef.current;
49
58
  if (chart && onBrush) {
50
59
  chart.on("brush", onBrush);
51
60
  return function () {
52
- !chart.isDisposed() && chart.off("brush");
61
+ if (!chart.isDisposed()) chart.off("brush");
53
62
  };
54
63
  }
55
- }, [chartRef.current, onBrush]);
64
+ }, [onBrush]);
56
65
  useEffect(function () {
57
66
  var chart = chartRef.current;
58
67
  if (chart && onBrushEnd) {
59
68
  chart.on("brushend", onBrushEnd);
60
69
  return function () {
61
- !chart.isDisposed() && chart.off("brushend");
70
+ if (!chart.isDisposed()) chart.off("brushend");
62
71
  };
63
72
  }
64
- }, [chartRef.current, onBrushEnd]);
73
+ }, [onBrushEnd]);
65
74
  useEffect(function () {
66
75
  var chart = chartRef.current;
67
76
  if (chart && onBrushSelected) {
68
77
  chart.on("brushselected", onBrushSelected);
69
78
  return function () {
70
- !chart.isDisposed() && chart.off("brushselected");
79
+ if (!chart.isDisposed()) chart.off("brushselected");
71
80
  };
72
81
  }
73
- }, [chartRef.current, onBrushSelected]);
74
- return /*#__PURE__*/jsx(ChartContainer, {
75
- theme: theme,
82
+ }, [onBrushSelected]);
83
+ return /*#__PURE__*/jsxs(ChartContainer, {
76
84
  options: options,
77
85
  chartRef: chartRef,
86
+ theme: theme,
78
87
  title: title,
79
88
  dataTableRenderer: dataTableRenderer,
80
- children: actions
89
+ children: [actions, showThemeSelector && /*#__PURE__*/jsx(PaletteSelect, {
90
+ theme: theme,
91
+ onClick: setTheme
92
+ })]
81
93
  });
82
94
  });
83
95
  GenericChartBase.displayName = "GenericChart";
84
- var GenericChart = function GenericChart(props) {
96
+
97
+ /**
98
+ * GenericChart component renders a generic chart using ECharts.
99
+ * It accepts various chart options and configurations, allowing for flexible chart rendering.
100
+ * It supports click events, brush events, and custom actions.
101
+ * It can be used to create a wide range of chart types by passing the appropriate ECharts options.
102
+ *
103
+ * @see {@link https://echarts.apache.org/en/option.html} for ECharts options documentation.
104
+ * @see {@link https://echarts.apache.org/en/api.html#echartsInstance} for ECharts instance methods and properties.
105
+ */
106
+ function GenericChart(props) {
85
107
  return /*#__PURE__*/jsx(ChartWrapper, {
86
108
  children: /*#__PURE__*/jsx(GenericChartBase, _objectSpread({}, props))
87
109
  });
88
- };
110
+ }
89
111
 
90
112
  export { GenericChart };
@@ -3,6 +3,7 @@
3
3
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
4
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
+ import { useMemoDebugger, ToggleButtonGroup, Button } from '@react-fabric/core';
6
7
  import { isEmpty, Countries, compareValues, Format } from '@react-fabric/utilities';
7
8
  import * as echarts from 'echarts';
8
9
  import { memo, useRef, useState, useEffect } from 'react';
@@ -10,20 +11,19 @@ import { ChartPalette } from '../theme/palettes.js';
10
11
  import { countRenderer } from '../types/utils.js';
11
12
  import { ChartContainer } from '../wrapper/ChartContainer.js';
12
13
  import { ChartWrapper } from '../wrapper/ChartWrapper.js';
13
- import { useMemoDebugger, ToggleButtonGroup, Button, CoreIcons } from '@react-fabric/core';
14
14
  import WorldMap from '../types/world.svg.js';
15
15
  import { jsxs, jsx } from 'react/jsx-runtime';
16
16
 
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  echarts.registerMap("world", {
20
20
  svg: WorldMap
21
21
  });
22
22
  var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
23
- var data = _ref.data,
24
- onExport = _ref.onExport;
25
- _ref.theme;
26
- var title = _ref.title,
23
+ var series = _ref.series,
24
+ onExport = _ref.onExport,
25
+ showTypeSelector = _ref.showTypeSelector,
26
+ title = _ref.title,
27
27
  _onClick = _ref.onClick;
28
28
  var chartRef = useRef(null);
29
29
  var _useState = useState("map"),
@@ -35,14 +35,14 @@ var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
35
35
  zoom = _useState4[0],
36
36
  setZoom = _useState4[1];
37
37
  var options = useMemoDebugger(function () {
38
- if (isEmpty(data)) return {};
39
- var sorted = data.map(function (d) {
38
+ if (isEmpty(series)) return {};
39
+ var sorted = series.map(function (d) {
40
40
  var _d$label;
41
41
  return _objectSpread(_objectSpread({}, d), {}, {
42
42
  label: (_d$label = d.label) !== null && _d$label !== void 0 ? _d$label : Countries.name(d.id)
43
43
  });
44
44
  }).sort(compareValues("desc", "count"));
45
- var valueMap = data.map(function (d) {
45
+ var valueMap = series.map(function (d) {
46
46
  return d.count;
47
47
  });
48
48
  if (type === "column") {
@@ -132,10 +132,11 @@ var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
132
132
  })
133
133
  }]
134
134
  };
135
- }, [data, title, type], "MapChart options");
135
+ }, [series, title, type], "MapChart options");
136
136
  useEffect(function () {
137
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
137
138
  setZoom(1.25);
138
- }, [data, type]);
139
+ }, [series, type]);
139
140
  useEffect(function () {
140
141
  var _chartRef$current;
141
142
  (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 || _chartRef$current.setOption({
@@ -151,8 +152,8 @@ var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
151
152
  options: options,
152
153
  dataTableRenderer: countRenderer,
153
154
  onClick: function onClick(e) {
154
- var _e$data$id, _e$data;
155
- return e.data && (_onClick === null || _onClick === void 0 ? void 0 : _onClick((_e$data$id = e === null || e === void 0 || (_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.id) !== null && _e$data$id !== void 0 ? _e$data$id : ""));
155
+ var _id, _e$data;
156
+ return e.data && (_onClick === null || _onClick === void 0 ? void 0 : _onClick((_id = e === null || e === void 0 || (_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.id) !== null && _id !== void 0 ? _id : ""));
156
157
  },
157
158
  children: [type === "map" && /*#__PURE__*/jsx("input", {
158
159
  type: "range",
@@ -163,19 +164,19 @@ var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
163
164
  onChange: function onChange(e) {
164
165
  return setZoom(e.target.valueAsNumber);
165
166
  }
166
- }), /*#__PURE__*/jsxs(ToggleButtonGroup, {
167
+ }), showTypeSelector && /*#__PURE__*/jsxs(ToggleButtonGroup, {
167
168
  value: type,
168
169
  onChange: setType,
169
170
  children: [/*#__PURE__*/jsx(Button, {
170
171
  size: "sm",
171
172
  variant: "link",
172
- icon: CoreIcons.map,
173
+ icon: "icon-[mdi--map]",
173
174
  "aria-label": "map",
174
175
  value: "map"
175
176
  }), /*#__PURE__*/jsx(Button, {
176
177
  size: "sm",
177
178
  variant: "link",
178
- icon: CoreIcons.chartColumn,
179
+ icon: "icon-[mdi--chart-bar] rotate-90 -scale-x-100",
179
180
  "aria-label": "column",
180
181
  value: "column"
181
182
  })]
@@ -185,7 +186,30 @@ var MapSeriesChart = /*#__PURE__*/memo(function (_ref) {
185
186
  MapSeriesChart.displayName = "MapSeriesChart";
186
187
 
187
188
  /**
188
- * Chart to display simple map data series
189
+ * MapSeries component renders a map chart using ECharts.
190
+ * It displays data on a world map, allowing users to visualize counts or other metrics by country.
191
+ * It supports zooming and switching between map and column views.
192
+ *
193
+ * @param {MapSeriesProps} props - The properties for the MapSeries component.
194
+ * @returns {React.ReactElement} The rendered MapSeries component.
195
+ *
196
+ * @example
197
+ * ```jsx
198
+ * <MapSeries
199
+ * data={[
200
+ * { id: "US", label: "United States", count: 100 },
201
+ * { id: "IN", label: "India", count: 200 },
202
+ * { id: "CN", label: "China", count: 300 },
203
+ * ]}
204
+ * onExport={() => console.log("Exporting chart")}
205
+ * title="World Map Series"
206
+ * onClick={(key) => console.log("Clicked country:", key)}
207
+ * theme="light"
208
+ * />
209
+ * ```
210
+ *
211
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-mapseries--docs} for more details on the properties.
212
+ * @see {@link https://echarts.apache.org/en/option.html#series-map} for ECharts map series options documentation.
189
213
  */
190
214
  var MapSeries = function MapSeries(props) {
191
215
  return /*#__PURE__*/jsx(ChartWrapper, {