@automattic/charts 0.2.1 → 0.2.3
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/CHANGELOG.md +12 -0
- package/dist/cjs/components/bar-chart/index.js +2 -0
- package/dist/cjs/components/bar-chart/index.js.map +1 -0
- package/dist/cjs/components/bar-chart/style.css +6 -0
- package/dist/cjs/components/bar-chart/style.css.map +1 -0
- package/dist/cjs/components/grid-control/index.js +2 -0
- package/dist/cjs/components/grid-control/index.js.map +1 -0
- package/dist/cjs/components/grid-control/style.css +3 -0
- package/dist/cjs/components/grid-control/style.css.map +1 -0
- package/dist/cjs/components/legend/index.js +2 -0
- package/dist/cjs/components/legend/index.js.map +1 -0
- package/dist/cjs/components/legend/style.css +3 -0
- package/dist/cjs/components/legend/style.css.map +1 -0
- package/dist/cjs/components/line-chart/index.js +2 -0
- package/dist/cjs/components/line-chart/index.js.map +1 -0
- package/dist/cjs/components/line-chart/style.css +4 -0
- package/dist/cjs/components/line-chart/style.css.map +1 -0
- package/dist/cjs/components/pie-chart/index.js +2 -0
- package/dist/cjs/components/pie-chart/index.js.map +1 -0
- package/dist/cjs/components/pie-chart/style.css +5 -0
- package/dist/cjs/components/pie-chart/style.css.map +1 -0
- package/dist/cjs/components/pie-semi-circle-chart/index.js +2 -0
- package/dist/cjs/components/pie-semi-circle-chart/index.js.map +1 -0
- package/dist/cjs/components/pie-semi-circle-chart/style.css +5 -0
- package/dist/cjs/components/pie-semi-circle-chart/style.css.map +1 -0
- package/dist/cjs/components/tooltip/index.js +2 -0
- package/dist/cjs/components/tooltip/index.js.map +1 -0
- package/dist/cjs/components/tooltip/style.css +3 -0
- package/dist/cjs/components/tooltip/style.css.map +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/providers/theme/index.js +2 -0
- package/dist/cjs/providers/theme/index.js.map +1 -0
- package/dist/cjs/style.css +9 -0
- package/dist/cjs/style.css.map +1 -0
- package/dist/mjs/components/bar-chart/index.js +2 -0
- package/dist/mjs/components/bar-chart/index.js.map +1 -0
- package/dist/mjs/components/bar-chart/style.css +6 -0
- package/dist/mjs/components/bar-chart/style.css.map +1 -0
- package/dist/mjs/components/grid-control/index.js +2 -0
- package/dist/mjs/components/grid-control/index.js.map +1 -0
- package/dist/mjs/components/grid-control/style.css +3 -0
- package/dist/mjs/components/grid-control/style.css.map +1 -0
- package/dist/mjs/components/legend/index.js +2 -0
- package/dist/mjs/components/legend/index.js.map +1 -0
- package/dist/mjs/components/legend/style.css +3 -0
- package/dist/mjs/components/legend/style.css.map +1 -0
- package/dist/mjs/components/line-chart/index.js +2 -0
- package/dist/mjs/components/line-chart/index.js.map +1 -0
- package/dist/mjs/components/line-chart/style.css +4 -0
- package/dist/mjs/components/line-chart/style.css.map +1 -0
- package/dist/mjs/components/pie-chart/index.js +2 -0
- package/dist/mjs/components/pie-chart/index.js.map +1 -0
- package/dist/mjs/components/pie-chart/style.css +5 -0
- package/dist/mjs/components/pie-chart/style.css.map +1 -0
- package/dist/mjs/components/pie-semi-circle-chart/index.js +2 -0
- package/dist/mjs/components/pie-semi-circle-chart/index.js.map +1 -0
- package/dist/mjs/components/pie-semi-circle-chart/style.css +5 -0
- package/dist/mjs/components/pie-semi-circle-chart/style.css.map +1 -0
- package/dist/mjs/components/tooltip/index.js +2 -0
- package/dist/mjs/components/tooltip/index.js.map +1 -0
- package/dist/mjs/components/tooltip/style.css +3 -0
- package/dist/mjs/components/tooltip/style.css.map +1 -0
- package/dist/mjs/index.js +2 -0
- package/dist/mjs/index.js.map +1 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/providers/theme/index.js +2 -0
- package/dist/mjs/providers/theme/index.js.map +1 -0
- package/dist/mjs/style.css +9 -0
- package/dist/mjs/style.css.map +1 -0
- package/dist/types/components/bar-chart/bar-chart.d.ts +6 -0
- package/dist/types/components/bar-chart/index.d.ts +1 -0
- package/dist/types/components/grid-control/grid-control.d.ts +4 -0
- package/dist/types/components/grid-control/index.d.ts +1 -0
- package/dist/types/components/legend/base-legend.d.ts +3 -0
- package/dist/types/components/legend/index.d.ts +2 -0
- package/dist/types/components/legend/types.d.ts +12 -0
- package/dist/types/components/line-chart/index.d.ts +1 -0
- package/dist/types/components/line-chart/line-chart.d.ts +6 -0
- package/dist/types/components/pie-chart/index.d.ts +1 -0
- package/dist/types/components/pie-chart/pie-chart.d.ts +15 -0
- package/dist/types/components/pie-semi-circle-chart/index.d.ts +1 -0
- package/dist/types/components/pie-semi-circle-chart/pie-semi-circle-chart.d.ts +23 -0
- package/dist/types/components/tooltip/base-tooltip.d.ts +29 -0
- package/dist/types/components/tooltip/index.d.ts +2 -0
- package/dist/types/hooks/use-chart-mouse-handler.d.ts +41 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/providers/theme/index.d.ts +2 -0
- package/dist/types/providers/theme/theme-provider.d.ts +18 -0
- package/dist/types/providers/theme/themes.d.ts +14 -0
- package/dist/types/types.d.ts +137 -0
- package/index.ts +1 -1
- package/package.json +51 -23
- package/src/components/bar-chart/bar-chart.tsx +8 -8
- package/src/components/grid-control/grid-control.tsx +1 -1
- package/src/components/line-chart/line-chart.tsx +1 -1
- package/src/components/pie-chart/pie-chart.tsx +21 -13
- package/src/components/pie-semi-circle-chart/pie-semi-circle-chart.tsx +5 -5
- package/src/components/tooltip/base-tooltip.tsx +1 -1
- package/src/hooks/use-chart-mouse-handler.ts +2 -2
- package/src/index.ts +0 -4
- package/src/providers/theme/theme-provider.tsx +2 -2
- package/src/providers/theme/themes.ts +1 -1
- package/tools/fixup.sh +11 -0
- package/webpack.config.cjs +132 -0
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -1
- package/dist/index.d.mts +0 -287
- package/dist/index.d.ts +0 -287
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/tsup.config.js +0 -26
- /package/src/{components/shared/types.d.ts → types.ts} +0 -0
package/dist/index.d.mts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, FC, ComponentType, ReactNode } from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { scaleOrdinal } from '@visx/scale';
|
|
4
|
-
|
|
5
|
-
type DataPoint = {
|
|
6
|
-
label: string;
|
|
7
|
-
value: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type DataPointDate = {
|
|
11
|
-
date: Date;
|
|
12
|
-
label?: string;
|
|
13
|
-
value: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type SeriesData = {
|
|
17
|
-
group?: string;
|
|
18
|
-
label: string;
|
|
19
|
-
data: DataPointDate[] | DataPoint[];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type MultipleDataPointsDate = {
|
|
23
|
-
label: string;
|
|
24
|
-
data: DataPointDate[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type DataPointPercentage = {
|
|
28
|
-
/**
|
|
29
|
-
* Label for the data point
|
|
30
|
-
*/
|
|
31
|
-
label: string;
|
|
32
|
-
/**
|
|
33
|
-
* Numerical value
|
|
34
|
-
*/
|
|
35
|
-
value: number;
|
|
36
|
-
/**
|
|
37
|
-
* Formatted value for display
|
|
38
|
-
*/
|
|
39
|
-
valueDisplay?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Percentage value
|
|
42
|
-
*/
|
|
43
|
-
percentage: number;
|
|
44
|
-
/**
|
|
45
|
-
* Color code for the segment, by default colours are taken from the theme but this property can overrides it
|
|
46
|
-
*/
|
|
47
|
-
color?: string;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Theme configuration for chart components
|
|
52
|
-
*/
|
|
53
|
-
type ChartTheme = {
|
|
54
|
-
/** Background color for chart components */
|
|
55
|
-
backgroundColor: string;
|
|
56
|
-
/** Background color for labels */
|
|
57
|
-
labelBackgroundColor?: string;
|
|
58
|
-
/** Array of colors used for data visualization */
|
|
59
|
-
colors: string[];
|
|
60
|
-
/** Optional CSS styles for grid lines */
|
|
61
|
-
gridStyles?: CSSProperties;
|
|
62
|
-
/** Length of axis ticks in pixels */
|
|
63
|
-
tickLength: number;
|
|
64
|
-
/** Color of the grid lines */
|
|
65
|
-
gridColor: string;
|
|
66
|
-
/** Color of the grid lines in dark mode */
|
|
67
|
-
gridColorDark: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Base properties shared across all chart components
|
|
72
|
-
*/
|
|
73
|
-
type BaseChartProps< T = DataPoint | DataPointDate > = {
|
|
74
|
-
/**
|
|
75
|
-
* Array of data points to display in the chart
|
|
76
|
-
*/
|
|
77
|
-
data: T extends DataPoint | DataPointDate ? T[] : T;
|
|
78
|
-
/**
|
|
79
|
-
* Additional CSS class name for the chart container
|
|
80
|
-
*/
|
|
81
|
-
className?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Width of the chart in pixels
|
|
84
|
-
*/
|
|
85
|
-
width: number;
|
|
86
|
-
/**
|
|
87
|
-
* Height of the chart in pixels
|
|
88
|
-
*/
|
|
89
|
-
height?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Chart margins
|
|
92
|
-
*/
|
|
93
|
-
margin?: {
|
|
94
|
-
top: number;
|
|
95
|
-
right: number;
|
|
96
|
-
bottom: number;
|
|
97
|
-
left: number;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Whether to show tooltips on hover. False by default.
|
|
101
|
-
*/
|
|
102
|
-
withTooltips?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Whether to show legend
|
|
105
|
-
*/
|
|
106
|
-
showLegend?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Legend orientation
|
|
109
|
-
*/
|
|
110
|
-
legendOrientation?: 'horizontal' | 'vertical';
|
|
111
|
-
/**
|
|
112
|
-
* Grid visibility. x is default.
|
|
113
|
-
*/
|
|
114
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Properties for grid components
|
|
119
|
-
*/
|
|
120
|
-
type GridProps = {
|
|
121
|
-
/**
|
|
122
|
-
* Width of the grid in pixels
|
|
123
|
-
*/
|
|
124
|
-
width: number;
|
|
125
|
-
/**
|
|
126
|
-
* Height of the grid in pixels
|
|
127
|
-
*/
|
|
128
|
-
height: number;
|
|
129
|
-
/**
|
|
130
|
-
* Grid visibility. x is default.
|
|
131
|
-
*/
|
|
132
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
133
|
-
/**
|
|
134
|
-
* X-axis scale for the grid
|
|
135
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
136
|
-
*/
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
-
xScale: any;
|
|
139
|
-
/**
|
|
140
|
-
* Y-axis scale for the grid
|
|
141
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
142
|
-
*/
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
yScale: any;
|
|
145
|
-
/**
|
|
146
|
-
* Top offset for the grid
|
|
147
|
-
*/
|
|
148
|
-
top?: number;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
interface BarChartProps extends BaseChartProps<SeriesData[]> {
|
|
152
|
-
}
|
|
153
|
-
declare const BarChart: FC<BarChartProps>;
|
|
154
|
-
|
|
155
|
-
interface LineChartProps extends BaseChartProps<SeriesData[]> {
|
|
156
|
-
}
|
|
157
|
-
declare const LineChart: FC<LineChartProps>;
|
|
158
|
-
|
|
159
|
-
interface PieChartProps extends BaseChartProps<DataPoint[]> {
|
|
160
|
-
/**
|
|
161
|
-
* Inner radius in pixels. If > 0, creates a donut chart. Defaults to 0.
|
|
162
|
-
*/
|
|
163
|
-
innerRadius?: number;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Renders a pie or donut chart using the provided data.
|
|
167
|
-
*
|
|
168
|
-
* @param {PieChartProps} props - Component props
|
|
169
|
-
* @return {JSX.Element} The rendered chart component
|
|
170
|
-
*/
|
|
171
|
-
declare const PieChart: ({ data, width, height, withTooltips, innerRadius, className, showLegend, legendOrientation, }: PieChartProps) => react_jsx_runtime.JSX.Element;
|
|
172
|
-
|
|
173
|
-
interface PieSemiCircleChartProps extends BaseChartProps<DataPointPercentage[]> {
|
|
174
|
-
/**
|
|
175
|
-
* Label text to display above the chart
|
|
176
|
-
*/
|
|
177
|
-
label: string;
|
|
178
|
-
/**
|
|
179
|
-
* Note text to display below the label
|
|
180
|
-
*/
|
|
181
|
-
note: string;
|
|
182
|
-
/**
|
|
183
|
-
* Direction of chart rendering
|
|
184
|
-
* true for clockwise, false for counter-clockwise
|
|
185
|
-
*/
|
|
186
|
-
clockwise?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Thickness of the pie chart. A value between 0 and 1
|
|
189
|
-
*/
|
|
190
|
-
thickness?: number;
|
|
191
|
-
}
|
|
192
|
-
declare const PieSemiCircleChart: FC<PieSemiCircleChartProps>;
|
|
193
|
-
|
|
194
|
-
type TooltipData = {
|
|
195
|
-
label: string;
|
|
196
|
-
value: number;
|
|
197
|
-
valueDisplay?: string;
|
|
198
|
-
};
|
|
199
|
-
type TooltipComponentProps = {
|
|
200
|
-
data: TooltipData;
|
|
201
|
-
className?: string;
|
|
202
|
-
};
|
|
203
|
-
type TooltipCommonProps = {
|
|
204
|
-
top: number;
|
|
205
|
-
left: number;
|
|
206
|
-
style?: CSSProperties;
|
|
207
|
-
className?: string;
|
|
208
|
-
};
|
|
209
|
-
type DefaultDataTooltip = {
|
|
210
|
-
data: TooltipData;
|
|
211
|
-
component?: ComponentType<TooltipComponentProps>;
|
|
212
|
-
children?: never;
|
|
213
|
-
};
|
|
214
|
-
type CustomTooltip = {
|
|
215
|
-
children: ReactNode;
|
|
216
|
-
data?: never;
|
|
217
|
-
component?: never;
|
|
218
|
-
};
|
|
219
|
-
type BaseTooltipProps = TooltipCommonProps & (DefaultDataTooltip | CustomTooltip);
|
|
220
|
-
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, }: BaseTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
221
|
-
|
|
222
|
-
type LegendItem = {
|
|
223
|
-
label: string;
|
|
224
|
-
value: number | string;
|
|
225
|
-
color: string;
|
|
226
|
-
};
|
|
227
|
-
type LegendProps = {
|
|
228
|
-
items: LegendItem[];
|
|
229
|
-
className?: string;
|
|
230
|
-
orientation?: 'horizontal' | 'vertical';
|
|
231
|
-
scale?: ReturnType<typeof scaleOrdinal>;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
declare const BaseLegend: FC<LegendProps>;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Props for the ThemeProvider component
|
|
238
|
-
*/
|
|
239
|
-
type ThemeProviderProps = {
|
|
240
|
-
/** Optional partial theme override */
|
|
241
|
-
theme?: Partial<ChartTheme>;
|
|
242
|
-
/** Child components that will have access to the theme */
|
|
243
|
-
children: ReactNode;
|
|
244
|
-
};
|
|
245
|
-
declare const ThemeProvider: FC<ThemeProviderProps>;
|
|
246
|
-
|
|
247
|
-
type UseChartMouseHandlerProps = {
|
|
248
|
-
/**
|
|
249
|
-
* Whether tooltips are enabled
|
|
250
|
-
*/
|
|
251
|
-
withTooltips: boolean;
|
|
252
|
-
};
|
|
253
|
-
type UseChartMouseHandlerReturn = {
|
|
254
|
-
/**
|
|
255
|
-
* Handler for mouse move events
|
|
256
|
-
*/
|
|
257
|
-
onMouseMove: (event: React.MouseEvent<SVGElement>, data: DataPoint) => void;
|
|
258
|
-
/**
|
|
259
|
-
* Handler for mouse leave events
|
|
260
|
-
*/
|
|
261
|
-
onMouseLeave: () => void;
|
|
262
|
-
/**
|
|
263
|
-
* Whether the tooltip is currently open
|
|
264
|
-
*/
|
|
265
|
-
tooltipOpen: boolean;
|
|
266
|
-
/**
|
|
267
|
-
* The current tooltip data
|
|
268
|
-
*/
|
|
269
|
-
tooltipData: DataPoint | null;
|
|
270
|
-
/**
|
|
271
|
-
* The current tooltip left position
|
|
272
|
-
*/
|
|
273
|
-
tooltipLeft: number | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* The current tooltip top position
|
|
276
|
-
*/
|
|
277
|
-
tooltipTop: number | undefined;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Hook to handle mouse interactions for chart components
|
|
281
|
-
*
|
|
282
|
-
* @param {UseChartMouseHandlerProps} props - Hook configuration
|
|
283
|
-
* @return {UseChartMouseHandlerReturn} Object containing handlers and tooltip state
|
|
284
|
-
*/
|
|
285
|
-
declare const useChartMouseHandler: ({ withTooltips, }: UseChartMouseHandlerProps) => UseChartMouseHandlerReturn;
|
|
286
|
-
|
|
287
|
-
export { BarChart, type BaseChartProps, BaseTooltip, type BaseTooltipProps, type ChartTheme, type DataPoint, type DataPointDate, type DataPointPercentage, type GridProps, BaseLegend as Legend, LineChart, type MultipleDataPointsDate, PieChart, PieSemiCircleChart, type SeriesData, ThemeProvider, useChartMouseHandler };
|
package/dist/index.d.ts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, FC, ComponentType, ReactNode } from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { scaleOrdinal } from '@visx/scale';
|
|
4
|
-
|
|
5
|
-
type DataPoint = {
|
|
6
|
-
label: string;
|
|
7
|
-
value: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type DataPointDate = {
|
|
11
|
-
date: Date;
|
|
12
|
-
label?: string;
|
|
13
|
-
value: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type SeriesData = {
|
|
17
|
-
group?: string;
|
|
18
|
-
label: string;
|
|
19
|
-
data: DataPointDate[] | DataPoint[];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type MultipleDataPointsDate = {
|
|
23
|
-
label: string;
|
|
24
|
-
data: DataPointDate[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type DataPointPercentage = {
|
|
28
|
-
/**
|
|
29
|
-
* Label for the data point
|
|
30
|
-
*/
|
|
31
|
-
label: string;
|
|
32
|
-
/**
|
|
33
|
-
* Numerical value
|
|
34
|
-
*/
|
|
35
|
-
value: number;
|
|
36
|
-
/**
|
|
37
|
-
* Formatted value for display
|
|
38
|
-
*/
|
|
39
|
-
valueDisplay?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Percentage value
|
|
42
|
-
*/
|
|
43
|
-
percentage: number;
|
|
44
|
-
/**
|
|
45
|
-
* Color code for the segment, by default colours are taken from the theme but this property can overrides it
|
|
46
|
-
*/
|
|
47
|
-
color?: string;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Theme configuration for chart components
|
|
52
|
-
*/
|
|
53
|
-
type ChartTheme = {
|
|
54
|
-
/** Background color for chart components */
|
|
55
|
-
backgroundColor: string;
|
|
56
|
-
/** Background color for labels */
|
|
57
|
-
labelBackgroundColor?: string;
|
|
58
|
-
/** Array of colors used for data visualization */
|
|
59
|
-
colors: string[];
|
|
60
|
-
/** Optional CSS styles for grid lines */
|
|
61
|
-
gridStyles?: CSSProperties;
|
|
62
|
-
/** Length of axis ticks in pixels */
|
|
63
|
-
tickLength: number;
|
|
64
|
-
/** Color of the grid lines */
|
|
65
|
-
gridColor: string;
|
|
66
|
-
/** Color of the grid lines in dark mode */
|
|
67
|
-
gridColorDark: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Base properties shared across all chart components
|
|
72
|
-
*/
|
|
73
|
-
type BaseChartProps< T = DataPoint | DataPointDate > = {
|
|
74
|
-
/**
|
|
75
|
-
* Array of data points to display in the chart
|
|
76
|
-
*/
|
|
77
|
-
data: T extends DataPoint | DataPointDate ? T[] : T;
|
|
78
|
-
/**
|
|
79
|
-
* Additional CSS class name for the chart container
|
|
80
|
-
*/
|
|
81
|
-
className?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Width of the chart in pixels
|
|
84
|
-
*/
|
|
85
|
-
width: number;
|
|
86
|
-
/**
|
|
87
|
-
* Height of the chart in pixels
|
|
88
|
-
*/
|
|
89
|
-
height?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Chart margins
|
|
92
|
-
*/
|
|
93
|
-
margin?: {
|
|
94
|
-
top: number;
|
|
95
|
-
right: number;
|
|
96
|
-
bottom: number;
|
|
97
|
-
left: number;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Whether to show tooltips on hover. False by default.
|
|
101
|
-
*/
|
|
102
|
-
withTooltips?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Whether to show legend
|
|
105
|
-
*/
|
|
106
|
-
showLegend?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Legend orientation
|
|
109
|
-
*/
|
|
110
|
-
legendOrientation?: 'horizontal' | 'vertical';
|
|
111
|
-
/**
|
|
112
|
-
* Grid visibility. x is default.
|
|
113
|
-
*/
|
|
114
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Properties for grid components
|
|
119
|
-
*/
|
|
120
|
-
type GridProps = {
|
|
121
|
-
/**
|
|
122
|
-
* Width of the grid in pixels
|
|
123
|
-
*/
|
|
124
|
-
width: number;
|
|
125
|
-
/**
|
|
126
|
-
* Height of the grid in pixels
|
|
127
|
-
*/
|
|
128
|
-
height: number;
|
|
129
|
-
/**
|
|
130
|
-
* Grid visibility. x is default.
|
|
131
|
-
*/
|
|
132
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
133
|
-
/**
|
|
134
|
-
* X-axis scale for the grid
|
|
135
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
136
|
-
*/
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
-
xScale: any;
|
|
139
|
-
/**
|
|
140
|
-
* Y-axis scale for the grid
|
|
141
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
142
|
-
*/
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
yScale: any;
|
|
145
|
-
/**
|
|
146
|
-
* Top offset for the grid
|
|
147
|
-
*/
|
|
148
|
-
top?: number;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
interface BarChartProps extends BaseChartProps<SeriesData[]> {
|
|
152
|
-
}
|
|
153
|
-
declare const BarChart: FC<BarChartProps>;
|
|
154
|
-
|
|
155
|
-
interface LineChartProps extends BaseChartProps<SeriesData[]> {
|
|
156
|
-
}
|
|
157
|
-
declare const LineChart: FC<LineChartProps>;
|
|
158
|
-
|
|
159
|
-
interface PieChartProps extends BaseChartProps<DataPoint[]> {
|
|
160
|
-
/**
|
|
161
|
-
* Inner radius in pixels. If > 0, creates a donut chart. Defaults to 0.
|
|
162
|
-
*/
|
|
163
|
-
innerRadius?: number;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Renders a pie or donut chart using the provided data.
|
|
167
|
-
*
|
|
168
|
-
* @param {PieChartProps} props - Component props
|
|
169
|
-
* @return {JSX.Element} The rendered chart component
|
|
170
|
-
*/
|
|
171
|
-
declare const PieChart: ({ data, width, height, withTooltips, innerRadius, className, showLegend, legendOrientation, }: PieChartProps) => react_jsx_runtime.JSX.Element;
|
|
172
|
-
|
|
173
|
-
interface PieSemiCircleChartProps extends BaseChartProps<DataPointPercentage[]> {
|
|
174
|
-
/**
|
|
175
|
-
* Label text to display above the chart
|
|
176
|
-
*/
|
|
177
|
-
label: string;
|
|
178
|
-
/**
|
|
179
|
-
* Note text to display below the label
|
|
180
|
-
*/
|
|
181
|
-
note: string;
|
|
182
|
-
/**
|
|
183
|
-
* Direction of chart rendering
|
|
184
|
-
* true for clockwise, false for counter-clockwise
|
|
185
|
-
*/
|
|
186
|
-
clockwise?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Thickness of the pie chart. A value between 0 and 1
|
|
189
|
-
*/
|
|
190
|
-
thickness?: number;
|
|
191
|
-
}
|
|
192
|
-
declare const PieSemiCircleChart: FC<PieSemiCircleChartProps>;
|
|
193
|
-
|
|
194
|
-
type TooltipData = {
|
|
195
|
-
label: string;
|
|
196
|
-
value: number;
|
|
197
|
-
valueDisplay?: string;
|
|
198
|
-
};
|
|
199
|
-
type TooltipComponentProps = {
|
|
200
|
-
data: TooltipData;
|
|
201
|
-
className?: string;
|
|
202
|
-
};
|
|
203
|
-
type TooltipCommonProps = {
|
|
204
|
-
top: number;
|
|
205
|
-
left: number;
|
|
206
|
-
style?: CSSProperties;
|
|
207
|
-
className?: string;
|
|
208
|
-
};
|
|
209
|
-
type DefaultDataTooltip = {
|
|
210
|
-
data: TooltipData;
|
|
211
|
-
component?: ComponentType<TooltipComponentProps>;
|
|
212
|
-
children?: never;
|
|
213
|
-
};
|
|
214
|
-
type CustomTooltip = {
|
|
215
|
-
children: ReactNode;
|
|
216
|
-
data?: never;
|
|
217
|
-
component?: never;
|
|
218
|
-
};
|
|
219
|
-
type BaseTooltipProps = TooltipCommonProps & (DefaultDataTooltip | CustomTooltip);
|
|
220
|
-
declare const BaseTooltip: ({ data, top, left, component: Component, children, className, }: BaseTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
221
|
-
|
|
222
|
-
type LegendItem = {
|
|
223
|
-
label: string;
|
|
224
|
-
value: number | string;
|
|
225
|
-
color: string;
|
|
226
|
-
};
|
|
227
|
-
type LegendProps = {
|
|
228
|
-
items: LegendItem[];
|
|
229
|
-
className?: string;
|
|
230
|
-
orientation?: 'horizontal' | 'vertical';
|
|
231
|
-
scale?: ReturnType<typeof scaleOrdinal>;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
declare const BaseLegend: FC<LegendProps>;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Props for the ThemeProvider component
|
|
238
|
-
*/
|
|
239
|
-
type ThemeProviderProps = {
|
|
240
|
-
/** Optional partial theme override */
|
|
241
|
-
theme?: Partial<ChartTheme>;
|
|
242
|
-
/** Child components that will have access to the theme */
|
|
243
|
-
children: ReactNode;
|
|
244
|
-
};
|
|
245
|
-
declare const ThemeProvider: FC<ThemeProviderProps>;
|
|
246
|
-
|
|
247
|
-
type UseChartMouseHandlerProps = {
|
|
248
|
-
/**
|
|
249
|
-
* Whether tooltips are enabled
|
|
250
|
-
*/
|
|
251
|
-
withTooltips: boolean;
|
|
252
|
-
};
|
|
253
|
-
type UseChartMouseHandlerReturn = {
|
|
254
|
-
/**
|
|
255
|
-
* Handler for mouse move events
|
|
256
|
-
*/
|
|
257
|
-
onMouseMove: (event: React.MouseEvent<SVGElement>, data: DataPoint) => void;
|
|
258
|
-
/**
|
|
259
|
-
* Handler for mouse leave events
|
|
260
|
-
*/
|
|
261
|
-
onMouseLeave: () => void;
|
|
262
|
-
/**
|
|
263
|
-
* Whether the tooltip is currently open
|
|
264
|
-
*/
|
|
265
|
-
tooltipOpen: boolean;
|
|
266
|
-
/**
|
|
267
|
-
* The current tooltip data
|
|
268
|
-
*/
|
|
269
|
-
tooltipData: DataPoint | null;
|
|
270
|
-
/**
|
|
271
|
-
* The current tooltip left position
|
|
272
|
-
*/
|
|
273
|
-
tooltipLeft: number | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* The current tooltip top position
|
|
276
|
-
*/
|
|
277
|
-
tooltipTop: number | undefined;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Hook to handle mouse interactions for chart components
|
|
281
|
-
*
|
|
282
|
-
* @param {UseChartMouseHandlerProps} props - Hook configuration
|
|
283
|
-
* @return {UseChartMouseHandlerReturn} Object containing handlers and tooltip state
|
|
284
|
-
*/
|
|
285
|
-
declare const useChartMouseHandler: ({ withTooltips, }: UseChartMouseHandlerProps) => UseChartMouseHandlerReturn;
|
|
286
|
-
|
|
287
|
-
export { BarChart, type BaseChartProps, BaseTooltip, type BaseTooltipProps, type ChartTheme, type DataPoint, type DataPointDate, type DataPointPercentage, type GridProps, BaseLegend as Legend, LineChart, type MultipleDataPointsDate, PieChart, PieSemiCircleChart, type SeriesData, ThemeProvider, useChartMouseHandler };
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var Ee=Object.create;var Z=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var We=(e,t)=>{for(var o in t)Z(e,o,{get:t[o],enumerable:!0})},fe=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Xe(t))!Ke.call(e,r)&&r!==o&&Z(e,r,{get:()=>t[r],enumerable:!(a=Ie(t,r))||a.enumerable});return e};var W=(e,t,o)=>(o=e!=null?Ee(Ve(e)):{},fe(t||!e||!e.__esModule?Z(o,"default",{value:e,enumerable:!0}):o,e)),Ye=e=>fe(Z({},"__esModule",{value:!0}),e);var tt={};We(tt,{BarChart:()=>se,BaseTooltip:()=>N,Legend:()=>T,LineChart:()=>me,PieChart:()=>he,PieSemiCircleChart:()=>ge,ThemeProvider:()=>re,useChartMouseHandler:()=>te});module.exports=Ye(tt);var ee=require("@visx/axis"),De=require("@visx/event"),le=require("@visx/group"),U=require("@visx/scale"),Fe=require("@visx/shape"),ke=require("@visx/tooltip"),ie=W(require("clsx")),ne=require("react");var j=require("react");var Y={backgroundColor:"#FFFFFF",labelBackgroundColor:"#FFFFFF",colors:["#98C8DF","#006DAB","#A6DC80","#1F9828","#FF8C8F"],gridStyles:{stroke:"#787C82",strokeWidth:1},tickLength:0,gridColor:"",gridColorDark:""};var Ce=require("react/jsx-runtime"),ve=(0,j.createContext)(Y),B=()=>(0,j.useContext)(ve),re=({theme:e={},children:t})=>{let o={...Y,...e};return(0,Ce.jsx)(ve.Provider,{value:o,children:t})};var Q=require("@visx/grid");var be={"grid-control":"grid-control-module__grid-control___KOnZN"};var q=require("react/jsx-runtime"),He=({width:e,height:t,xScale:o,yScale:a,gridVisibility:r="x",top:i=0})=>(0,q.jsxs)("g",{transform:`translate(0, ${i})`,className:be["grid-control"],children:[r.includes("x")&&(0,q.jsx)(Q.GridRows,{scale:o,width:e}),r.includes("y")&&(0,q.jsx)(Q.GridColumns,{scale:a,height:t})]}),ae=He;var ye=require("@visx/legend"),xe=require("@visx/scale"),Pe=W(require("clsx"));var S={"legend--horizontal":"legend-module__legend--horizontal___IUN13","legend--vertical":"legend-module__legend--vertical___Scfzo","legend-item":"legend-module__legend-item___feemn","legend-item-swatch":"legend-module__legend-item-swatch___nRyXf","legend-item-label":"legend-module__legend-item-label___ksx6I","legend-item-value":"legend-module__legend-item-value___d9x1j"};var k=require("react/jsx-runtime"),qe={horizontal:"row",vertical:"column"},T=({items:e,className:t,orientation:o="horizontal"})=>{let a=(0,xe.scaleOrdinal)({domain:e.map(r=>r.label),range:e.map(r=>r.color)});return(0,k.jsx)("div",{className:(0,Pe.default)(S.legend,S[`legend--${o}`],t),role:"list",children:(0,k.jsx)(ye.LegendOrdinal,{scale:a,direction:qe[o],shape:"rect",shapeWidth:16,shapeHeight:16,className:S["legend-items"],children:r=>(0,k.jsx)("div",{className:S[`legend--${o}`],children:r.map(i=>(0,k.jsxs)("div",{className:S["legend-item"],children:[(0,k.jsx)("svg",{width:16,height:16,children:(0,k.jsx)("rect",{width:16,height:16,fill:i.value,className:S["legend-item-swatch"]})}),(0,k.jsxs)("span",{className:S["legend-item-label"],children:[i.text,e.find(_=>_.label===i.text)?.value&&(0,k.jsx)("span",{className:S["legend-item-value"],children:e.find(_=>_.label===i.text)?.value})]})]},i.text))})})})};var Te={tooltip:"base-tooltip-module__tooltip___OfX6n"};var E=require("react/jsx-runtime"),Ue=({data:e})=>(0,E.jsxs)(E.Fragment,{children:[e?.label,": ",e?.valueDisplay||e?.value]}),N=({data:e,top:t,left:o,component:a=Ue,children:r,className:i})=>(0,E.jsx)("div",{className:Te.tooltip,style:{top:t,left:o},role:"tooltip",children:r||(0,E.jsx)(a,{data:e,className:i})});var J={"bar-chart":"bar-chart-module__bar-chart___lmYNi","bar-chart-legend":"bar-chart-module__bar-chart-legend___vgKKq"};var h=require("react/jsx-runtime"),Me=({data:e,width:t,height:o,margin:a={top:20,right:20,bottom:40,left:40},withTooltips:r=!1,showLegend:i=!1,legendOrientation:_="horizontal",className:M,gridVisibility:s="x"})=>{let b=B(),{tooltipOpen:F,tooltipLeft:g,tooltipTop:c,tooltipData:y,hideTooltip:L,showTooltip:z}=(0,ke.useTooltip)(),I=(0,ne.useCallback)((d,m,x,K,l)=>{let n=(0,De.localPoint)(d);n&&z({tooltipData:{value:m,xLabel:x,yLabel:K,seriesIndex:l},tooltipLeft:n.x,tooltipTop:n.y-10})},[z]),X=(0,ne.useCallback)(()=>{L()},[L]);if(!e?.length)return(0,h.jsx)("div",{className:(0,ie.default)("bar-chart-empty",J["bat-chart-empty"]),children:"Empty..."});let P=a,O=t-P.left-P.right,p=o-P.top-P.bottom,f=e[0].data?.map(d=>d?.label),w=(0,U.scaleBand)({range:[0,O],domain:f,padding:.2}),V=(0,U.scaleBand)({range:[0,w.bandwidth()],domain:e.map((d,m)=>m.toString()),padding:.1}),G=(0,U.scaleLinear)({range:[p,0],domain:[0,Math.max(...e.map(d=>Math.max(...d.data.map(m=>m?.value||0))))]}),R=e.map((d,m)=>({label:d.label,value:"",color:b.colors[m%b.colors.length]}));return(0,h.jsxs)("div",{className:(0,ie.default)("bar-chart",M,J["bar-chart"]),children:[(0,h.jsx)("svg",{width:t,height:o,children:(0,h.jsxs)(le.Group,{left:P.left,top:P.top,children:[(0,h.jsx)(ae,{width:O,height:p,xScale:w,yScale:G,gridVisibility:s}),e.map((d,m)=>(0,h.jsx)(le.Group,{children:d.data.map(x=>{let K=w(x.label);if(K===void 0)return null;let l=V.bandwidth(),n=K+(V(m.toString())??0),H=Oe=>I(Oe,x.value,x.label,d.label,m);return(0,h.jsx)(Fe.Bar,{x:n,y:G(x.value),width:l,height:p-(G(x.value)??0),fill:b.colors[m%b.colors.length],onMouseMove:r?H:void 0,onMouseLeave:r?X:void 0},`bar-${m}-${x.label}`)})},m)),(0,h.jsx)(ee.AxisLeft,{scale:G}),(0,h.jsx)(ee.AxisBottom,{scale:w,top:p})]})}),r&&F&&y&&(0,h.jsx)(N,{top:c,left:g,children:(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{children:y.yLabel}),(0,h.jsxs)("div",{children:[y.xLabel,": ",y.value]})]})}),i&&(0,h.jsx)(T,{items:R,orientation:_,className:J["bar-chart-legend"]})]})};Me.displayName="BarChart";var se=Me;var v=require("@visx/xychart"),pe=W(require("clsx"));var A={"line-chart":"line-chart-module__line-chart___ITM3d","line-chart__tooltip":"line-chart-module__line-chart__tooltip___aqcme","line-chart__tooltip-date":"line-chart-module__line-chart__tooltip-date___4Dzab","line-chart__tooltip-row":"line-chart-module__line-chart__tooltip-row___6A37G","line-chart__tooltip-label":"line-chart-module__line-chart__tooltip-label___IvnFF"};var u=require("react/jsx-runtime"),$e=({tooltipData:e})=>{let t=e?.nearestDatum?.datum;if(!t)return null;let o=Object.entries(e?.datumByKey||{}).map(([a,{datum:r}])=>({key:a,value:r.value})).sort((a,r)=>r.value-a.value);return(0,u.jsxs)("div",{className:A["line-chart__tooltip"],children:[(0,u.jsx)("div",{className:A["line-chart__tooltip-date"],children:t.date.toLocaleDateString()}),o.map(a=>(0,u.jsxs)("div",{className:A["line-chart__tooltip-row"],children:[(0,u.jsxs)("span",{className:A["line-chart__tooltip-label"],children:[a.key,":"]}),(0,u.jsx)("span",{className:A["line-chart__tooltip-value"],children:a.value})]},a.key))]})},Ze=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"}),je=({data:e,width:t,height:o,margin:a={top:20,right:20,bottom:40,left:40},className:r,withTooltips:i=!0,showLegend:_=!1,legendOrientation:M="horizontal"})=>{let s=B();if(!e?.length)return(0,u.jsx)("div",{className:(0,pe.default)("line-chart-empty",A["line-chart-empty"]),children:"Empty..."});let b=e.map((c,y)=>({label:c.label,value:"",color:s.colors[y%s.colors.length]})),F={xAccessor:c=>c.date,yAccessor:c=>c.value},g=(0,v.buildChartTheme)({backgroundColor:s.backgroundColor,colors:s.colors,gridStyles:s.gridStyles,tickLength:s?.tickLength||0,gridColor:s?.gridColor||"",gridColorDark:s?.gridColorDark||""});return(0,u.jsxs)("div",{className:(0,pe.default)("line-chart",A["line-chart"],r),children:[(0,u.jsxs)(v.XYChart,{theme:g,width:t,height:o,margin:a,xScale:{type:"time"},yScale:{type:"linear",nice:!0},children:[(0,u.jsx)(v.AnimatedGrid,{columns:!1,numTicks:4}),(0,u.jsx)(v.AnimatedAxis,{orientation:"bottom",numTicks:5,tickFormat:Ze}),(0,u.jsx)(v.AnimatedAxis,{orientation:"left",numTicks:4}),e.map((c,y)=>(0,u.jsx)(v.AnimatedLineSeries,{dataKey:c?.label,data:c.data,...F,stroke:g.colors[y%g.colors.length],strokeWidth:2},c?.label)),i&&(0,u.jsx)(v.Tooltip,{snapTooltipToDatumX:!0,snapTooltipToDatumY:!0,showSeriesGlyphs:!0,renderTooltip:$e})]}),_&&(0,u.jsx)(T,{items:b,orientation:M,className:A["line-chart-legend"]})]})},me=je;var Se=require("@visx/group"),Ne=require("@visx/shape"),Ae=W(require("clsx"));var Le=require("@visx/event"),Be=require("@visx/tooltip"),ce=require("react"),Qe=({withTooltips:e})=>{let{tooltipOpen:t,tooltipLeft:o,tooltipTop:a,tooltipData:r,hideTooltip:i,showTooltip:_}=(0,Be.useTooltip)(),M=(0,ce.useCallback)((b,F)=>{if(!e)return;let g=(0,Le.localPoint)(b);g&&_({tooltipData:F,tooltipLeft:g.x,tooltipTop:g.y-10})},[e,_]),s=(0,ce.useCallback)(()=>{e&&i()},[e,i]);return{onMouseMove:M,onMouseLeave:s,tooltipOpen:t,tooltipData:r,tooltipLeft:o,tooltipTop:a}},te=Qe;var de={"pie-chart":"pie-chart-module__pie-chart___R12Vh"};var D=require("react/jsx-runtime"),Je=({data:e,width:t,height:o,withTooltips:a=!1,innerRadius:r=0,className:i,showLegend:_,legendOrientation:M})=>{let s=B(),{onMouseMove:b,onMouseLeave:F,tooltipOpen:g,tooltipData:c,tooltipLeft:y,tooltipTop:L}=te({withTooltips:a}),z=Math.min(t,o)/2,I=t/2,X=o/2,P={value:p=>p.value,fill:p=>p.color||s.colors[p.index]},O=e.map((p,f)=>({label:p.label,value:p.value.toString(),color:s.colors[f%s.colors.length]}));return(0,D.jsxs)("div",{className:(0,Ae.default)("pie-chart",de["pie-chart"],i),children:[(0,D.jsx)("svg",{width:t,height:o,children:(0,D.jsx)(Se.Group,{top:X,left:I,children:(0,D.jsx)(Ne.Pie,{data:e,pieValue:P.value,outerRadius:z-20,innerRadius:r,children:p=>p.arcs.map((f,w)=>{let[V,G]=p.path.centroid(f),R=f.endAngle-f.startAngle>=.25,d=x=>b(x,f.data),m={d:p.path(f)||"",fill:P.fill(f)};return a&&(m.onMouseMove=d,m.onMouseLeave=F),(0,D.jsxs)("g",{children:[(0,D.jsx)("path",{...m}),R&&(0,D.jsx)("text",{x:V,y:G,dy:".33em",fill:s.labelBackgroundColor||Y.labelBackgroundColor,fontSize:12,textAnchor:"middle",pointerEvents:"none",children:f.data.label})]},`arc-${w}`)})})})}),_&&(0,D.jsx)(T,{items:O,orientation:M,className:de["pie-chart-legend"]}),a&&g&&c&&(0,D.jsx)(N,{data:c,top:L,left:y,style:{transform:"translate(-50%, -100%)"}})]})},he=Je;var we=require("@visx/event"),ue=require("@visx/group"),Ge=W(require("@visx/shape/lib/shapes/Pie")),_e=require("@visx/text"),Re=require("@visx/tooltip"),ze=W(require("clsx")),oe=require("react");var $={"pie-semi-circle-chart":"pie-semi-circle-chart-module__pie-semi-circle-chart___r5jk9","pie-semi-circle-chart-legend":"pie-semi-circle-chart-module__pie-semi-circle-chart-legend___c8W1Y",label:"pie-semi-circle-chart-module__label___nPqOg",note:"pie-semi-circle-chart-module__note___LpBZQ"};var C=require("react/jsx-runtime"),et=({data:e,width:t,label:o,note:a,className:r,withTooltips:i=!1,clockwise:_=!0,thickness:M=.4,showLegend:s,legendOrientation:b})=>{let F=B(),{tooltipOpen:g,tooltipLeft:c,tooltipTop:y,tooltipData:L,hideTooltip:z,showTooltip:I}=(0,Re.useTooltip)(),X=t/2,P=t/2,O=t/2,p=.03,f=O*(1-M+p),w=e.map((l,n)=>({...l,index:n})),V=_?-Math.PI/2:Math.PI/2,G=_?Math.PI/2:-Math.PI/2,R={value:l=>l.value,sort:(l,n)=>n.value-l.value,fill:l=>l.color||F.colors[l.index%F.colors.length]},d=(0,oe.useCallback)((l,n)=>{let H=(0,we.localPoint)(l);H&&I({tooltipData:n.data,tooltipLeft:H.x,tooltipTop:H.y-10})},[I]),m=(0,oe.useCallback)(()=>{z()},[z]),x=(0,oe.useCallback)(l=>n=>{d(n,l)},[d]),K=e.map((l,n)=>({label:l.label,value:l.valueDisplay||l.value.toString(),color:R.fill({...l,index:n})}));return(0,C.jsxs)("div",{className:(0,ze.default)("pie-semi-circle-chart",$["pie-semi-circle-chart"],r),children:[(0,C.jsx)("svg",{width:t,height:P,children:(0,C.jsxs)(ue.Group,{top:X,left:X,children:[(0,C.jsx)(Ge.default,{data:w,pieValue:R.value,outerRadius:O,innerRadius:f,cornerRadius:3,padAngle:p,startAngle:V,endAngle:G,pieSort:R.sort,children:l=>l.arcs.map(n=>(0,C.jsx)("g",{onMouseMove:x(n),onMouseLeave:m,children:(0,C.jsx)("path",{d:l.path(n)||"",fill:R.fill(n.data)})},n.data.label))}),(0,C.jsxs)(ue.Group,{children:[(0,C.jsx)(_e.Text,{textAnchor:"middle",verticalAnchor:"start",y:-40,className:$.label,children:o}),(0,C.jsx)(_e.Text,{textAnchor:"middle",verticalAnchor:"start",y:-20,className:$.note,children:a})]})]})}),i&&g&&L&&(0,C.jsx)(N,{data:{label:L.label,value:L.value,valueDisplay:L.valueDisplay},top:y,left:c}),s&&(0,C.jsx)(T,{items:K,orientation:b,className:$["pie-semi-circle-chart-legend"]})]})},ge=et;0&&(module.exports={BarChart,BaseTooltip,Legend,LineChart,PieChart,PieSemiCircleChart,ThemeProvider,useChartMouseHandler});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|