@react-fabric/chart 1.0.0-beta.8 → 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
@@ -21,13 +21,13 @@
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
- .chartContainer {
24
+ .fabric-chartContainer {
25
25
  & > div:last-child:not(:first-child) > :last-child {
26
+ inset-inline-end: 0 !important;
26
27
  top: 0;
27
28
  right: unset !important;
28
29
  bottom: unset !important;
29
30
  left: unset !important;
30
- inset-inline-end: 0 !important;
31
31
 
32
32
  padding: 0.5rem;
33
33
 
@@ -38,16 +38,17 @@
38
38
  }
39
39
  }
40
40
 
41
- .chartToolbar {
41
+ .fabric-chartToolbar {
42
42
  input[type="range"] {
43
43
  position: relative;
44
44
 
45
45
  overflow: hidden;
46
46
 
47
- color: theme(colors.primary.500);
47
+ border-radius: 999px;
48
+
49
+ color: var(--color-primary-500);
48
50
 
49
51
  appearance: none;
50
- border-radius: 999px;
51
52
 
52
53
  &::-webkit-slider-thumb {
53
54
  cursor: pointer;
@@ -56,10 +57,12 @@
56
57
 
57
58
  width: 1rem;
58
59
  height: 1rem;
60
+ border: 1px solid var(--color-tint-50);
61
+ border-radius: 0.5rem;
59
62
 
60
63
  appearance: none;
61
64
  opacity: 0.7;
62
- background: theme(colors.primary.500);
65
+ background: var(--color-primary-500);
63
66
  clip-path: polygon(
64
67
  100% -1px,
65
68
  0.125rem -1px,
@@ -71,20 +74,17 @@
71
74
  calc(100% + 1px) calc(100% + 1px)
72
75
  );
73
76
  filter: brightness(100%);
74
- border: 1px solid theme(colors.tint.50);
75
- border-radius: 0.5rem;
76
77
  box-shadow: calc(-100vmax - 1rem) 0 0 100vmax currentColor;
77
78
 
78
79
  &:hover {
79
- background: theme(colors.primary.600);
80
+ background: var(--color-primary-600);
80
81
  }
81
82
  }
82
83
 
83
84
  &&::-webkit-slider-runnable-track {
84
85
  height: 1rem;
85
- background: linear-gradient(theme(colors.tint.100) 0 0) scroll no-repeat
86
- center / 100% 0.25rem;
87
86
  border-radius: 99px;
87
+ background: linear-gradient(var(--color-tint-100) 0 0) scroll no-repeat center / 100% 0.25rem;
88
88
  }
89
89
  }
90
90
  }
package/css/styles.css ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ @import "./_chart.css";
@@ -6,7 +6,6 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
6
  var core = require('@react-fabric/core');
7
7
  var utilities = require('@react-fabric/utilities');
8
8
  var react = require('react');
9
- var palettes = require('../theme/palettes.js');
10
9
  var utils = require('../types/utils.js');
11
10
  var ChartContainer = require('../wrapper/ChartContainer.js');
12
11
  var ChartWrapper = require('../wrapper/ChartWrapper.js');
@@ -14,7 +13,7 @@ var PaletteSelect = require('../wrapper/PaletteSelect.js');
14
13
  var jsxRuntime = require('react/jsx-runtime');
15
14
 
16
15
  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; }
17
- 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
+ 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; }
18
17
  var DAY_HOUR = {
19
18
  high: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20
19
  low: ["12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p"]
@@ -24,33 +23,42 @@ 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__*/react.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,
39
41
  chartType = _ref$type === void 0 ? "scatter" : _ref$type,
40
42
  _onClick = _ref.onClick;
41
43
  var chartRef = react.useRef(null);
42
- var _useState = react.useState(chartType),
44
+ var _useState = react.useState(function () {
45
+ return chartType;
46
+ }),
43
47
  _useState2 = _slicedToArray(_useState, 2),
44
48
  type = _useState2[0],
45
49
  setType = _useState2[1];
46
- var _useState3 = react.useState(chartTheme),
50
+ var _useState3 = react.useState(function () {
51
+ return chartTheme;
52
+ }),
47
53
  _useState4 = _slicedToArray(_useState3, 2),
48
54
  theme = _useState4[0],
49
55
  setTheme = _useState4[1];
50
56
  react.useEffect(function () {
57
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
51
58
  setType(chartType);
52
59
  }, [chartType]);
53
60
  react.useEffect(function () {
61
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
54
62
  setTheme(chartTheme);
55
63
  }, [chartTheme]);
56
64
  var options = core.useMemoDebugger(function () {
@@ -58,8 +66,8 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
58
66
  var options = {
59
67
  series: []
60
68
  };
61
- if (utilities.isEmpty(data)) return {};
62
- options.xAxis = {
69
+ if (utilities.isEmpty(series)) return {};
70
+ options.xAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
63
71
  type: "category",
64
72
  data: lowLabels !== null && lowLabels !== void 0 ? lowLabels : defaultMap.low,
65
73
  boundaryGap: type === "heatmap",
@@ -69,8 +77,8 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
69
77
  axisLine: {
70
78
  show: false
71
79
  }
72
- };
73
- options.yAxis = {
80
+ });
81
+ options.yAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, {
74
82
  type: "category",
75
83
  axisLabel: {
76
84
  margin: 16
@@ -79,13 +87,13 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
79
87
  axisLine: {
80
88
  show: false
81
89
  }
82
- };
83
- options.series = data.map(function (points, index) {
90
+ });
91
+ options.series = series.map(function (points, index) {
84
92
  var total = points.reduce(function (t, p) {
85
93
  return t + p[2];
86
94
  }, 0);
87
95
  return {
88
- id: index,
96
+ id: "".concat(index),
89
97
  name: defaultMap.high[index],
90
98
  type: type,
91
99
  symbolSize: function symbolSize(dataItem) {
@@ -96,55 +104,64 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
96
104
  };
97
105
  });
98
106
  if (type === "heatmap") {
99
- var dataPoints = data.map(function (points) {
107
+ var dataPoints = series.map(function (points) {
100
108
  return Math.max.apply(Math, _toConsumableArray(points.map(function (pt) {
101
109
  return pt[2];
102
110
  })));
103
111
  });
104
112
  options.grid = {
105
113
  top: 32,
106
- bottom: 128
114
+ bottom: 64
107
115
  };
108
- options.visualMap = {
116
+ options.legend = {
117
+ show: false
118
+ };
119
+ options.visualMap = [{
109
120
  type: "piecewise",
110
121
  min: 1,
111
122
  show: type === "heatmap",
112
- color: heatmapPalette !== null && heatmapPalette !== void 0 ? heatmapPalette : _toConsumableArray(palettes.ChartPalette.Heatmap),
113
123
  max: Math.max.apply(Math, _toConsumableArray(dataPoints)),
114
- calculable: true,
124
+ // calculable: true,inRange:
115
125
  orient: "horizontal",
116
126
  left: "center",
117
- bottom: 48
118
- };
127
+ bottom: 4
128
+ }];
129
+ if (heatmapPalette) {
130
+ options.visualMap[0].inRange = {
131
+ color: heatmapPalette
132
+ };
133
+ }
119
134
  }
120
- return _objectSpread({
135
+ return _objectSpread(_objectSpread({
121
136
  grid: {
122
137
  top: 32,
123
138
  bottom: 64
124
139
  },
125
- tooltip: {
140
+ tooltip: Object.assign({
126
141
  trigger: "item",
127
142
  confine: true,
128
143
  position: "top",
144
+ appendToBody: true,
129
145
  valueFormatter: function valueFormatter(c) {
130
146
  return utilities.isArray(c) ? c[2] : c;
131
147
  }
132
- }
133
- }, options);
134
- }, [data, title, type], "ActivityChart options");
148
+ }, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip)
149
+ }, optionOverride), options);
150
+ }, [series, title, type, heatmapPalette, optionOverride], "ActivityChart options");
135
151
  return /*#__PURE__*/jsxRuntime.jsxs(ChartContainer.ChartContainer, {
136
152
  title: title,
137
153
  onExport: onExport,
138
154
  theme: theme,
139
155
  options: options,
140
156
  chartRef: chartRef,
141
- isEmpty: utilities.isEmpty(data),
142
- emptyIcon: core.CoreIcons.chartActivityScatter,
157
+ isEmpty: utilities.isEmpty(series),
158
+ emptyIcon: "icon-[mdi--chart-scatter-plot]",
143
159
  dataTableRenderer: utils.activityRenderer,
144
160
  onClick: function onClick(e) {
145
- return _onClick === null || _onClick === void 0 ? void 0 : _onClick(e.seriesIndex, e.dataIndex);
161
+ var _e$seriesIndex;
162
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick((_e$seriesIndex = e.seriesIndex) !== null && _e$seriesIndex !== void 0 ? _e$seriesIndex : 0, e.dataIndex);
146
163
  },
147
- children: [/*#__PURE__*/jsxRuntime.jsxs(core.ToggleButtonGroup, {
164
+ children: [showTypeSelector && /*#__PURE__*/jsxRuntime.jsxs(core.ToggleButtonGroup, {
148
165
  value: type,
149
166
  onChange: setType,
150
167
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
@@ -152,17 +169,17 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
152
169
  variant: "link",
153
170
  value: "scatter",
154
171
  "aria-label": "scatter",
155
- icon: core.CoreIcons.chartActivityScatter
172
+ icon: "icon-[mdi--chart-scatter-plot]"
156
173
  }), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
157
174
  size: "sm",
158
175
  variant: "link",
159
176
  value: "heatmap",
160
177
  "aria-label": "heatmap",
161
- icon: core.CoreIcons.chartActivityCalendar
178
+ icon: "icon-[mdi--checkerboard]"
162
179
  })]
163
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {
180
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsxRuntime.jsx(core.Divider, {
164
181
  vertical: true
165
- }), /*#__PURE__*/jsxRuntime.jsx(PaletteSelect.PaletteSelect, {
182
+ }), showThemeSelector && /*#__PURE__*/jsxRuntime.jsx(PaletteSelect.PaletteSelect, {
166
183
  theme: theme,
167
184
  onClick: setTheme,
168
185
  defaultTheme: "activity"
@@ -172,12 +189,29 @@ var ActivityMapChart = /*#__PURE__*/react.memo(function (_ref) {
172
189
  ActivityMapChart.displayName = "ActivityMapChart";
173
190
 
174
191
  /**
175
- * Chart showing activity map
192
+ * ActivityMap component renders a chart that visualizes activity data
193
+ * over time, using either a scatter plot or a heatmap.
194
+ * It allows users to switch between different types of visualizations
195
+ * and customize the color palette used in the chart.
196
+ *
197
+ * @example
198
+ * ```jsx
199
+ * <ActivityMap
200
+ * data={activityData}
201
+ * time="day-hour"
202
+ * type="heatmap"
203
+ * heatmapPalette={["#f0f8ff", "#faebd7", "#00ffff", "#7fffd4"]}
204
+ * highLabels={["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}
205
+ * 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"]}
206
+ * onClick={(highIndex, lowIndex) => console.log(`Clicked on: ${highIndex}, ${lowIndex}`)}
207
+ * />
208
+ * ```
209
+ * @see {@link https://echarts.apache.org/en/option.html#series-scatter} for more details on the ECharts scatter series.
176
210
  */
177
- var ActivityMap = function ActivityMap(props) {
211
+ function ActivityMap(props) {
178
212
  return /*#__PURE__*/jsxRuntime.jsx(ChartWrapper.ChartWrapper, {
179
213
  children: /*#__PURE__*/jsxRuntime.jsx(ActivityMapChart, _objectSpread({}, props))
180
214
  });
181
- };
215
+ }
182
216
 
183
217
  exports.ActivityMap = ActivityMap;
@@ -12,68 +12,78 @@ var PaletteSelect = require('../wrapper/PaletteSelect.js');
12
12
  var jsxRuntime = require('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 CountSeriesChart = /*#__PURE__*/react.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 = react.useRef(null);
25
- var _useState = react.useState(chartType),
29
+ var _useState = react.useState(function () {
30
+ return chartType;
31
+ }),
26
32
  _useState2 = _slicedToArray(_useState, 2),
27
33
  type = _useState2[0],
28
34
  setType = _useState2[1];
29
- var _useState3 = react.useState(chartTheme),
35
+ var _useState3 = react.useState(function () {
36
+ return chartTheme;
37
+ }),
30
38
  _useState4 = _slicedToArray(_useState3, 2),
31
39
  theme = _useState4[0],
32
40
  setTheme = _useState4[1];
33
41
  react.useEffect(function () {
42
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
34
43
  setType(chartType);
35
44
  }, [chartType]);
36
45
  react.useEffect(function () {
46
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
37
47
  setTheme(chartTheme);
38
48
  }, [chartTheme]);
39
49
  var options = core.useMemoDebugger(function () {
40
- if (utilities.isEmpty(data)) {
50
+ if (utilities.isEmpty(_series)) {
41
51
  var _chartRef$current;
42
52
  (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 || _chartRef$current.clear();
43
53
  return {};
44
54
  }
45
- var sorted = data === null || data === void 0 ? void 0 : data.sort(utilities.compareValues("desc", "count"));
46
- var categoryAxis = {
55
+ var sorted = _series === null || _series === void 0 ? void 0 : _series.sort(utilities.compareValues("desc", "count"));
56
+ var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
47
57
  type: "category",
48
- name: title !== null && title !== void 0 ? title : "Count Series",
58
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
49
59
  nameLocation: "center",
50
60
  axisTick: {
51
61
  show: false
52
62
  },
53
63
  data: []
54
- };
55
- var valueAxis = {
64
+ });
65
+ var valueAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.yAxis, {
56
66
  type: "value",
57
67
  axisLabel: {
58
68
  formatter: function formatter(val) {
59
69
  return utilities.Format.number(val);
60
70
  }
61
71
  }
62
- };
72
+ });
63
73
  var series = type === "pie" ? [{
64
74
  type: "pie",
65
- name: title !== null && title !== void 0 ? title : "Count Series",
66
- data: sorted.map(function (item, index) {
67
- var _item$label;
75
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
76
+ data: sorted.map(function (item) {
77
+ var _item$name;
68
78
  return {
69
79
  id: item.id,
70
80
  value: item.count,
71
- name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id
81
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
72
82
  };
73
83
  }),
74
84
  universalTransition: true
75
- }] : sorted.map(function (item, index) {
76
- var _item$label2;
85
+ }] : sorted.map(function (item) {
86
+ var _item$name2;
77
87
  return {
78
88
  id: item.id,
79
89
  type: "bar",
@@ -85,34 +95,34 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
85
95
  color: "#fff"
86
96
  },
87
97
  data: [{
88
- name: title !== null && title !== void 0 ? title : "Count Series",
98
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
89
99
  value: item.count
90
100
  }],
91
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id,
101
+ name: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : item.id,
92
102
  universalTransition: true
93
103
  };
94
104
  });
95
- return {
105
+ return _objectSpread(_objectSpread({}, optionOverride), {}, {
96
106
  series: series,
97
107
  countSeries: true,
98
108
  xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
99
109
  yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
100
- };
101
- }, [data, title, type], "CountChart options");
110
+ });
111
+ }, [_series, seriesName, type, optionOverride], "CountChart options");
102
112
  return /*#__PURE__*/jsxRuntime.jsxs(ChartContainer.ChartContainer, {
103
113
  title: title,
104
114
  onExport: onExport,
105
115
  theme: theme,
106
116
  options: options,
107
117
  chartRef: chartRef,
108
- isEmpty: utilities.isEmpty(data),
109
- emptyIcon: core.CoreIcons.chartPie,
118
+ isEmpty: utilities.isEmpty(_series),
119
+ emptyIcon: "icon-[mdi--chart-pie]",
110
120
  dataTableRenderer: utils.countRenderer,
111
121
  onClick: function onClick(e) {
112
- var _e$data$id;
113
- 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);
122
+ var _ref2, _id, _e$data;
123
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick((_ref2 = (_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 : e.seriesId) !== null && _ref2 !== void 0 ? _ref2 : "");
114
124
  },
115
- children: [/*#__PURE__*/jsxRuntime.jsxs(core.ToggleButtonGroup, {
125
+ children: [showTypeSelector && /*#__PURE__*/jsxRuntime.jsxs(core.ToggleButtonGroup, {
116
126
  value: type,
117
127
  onChange: setType,
118
128
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
@@ -120,23 +130,23 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
120
130
  variant: "link",
121
131
  value: "pie",
122
132
  "aria-label": "pie",
123
- icon: core.CoreIcons.chartPie
133
+ icon: "icon-[mdi--chart-pie]"
124
134
  }), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
125
135
  size: "sm",
126
136
  variant: "link",
127
137
  value: "column",
128
138
  "aria-label": "column",
129
- icon: core.CoreIcons.chartColumn
139
+ icon: "icon-[mdi--chart-bar]"
130
140
  }), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
131
141
  size: "sm",
132
142
  variant: "link",
133
143
  value: "bar",
134
144
  "aria-label": "bar",
135
- icon: core.CoreIcons.chartBar
145
+ icon: "icon-[mdi--chart-bar] rotate-90 -scale-x-100"
136
146
  })]
137
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {
147
+ }), showTypeSelector && showThemeSelector && /*#__PURE__*/jsxRuntime.jsx(core.Divider, {
138
148
  vertical: true
139
- }), /*#__PURE__*/jsxRuntime.jsx(PaletteSelect.PaletteSelect, {
149
+ }), showThemeSelector && /*#__PURE__*/jsxRuntime.jsx(PaletteSelect.PaletteSelect, {
140
150
  theme: theme,
141
151
  onClick: setTheme
142
152
  })]
@@ -145,12 +155,34 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
145
155
  CountSeriesChart.displayName = "CountSeriesChart";
146
156
 
147
157
  /**
148
- * Chart to display simple data count series
158
+ * CountSeries component renders a chart that displays counts of items in various formats.
159
+ * It supports pie, bar, and column charts.
160
+ * It can be used to visualize the distribution of counts across different categories.
161
+ * It allows users to switch between different types of visualizations and customize the color palette used in the chart.
162
+ *
163
+ * @example
164
+ * ```jsx
165
+ * <CountSeries
166
+ * data={[
167
+ * { id: "A", label: "Category A", count: 10 },
168
+ * { id: "B", label: "Category B", count: 20 },
169
+ * { id: "C", label: "Category C", count: 30 },
170
+ * ]}
171
+ * title="Count Distribution"
172
+ * onExport={() => console.log("Exporting chart data")}
173
+ * theme="light"
174
+ * type="pie"
175
+ * onClick={(key) => console.log("Clicked on:", key)}
176
+ * />
177
+ * ```
178
+ *
179
+ * @see {@link https://echarts.apache.org/en/option.html#series-pie} for more details on the ECharts pie series options.
180
+ * @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
149
181
  */
150
- var CountSeries = function CountSeries(props) {
182
+ function CountSeries(props) {
151
183
  return /*#__PURE__*/jsxRuntime.jsx(ChartWrapper.ChartWrapper, {
152
184
  children: /*#__PURE__*/jsxRuntime.jsx(CountSeriesChart, _objectSpread({}, props))
153
185
  });
154
- };
186
+ }
155
187
 
156
188
  exports.CountSeries = CountSeries;