@react-fabric/chart 1.0.0-beta.6 → 1.0.0-beta.61

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 (73) hide show
  1. package/{src/wrapper/Chart.module.css → css/_chart.css} +7 -7
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/charts/ActivityMap.js +61 -30
  4. package/dist/cjs/charts/CountSeries.js +56 -26
  5. package/dist/cjs/charts/DataSeries.js +64 -36
  6. package/dist/cjs/charts/Generic.js +29 -5
  7. package/dist/cjs/charts/MapSeries.js +35 -11
  8. package/dist/cjs/charts/TimeSeries.js +60 -34
  9. package/dist/cjs/charts/TimeSlider.js +30 -10
  10. package/dist/cjs/charts/WordBubble.js +37 -7
  11. package/dist/cjs/theme/darkBase.js +13 -10
  12. package/dist/cjs/theme/index.js +38 -18
  13. package/dist/cjs/theme/lightBase.js +18 -15
  14. package/dist/cjs/theme/palettes.js +27 -27
  15. package/dist/cjs/types/charts.js +2 -2
  16. package/dist/cjs/types/utils.js +1 -4
  17. package/dist/cjs/wrapper/ChartContainer.js +12 -9
  18. package/dist/cjs/wrapper/ChartToolbar.js +1 -2
  19. package/dist/cjs/wrapper/PaletteSelect.js +1 -1
  20. package/dist/esm/charts/ActivityMap.js +62 -31
  21. package/dist/esm/charts/CountSeries.js +57 -27
  22. package/dist/esm/charts/DataSeries.js +65 -37
  23. package/dist/esm/charts/Generic.js +31 -7
  24. package/dist/esm/charts/MapSeries.js +36 -12
  25. package/dist/esm/charts/TimeSeries.js +61 -35
  26. package/dist/esm/charts/TimeSlider.js +30 -10
  27. package/dist/esm/charts/WordBubble.js +38 -8
  28. package/dist/esm/theme/darkBase.js +13 -10
  29. package/dist/esm/theme/index.js +38 -18
  30. package/dist/esm/theme/lightBase.js +18 -15
  31. package/dist/esm/theme/palettes.js +27 -27
  32. package/dist/esm/types/charts.js +2 -2
  33. package/dist/esm/types/utils.js +1 -4
  34. package/dist/esm/wrapper/ChartContainer.js +13 -10
  35. package/dist/esm/wrapper/ChartToolbar.js +1 -2
  36. package/dist/esm/wrapper/PaletteSelect.js +2 -2
  37. package/dist/types/charts/ActivityMap.d.ts +23 -2
  38. package/dist/types/charts/CountSeries.d.ts +28 -1
  39. package/dist/types/charts/DataSeries.d.ts +26 -1
  40. package/dist/types/charts/Generic.d.ts +29 -41
  41. package/dist/types/charts/MapSeries.d.ts +31 -3
  42. package/dist/types/charts/TimeSeries.d.ts +24 -1
  43. package/dist/types/charts/TimeSlider.d.ts +22 -2
  44. package/dist/types/charts/WordBubble.d.ts +32 -3
  45. package/dist/types/theme/darkBase.d.ts +8 -5
  46. package/dist/types/theme/index.d.ts +1 -1
  47. package/dist/types/theme/lightBase.d.ts +8 -5
  48. package/dist/types/types/charts.d.ts +1 -1
  49. package/dist/types/types/index.d.ts +30 -12
  50. package/dist/types/types/world.svg.d.ts +1 -1
  51. package/dist/types/wrapper/ChartContainer.d.ts +4 -4
  52. package/dist/types/wrapper/ChartWrapper.d.ts +0 -1
  53. package/package.json +15 -16
  54. package/src/charts/ActivityMap.tsx +104 -60
  55. package/src/charts/CountSeries.tsx +89 -50
  56. package/src/charts/DataSeries.tsx +127 -78
  57. package/src/charts/Generic.tsx +43 -51
  58. package/src/charts/MapSeries.tsx +61 -33
  59. package/src/charts/TimeSeries.tsx +116 -79
  60. package/src/charts/TimeSlider.tsx +38 -15
  61. package/src/charts/WordBubble.tsx +43 -12
  62. package/src/theme/darkBase.ts +12 -9
  63. package/src/theme/index.ts +94 -20
  64. package/src/theme/lightBase.ts +17 -14
  65. package/src/theme/palettes.ts +1 -52
  66. package/src/types/charts.ts +6 -2
  67. package/src/types/index.ts +40 -4
  68. package/src/types/utils.ts +0 -1
  69. package/src/wrapper/ChartContainer.tsx +17 -12
  70. package/src/wrapper/ChartToolbar.tsx +1 -2
  71. package/src/wrapper/PaletteSelect.tsx +2 -8
  72. package/dist/cjs/wrapper/Chart.module.css +0 -1
  73. package/dist/esm/wrapper/Chart.module.css +0 -1
@@ -3,10 +3,9 @@
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
- import { useMemoDebugger, CoreIcons, ToggleButtonGroup, Button, Divider } from '@react-fabric/core';
6
+ import { useMemoDebugger, ToggleButtonGroup, Button, Divider } from '@react-fabric/core';
7
7
  import { isEmpty, isArray } from '@react-fabric/utilities';
8
8
  import { memo, useRef, useState, useEffect } from 'react';
9
- import { ChartPalette } from '../theme/palettes.js';
10
9
  import { activityRenderer } from '../types/utils.js';
11
10
  import { ChartContainer } from '../wrapper/ChartContainer.js';
12
11
  import { ChartWrapper } from '../wrapper/ChartWrapper.js';
@@ -24,15 +23,18 @@ var MONTH_DAY = {
24
23
  low: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"]
25
24
  };
26
25
  var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
27
- var _ref$data = _ref.data,
28
- data = _ref$data === void 0 ? [] : _ref$data,
26
+ var _ref$series = _ref.series,
27
+ series = _ref$series === void 0 ? [] : _ref$series,
29
28
  title = _ref.title,
30
29
  onExport = _ref.onExport,
30
+ optionOverride = _ref.options,
31
31
  _ref$theme = _ref.theme,
32
32
  chartTheme = _ref$theme === void 0 ? "activity" : _ref$theme,
33
33
  heatmapPalette = _ref.heatmapPalette,
34
34
  highLabels = _ref.highLabels,
35
35
  lowLabels = _ref.lowLabels,
36
+ showThemeSelector = _ref.showThemeSelector,
37
+ showTypeSelector = _ref.showTypeSelector,
36
38
  _ref$time = _ref.time,
37
39
  time = _ref$time === void 0 ? "day-hour" : _ref$time,
38
40
  _ref$type = _ref.type,
@@ -58,8 +60,8 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
58
60
  var options = {
59
61
  series: []
60
62
  };
61
- if (isEmpty(data)) return {};
62
- options.xAxis = {
63
+ if (isEmpty(series)) return {};
64
+ options.xAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
63
65
  type: "category",
64
66
  data: lowLabels !== null && lowLabels !== void 0 ? lowLabels : defaultMap.low,
65
67
  boundaryGap: type === "heatmap",
@@ -69,8 +71,8 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
69
71
  axisLine: {
70
72
  show: false
71
73
  }
72
- };
73
- options.yAxis = {
74
+ });
75
+ options.yAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, {
74
76
  type: "category",
75
77
  axisLabel: {
76
78
  margin: 16
@@ -79,13 +81,13 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
79
81
  axisLine: {
80
82
  show: false
81
83
  }
82
- };
83
- options.series = data.map(function (points, index) {
84
+ });
85
+ options.series = series.map(function (points, index) {
84
86
  var total = points.reduce(function (t, p) {
85
87
  return t + p[2];
86
88
  }, 0);
87
89
  return {
88
- id: index,
90
+ id: "".concat(index),
89
91
  name: defaultMap.high[index],
90
92
  type: type,
91
93
  symbolSize: function symbolSize(dataItem) {
@@ -96,55 +98,63 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
96
98
  };
97
99
  });
98
100
  if (type === "heatmap") {
99
- var dataPoints = data.map(function (points) {
101
+ var dataPoints = series.map(function (points) {
100
102
  return Math.max.apply(Math, _toConsumableArray(points.map(function (pt) {
101
103
  return pt[2];
102
104
  })));
103
105
  });
104
106
  options.grid = {
105
107
  top: 32,
106
- bottom: 128
108
+ bottom: 64
107
109
  };
108
- options.visualMap = {
110
+ options.legend = {
111
+ show: false
112
+ };
113
+ options.visualMap = [{
109
114
  type: "piecewise",
110
115
  min: 1,
111
116
  show: type === "heatmap",
112
- color: heatmapPalette !== null && heatmapPalette !== void 0 ? heatmapPalette : _toConsumableArray(ChartPalette.Heatmap),
113
117
  max: Math.max.apply(Math, _toConsumableArray(dataPoints)),
114
- calculable: true,
118
+ // calculable: true,inRange:
115
119
  orient: "horizontal",
116
120
  left: "center",
117
- bottom: 48
118
- };
121
+ bottom: 4
122
+ }];
123
+ if (heatmapPalette) {
124
+ options.visualMap[0].inRange = {
125
+ color: heatmapPalette
126
+ };
127
+ }
119
128
  }
120
- return _objectSpread({
129
+ return _objectSpread(_objectSpread({
121
130
  grid: {
122
131
  top: 32,
123
132
  bottom: 64
124
133
  },
125
- tooltip: {
134
+ tooltip: Object.assign({
126
135
  trigger: "item",
127
136
  confine: true,
128
137
  position: "top",
138
+ appendToBody: true,
129
139
  valueFormatter: function valueFormatter(c) {
130
140
  return isArray(c) ? c[2] : c;
131
141
  }
132
- }
133
- }, options);
134
- }, [data, title, type], "ActivityChart options");
142
+ }, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip)
143
+ }, optionOverride), options);
144
+ }, [series, title, type, heatmapPalette, optionOverride], "ActivityChart options");
135
145
  return /*#__PURE__*/jsxs(ChartContainer, {
136
146
  title: title,
137
147
  onExport: onExport,
138
148
  theme: theme,
139
149
  options: options,
140
150
  chartRef: chartRef,
141
- isEmpty: isEmpty(data),
142
- emptyIcon: CoreIcons.chartActivityScatter,
151
+ isEmpty: isEmpty(series),
152
+ emptyIcon: "icon-[mdi--chart-scatter-plot]",
143
153
  dataTableRenderer: activityRenderer,
144
154
  onClick: function onClick(e) {
145
155
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick(e.seriesIndex, e.dataIndex);
146
156
  },
147
- children: [/*#__PURE__*/jsxs(ToggleButtonGroup, {
157
+ children: [showTypeSelector && /*#__PURE__*/jsxs(ToggleButtonGroup, {
148
158
  value: type,
149
159
  onChange: setType,
150
160
  children: [/*#__PURE__*/jsx(Button, {
@@ -152,17 +162,17 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
152
162
  variant: "link",
153
163
  value: "scatter",
154
164
  "aria-label": "scatter",
155
- icon: CoreIcons.chartActivityScatter
165
+ icon: "icon-[mdi--chart-scatter-plot]"
156
166
  }), /*#__PURE__*/jsx(Button, {
157
167
  size: "sm",
158
168
  variant: "link",
159
169
  value: "heatmap",
160
170
  "aria-label": "heatmap",
161
- icon: CoreIcons.chartActivityCalendar
171
+ icon: "icon-[mdi--checkerboard]"
162
172
  })]
163
- }), /*#__PURE__*/jsx(Divider, {
173
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsx(Divider, {
164
174
  vertical: true
165
- }), /*#__PURE__*/jsx(PaletteSelect, {
175
+ }), showThemeSelector && /*#__PURE__*/jsx(PaletteSelect, {
166
176
  theme: theme,
167
177
  onClick: setTheme,
168
178
  defaultTheme: "activity"
@@ -172,7 +182,28 @@ var ActivityMapChart = /*#__PURE__*/memo(function (_ref) {
172
182
  ActivityMapChart.displayName = "ActivityMapChart";
173
183
 
174
184
  /**
175
- * Chart showing activity map
185
+ * ActivityMap component renders a chart that visualizes activity data
186
+ * over time, using either a scatter plot or a heatmap.
187
+ * It allows users to switch between different types of visualizations
188
+ * and customize the color palette used in the chart.
189
+ *
190
+ * @param {ActivityMapProps} props - The properties for the ActivityMap component.
191
+ * @returns {JSX.Element} The rendered ActivityMap component.
192
+ *
193
+ * @example
194
+ * ```jsx
195
+ * <ActivityMap
196
+ * data={activityData}
197
+ * time="day-hour"
198
+ * type="heatmap"
199
+ * heatmapPalette={["#f0f8ff", "#faebd7", "#00ffff", "#7fffd4"]}
200
+ * highLabels={["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}
201
+ * lowLabels={["12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p"]}
202
+ * onClick={(highIndex, lowIndex) => console.log(`Clicked on: ${highIndex}, ${lowIndex}`)}
203
+ * />
204
+ * ```
205
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-activitymap--docs} for more details on the properties.
206
+ * @see {@link https://echarts.apache.org/en/option.html#series-scatter} for more details on the ECharts scatter series.
176
207
  */
177
208
  var ActivityMap = function ActivityMap(props) {
178
209
  return /*#__PURE__*/jsx(ChartWrapper, {
@@ -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, compareValues, Format } from '@react-fabric/utilities';
7
7
  import { memo, useRef, useState, useEffect } from 'react';
8
8
  import { countRenderer } from '../types/utils.js';
@@ -14,12 +14,16 @@ import { jsxs, jsx } from 'react/jsx-runtime';
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
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; }
16
16
  var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
17
- var data = _ref.data,
17
+ var _series = _ref.series,
18
18
  title = _ref.title,
19
+ seriesName = _ref.seriesName,
19
20
  onExport = _ref.onExport,
20
21
  chartTheme = _ref.theme,
21
22
  _ref$type = _ref.type,
22
23
  chartType = _ref$type === void 0 ? "pie" : _ref$type,
24
+ optionOverride = _ref.options,
25
+ showThemeSelector = _ref.showThemeSelector,
26
+ showTypeSelector = _ref.showTypeSelector,
23
27
  _onClick = _ref.onClick;
24
28
  var chartRef = useRef(null);
25
29
  var _useState = useState(chartType),
@@ -37,43 +41,43 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
37
41
  setTheme(chartTheme);
38
42
  }, [chartTheme]);
39
43
  var options = useMemoDebugger(function () {
40
- if (isEmpty(data)) {
44
+ if (isEmpty(_series)) {
41
45
  var _chartRef$current;
42
46
  (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 || _chartRef$current.clear();
43
47
  return {};
44
48
  }
45
- var sorted = data === null || data === void 0 ? void 0 : data.sort(compareValues("desc", "count"));
46
- var categoryAxis = {
49
+ var sorted = _series === null || _series === void 0 ? void 0 : _series.sort(compareValues("desc", "count"));
50
+ var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
47
51
  type: "category",
48
- name: title !== null && title !== void 0 ? title : "Count Series",
52
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
49
53
  nameLocation: "center",
50
54
  axisTick: {
51
55
  show: false
52
56
  },
53
57
  data: []
54
- };
55
- var valueAxis = {
58
+ });
59
+ var valueAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, {
56
60
  type: "value",
57
61
  axisLabel: {
58
62
  formatter: function formatter(val) {
59
63
  return Format.number(val);
60
64
  }
61
65
  }
62
- };
66
+ });
63
67
  var series = type === "pie" ? [{
64
68
  type: "pie",
65
- name: title !== null && title !== void 0 ? title : "Count Series",
69
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
66
70
  data: sorted.map(function (item, index) {
67
- var _item$label;
71
+ var _item$name;
68
72
  return {
69
73
  id: item.id,
70
74
  value: item.count,
71
- name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id
75
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
72
76
  };
73
77
  }),
74
78
  universalTransition: true
75
79
  }] : sorted.map(function (item, index) {
76
- var _item$label2;
80
+ var _item$name2;
77
81
  return {
78
82
  id: item.id,
79
83
  type: "bar",
@@ -85,34 +89,34 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
85
89
  color: "#fff"
86
90
  },
87
91
  data: [{
88
- name: title !== null && title !== void 0 ? title : "Count Series",
92
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
89
93
  value: item.count
90
94
  }],
91
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id,
95
+ name: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : item.id,
92
96
  universalTransition: true
93
97
  };
94
98
  });
95
- return {
99
+ return _objectSpread(_objectSpread({}, optionOverride), {}, {
96
100
  series: series,
97
101
  countSeries: true,
98
102
  xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
99
103
  yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
100
- };
101
- }, [data, title, type], "CountChart options");
104
+ });
105
+ }, [_series, seriesName, type, optionOverride], "CountChart options");
102
106
  return /*#__PURE__*/jsxs(ChartContainer, {
103
107
  title: title,
104
108
  onExport: onExport,
105
109
  theme: theme,
106
110
  options: options,
107
111
  chartRef: chartRef,
108
- isEmpty: isEmpty(data),
109
- emptyIcon: CoreIcons.chartPie,
112
+ isEmpty: isEmpty(_series),
113
+ emptyIcon: "icon-[mdi--chart-pie]",
110
114
  dataTableRenderer: countRenderer,
111
115
  onClick: function onClick(e) {
112
116
  var _e$data$id;
113
117
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick((_e$data$id = e.data.id) !== null && _e$data$id !== void 0 ? _e$data$id : e.seriesId);
114
118
  },
115
- children: [/*#__PURE__*/jsxs(ToggleButtonGroup, {
119
+ children: [showTypeSelector && /*#__PURE__*/jsxs(ToggleButtonGroup, {
116
120
  value: type,
117
121
  onChange: setType,
118
122
  children: [/*#__PURE__*/jsx(Button, {
@@ -120,23 +124,23 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
120
124
  variant: "link",
121
125
  value: "pie",
122
126
  "aria-label": "pie",
123
- icon: CoreIcons.chartPie
127
+ icon: "icon-[mdi--chart-pie]"
124
128
  }), /*#__PURE__*/jsx(Button, {
125
129
  size: "sm",
126
130
  variant: "link",
127
131
  value: "column",
128
132
  "aria-label": "column",
129
- icon: CoreIcons.chartColumn
133
+ icon: "icon-[mdi--chart-bar]"
130
134
  }), /*#__PURE__*/jsx(Button, {
131
135
  size: "sm",
132
136
  variant: "link",
133
137
  value: "bar",
134
138
  "aria-label": "bar",
135
- icon: CoreIcons.chartBar
139
+ icon: "icon-[mdi--chart-bar] rotate-90 -scale-x-100"
136
140
  })]
137
- }), /*#__PURE__*/jsx(Divider, {
141
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsx(Divider, {
138
142
  vertical: true
139
- }), /*#__PURE__*/jsx(PaletteSelect, {
143
+ }), showThemeSelector && /*#__PURE__*/jsx(PaletteSelect, {
140
144
  theme: theme,
141
145
  onClick: setTheme
142
146
  })]
@@ -145,7 +149,33 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
145
149
  CountSeriesChart.displayName = "CountSeriesChart";
146
150
 
147
151
  /**
148
- * Chart to display simple data count series
152
+ * CountSeries component renders a chart that displays counts of items in various formats.
153
+ * It supports pie, bar, and column charts.
154
+ * It can be used to visualize the distribution of counts across different categories.
155
+ * It allows users to switch between different types of visualizations and customize the color palette used in the chart.
156
+ *
157
+ * @param {CountSeriesProps} props - The properties for the CountSeries component.
158
+ * @returns {JSX.Element} The rendered CountSeries component.
159
+ *
160
+ * @example
161
+ * ```jsx
162
+ * <CountSeries
163
+ * data={[
164
+ * { id: "A", label: "Category A", count: 10 },
165
+ * { id: "B", label: "Category B", count: 20 },
166
+ * { id: "C", label: "Category C", count: 30 },
167
+ * ]}
168
+ * title="Count Distribution"
169
+ * onExport={() => console.log("Exporting chart data")}
170
+ * theme="light"
171
+ * type="pie"
172
+ * onClick={(key) => console.log("Clicked on:", key)}
173
+ * />
174
+ * ```
175
+ *
176
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-countseries--docs} for more details on the properties.
177
+ * @see {@link https://echarts.apache.org/en/option.html#series-pie} for more details on the ECharts pie series options.
178
+ * @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
149
179
  */
150
180
  var CountSeries = function CountSeries(props) {
151
181
  return /*#__PURE__*/jsx(ChartWrapper, {
@@ -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';
@@ -14,12 +14,15 @@ import { jsxs, jsx } from 'react/jsx-runtime';
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
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; }
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,
@@ -40,7 +43,7 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
40
43
  setTheme(chartTheme);
41
44
  }, [chartTheme]);
42
45
  var options = useMemoDebugger(function () {
43
- if (isEmpty(data)) {
46
+ if (isEmpty(_series)) {
44
47
  var _chartRef$current;
45
48
  (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 || _chartRef$current.clear();
46
49
  return {};
@@ -50,7 +53,7 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
50
53
  _type$split2 = _slicedToArray(_type$split, 2),
51
54
  _type = _type$split2[0],
52
55
  stacked = _type$split2[1];
53
- var categoryAxis = _type === "radar" ? undefined : {
56
+ var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, _type === "radar" ? undefined : {
54
57
  name: categoryAxisName,
55
58
  type: "category",
56
59
  nameGap: 32,
@@ -59,57 +62,57 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
59
62
  show: false
60
63
  },
61
64
  data: categories
62
- };
63
- var valueAxis = _type === "radar" ? undefined : {
65
+ });
66
+ var valueAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, _type === "radar" ? undefined : {
64
67
  name: valueAxisName,
65
68
  type: "value",
66
69
  nameGap: 32,
67
70
  nameLocation: "center"
68
- };
69
- var radar = _type !== "radar" ? undefined : {
71
+ });
72
+ var radar = _type !== "radar" ? undefined : Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.radar, {
70
73
  shape: "circle",
71
74
  indicator: categories === null || categories === void 0 ? void 0 : categories.map(function (c) {
72
75
  return {
73
76
  name: c
74
77
  };
75
78
  })
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,
79
+ });
80
+ var series = _series === null || _series === void 0 ? void 0 : _series.map(function (item, index) {
81
+ var _item$stack, _item$label, _item$name;
82
+ return _objectSpread(_objectSpread({}, item), {}, {
83
+ stack: (_item$stack = item.stack) !== null && _item$stack !== void 0 ? _item$stack : stack,
82
84
  areaStyle: stacked ? {} : undefined,
83
85
  type: _type === "column" ? "bar" : _type,
84
86
  name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id,
85
87
  universalTransition: true,
86
88
  data: _type === "radar" ? [{
87
- value: item.values,
89
+ value: item.data,
88
90
  id: item.id,
89
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id
90
- }] : item.values
91
- };
91
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
92
+ }] : item.data
93
+ });
92
94
  });
93
- return {
95
+ return _objectSpread(_objectSpread({}, optionOverride), {}, {
94
96
  xAxis: type.startsWith("bar") ? valueAxis : categoryAxis,
95
97
  yAxis: type.startsWith("bar") ? categoryAxis : valueAxis,
96
98
  radar: radar,
97
99
  series: series,
98
- tooltip: {
100
+ tooltip: Object.assign({
99
101
  trigger: _type === "radar" ? "item" : "axis",
100
102
  confine: true,
101
- position: "top"
102
- }
103
- };
104
- }, [data, type, categories, categoryAxisName, valueAxisName], "DataChart options");
103
+ position: "top",
104
+ appendToBody: true
105
+ }, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip)
106
+ });
107
+ }, [_series, type, categories, categoryAxisName, valueAxisName, optionOverride], "DataChart options");
105
108
  return /*#__PURE__*/jsxs(ChartContainer, {
106
109
  title: title,
107
110
  onExport: onExport,
108
111
  theme: theme,
109
112
  options: options,
110
113
  chartRef: chartRef,
111
- isEmpty: isEmpty(data),
112
- emptyIcon: CoreIcons.chartColumn,
114
+ isEmpty: isEmpty(_series),
115
+ emptyIcon: "icon-[mdi--chart-bar]",
113
116
  dataTableRenderer: seriesRenderer,
114
117
  onClick: function onClick(e) {
115
118
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick({
@@ -117,55 +120,55 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
117
120
  series: e.seriesId
118
121
  });
119
122
  },
120
- children: [/*#__PURE__*/jsxs(ToggleButtonGroup, {
123
+ children: [showTypeSelector && /*#__PURE__*/jsxs(ToggleButtonGroup, {
121
124
  value: type,
122
125
  onChange: setType,
123
126
  children: [/*#__PURE__*/jsx(Button, {
124
127
  size: "sm",
125
128
  variant: "link",
126
- icon: CoreIcons.chartLine,
129
+ icon: "icon-[mdi--chart-line]",
127
130
  "aria-label": "line",
128
131
  value: "line"
129
132
  }), /*#__PURE__*/jsx(Button, {
130
133
  size: "sm",
131
134
  variant: "link",
132
- icon: CoreIcons.chartColumn,
135
+ icon: "icon-[mdi--chart-bar]",
133
136
  "aria-label": "column",
134
137
  value: "column"
135
138
  }), /*#__PURE__*/jsx(Button, {
136
139
  size: "sm",
137
140
  variant: "link",
138
- icon: CoreIcons.chartBar,
141
+ icon: "icon-[mdi--chart-bar] rotate-90 -scale-x-100",
139
142
  "aria-label": "bar",
140
143
  value: "bar"
141
144
  }), /*#__PURE__*/jsx(Button, {
142
145
  size: "sm",
143
146
  variant: "link",
144
- icon: CoreIcons.chartRadar,
147
+ icon: "icon-[mdi--radar]",
145
148
  "aria-label": "radar",
146
149
  value: "radar"
147
150
  }), /*#__PURE__*/jsx(Button, {
148
151
  size: "sm",
149
152
  variant: "link",
150
- icon: CoreIcons.chartLineStacked,
153
+ icon: "icon-[mdi--chart-line-stacked]",
151
154
  "aria-label": "line-stacked",
152
155
  value: "line-stacked"
153
156
  }), /*#__PURE__*/jsx(Button, {
154
157
  size: "sm",
155
158
  variant: "link",
156
- icon: CoreIcons.chartColumnStacked,
159
+ icon: "icon-[mdi--chart-bar-stacked]",
157
160
  "aria-label": "column-stacked",
158
161
  value: "column-stacked"
159
162
  }), /*#__PURE__*/jsx(Button, {
160
163
  size: "sm",
161
164
  variant: "link",
162
- icon: CoreIcons.chartBarStacked,
165
+ icon: "icon-[mdi--chart-bar-stacked] rotate-90 -scale-x-100",
163
166
  "aria-label": "bar-stacked",
164
167
  value: "bar-stacked"
165
168
  })]
166
- }), /*#__PURE__*/jsx(Divider, {
169
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsx(Divider, {
167
170
  vertical: true
168
- }), /*#__PURE__*/jsx(PaletteSelect, {
171
+ }), showThemeSelector && /*#__PURE__*/jsx(PaletteSelect, {
169
172
  theme: theme,
170
173
  onClick: setTheme
171
174
  })]
@@ -174,7 +177,32 @@ var DataSeriesChart = /*#__PURE__*/memo(function (_ref) {
174
177
  DataSeriesChart.displayName = "DataSeriesChart";
175
178
 
176
179
  /**
177
- * Chart to display simple data category series
180
+ * DataSeries component renders a chart for visualizing data series.
181
+ * It supports various chart types such as column, line, bar, radar, and stacked variants.
182
+ * It allows users to click on data points to trigger custom actions.
183
+ *
184
+ * @param {DataSeriesProps} props - The properties for the DataSeries component.
185
+ * @returns {JSX.Element} The rendered DataSeries component.
186
+ *
187
+ * @example
188
+ * ```jsx
189
+ * <DataSeries
190
+ * data={[{ id: "1", label: "Series 1", values: [10, 20, 30] }]}
191
+ * categories={["Category 1", "Category 2", "Category 3"]}
192
+ * categoryAxisName="Categories"
193
+ * valueAxisName="Values"
194
+ * title="Data Series Example"
195
+ * type="column"
196
+ * onClick={(data) => console.log("Clicked data:", data)}
197
+ * onExport={() => console.log("Exporting chart data")}
198
+ * theme="light"
199
+ * />
200
+ * ```
201
+ *
202
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-dataseries--docs} for more details on the properties.
203
+ * @see {@link https://echarts.apache.org/en/option.html#series-bar} for ECharts bar series options.
204
+ * @see {@link https://echarts.apache.org/en/option.html#series-line} for ECharts line series options.
205
+ * @see {@link https://echarts.apache.org/en/option.html#series-radar} for ECharts radar series options.
178
206
  */
179
207
  var DataSeries = function DataSeries(props) {
180
208
  return /*#__PURE__*/jsx(ChartWrapper, {