@react-fabric/chart 1.0.0-beta.51 → 1.0.0-beta.53
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.
- package/dist/cjs/charts/ActivityMap.js +43 -13
- package/dist/cjs/charts/CountSeries.js +32 -4
- package/dist/cjs/charts/DataSeries.js +33 -5
- package/dist/cjs/charts/Generic.js +29 -5
- package/dist/cjs/charts/MapSeries.js +27 -3
- package/dist/cjs/charts/TimeSeries.js +31 -5
- package/dist/cjs/charts/TimeSlider.js +21 -1
- package/dist/cjs/charts/WordBubble.js +31 -1
- package/dist/cjs/theme/darkBase.js +0 -5
- package/dist/cjs/theme/index.js +38 -18
- package/dist/cjs/theme/lightBase.js +0 -5
- package/dist/cjs/theme/palettes.js +27 -27
- package/dist/cjs/types/charts.js +2 -2
- package/dist/cjs/wrapper/ChartContainer.js +2 -1
- package/dist/cjs/wrapper/ChartToolbar.js +1 -1
- package/dist/esm/charts/ActivityMap.js +43 -13
- package/dist/esm/charts/CountSeries.js +32 -4
- package/dist/esm/charts/DataSeries.js +33 -5
- package/dist/esm/charts/Generic.js +31 -7
- package/dist/esm/charts/MapSeries.js +27 -3
- package/dist/esm/charts/TimeSeries.js +31 -5
- package/dist/esm/charts/TimeSlider.js +21 -1
- package/dist/esm/charts/WordBubble.js +31 -1
- package/dist/esm/theme/darkBase.js +0 -5
- package/dist/esm/theme/index.js +38 -18
- package/dist/esm/theme/lightBase.js +0 -5
- package/dist/esm/theme/palettes.js +27 -27
- package/dist/esm/types/charts.js +2 -2
- package/dist/esm/wrapper/ChartContainer.js +2 -1
- package/dist/esm/wrapper/ChartToolbar.js +1 -1
- package/dist/types/charts/ActivityMap.d.ts +22 -1
- package/dist/types/charts/CountSeries.d.ts +27 -1
- package/dist/types/charts/DataSeries.d.ts +26 -1
- package/dist/types/charts/Generic.d.ts +13 -0
- package/dist/types/charts/MapSeries.d.ts +24 -1
- package/dist/types/charts/TimeSeries.d.ts +24 -1
- package/dist/types/charts/TimeSlider.d.ts +21 -1
- package/dist/types/charts/WordBubble.d.ts +25 -1
- package/dist/types/theme/darkBase.d.ts +0 -5
- package/dist/types/theme/index.d.ts +1 -1
- package/dist/types/theme/lightBase.d.ts +0 -5
- package/dist/types/types/charts.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types/types/world.svg.d.ts +1 -1
- package/package.json +4 -4
- package/src/charts/ActivityMap.tsx +75 -37
- package/src/charts/CountSeries.tsx +58 -26
- package/src/charts/DataSeries.tsx +86 -54
- package/src/charts/Generic.tsx +24 -4
- package/src/charts/MapSeries.tsx +50 -18
- package/src/charts/TimeSeries.tsx +64 -34
- package/src/charts/TimeSlider.tsx +21 -1
- package/src/charts/WordBubble.tsx +31 -1
- package/src/theme/darkBase.ts +0 -5
- package/src/theme/index.ts +94 -20
- package/src/theme/lightBase.ts +0 -5
- package/src/theme/palettes.ts +1 -52
- package/src/types/charts.ts +6 -2
- package/src/types/index.ts +6 -1
- package/src/wrapper/ChartContainer.tsx +1 -0
- package/src/wrapper/ChartToolbar.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/chart",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.53",
|
|
4
4
|
"description": "RUF: Charting package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.53",
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
40
40
|
"classnames": "^2.5.1",
|
|
41
41
|
"color": "^4.2.3",
|
|
42
42
|
"date-fns": "^4.0.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"node": ">=18.12.0",
|
|
57
57
|
"npm": ">=8.19.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "1042327831f9c908912c552d5c2704b765a6f9c2"
|
|
60
60
|
}
|
|
@@ -37,6 +37,7 @@ import { activityRenderer } from "../types/utils";
|
|
|
37
37
|
import { ChartContainer } from "../wrapper/ChartContainer";
|
|
38
38
|
import { ChartWrapper } from "../wrapper/ChartWrapper";
|
|
39
39
|
import { PaletteSelect } from "../wrapper/PaletteSelect";
|
|
40
|
+
import { E } from "react-router/dist/development/register-DCE0tH5m";
|
|
40
41
|
|
|
41
42
|
export interface ActivityMapProps extends BaseChart {
|
|
42
43
|
heatmapPalette?: string[];
|
|
@@ -142,6 +143,8 @@ const ActivityMapChart = memo(
|
|
|
142
143
|
heatmapPalette,
|
|
143
144
|
highLabels,
|
|
144
145
|
lowLabels,
|
|
146
|
+
showThemeSelector,
|
|
147
|
+
showTypeSelector,
|
|
145
148
|
time = "day-hour",
|
|
146
149
|
type: chartType = "scatter",
|
|
147
150
|
onClick,
|
|
@@ -161,7 +164,7 @@ const ActivityMapChart = memo(
|
|
|
161
164
|
() => {
|
|
162
165
|
const defaultMap = time === "day-hour" ? DAY_HOUR : MONTH_DAY;
|
|
163
166
|
|
|
164
|
-
const options:
|
|
167
|
+
const options: EChartOption = {
|
|
165
168
|
series: [],
|
|
166
169
|
};
|
|
167
170
|
|
|
@@ -191,7 +194,7 @@ const ActivityMapChart = memo(
|
|
|
191
194
|
options.series = data.map((points, index) => {
|
|
192
195
|
const total = points.reduce((t, p) => t + p[2], 0);
|
|
193
196
|
return {
|
|
194
|
-
id: index
|
|
197
|
+
id: `${index}`,
|
|
195
198
|
name: defaultMap.high[index],
|
|
196
199
|
type,
|
|
197
200
|
symbolSize: function (dataItem: number[]) {
|
|
@@ -201,7 +204,7 @@ const ActivityMapChart = memo(
|
|
|
201
204
|
},
|
|
202
205
|
data: points,
|
|
203
206
|
universalTransition: true,
|
|
204
|
-
};
|
|
207
|
+
} as EChartOption.SeriesScatter;
|
|
205
208
|
});
|
|
206
209
|
|
|
207
210
|
if (type === "heatmap") {
|
|
@@ -210,19 +213,28 @@ const ActivityMapChart = memo(
|
|
|
210
213
|
);
|
|
211
214
|
options.grid = {
|
|
212
215
|
top: 32,
|
|
213
|
-
bottom:
|
|
216
|
+
bottom: 64,
|
|
214
217
|
};
|
|
215
|
-
options.
|
|
216
|
-
|
|
217
|
-
min: 1,
|
|
218
|
-
show: type === "heatmap",
|
|
219
|
-
color: heatmapPalette ?? [...ChartPalette.Heatmap],
|
|
220
|
-
max: Math.max(...dataPoints),
|
|
221
|
-
calculable: true,
|
|
222
|
-
orient: "horizontal",
|
|
223
|
-
left: "center",
|
|
224
|
-
bottom: 48,
|
|
218
|
+
options.legend = {
|
|
219
|
+
show: false,
|
|
225
220
|
};
|
|
221
|
+
options.visualMap = [
|
|
222
|
+
{
|
|
223
|
+
type: "piecewise",
|
|
224
|
+
min: 1,
|
|
225
|
+
show: type === "heatmap",
|
|
226
|
+
max: Math.max(...dataPoints),
|
|
227
|
+
// calculable: true,inRange:
|
|
228
|
+
orient: "horizontal",
|
|
229
|
+
left: "center",
|
|
230
|
+
bottom: 4,
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
if (heatmapPalette) {
|
|
234
|
+
options.visualMap[0].inRange = {
|
|
235
|
+
color: heatmapPalette,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
226
238
|
}
|
|
227
239
|
|
|
228
240
|
return {
|
|
@@ -234,6 +246,7 @@ const ActivityMapChart = memo(
|
|
|
234
246
|
trigger: "item",
|
|
235
247
|
confine: true,
|
|
236
248
|
position: "top",
|
|
249
|
+
appendToBody: true,
|
|
237
250
|
valueFormatter: (c: AnyObject) => {
|
|
238
251
|
return isArray(c) ? c[2] : c;
|
|
239
252
|
},
|
|
@@ -241,7 +254,7 @@ const ActivityMapChart = memo(
|
|
|
241
254
|
...options,
|
|
242
255
|
};
|
|
243
256
|
},
|
|
244
|
-
[data, title, type],
|
|
257
|
+
[data, title, type, heatmapPalette],
|
|
245
258
|
"ActivityChart options",
|
|
246
259
|
);
|
|
247
260
|
|
|
@@ -257,28 +270,32 @@ const ActivityMapChart = memo(
|
|
|
257
270
|
dataTableRenderer={activityRenderer}
|
|
258
271
|
onClick={(e) => onClick?.(e.seriesIndex, e.dataIndex)}
|
|
259
272
|
>
|
|
260
|
-
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
{showTypeSelector && (
|
|
274
|
+
<ToggleButtonGroup value={type} onChange={setType as AnyObject}>
|
|
275
|
+
<Button
|
|
276
|
+
size="sm"
|
|
277
|
+
variant="link"
|
|
278
|
+
value="scatter"
|
|
279
|
+
aria-label="scatter"
|
|
280
|
+
icon={CoreIcons.chartActivityScatter}
|
|
281
|
+
/>
|
|
282
|
+
<Button
|
|
283
|
+
size="sm"
|
|
284
|
+
variant="link"
|
|
285
|
+
value="heatmap"
|
|
286
|
+
aria-label="heatmap"
|
|
287
|
+
icon={CoreIcons.chartActivityCalendar}
|
|
288
|
+
/>
|
|
289
|
+
</ToggleButtonGroup>
|
|
290
|
+
)}
|
|
291
|
+
{showTypeSelector && showThemeSelector && <Divider vertical />}
|
|
292
|
+
{showThemeSelector && (
|
|
293
|
+
<PaletteSelect
|
|
294
|
+
theme={theme}
|
|
295
|
+
onClick={setTheme}
|
|
296
|
+
defaultTheme="activity"
|
|
267
297
|
/>
|
|
268
|
-
|
|
269
|
-
size="sm"
|
|
270
|
-
variant="link"
|
|
271
|
-
value="heatmap"
|
|
272
|
-
aria-label="heatmap"
|
|
273
|
-
icon={CoreIcons.chartActivityCalendar}
|
|
274
|
-
/>
|
|
275
|
-
</ToggleButtonGroup>
|
|
276
|
-
<Divider vertical />
|
|
277
|
-
<PaletteSelect
|
|
278
|
-
theme={theme}
|
|
279
|
-
onClick={setTheme}
|
|
280
|
-
defaultTheme="activity"
|
|
281
|
-
/>
|
|
298
|
+
)}
|
|
282
299
|
</ChartContainer>
|
|
283
300
|
);
|
|
284
301
|
},
|
|
@@ -286,7 +303,28 @@ const ActivityMapChart = memo(
|
|
|
286
303
|
ActivityMapChart.displayName = "ActivityMapChart";
|
|
287
304
|
|
|
288
305
|
/**
|
|
289
|
-
*
|
|
306
|
+
* ActivityMap component renders a chart that visualizes activity data
|
|
307
|
+
* over time, using either a scatter plot or a heatmap.
|
|
308
|
+
* It allows users to switch between different types of visualizations
|
|
309
|
+
* and customize the color palette used in the chart.
|
|
310
|
+
*
|
|
311
|
+
* @param {ActivityMapProps} props - The properties for the ActivityMap component.
|
|
312
|
+
* @returns {JSX.Element} The rendered ActivityMap component.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```jsx
|
|
316
|
+
* <ActivityMap
|
|
317
|
+
* data={activityData}
|
|
318
|
+
* time="day-hour"
|
|
319
|
+
* type="heatmap"
|
|
320
|
+
* heatmapPalette={["#f0f8ff", "#faebd7", "#00ffff", "#7fffd4"]}
|
|
321
|
+
* highLabels={["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}
|
|
322
|
+
* 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"]}
|
|
323
|
+
* onClick={(highIndex, lowIndex) => console.log(`Clicked on: ${highIndex}, ${lowIndex}`)}
|
|
324
|
+
* />
|
|
325
|
+
* ```
|
|
326
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-activitymap--docs} for more details on the properties.
|
|
327
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-scatter} for more details on the ECharts scatter series.
|
|
290
328
|
*/
|
|
291
329
|
export const ActivityMap: FC<ActivityMapProps> = (props) => (
|
|
292
330
|
<ChartWrapper>
|
|
@@ -49,6 +49,8 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
49
49
|
onExport,
|
|
50
50
|
theme: chartTheme,
|
|
51
51
|
type: chartType = "pie",
|
|
52
|
+
showThemeSelector,
|
|
53
|
+
showTypeSelector,
|
|
52
54
|
onClick,
|
|
53
55
|
}: CountSeriesProps) => {
|
|
54
56
|
const chartRef = useRef<EChartsType>(null);
|
|
@@ -145,31 +147,35 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
145
147
|
dataTableRenderer={countRenderer}
|
|
146
148
|
onClick={(e) => onClick?.(e.data.id ?? e.seriesId)}
|
|
147
149
|
>
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
150
|
+
{showTypeSelector && (
|
|
151
|
+
<ToggleButtonGroup value={type} onChange={setType as AnyObject}>
|
|
152
|
+
<Button
|
|
153
|
+
size="sm"
|
|
154
|
+
variant="link"
|
|
155
|
+
value="pie"
|
|
156
|
+
aria-label="pie"
|
|
157
|
+
icon={CoreIcons.chartPie}
|
|
158
|
+
/>
|
|
159
|
+
<Button
|
|
160
|
+
size="sm"
|
|
161
|
+
variant="link"
|
|
162
|
+
value="column"
|
|
163
|
+
aria-label="column"
|
|
164
|
+
icon={CoreIcons.chartColumn}
|
|
165
|
+
/>
|
|
166
|
+
<Button
|
|
167
|
+
size="sm"
|
|
168
|
+
variant="link"
|
|
169
|
+
value="bar"
|
|
170
|
+
aria-label="bar"
|
|
171
|
+
icon={CoreIcons.chartBar}
|
|
172
|
+
/>
|
|
173
|
+
</ToggleButtonGroup>
|
|
174
|
+
)}
|
|
175
|
+
{showTypeSelector && showThemeSelector && <Divider vertical />}
|
|
176
|
+
{showThemeSelector && (
|
|
177
|
+
<PaletteSelect theme={theme} onClick={setTheme} />
|
|
178
|
+
)}
|
|
173
179
|
</ChartContainer>
|
|
174
180
|
);
|
|
175
181
|
},
|
|
@@ -177,7 +183,33 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
177
183
|
CountSeriesChart.displayName = "CountSeriesChart";
|
|
178
184
|
|
|
179
185
|
/**
|
|
180
|
-
*
|
|
186
|
+
* CountSeries component renders a chart that displays counts of items in various formats.
|
|
187
|
+
* It supports pie, bar, and column charts.
|
|
188
|
+
* It can be used to visualize the distribution of counts across different categories.
|
|
189
|
+
* It allows users to switch between different types of visualizations and customize the color palette used in the chart.
|
|
190
|
+
*
|
|
191
|
+
* @param {CountSeriesProps} props - The properties for the CountSeries component.
|
|
192
|
+
* @returns {JSX.Element} The rendered CountSeries component.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```jsx
|
|
196
|
+
* <CountSeries
|
|
197
|
+
* data={[
|
|
198
|
+
* { id: "A", label: "Category A", count: 10 },
|
|
199
|
+
* { id: "B", label: "Category B", count: 20 },
|
|
200
|
+
* { id: "C", label: "Category C", count: 30 },
|
|
201
|
+
* ]}
|
|
202
|
+
* title="Count Distribution"
|
|
203
|
+
* onExport={() => console.log("Exporting chart data")}
|
|
204
|
+
* theme="light"
|
|
205
|
+
* type="pie"
|
|
206
|
+
* onClick={(key) => console.log("Clicked on:", key)}
|
|
207
|
+
* />
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-countseries--docs} for more details on the properties.
|
|
211
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-pie} for more details on the ECharts pie series options.
|
|
212
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
|
|
181
213
|
*/
|
|
182
214
|
export const CountSeries: FC<CountSeriesProps> = (props) => (
|
|
183
215
|
<ChartWrapper>
|
|
@@ -57,6 +57,8 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
57
57
|
categoryAxisName,
|
|
58
58
|
valueAxisName,
|
|
59
59
|
title,
|
|
60
|
+
showThemeSelector,
|
|
61
|
+
showTypeSelector,
|
|
60
62
|
theme: chartTheme,
|
|
61
63
|
type: chartType = "column",
|
|
62
64
|
onClick,
|
|
@@ -140,6 +142,7 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
140
142
|
trigger: _type === "radar" ? "item" : "axis",
|
|
141
143
|
confine: true,
|
|
142
144
|
position: "top",
|
|
145
|
+
appendToBody: true,
|
|
143
146
|
} as AnyObject,
|
|
144
147
|
};
|
|
145
148
|
},
|
|
@@ -159,59 +162,63 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
159
162
|
dataTableRenderer={seriesRenderer}
|
|
160
163
|
onClick={(e) => onClick?.({ category: e.name, series: e.seriesId })}
|
|
161
164
|
>
|
|
162
|
-
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
165
|
+
{showTypeSelector && (
|
|
166
|
+
<ToggleButtonGroup value={type} onChange={setType as AnyObject}>
|
|
167
|
+
<Button
|
|
168
|
+
size="sm"
|
|
169
|
+
variant="link"
|
|
170
|
+
icon={CoreIcons.chartLine}
|
|
171
|
+
aria-label="line"
|
|
172
|
+
value="line"
|
|
173
|
+
/>
|
|
174
|
+
<Button
|
|
175
|
+
size="sm"
|
|
176
|
+
variant="link"
|
|
177
|
+
icon={CoreIcons.chartColumn}
|
|
178
|
+
aria-label="column"
|
|
179
|
+
value="column"
|
|
180
|
+
/>
|
|
181
|
+
<Button
|
|
182
|
+
size="sm"
|
|
183
|
+
variant="link"
|
|
184
|
+
icon={CoreIcons.chartBar}
|
|
185
|
+
aria-label="bar"
|
|
186
|
+
value="bar"
|
|
187
|
+
/>
|
|
188
|
+
<Button
|
|
189
|
+
size="sm"
|
|
190
|
+
variant="link"
|
|
191
|
+
icon={CoreIcons.chartRadar}
|
|
192
|
+
aria-label="radar"
|
|
193
|
+
value="radar"
|
|
194
|
+
/>
|
|
195
|
+
<Button
|
|
196
|
+
size="sm"
|
|
197
|
+
variant="link"
|
|
198
|
+
icon={CoreIcons.chartLineStacked}
|
|
199
|
+
aria-label="line-stacked"
|
|
200
|
+
value="line-stacked"
|
|
201
|
+
/>
|
|
202
|
+
<Button
|
|
203
|
+
size="sm"
|
|
204
|
+
variant="link"
|
|
205
|
+
icon={CoreIcons.chartColumnStacked}
|
|
206
|
+
aria-label="column-stacked"
|
|
207
|
+
value="column-stacked"
|
|
208
|
+
/>
|
|
209
|
+
<Button
|
|
210
|
+
size="sm"
|
|
211
|
+
variant="link"
|
|
212
|
+
icon={CoreIcons.chartBarStacked}
|
|
213
|
+
aria-label="bar-stacked"
|
|
214
|
+
value="bar-stacked"
|
|
215
|
+
/>
|
|
216
|
+
</ToggleButtonGroup>
|
|
217
|
+
)}
|
|
218
|
+
{showTypeSelector && showThemeSelector && <Divider vertical />}
|
|
219
|
+
{showThemeSelector && (
|
|
220
|
+
<PaletteSelect theme={theme} onClick={setTheme} />
|
|
221
|
+
)}
|
|
215
222
|
</ChartContainer>
|
|
216
223
|
);
|
|
217
224
|
},
|
|
@@ -219,7 +226,32 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
219
226
|
DataSeriesChart.displayName = "DataSeriesChart";
|
|
220
227
|
|
|
221
228
|
/**
|
|
222
|
-
*
|
|
229
|
+
* DataSeries component renders a chart for visualizing data series.
|
|
230
|
+
* It supports various chart types such as column, line, bar, radar, and stacked variants.
|
|
231
|
+
* It allows users to click on data points to trigger custom actions.
|
|
232
|
+
*
|
|
233
|
+
* @param {DataSeriesProps} props - The properties for the DataSeries component.
|
|
234
|
+
* @returns {JSX.Element} The rendered DataSeries component.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```jsx
|
|
238
|
+
* <DataSeries
|
|
239
|
+
* data={[{ id: "1", label: "Series 1", values: [10, 20, 30] }]}
|
|
240
|
+
* categories={["Category 1", "Category 2", "Category 3"]}
|
|
241
|
+
* categoryAxisName="Categories"
|
|
242
|
+
* valueAxisName="Values"
|
|
243
|
+
* title="Data Series Example"
|
|
244
|
+
* type="column"
|
|
245
|
+
* onClick={(data) => console.log("Clicked data:", data)}
|
|
246
|
+
* onExport={() => console.log("Exporting chart data")}
|
|
247
|
+
* theme="light"
|
|
248
|
+
* />
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-dataseries--docs} for more details on the properties.
|
|
252
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-bar} for ECharts bar series options.
|
|
253
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-line} for ECharts line series options.
|
|
254
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-radar} for ECharts radar series options.
|
|
223
255
|
*/
|
|
224
256
|
export const DataSeries: FC<DataSeriesProps> = (props) => (
|
|
225
257
|
<ChartWrapper>
|
package/src/charts/Generic.tsx
CHANGED
|
@@ -27,12 +27,14 @@ import {
|
|
|
27
27
|
useEffect,
|
|
28
28
|
useImperativeHandle,
|
|
29
29
|
useRef,
|
|
30
|
+
useState,
|
|
30
31
|
type FC,
|
|
31
32
|
type Ref,
|
|
32
33
|
} from "react";
|
|
33
34
|
import { type BaseChart } from "../types";
|
|
34
35
|
import { ChartContainer } from "../wrapper/ChartContainer";
|
|
35
36
|
import { ChartWrapper } from "../wrapper/ChartWrapper";
|
|
37
|
+
import { PaletteSelect } from "../wrapper/PaletteSelect";
|
|
36
38
|
|
|
37
39
|
export interface GenericProps extends BaseChart {
|
|
38
40
|
chartRef?: Ref<EChartsType>;
|
|
@@ -96,7 +98,7 @@ export interface GenericProps extends BaseChart {
|
|
|
96
98
|
dataTableRenderer?: (chartOption: EChartOption) => string;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
const GenericChartBase
|
|
101
|
+
const GenericChartBase = memo(
|
|
100
102
|
({
|
|
101
103
|
chartRef: _ref,
|
|
102
104
|
onBrush,
|
|
@@ -105,12 +107,14 @@ const GenericChartBase: FC<GenericProps> = memo(
|
|
|
105
107
|
dataTableRenderer,
|
|
106
108
|
onClick,
|
|
107
109
|
onRendered,
|
|
110
|
+
showThemeSelector,
|
|
108
111
|
actions,
|
|
109
112
|
title,
|
|
110
|
-
theme,
|
|
113
|
+
theme: chartTheme,
|
|
111
114
|
...options
|
|
112
|
-
}: GenericProps) => {
|
|
115
|
+
}: Omit<GenericProps, "showTypeSelector">) => {
|
|
113
116
|
const chartRef = useRef<EChartsType>(null);
|
|
117
|
+
const [theme, setTheme] = useState(chartTheme);
|
|
114
118
|
|
|
115
119
|
useImperativeHandle<EChartsType | null, EChartsType | null>(
|
|
116
120
|
_ref,
|
|
@@ -170,19 +174,35 @@ const GenericChartBase: FC<GenericProps> = memo(
|
|
|
170
174
|
|
|
171
175
|
return (
|
|
172
176
|
<ChartContainer
|
|
173
|
-
theme={theme}
|
|
174
177
|
options={options}
|
|
175
178
|
chartRef={chartRef}
|
|
179
|
+
theme={theme}
|
|
176
180
|
title={title}
|
|
177
181
|
dataTableRenderer={dataTableRenderer}
|
|
178
182
|
>
|
|
179
183
|
{actions}
|
|
184
|
+
{showThemeSelector && (
|
|
185
|
+
<PaletteSelect theme={theme} onClick={setTheme} />
|
|
186
|
+
)}
|
|
180
187
|
</ChartContainer>
|
|
181
188
|
);
|
|
182
189
|
},
|
|
183
190
|
);
|
|
184
191
|
GenericChartBase.displayName = "GenericChart";
|
|
185
192
|
|
|
193
|
+
/**
|
|
194
|
+
* GenericChart component renders a generic chart using ECharts.
|
|
195
|
+
* It accepts various chart options and configurations, allowing for flexible chart rendering.
|
|
196
|
+
* It supports click events, brush events, and custom actions.
|
|
197
|
+
* It can be used to create a wide range of chart types by passing the appropriate ECharts options.
|
|
198
|
+
*
|
|
199
|
+
* @param props - The properties for the GenericChart component, including chart options, event handlers, and custom actions.
|
|
200
|
+
* @returns A React functional component that renders the chart within a ChartWrapper.
|
|
201
|
+
*
|
|
202
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-genericchart--docs} for more details on the properties.
|
|
203
|
+
* @see {@link https://echarts.apache.org/en/option.html} for ECharts options documentation.
|
|
204
|
+
* @see {@link https://echarts.apache.org/en/api.html#echartsInstance} for ECharts instance methods and properties.
|
|
205
|
+
*/
|
|
186
206
|
export const GenericChart: FC<GenericProps> = (props) => (
|
|
187
207
|
<ChartWrapper>
|
|
188
208
|
<GenericChartBase {...props} />
|
package/src/charts/MapSeries.tsx
CHANGED
|
@@ -50,7 +50,14 @@ export interface MapSeriesProps extends BaseChart, CountType {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const MapSeriesChart: FC<MapSeriesProps> = memo(
|
|
53
|
-
({
|
|
53
|
+
({
|
|
54
|
+
data,
|
|
55
|
+
onExport,
|
|
56
|
+
theme: chartTheme,
|
|
57
|
+
showTypeSelector,
|
|
58
|
+
title,
|
|
59
|
+
onClick,
|
|
60
|
+
}: MapSeriesProps) => {
|
|
54
61
|
const chartRef = useRef<EChartsType>(null);
|
|
55
62
|
const [type, setType] = useState("map");
|
|
56
63
|
const [zoom, setZoom] = useState(1.25);
|
|
@@ -185,22 +192,24 @@ const MapSeriesChart: FC<MapSeriesProps> = memo(
|
|
|
185
192
|
onChange={(e) => setZoom(e.target.valueAsNumber)}
|
|
186
193
|
/>
|
|
187
194
|
)}
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
{showTypeSelector && (
|
|
196
|
+
<ToggleButtonGroup value={type} onChange={setType as AnyObject}>
|
|
197
|
+
<Button
|
|
198
|
+
size="sm"
|
|
199
|
+
variant="link"
|
|
200
|
+
icon={CoreIcons.map}
|
|
201
|
+
aria-label="map"
|
|
202
|
+
value="map"
|
|
203
|
+
/>
|
|
204
|
+
<Button
|
|
205
|
+
size="sm"
|
|
206
|
+
variant="link"
|
|
207
|
+
icon={CoreIcons.chartColumn}
|
|
208
|
+
aria-label="column"
|
|
209
|
+
value="column"
|
|
210
|
+
/>
|
|
211
|
+
</ToggleButtonGroup>
|
|
212
|
+
)}
|
|
204
213
|
</ChartContainer>
|
|
205
214
|
);
|
|
206
215
|
},
|
|
@@ -208,7 +217,30 @@ const MapSeriesChart: FC<MapSeriesProps> = memo(
|
|
|
208
217
|
MapSeriesChart.displayName = "MapSeriesChart";
|
|
209
218
|
|
|
210
219
|
/**
|
|
211
|
-
*
|
|
220
|
+
* MapSeries component renders a map chart using ECharts.
|
|
221
|
+
* It displays data on a world map, allowing users to visualize counts or other metrics by country.
|
|
222
|
+
* It supports zooming and switching between map and column views.
|
|
223
|
+
*
|
|
224
|
+
* @param {MapSeriesProps} props - The properties for the MapSeries component.
|
|
225
|
+
* @returns {JSX.Element} The rendered MapSeries component.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```jsx
|
|
229
|
+
* <MapSeries
|
|
230
|
+
* data={[
|
|
231
|
+
* { id: "US", label: "United States", count: 100 },
|
|
232
|
+
* { id: "IN", label: "India", count: 200 },
|
|
233
|
+
* { id: "CN", label: "China", count: 300 },
|
|
234
|
+
* ]}
|
|
235
|
+
* onExport={() => console.log("Exporting chart")}
|
|
236
|
+
* title="World Map Series"
|
|
237
|
+
* onClick={(key) => console.log("Clicked country:", key)}
|
|
238
|
+
* theme="light"
|
|
239
|
+
* />
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-mapseries--docs} for more details on the properties.
|
|
243
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-map} for ECharts map series options documentation.
|
|
212
244
|
*/
|
|
213
245
|
export const MapSeries: FC<MapSeriesProps> = (props) => (
|
|
214
246
|
<ChartWrapper>
|