@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.
- package/{src/wrapper/Chart.module.css → css/_chart.css} +11 -11
- package/css/styles.css +24 -0
- package/dist/cjs/charts/ActivityMap.js +70 -36
- package/dist/cjs/charts/CountSeries.js +67 -35
- package/dist/cjs/charts/DataSeries.js +75 -40
- package/dist/cjs/charts/Generic.js +41 -19
- package/dist/cjs/charts/MapSeries.js +41 -17
- package/dist/cjs/charts/TimeSeries.js +73 -40
- package/dist/cjs/charts/TimeSlider.js +40 -21
- package/dist/cjs/charts/WordBubble.js +65 -29
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/theme/darkBase.js +13 -10
- package/dist/cjs/theme/index.js +43 -23
- package/dist/cjs/theme/lightBase.js +18 -15
- package/dist/cjs/theme/palettes.js +5 -54
- package/dist/cjs/types/charts.js +4 -2
- package/dist/cjs/types/utils.js +6 -9
- package/dist/cjs/wrapper/ChartContainer.js +26 -18
- package/dist/cjs/wrapper/ChartToolbar.js +4 -5
- package/dist/cjs/wrapper/ChartWrapper.js +4 -5
- package/dist/cjs/wrapper/PaletteSelect.js +31 -18
- package/dist/esm/charts/ActivityMap.js +71 -37
- package/dist/esm/charts/CountSeries.js +68 -36
- package/dist/esm/charts/DataSeries.js +76 -41
- package/dist/esm/charts/Generic.js +43 -21
- package/dist/esm/charts/MapSeries.js +41 -17
- package/dist/esm/charts/TimeSeries.js +74 -41
- package/dist/esm/charts/TimeSlider.js +41 -22
- package/dist/esm/charts/WordBubble.js +67 -31
- package/dist/esm/index.js +30 -0
- package/dist/esm/theme/darkBase.js +13 -10
- package/dist/esm/theme/index.js +43 -23
- package/dist/esm/theme/lightBase.js +18 -15
- package/dist/esm/theme/palettes.js +5 -54
- package/dist/esm/types/charts.js +4 -2
- package/dist/esm/types/utils.js +6 -9
- package/dist/esm/wrapper/ChartContainer.js +27 -19
- package/dist/esm/wrapper/ChartToolbar.js +4 -5
- package/dist/esm/wrapper/ChartWrapper.js +4 -5
- package/dist/esm/wrapper/PaletteSelect.js +32 -19
- package/dist/types/charts/ActivityMap.d.ts +20 -4
- package/dist/types/charts/CountSeries.d.ts +25 -3
- package/dist/types/charts/DataSeries.d.ts +26 -1
- package/dist/types/charts/Generic.d.ts +36 -52
- package/dist/types/charts/MapSeries.d.ts +31 -3
- package/dist/types/charts/TimeSeries.d.ts +24 -1
- package/dist/types/charts/TimeSlider.d.ts +19 -5
- package/dist/types/charts/WordBubble.d.ts +28 -5
- package/dist/types/index.d.ts +26 -0
- package/dist/types/theme/darkBase.d.ts +8 -5
- package/dist/types/theme/index.d.ts +3 -2
- package/dist/types/theme/lightBase.d.ts +8 -5
- package/dist/types/types/charts.d.ts +2 -1
- package/dist/types/types/index.d.ts +30 -12
- package/dist/types/types/world.svg.d.ts +1 -1
- package/dist/types/wrapper/ChartContainer.d.ts +7 -7
- package/dist/types/wrapper/ChartToolbar.d.ts +2 -3
- package/dist/types/wrapper/ChartWrapper.d.ts +3 -5
- package/dist/types/wrapper/PaletteSelect.d.ts +6 -1
- package/package.json +17 -21
- package/src/charts/ActivityMap.tsx +95 -94
- package/src/charts/CountSeries.tsx +73 -65
- package/src/charts/DataSeries.tsx +104 -98
- package/src/charts/Generic.tsx +56 -86
- package/src/charts/MapSeries.tsx +153 -151
- package/src/charts/TimeSeries.tsx +96 -79
- package/src/charts/TimeSlider.tsx +194 -195
- package/src/charts/WordBubble.tsx +97 -62
- package/src/index.ts +22 -17
- package/src/theme/darkBase.ts +12 -9
- package/src/theme/index.ts +92 -30
- package/src/theme/lightBase.ts +17 -14
- package/src/theme/palettes.ts +1 -52
- package/src/types/charts.ts +6 -2
- package/src/types/index.ts +40 -4
- package/src/types/utils.ts +18 -30
- package/src/wrapper/ChartContainer.tsx +48 -79
- package/src/wrapper/ChartToolbar.tsx +5 -12
- package/src/wrapper/ChartWrapper.tsx +5 -10
- package/src/wrapper/PaletteSelect.tsx +43 -40
- package/dist/cjs/wrapper/Chart.module.css +0 -1
- package/dist/esm/wrapper/Chart.module.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Dropdown, Button,
|
|
3
|
+
import { Dropdown, Button, Menu, MenuItem } from '@react-fabric/core';
|
|
4
4
|
import { ChartPalette } from '../theme/palettes.js';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
27
27
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
function PaletteMap(_ref) {
|
|
31
31
|
var _ref$colors = _ref.colors,
|
|
32
32
|
colors = _ref$colors === void 0 ? [] : _ref$colors,
|
|
33
33
|
_ref$label = _ref.label,
|
|
@@ -46,101 +46,114 @@ var PaletteMap = function PaletteMap(_ref) {
|
|
|
46
46
|
children: label
|
|
47
47
|
})]
|
|
48
48
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var
|
|
49
|
+
}
|
|
50
|
+
function PaletteSelect(_ref2) {
|
|
51
|
+
var _onClick = _ref2.onClick,
|
|
52
52
|
_ref2$theme = _ref2.theme,
|
|
53
53
|
theme = _ref2$theme === void 0 ? "default" : _ref2$theme,
|
|
54
54
|
_ref2$defaultTheme = _ref2.defaultTheme,
|
|
55
55
|
defaultTheme = _ref2$defaultTheme === void 0 ? "default" : _ref2$defaultTheme;
|
|
56
56
|
return /*#__PURE__*/jsxs(Dropdown, {
|
|
57
57
|
children: [/*#__PURE__*/jsx(Button, {
|
|
58
|
-
icon:
|
|
58
|
+
icon: "icon-[mdi--palette-outline]",
|
|
59
59
|
"aria-label": "palette",
|
|
60
60
|
size: "sm",
|
|
61
61
|
variant: "link"
|
|
62
62
|
}), /*#__PURE__*/jsxs(Menu, {
|
|
63
|
-
onClick: onClick
|
|
63
|
+
onClick: function onClick(t) {
|
|
64
|
+
return _onClick(t);
|
|
65
|
+
},
|
|
64
66
|
children: [/*#__PURE__*/jsx(MenuItem, {
|
|
65
67
|
id: defaultTheme,
|
|
66
68
|
icon: theme === defaultTheme ? "◉" : "◯",
|
|
67
|
-
label:
|
|
69
|
+
label: "Default",
|
|
70
|
+
labelRender: PaletteMap({
|
|
68
71
|
label: "Default",
|
|
69
72
|
colors: ChartPalette.Default
|
|
70
73
|
})
|
|
71
74
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
72
75
|
id: "qualitative",
|
|
73
76
|
icon: theme === "qualitative" ? "◉" : "◯",
|
|
74
|
-
label:
|
|
77
|
+
label: "Qualitative",
|
|
78
|
+
labelRender: PaletteMap({
|
|
75
79
|
label: "Qualitative",
|
|
76
80
|
colors: ChartPalette.Qualitative
|
|
77
81
|
})
|
|
78
82
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
79
83
|
id: "diverging",
|
|
80
84
|
icon: theme === "diverging" ? "◉" : "◯",
|
|
81
|
-
label:
|
|
85
|
+
label: "Diverging",
|
|
86
|
+
labelRender: PaletteMap({
|
|
82
87
|
label: "Diverging",
|
|
83
88
|
colors: ChartPalette.Diverging
|
|
84
89
|
})
|
|
85
90
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
86
91
|
id: "sequential",
|
|
87
92
|
icon: theme === "sequential" ? "◉" : "◯",
|
|
88
|
-
label:
|
|
93
|
+
label: "Sequential",
|
|
94
|
+
labelRender: PaletteMap({
|
|
89
95
|
label: "Sequential",
|
|
90
96
|
colors: ChartPalette.Sequential
|
|
91
97
|
})
|
|
92
98
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
93
99
|
id: "spectral",
|
|
94
100
|
icon: theme === "spectral" ? "◉" : "◯",
|
|
95
|
-
label:
|
|
101
|
+
label: "Spectral",
|
|
102
|
+
labelRender: PaletteMap({
|
|
96
103
|
label: "Spectral",
|
|
97
104
|
colors: ChartPalette.Spectral
|
|
98
105
|
})
|
|
99
106
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
100
107
|
id: "uber",
|
|
101
108
|
icon: theme === "uber" ? "◉" : "◯",
|
|
102
|
-
label:
|
|
109
|
+
label: "Uber Pool",
|
|
110
|
+
labelRender: PaletteMap({
|
|
103
111
|
label: "Uber Pool",
|
|
104
112
|
colors: ChartPalette.UberPool
|
|
105
113
|
})
|
|
106
114
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
107
115
|
id: "fireice",
|
|
108
116
|
icon: theme === "fireice" ? "◉" : "◯",
|
|
109
|
-
label:
|
|
117
|
+
label: "Fire Ice",
|
|
118
|
+
labelRender: PaletteMap({
|
|
110
119
|
label: "Fire Ice",
|
|
111
120
|
colors: ChartPalette.FireIce
|
|
112
121
|
})
|
|
113
122
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
114
123
|
id: "warming",
|
|
115
124
|
icon: theme === "warming" ? "◉" : "◯",
|
|
116
|
-
label:
|
|
125
|
+
label: "Global Warming",
|
|
126
|
+
labelRender: PaletteMap({
|
|
117
127
|
label: "Global Warming",
|
|
118
128
|
colors: ChartPalette.GlobalWarming
|
|
119
129
|
})
|
|
120
130
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
121
131
|
id: "sunrise",
|
|
122
132
|
icon: theme === "sunrise" ? "◉" : "◯",
|
|
123
|
-
label:
|
|
133
|
+
label: "Sunrise",
|
|
134
|
+
labelRender: PaletteMap({
|
|
124
135
|
label: "Sunrise",
|
|
125
136
|
colors: ChartPalette.Sunrise
|
|
126
137
|
})
|
|
127
138
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
128
139
|
id: "ocean",
|
|
129
140
|
icon: theme === "ocean" ? "◉" : "◯",
|
|
130
|
-
label:
|
|
141
|
+
label: "Ocean",
|
|
142
|
+
labelRender: PaletteMap({
|
|
131
143
|
label: "Ocean",
|
|
132
144
|
colors: ChartPalette.Ocean
|
|
133
145
|
})
|
|
134
146
|
}), /*#__PURE__*/jsx(MenuItem, {
|
|
135
147
|
id: "wine",
|
|
136
148
|
icon: theme === "wine" ? "◉" : "◯",
|
|
137
|
-
label:
|
|
149
|
+
label: "Wine",
|
|
150
|
+
labelRender: PaletteMap({
|
|
138
151
|
label: "Wine",
|
|
139
152
|
colors: ChartPalette.Wine
|
|
140
153
|
})
|
|
141
154
|
})]
|
|
142
155
|
})]
|
|
143
156
|
});
|
|
144
|
-
}
|
|
157
|
+
}
|
|
145
158
|
|
|
146
159
|
export { PaletteSelect };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type FC } from "react";
|
|
2
1
|
import { type BaseChart } from "../types";
|
|
3
2
|
export interface ActivityMapProps extends BaseChart {
|
|
4
3
|
heatmapPalette?: string[];
|
|
5
|
-
|
|
4
|
+
series: Array<Array<[low: number, high: number, count: number]>>;
|
|
6
5
|
time?: "day-hour" | "month-day";
|
|
7
6
|
type?: "scatter" | "heatmap";
|
|
8
7
|
/**
|
|
@@ -16,6 +15,23 @@ export interface ActivityMapProps extends BaseChart {
|
|
|
16
15
|
onClick?: (highIndex: number, lowIndex: number) => void;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* ActivityMap component renders a chart that visualizes activity data
|
|
19
|
+
* over time, using either a scatter plot or a heatmap.
|
|
20
|
+
* It allows users to switch between different types of visualizations
|
|
21
|
+
* and customize the color palette used in the chart.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <ActivityMap
|
|
26
|
+
* data={activityData}
|
|
27
|
+
* time="day-hour"
|
|
28
|
+
* type="heatmap"
|
|
29
|
+
* heatmapPalette={["#f0f8ff", "#faebd7", "#00ffff", "#7fffd4"]}
|
|
30
|
+
* highLabels={["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}
|
|
31
|
+
* 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"]}
|
|
32
|
+
* onClick={(highIndex, lowIndex) => console.log(`Clicked on: ${highIndex}, ${lowIndex}`)}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-scatter} for more details on the ECharts scatter series.
|
|
20
36
|
*/
|
|
21
|
-
export declare
|
|
37
|
+
export declare function ActivityMap(props: ActivityMapProps): import("react").JSX.Element;
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import { type FC } from "react";
|
|
2
1
|
import { type BaseChart, type CountType } from "../types";
|
|
3
2
|
export interface CountSeriesProps extends BaseChart, CountType {
|
|
3
|
+
seriesName?: string;
|
|
4
4
|
type?: "pie" | "bar" | "column";
|
|
5
5
|
onClick?: (key: string) => void;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* CountSeries component renders a chart that displays counts of items in various formats.
|
|
9
|
+
* It supports pie, bar, and column charts.
|
|
10
|
+
* It can be used to visualize the distribution of counts across different categories.
|
|
11
|
+
* It allows users to switch between different types of visualizations and customize the color palette used in the chart.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```jsx
|
|
15
|
+
* <CountSeries
|
|
16
|
+
* data={[
|
|
17
|
+
* { id: "A", label: "Category A", count: 10 },
|
|
18
|
+
* { id: "B", label: "Category B", count: 20 },
|
|
19
|
+
* { id: "C", label: "Category C", count: 30 },
|
|
20
|
+
* ]}
|
|
21
|
+
* title="Count Distribution"
|
|
22
|
+
* onExport={() => console.log("Exporting chart data")}
|
|
23
|
+
* theme="light"
|
|
24
|
+
* type="pie"
|
|
25
|
+
* onClick={(key) => console.log("Clicked on:", key)}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-pie} for more details on the ECharts pie series options.
|
|
30
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
|
|
9
31
|
*/
|
|
10
|
-
export declare
|
|
32
|
+
export declare function CountSeries(props: CountSeriesProps): import("react").JSX.Element;
|
|
@@ -8,6 +8,31 @@ export interface DataSeriesProps extends BaseChart, SeriesType {
|
|
|
8
8
|
}) => void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* DataSeries component renders a chart for visualizing data series.
|
|
12
|
+
* It supports various chart types such as column, line, bar, radar, and stacked variants.
|
|
13
|
+
* It allows users to click on data points to trigger custom actions.
|
|
14
|
+
*
|
|
15
|
+
* @param {DataSeriesProps} props - The properties for the DataSeries component.
|
|
16
|
+
* @returns {React.ReactElement} The rendered DataSeries component.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* <DataSeries
|
|
21
|
+
* data={[{ id: "1", label: "Series 1", values: [10, 20, 30] }]}
|
|
22
|
+
* categories={["Category 1", "Category 2", "Category 3"]}
|
|
23
|
+
* categoryAxisName="Categories"
|
|
24
|
+
* valueAxisName="Values"
|
|
25
|
+
* title="Data Series Example"
|
|
26
|
+
* type="column"
|
|
27
|
+
* onClick={(data) => console.log("Clicked data:", data)}
|
|
28
|
+
* onExport={() => console.log("Exporting chart data")}
|
|
29
|
+
* theme="light"
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-dataseries--docs} for more details on the properties.
|
|
34
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-bar} for ECharts bar series options.
|
|
35
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-line} for ECharts line series options.
|
|
36
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-radar} for ECharts radar series options.
|
|
12
37
|
*/
|
|
13
38
|
export declare const DataSeries: FC<DataSeriesProps>;
|
|
@@ -1,56 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
4
|
-
export interface GenericProps extends
|
|
5
|
-
chartRef?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* polar axis
|
|
28
|
-
*/
|
|
29
|
-
angleAxis?: EChartOption["angleAxis"];
|
|
30
|
-
/**
|
|
31
|
-
* polar axis
|
|
32
|
-
*/
|
|
33
|
-
radiusAxis?: EChartOption["radiusAxis"];
|
|
34
|
-
/**
|
|
35
|
-
* radar series
|
|
36
|
-
*/
|
|
37
|
-
radar?: EChartOption["radar"];
|
|
38
|
-
/**
|
|
39
|
-
* paarllel series
|
|
40
|
-
*/
|
|
41
|
-
parallel?: EChartOption["parallel"];
|
|
42
|
-
/**
|
|
43
|
-
* parallel axis
|
|
44
|
-
*/
|
|
45
|
-
parallelAxis?: EChartOption["parallelAxis"];
|
|
46
|
-
onClick?: (e: KeyValue) => void;
|
|
47
|
-
onRendered?: (e: KeyValue) => void;
|
|
48
|
-
onBrush?: (e: KeyValue) => void;
|
|
49
|
-
onBrushEnd?: (e: KeyValue) => void;
|
|
50
|
-
onBrushSelected?: (e: KeyValue) => void;
|
|
1
|
+
import type { ECElementEvent, EChartsOption, EChartsType } from "echarts";
|
|
2
|
+
import { type Ref } from "react";
|
|
3
|
+
import { type Theme } from "../types";
|
|
4
|
+
export interface GenericProps extends Omit<EChartsOption, "title"> {
|
|
5
|
+
chartRef?: Ref<EChartsType>;
|
|
6
|
+
title?: string;
|
|
7
|
+
actions?: React.ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* The theme to be applied to the chart.
|
|
10
|
+
* This can be one of the predefined themes or a custom theme object.
|
|
11
|
+
* Predefined themes include "default", "activity", "cloud", "qualitative", "diverging", "sequential",
|
|
12
|
+
* "spectral", "uber", "fireice", "warming", "sunrise", "ocean", "wine", "red", "green", and "blue".
|
|
13
|
+
*/
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the theme selector in the chart.
|
|
17
|
+
* This is useful for allowing users to switch between different themes.
|
|
18
|
+
* If set to true, the chart will render a toggle button group to select the theme.
|
|
19
|
+
*/
|
|
20
|
+
showThemeSelector?: boolean;
|
|
21
|
+
onClick?: (e: ECElementEvent) => void;
|
|
22
|
+
onRendered?: () => void;
|
|
23
|
+
onBrush?: () => void;
|
|
24
|
+
onBrushEnd?: () => void;
|
|
25
|
+
onBrushSelected?: () => void;
|
|
51
26
|
/**
|
|
52
27
|
* Data table renderer that returns HTML string
|
|
53
28
|
*/
|
|
54
|
-
dataTableRenderer?: (chartOption:
|
|
29
|
+
dataTableRenderer?: (chartOption: EChartsOption) => string;
|
|
55
30
|
}
|
|
56
|
-
|
|
31
|
+
/**
|
|
32
|
+
* GenericChart component renders a generic chart using ECharts.
|
|
33
|
+
* It accepts various chart options and configurations, allowing for flexible chart rendering.
|
|
34
|
+
* It supports click events, brush events, and custom actions.
|
|
35
|
+
* It can be used to create a wide range of chart types by passing the appropriate ECharts options.
|
|
36
|
+
*
|
|
37
|
+
* @see {@link https://echarts.apache.org/en/option.html} for ECharts options documentation.
|
|
38
|
+
* @see {@link https://echarts.apache.org/en/api.html#echartsInstance} for ECharts instance methods and properties.
|
|
39
|
+
*/
|
|
40
|
+
export declare function GenericChart(props: GenericProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { type FC } from "react";
|
|
2
|
-
import { type BaseChart
|
|
3
|
-
export interface MapSeriesProps extends BaseChart
|
|
2
|
+
import { type BaseChart } from "../types";
|
|
3
|
+
export interface MapSeriesProps extends BaseChart {
|
|
4
|
+
series: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
count: number;
|
|
8
|
+
}>;
|
|
4
9
|
onClick?: (key: string) => void;
|
|
5
10
|
}
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
12
|
+
* MapSeries component renders a map chart using ECharts.
|
|
13
|
+
* It displays data on a world map, allowing users to visualize counts or other metrics by country.
|
|
14
|
+
* It supports zooming and switching between map and column views.
|
|
15
|
+
*
|
|
16
|
+
* @param {MapSeriesProps} props - The properties for the MapSeries component.
|
|
17
|
+
* @returns {React.ReactElement} The rendered MapSeries component.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```jsx
|
|
21
|
+
* <MapSeries
|
|
22
|
+
* data={[
|
|
23
|
+
* { id: "US", label: "United States", count: 100 },
|
|
24
|
+
* { id: "IN", label: "India", count: 200 },
|
|
25
|
+
* { id: "CN", label: "China", count: 300 },
|
|
26
|
+
* ]}
|
|
27
|
+
* onExport={() => console.log("Exporting chart")}
|
|
28
|
+
* title="World Map Series"
|
|
29
|
+
* onClick={(key) => console.log("Clicked country:", key)}
|
|
30
|
+
* theme="light"
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-mapseries--docs} for more details on the properties.
|
|
35
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-map} for ECharts map series options documentation.
|
|
8
36
|
*/
|
|
9
37
|
export declare const MapSeries: FC<MapSeriesProps>;
|
|
@@ -12,6 +12,29 @@ export interface TimeSeriesProps extends BaseChart, TimeSeriesType {
|
|
|
12
12
|
}) => void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* TimeSeries component renders a time series chart using the provided data and options.
|
|
16
|
+
* It supports different chart types such as line, column, and stacked variants.
|
|
17
|
+
* It also allows for interaction through click and brush events.
|
|
18
|
+
*
|
|
19
|
+
* @param {TimeSeriesProps} props - The properties for the TimeSeries component.
|
|
20
|
+
* @returns {React.ReactElement} The rendered TimeSeries component.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```jsx
|
|
24
|
+
* <TimeSeries
|
|
25
|
+
* data={data}
|
|
26
|
+
* onExport={handleExport}
|
|
27
|
+
* categoryAxisName="Time"
|
|
28
|
+
* valueAxisName="Value"
|
|
29
|
+
* title="Time Series Chart"
|
|
30
|
+
* type="line"
|
|
31
|
+
* onClick={(data) => console.log(data)}
|
|
32
|
+
* onBrush={(range) => console.log(range)}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/charts-timeseries--docs} for more details on the properties.
|
|
37
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-line} for more details on the ECharts line series options.
|
|
38
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-bar} for more details on the ECharts bar series options.
|
|
16
39
|
*/
|
|
17
40
|
export declare const TimeSeries: FC<TimeSeriesProps>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type BaseChart } from "../types";
|
|
1
|
+
import type { BaseChart } from "../types";
|
|
3
2
|
export interface TimeSliderProps extends BaseChart {
|
|
4
|
-
|
|
3
|
+
series: Array<[Date, number]>;
|
|
5
4
|
range?: {
|
|
6
5
|
start: Date;
|
|
7
6
|
end: Date;
|
|
@@ -12,5 +11,20 @@ export interface TimeSliderProps extends BaseChart {
|
|
|
12
11
|
}) => void;
|
|
13
12
|
}
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
14
|
+
* TimeSlider component renders a time slider chart.
|
|
15
|
+
* It allows users to visualize time-based data and interactively select a range.
|
|
16
|
+
* The chart supports brushing to select a specific time range,
|
|
17
|
+
* and it emits an event when the range is changed.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```jsx
|
|
21
|
+
* <TimeSlider
|
|
22
|
+
* data={data}
|
|
23
|
+
* range={{ start: new Date("2023-01-01"), end: new Date("2023-12-31") }}
|
|
24
|
+
* onBrush={(range) => console.log("Selected range:", range)}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
* @see {@link https://echarts.apache.org/en/option.html#dataZoom} for more details on the ECharts dataZoom feature.
|
|
28
|
+
* @see {@link https://echarts.apache.org/en/option.html#series-line} for more details on the ECharts line series.
|
|
29
|
+
*/
|
|
30
|
+
export declare function TimeSlider(props: TimeSliderProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type BaseChart } from "../types";
|
|
2
|
+
export interface WordBubbleProps extends Omit<BaseChart, "theme"> {
|
|
3
|
+
series: Array<{
|
|
4
|
+
id: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
count: number;
|
|
7
|
+
}>;
|
|
4
8
|
onClick?: (key: string) => void;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* WordBubble component renders a word cloud chart using ECharts.
|
|
12
|
+
* It displays words with sizes proportional to their frequency in the data.
|
|
13
|
+
* Users can click on words to trigger an action, such as filtering or navigating.
|
|
14
|
+
* It also supports exporting the chart and displays an empty state when no data is available.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```jsx
|
|
18
|
+
* <WordBubble
|
|
19
|
+
* data={[
|
|
20
|
+
* { id: "1", label: "Word One", count: 10 },
|
|
21
|
+
* { id: "2", label: "Word Two", count: 20 },
|
|
22
|
+
* { id: "3", label: "Word Three", count: 30 },
|
|
23
|
+
* ]}
|
|
24
|
+
* title="Word Frequency"
|
|
25
|
+
* onExport={() => console.log("Exporting chart...")}
|
|
26
|
+
* onClick={(key) => console.log("Clicked word:", key)}
|
|
27
|
+
* theme="light"
|
|
28
|
+
* />
|
|
29
|
+
* ```
|
|
30
|
+
* @see {@link https://github.com/apache/echarts-custom-series} for the underlying chart implementation.
|
|
8
31
|
*/
|
|
9
|
-
export declare
|
|
32
|
+
export declare function WordBubble(props: WordBubbleProps): import("react").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
export declare const CHARTS_PACKAGE = "@react-fabric/charts";
|
|
26
|
+
export declare const CHARTS_VERSION = "1.0.0";
|
|
1
27
|
export { ActivityMap } from "./charts/ActivityMap";
|
|
2
28
|
export { CountSeries } from "./charts/CountSeries";
|
|
3
29
|
export { DataSeries } from "./charts/DataSeries";
|
|
@@ -284,11 +284,6 @@ export declare const DarkThemeBase: {
|
|
|
284
284
|
};
|
|
285
285
|
};
|
|
286
286
|
};
|
|
287
|
-
visualMap: {
|
|
288
|
-
textStyle: {
|
|
289
|
-
color: string;
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
287
|
toolbox: {
|
|
293
288
|
iconStyle: {
|
|
294
289
|
borderColor: string;
|
|
@@ -301,9 +296,17 @@ export declare const DarkThemeBase: {
|
|
|
301
296
|
};
|
|
302
297
|
legend: {
|
|
303
298
|
inactiveColor: string;
|
|
299
|
+
itemHeight: number;
|
|
304
300
|
textStyle: {
|
|
301
|
+
fontSize: number;
|
|
305
302
|
color: string;
|
|
306
303
|
};
|
|
304
|
+
pageTextStyle: {
|
|
305
|
+
fontSize: number;
|
|
306
|
+
};
|
|
307
|
+
pageIconSize: number;
|
|
308
|
+
pageIconColor: string;
|
|
309
|
+
pageIconInactiveColor: string;
|
|
307
310
|
};
|
|
308
311
|
tooltip: {
|
|
309
312
|
backgroundColor: string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import type { ECharts } from "../types/charts";
|
|
2
|
+
export declare const registerTheme: (echarts: ECharts, key: string, colors: string[], heatmap: string[]) => void;
|
|
3
|
+
export declare const registerThemes: (echarts: ECharts) => void;
|
|
@@ -282,11 +282,6 @@ export declare const LightThemeBase: {
|
|
|
282
282
|
};
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
|
-
visualMap: {
|
|
286
|
-
textStyle: {
|
|
287
|
-
color: string;
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
285
|
toolbox: {
|
|
291
286
|
iconStyle: {
|
|
292
287
|
borderColor: string;
|
|
@@ -299,9 +294,17 @@ export declare const LightThemeBase: {
|
|
|
299
294
|
};
|
|
300
295
|
legend: {
|
|
301
296
|
inactiveColor: string;
|
|
297
|
+
itemHeight: number;
|
|
302
298
|
textStyle: {
|
|
299
|
+
fontSize: number;
|
|
303
300
|
color: string;
|
|
304
301
|
};
|
|
302
|
+
pageTextStyle: {
|
|
303
|
+
fontSize: number;
|
|
304
|
+
};
|
|
305
|
+
pageIconSize: number;
|
|
306
|
+
pageIconColor: string;
|
|
307
|
+
pageIconInactiveColor: string;
|
|
305
308
|
};
|
|
306
309
|
tooltip: {
|
|
307
310
|
backgroundColor: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as echarts from "echarts";
|
|
2
|
+
export type ECharts = typeof echarts;
|
|
2
3
|
export default echarts;
|
|
3
|
-
export declare const registerTheme: (key: string, colors: string[]) => void;
|
|
4
|
+
export declare const registerTheme: (key: string, colors: string[], heatmap: string[]) => void;
|
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BarSeriesOption, EChartsOption, PieSeriesOption } from "echarts";
|
|
2
|
+
export type Theme = "default" | "activity" | "cloud" | "qualitative" | "diverging" | "sequential" | "spectral" | "uber" | "fireice" | "warming" | "sunrise" | "ocean" | "wine" | "red" | "green" | "blue";
|
|
2
3
|
export interface BaseChart {
|
|
3
4
|
title?: string;
|
|
5
|
+
/**
|
|
6
|
+
* The theme to be applied to the chart.
|
|
7
|
+
* This can be one of the predefined themes or a custom theme object.
|
|
8
|
+
* Predefined themes include "default", "activity", "cloud", "qualitative", "diverging", "sequential",
|
|
9
|
+
* "spectral", "uber", "fireice", "warming", "sunrise", "ocean", "wine", "red", "green", and "blue".
|
|
10
|
+
*/
|
|
4
11
|
theme?: Theme;
|
|
12
|
+
/**
|
|
13
|
+
* Additional options for the chart.
|
|
14
|
+
* This can include any ECharts options to customize the chart's appearance and behavior.
|
|
15
|
+
*/
|
|
16
|
+
options?: EChartsOption;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to show the theme selector in the chart.
|
|
19
|
+
* This is useful for allowing users to switch between different themes.
|
|
20
|
+
* If set to true, the chart will render a toggle button group to select the theme.
|
|
21
|
+
*/
|
|
22
|
+
showThemeSelector?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to show the type selector in the chart.
|
|
25
|
+
* This is useful for charts that can have multiple types (e.g., line, column, etc.).
|
|
26
|
+
* If set to true, the chart will render a toggle button group to select the type.
|
|
27
|
+
*/
|
|
28
|
+
showTypeSelector?: boolean;
|
|
5
29
|
onExport?: (chart: {
|
|
6
30
|
title: string;
|
|
7
31
|
image: string;
|
|
8
32
|
}) => void;
|
|
9
33
|
}
|
|
10
34
|
export interface CountType {
|
|
11
|
-
|
|
12
|
-
id: string;
|
|
13
|
-
label?: string;
|
|
35
|
+
series: Array<PieSeriesOption & {
|
|
14
36
|
count: number;
|
|
15
37
|
}>;
|
|
16
38
|
}
|
|
@@ -19,18 +41,14 @@ export interface SeriesType {
|
|
|
19
41
|
valueAxisName?: string;
|
|
20
42
|
valueFormat?: string;
|
|
21
43
|
categories: string[];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
label?: string;
|
|
25
|
-
values: number[];
|
|
44
|
+
series: Array<BarSeriesOption & {
|
|
45
|
+
data: number[];
|
|
26
46
|
}>;
|
|
27
47
|
}
|
|
28
48
|
export interface TimeSeriesType {
|
|
29
49
|
categoryAxisName?: string;
|
|
30
50
|
valueAxisName?: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
label?: string;
|
|
34
|
-
values: Array<[Date, number]>;
|
|
51
|
+
series: Array<BarSeriesOption & {
|
|
52
|
+
data: Array<[Date, number]>;
|
|
35
53
|
}>;
|
|
36
54
|
}
|