minerva-design 1.2.0 → 1.3.0
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 +7 -0
- package/dist/charts/canvas.d.cts +4 -1
- package/dist/charts/canvas.d.ts +4 -1
- package/dist/charts/core.cjs +1 -1
- package/dist/charts/core.d.cts +5 -2
- package/dist/charts/core.d.ts +5 -2
- package/dist/charts/core.js +6 -4
- package/dist/charts/engine/canvas.cjs +1 -1
- package/dist/charts/engine/canvas.cjs.map +1 -1
- package/dist/charts/engine/canvas.js +65 -53
- package/dist/charts/engine/canvas.js.map +1 -1
- package/dist/charts/engine/chart.cjs +1 -2
- package/dist/charts/engine/chart.cjs.map +1 -1
- package/dist/charts/engine/chart.js +342 -323
- package/dist/charts/engine/chart.js.map +1 -1
- package/dist/charts/engine/color.cjs +1 -1
- package/dist/charts/engine/color.cjs.map +1 -1
- package/dist/charts/engine/color.d.cts +17 -0
- package/dist/charts/engine/color.d.ts +17 -0
- package/dist/charts/engine/color.js +27 -3
- package/dist/charts/engine/color.js.map +1 -1
- package/dist/charts/engine/controller.cjs +2 -2
- package/dist/charts/engine/controller.cjs.map +1 -1
- package/dist/charts/engine/controller.d.cts +6 -0
- package/dist/charts/engine/controller.d.ts +6 -0
- package/dist/charts/engine/controller.js +317 -253
- package/dist/charts/engine/controller.js.map +1 -1
- package/dist/charts/engine/curve.cjs +2 -0
- package/dist/charts/engine/curve.cjs.map +1 -0
- package/dist/charts/engine/curve.d.cts +15 -0
- package/dist/charts/engine/curve.d.ts +15 -0
- package/dist/charts/engine/curve.js +56 -0
- package/dist/charts/engine/curve.js.map +1 -0
- package/dist/charts/engine/data.cjs +1 -1
- package/dist/charts/engine/data.cjs.map +1 -1
- package/dist/charts/engine/data.d.cts +15 -2
- package/dist/charts/engine/data.d.ts +15 -2
- package/dist/charts/engine/data.js +98 -38
- package/dist/charts/engine/data.js.map +1 -1
- package/dist/charts/engine/dom.cjs +1 -1
- package/dist/charts/engine/dom.cjs.map +1 -1
- package/dist/charts/engine/dom.d.cts +5 -3
- package/dist/charts/engine/dom.d.ts +5 -3
- package/dist/charts/engine/dom.js +27 -22
- package/dist/charts/engine/dom.js.map +1 -1
- package/dist/charts/engine/items.cjs +1 -1
- package/dist/charts/engine/items.cjs.map +1 -1
- package/dist/charts/engine/items.js +132 -61
- package/dist/charts/engine/items.js.map +1 -1
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +30 -3
- package/dist/charts/engine/model.d.ts +30 -3
- package/dist/charts/engine/model.js +225 -108
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +2 -0
- package/dist/charts/engine/overlay.d.ts +2 -0
- package/dist/charts/engine/overlay.js +16 -16
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +2 -2
- package/dist/charts/engine/presets.cjs.map +1 -1
- package/dist/charts/engine/presets.d.cts +71 -5
- package/dist/charts/engine/presets.d.ts +71 -5
- package/dist/charts/engine/presets.js +120 -33
- package/dist/charts/engine/presets.js.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.js +149 -111
- package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
- package/dist/charts/engine/renderers/range.cjs +1 -1
- package/dist/charts/engine/renderers/range.cjs.map +1 -1
- package/dist/charts/engine/renderers/range.js +4 -4
- package/dist/charts/engine/renderers/range.js.map +1 -1
- package/dist/charts/engine/renderers/shaders.cjs +37 -19
- package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
- package/dist/charts/engine/renderers/shaders.d.cts +2 -2
- package/dist/charts/engine/renderers/shaders.d.ts +2 -2
- package/dist/charts/engine/renderers/shaders.js +37 -19
- package/dist/charts/engine/renderers/shaders.js.map +1 -1
- package/dist/charts/engine/renderers/types.cjs.map +1 -1
- package/dist/charts/engine/renderers/types.d.cts +11 -4
- package/dist/charts/engine/renderers/types.d.ts +11 -4
- package/dist/charts/engine/renderers/types.js.map +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgl2.js +33 -12
- package/dist/charts/engine/renderers/webgl2.js.map +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgpu.js +18 -15
- package/dist/charts/engine/renderers/webgpu.js.map +1 -1
- package/dist/charts/engine/scene.cjs +1 -1
- package/dist/charts/engine/scene.cjs.map +1 -1
- package/dist/charts/engine/scene.d.cts +19 -6
- package/dist/charts/engine/scene.d.ts +19 -6
- package/dist/charts/engine/scene.js +201 -89
- package/dist/charts/engine/scene.js.map +1 -1
- package/dist/charts/engine/shapes/canvas.cjs +2 -0
- package/dist/charts/engine/shapes/canvas.cjs.map +1 -0
- package/dist/charts/engine/shapes/canvas.d.cts +58 -0
- package/dist/charts/engine/shapes/canvas.d.ts +58 -0
- package/dist/charts/engine/shapes/canvas.js +159 -0
- package/dist/charts/engine/shapes/canvas.js.map +1 -0
- package/dist/charts/engine/shapes/chart.cjs +2 -0
- package/dist/charts/engine/shapes/chart.cjs.map +1 -0
- package/dist/charts/engine/shapes/chart.d.cts +6 -0
- package/dist/charts/engine/shapes/chart.d.ts +6 -0
- package/dist/charts/engine/shapes/chart.js +273 -0
- package/dist/charts/engine/shapes/chart.js.map +1 -0
- package/dist/charts/engine/shapes/draw.cjs +2 -0
- package/dist/charts/engine/shapes/draw.cjs.map +1 -0
- package/dist/charts/engine/shapes/draw.d.cts +20 -0
- package/dist/charts/engine/shapes/draw.d.ts +20 -0
- package/dist/charts/engine/shapes/draw.js +152 -0
- package/dist/charts/engine/shapes/draw.js.map +1 -0
- package/dist/charts/engine/shapes/funnel.cjs +2 -0
- package/dist/charts/engine/shapes/funnel.cjs.map +1 -0
- package/dist/charts/engine/shapes/funnel.d.cts +6 -0
- package/dist/charts/engine/shapes/funnel.d.ts +6 -0
- package/dist/charts/engine/shapes/funnel.js +149 -0
- package/dist/charts/engine/shapes/funnel.js.map +1 -0
- package/dist/charts/engine/shapes/gauge.cjs +2 -0
- package/dist/charts/engine/shapes/gauge.cjs.map +1 -0
- package/dist/charts/engine/shapes/gauge.d.cts +7 -0
- package/dist/charts/engine/shapes/gauge.d.ts +7 -0
- package/dist/charts/engine/shapes/gauge.js +173 -0
- package/dist/charts/engine/shapes/gauge.js.map +1 -0
- package/dist/charts/engine/shapes/hit.cjs +2 -0
- package/dist/charts/engine/shapes/hit.cjs.map +1 -0
- package/dist/charts/engine/shapes/hit.d.cts +28 -0
- package/dist/charts/engine/shapes/hit.d.ts +28 -0
- package/dist/charts/engine/shapes/hit.js +124 -0
- package/dist/charts/engine/shapes/hit.js.map +1 -0
- package/dist/charts/engine/shapes/index.d.cts +9 -0
- package/dist/charts/engine/shapes/index.d.ts +9 -0
- package/dist/charts/engine/shapes/layout.cjs +3 -0
- package/dist/charts/engine/shapes/layout.cjs.map +1 -0
- package/dist/charts/engine/shapes/layout.d.cts +88 -0
- package/dist/charts/engine/shapes/layout.d.ts +88 -0
- package/dist/charts/engine/shapes/layout.js +266 -0
- package/dist/charts/engine/shapes/layout.js.map +1 -0
- package/dist/charts/engine/shapes/pie.cjs +2 -0
- package/dist/charts/engine/shapes/pie.cjs.map +1 -0
- package/dist/charts/engine/shapes/pie.d.cts +20 -0
- package/dist/charts/engine/shapes/pie.d.ts +20 -0
- package/dist/charts/engine/shapes/pie.js +302 -0
- package/dist/charts/engine/shapes/pie.js.map +1 -0
- package/dist/charts/engine/shapes/radar.cjs +2 -0
- package/dist/charts/engine/shapes/radar.cjs.map +1 -0
- package/dist/charts/engine/shapes/radar.d.cts +8 -0
- package/dist/charts/engine/shapes/radar.d.ts +8 -0
- package/dist/charts/engine/shapes/radar.js +197 -0
- package/dist/charts/engine/shapes/radar.js.map +1 -0
- package/dist/charts/engine/shapes/runtime.cjs +2 -0
- package/dist/charts/engine/shapes/runtime.cjs.map +1 -0
- package/dist/charts/engine/shapes/runtime.d.cts +29 -0
- package/dist/charts/engine/shapes/runtime.d.ts +29 -0
- package/dist/charts/engine/shapes/runtime.js +97 -0
- package/dist/charts/engine/shapes/runtime.js.map +1 -0
- package/dist/charts/engine/shapes/scene.cjs +2 -0
- package/dist/charts/engine/shapes/scene.cjs.map +1 -0
- package/dist/charts/engine/shapes/scene.d.cts +257 -0
- package/dist/charts/engine/shapes/scene.d.ts +257 -0
- package/dist/charts/engine/shapes/scene.js +123 -0
- package/dist/charts/engine/shapes/scene.js.map +1 -0
- package/dist/charts/engine/shapes/treemap.cjs +2 -0
- package/dist/charts/engine/shapes/treemap.cjs.map +1 -0
- package/dist/charts/engine/shapes/treemap.d.cts +14 -0
- package/dist/charts/engine/shapes/treemap.d.ts +14 -0
- package/dist/charts/engine/shapes/treemap.js +213 -0
- package/dist/charts/engine/shapes/treemap.js.map +1 -0
- package/dist/charts/engine/shapes/types.d.cts +292 -0
- package/dist/charts/engine/shapes/types.d.ts +292 -0
- package/dist/charts/engine/signature.cjs +2 -0
- package/dist/charts/engine/signature.cjs.map +1 -0
- package/dist/charts/engine/signature.d.cts +9 -0
- package/dist/charts/engine/signature.d.ts +9 -0
- package/dist/charts/engine/signature.js +13 -0
- package/dist/charts/engine/signature.js.map +1 -0
- package/dist/charts/engine/theme.cjs +1 -1
- package/dist/charts/engine/theme.cjs.map +1 -1
- package/dist/charts/engine/theme.d.cts +10 -1
- package/dist/charts/engine/theme.d.ts +10 -1
- package/dist/charts/engine/theme.js +40 -16
- package/dist/charts/engine/theme.js.map +1 -1
- package/dist/charts/engine/types.d.cts +70 -9
- package/dist/charts/engine/types.d.ts +70 -9
- package/dist/charts/index.cjs +1 -1
- package/dist/charts/index.d.cts +4 -2
- package/dist/charts/index.d.ts +4 -2
- package/dist/charts/index.js +8 -5
- package/dist/charts/react/Chart.cjs +1 -1
- package/dist/charts/react/Chart.cjs.map +1 -1
- package/dist/charts/react/Chart.d.cts +8 -1
- package/dist/charts/react/Chart.d.ts +8 -1
- package/dist/charts/react/Chart.js +66 -47
- package/dist/charts/react/Chart.js.map +1 -1
- package/dist/charts/react/charts.cjs +1 -1
- package/dist/charts/react/charts.cjs.map +1 -1
- package/dist/charts/react/charts.d.cts +10 -2
- package/dist/charts/react/charts.d.ts +10 -2
- package/dist/charts/react/charts.js +174 -51
- package/dist/charts/react/charts.js.map +1 -1
- package/dist/charts/react/shapes.cjs +2 -0
- package/dist/charts/react/shapes.cjs.map +1 -0
- package/dist/charts/react/shapes.d.cts +255 -0
- package/dist/charts/react/shapes.d.ts +255 -0
- package/dist/charts/react/shapes.js +242 -0
- package/dist/charts/react/shapes.js.map +1 -0
- package/dist/charts/react/types.d.cts +73 -4
- package/dist/charts/react/types.d.ts +73 -4
- package/dist/native/charts/src/engine/color.cjs +1 -1
- package/dist/native/charts/src/engine/color.cjs.map +1 -1
- package/dist/native/charts/src/engine/color.js +12 -3
- package/dist/native/charts/src/engine/color.js.map +1 -1
- package/dist/native/charts/src/engine/controller.cjs +2 -2
- package/dist/native/charts/src/engine/controller.cjs.map +1 -1
- package/dist/native/charts/src/engine/controller.js +334 -270
- package/dist/native/charts/src/engine/controller.js.map +1 -1
- package/dist/native/charts/src/engine/curve.cjs +2 -0
- package/dist/native/charts/src/engine/curve.cjs.map +1 -0
- package/dist/native/charts/src/engine/curve.js +56 -0
- package/dist/native/charts/src/engine/curve.js.map +1 -0
- package/dist/native/charts/src/engine/data.cjs +1 -1
- package/dist/native/charts/src/engine/data.cjs.map +1 -1
- package/dist/native/charts/src/engine/data.js +98 -38
- package/dist/native/charts/src/engine/data.js.map +1 -1
- package/dist/native/charts/src/engine/model.cjs +1 -1
- package/dist/native/charts/src/engine/model.cjs.map +1 -1
- package/dist/native/charts/src/engine/model.js +229 -112
- package/dist/native/charts/src/engine/model.js.map +1 -1
- package/dist/native/charts/src/engine/overlay.cjs +1 -1
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
- package/dist/native/charts/src/engine/overlay.js +16 -16
- package/dist/native/charts/src/engine/overlay.js.map +1 -1
- package/dist/native/charts/src/engine/presets.cjs +1 -1
- package/dist/native/charts/src/engine/presets.cjs.map +1 -1
- package/dist/native/charts/src/engine/presets.js +11 -4
- package/dist/native/charts/src/engine/presets.js.map +1 -1
- package/dist/native/charts/src/engine/scene.cjs +1 -1
- package/dist/native/charts/src/engine/scene.cjs.map +1 -1
- package/dist/native/charts/src/engine/scene.js +209 -97
- package/dist/native/charts/src/engine/scene.js.map +1 -1
- package/dist/native/charts/src/engine/theme.cjs.map +1 -1
- package/dist/native/charts/src/engine/theme.js.map +1 -1
- package/dist/native/components/Chart/scene.cjs +1 -1
- package/dist/native/components/Chart/scene.cjs.map +1 -1
- package/dist/native/components/Chart/scene.js +31 -19
- package/dist/native/components/Chart/scene.js.map +1 -1
- package/dist/native/source/components/Chart/scene.tsx +54 -20
- package/dist/taro/index.js +1059 -579
- package/dist/uni/charts-canvas.js +3 -1
- package/dist/weapp/controls.js +966 -225
- package/package.json +1 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { ChartPadding } from '../engine/types.cjs';
|
|
3
|
+
import { GaugeBand, RadarIndicator, RadarSeries, ShapeChartInstance, ShapeDatum, ShapeHoverEvent, ShapeLegendOptions, ShapeToggleEvent, ShapeTooltipOptions, TreemapNode } from '../engine/shapes/types.cjs';
|
|
4
|
+
/** Imperative handle of the shape chart components (`ref`) */
|
|
5
|
+
export interface ShapeChartHandle {
|
|
6
|
+
/** The underlying engine instance (minerva-design/charts/core) */
|
|
7
|
+
getInstance(): ShapeChartInstance | null;
|
|
8
|
+
}
|
|
9
|
+
/** Props shared by PieChart, DonutChart, RadarChart, GaugeChart, FunnelChart and TreemapChart */
|
|
10
|
+
export interface ShapeChartCommonProps {
|
|
11
|
+
/**
|
|
12
|
+
* Height of the chart (the legend included); numbers are pixels
|
|
13
|
+
* @default 320 (GaugeChart: 240)
|
|
14
|
+
*/
|
|
15
|
+
height?: number | string;
|
|
16
|
+
/**
|
|
17
|
+
* Width of the chart; numbers are pixels
|
|
18
|
+
* @default "100%"
|
|
19
|
+
*/
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/** Colors of the marks without `color` (defaults to the `--chart-series-1..8` CSS variables, then the theme colors) */
|
|
22
|
+
palette?: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* Legend; clicking an item hides / shows its slice, stage or series
|
|
25
|
+
* @default shown for pie, donut, funnel and multi-series radar charts
|
|
26
|
+
*/
|
|
27
|
+
legend?: boolean | ShapeLegendOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Tooltip; `false` disables it
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
tooltip?: boolean | ShapeTooltipOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Formats the values of the labels and the tooltip
|
|
35
|
+
* @default compact numbers (1.2k, 3.4M)
|
|
36
|
+
*/
|
|
37
|
+
format?: (value: number) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Formats the shares (labels, conversion rates, tooltip); `share` is 0-1
|
|
40
|
+
* @default one decimal, e.g. "40.0%"
|
|
41
|
+
*/
|
|
42
|
+
percentFormat?: (share: number) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Hidden slices / stages / radar series / top-level treemap nodes, by
|
|
45
|
+
* index. Makes the visibility controlled: legend clicks then only call
|
|
46
|
+
* `onToggle`, whose `hiddenIndexes` should be stored and passed back.
|
|
47
|
+
* Leave undefined to let the legend hide / show entries by itself.
|
|
48
|
+
*/
|
|
49
|
+
hidden?: readonly number[];
|
|
50
|
+
/**
|
|
51
|
+
* Called when a legend item is clicked (or the instance's `toggle()` is
|
|
52
|
+
* called), with the toggled index and every hidden index after the toggle
|
|
53
|
+
*/
|
|
54
|
+
onToggle?: (event: ShapeToggleEvent) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Entry and update animations (skipped when the user prefers reduced motion)
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
animation?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Space around the drawing, in pixels
|
|
62
|
+
* @default 8 on every side
|
|
63
|
+
*/
|
|
64
|
+
padding?: ChartPadding;
|
|
65
|
+
/**
|
|
66
|
+
* Accessible name of the chart
|
|
67
|
+
* @default the chart type, e.g. "Donut chart"
|
|
68
|
+
*/
|
|
69
|
+
ariaLabel?: string;
|
|
70
|
+
/** Called when the hovered (or keyboard-focused) mark changes */
|
|
71
|
+
onHover?: (event: ShapeHoverEvent | null) => void;
|
|
72
|
+
/** Called when a mark is clicked, tapped or activated with Enter */
|
|
73
|
+
onClick?: (event: ShapeHoverEvent) => void;
|
|
74
|
+
/** React content of the tooltip (replaces the default content) */
|
|
75
|
+
renderTooltip?: (event: ShapeHoverEvent) => ReactNode;
|
|
76
|
+
/** Additional class name of the root element */
|
|
77
|
+
className?: string;
|
|
78
|
+
/** Inline styles of the root element */
|
|
79
|
+
style?: CSSProperties;
|
|
80
|
+
/** Imperative handle */
|
|
81
|
+
ref?: Ref<ShapeChartHandle>;
|
|
82
|
+
}
|
|
83
|
+
/** Props of PieChart */
|
|
84
|
+
export interface PieChartProps extends ShapeChartCommonProps {
|
|
85
|
+
/** Slices: a name, a value (negative values count as 0) and an optional color */
|
|
86
|
+
data: readonly ShapeDatum[];
|
|
87
|
+
/**
|
|
88
|
+
* Inner radius as a fraction of the outer radius: 0 = pie, 0.6 = donut
|
|
89
|
+
* @default 0
|
|
90
|
+
*/
|
|
91
|
+
innerRadius?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Angle of the first slice, degrees clockwise from 12 o'clock
|
|
94
|
+
* @default 0
|
|
95
|
+
*/
|
|
96
|
+
startAngle?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Gap between the slices, in pixels
|
|
99
|
+
* @default 1 (pie), 2 (donut)
|
|
100
|
+
*/
|
|
101
|
+
padAngle?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Corner radius of the slices, in pixels
|
|
104
|
+
* @default 0 (pie), 4 (donut)
|
|
105
|
+
*/
|
|
106
|
+
cornerRadius?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Nightingale rose: the radius (instead of the angle) shows the value
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
rose?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Slice labels: `outside` with leader lines, `inside` the slices, or none
|
|
114
|
+
* @default "outside" (up to 12 slices), "none" otherwise
|
|
115
|
+
*/
|
|
116
|
+
labels?: "outside" | "inside" | "none";
|
|
117
|
+
/**
|
|
118
|
+
* What a label shows: name, value, percent (combinable)
|
|
119
|
+
* @default ["name", "percent"]
|
|
120
|
+
*/
|
|
121
|
+
labelContent?: readonly ("name" | "value" | "percent")[];
|
|
122
|
+
/** Big text in the hole of a donut (e.g. the total) */
|
|
123
|
+
centerValue?: string;
|
|
124
|
+
/** Small text under `centerValue` */
|
|
125
|
+
centerLabel?: string;
|
|
126
|
+
}
|
|
127
|
+
/** Props of DonutChart: a PieChart with a hole */
|
|
128
|
+
export interface DonutChartProps extends PieChartProps {
|
|
129
|
+
/**
|
|
130
|
+
* Inner radius as a fraction of the outer radius
|
|
131
|
+
* @default 0.62
|
|
132
|
+
*/
|
|
133
|
+
innerRadius?: number;
|
|
134
|
+
}
|
|
135
|
+
/** Props of RadarChart */
|
|
136
|
+
export interface RadarChartProps extends ShapeChartCommonProps {
|
|
137
|
+
/** Axes of the chart, clockwise from 12 o'clock */
|
|
138
|
+
indicators: readonly RadarIndicator[];
|
|
139
|
+
/** Polygons: one value per indicator */
|
|
140
|
+
series: readonly RadarSeries[];
|
|
141
|
+
/**
|
|
142
|
+
* Grid shape
|
|
143
|
+
* @default "polygon"
|
|
144
|
+
*/
|
|
145
|
+
shape?: "polygon" | "circle";
|
|
146
|
+
/**
|
|
147
|
+
* Number of grid rings
|
|
148
|
+
* @default 4
|
|
149
|
+
*/
|
|
150
|
+
levels?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Dots on the vertices
|
|
153
|
+
* @default true
|
|
154
|
+
*/
|
|
155
|
+
dots?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** Props of GaugeChart */
|
|
158
|
+
export interface GaugeChartProps extends ShapeChartCommonProps {
|
|
159
|
+
/** Value shown by the arc (clamped to `min` - `max` for the drawing) */
|
|
160
|
+
value: number;
|
|
161
|
+
/**
|
|
162
|
+
* Value at the start of the arc
|
|
163
|
+
* @default 0
|
|
164
|
+
*/
|
|
165
|
+
min?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Value at the end of the arc
|
|
168
|
+
* @default 100
|
|
169
|
+
*/
|
|
170
|
+
max?: number;
|
|
171
|
+
/** Caption under the value */
|
|
172
|
+
label?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Total angle of the arc, degrees
|
|
175
|
+
* @default 240
|
|
176
|
+
*/
|
|
177
|
+
sweep?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Thickness of the arc as a fraction of the radius
|
|
180
|
+
* @default 0.16
|
|
181
|
+
*/
|
|
182
|
+
thickness?: number;
|
|
183
|
+
/** Colored ranges of the track; the value arc takes the color of its band */
|
|
184
|
+
bands?: readonly GaugeBand[];
|
|
185
|
+
/**
|
|
186
|
+
* Color of the value arc (when there are no bands)
|
|
187
|
+
* @default the first palette color
|
|
188
|
+
*/
|
|
189
|
+
color?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Draws a needle in addition to the value arc
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
|
+
needle?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Tick labels at the ends (and at the band bounds)
|
|
197
|
+
* @default true
|
|
198
|
+
*/
|
|
199
|
+
ticks?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Props of FunnelChart */
|
|
202
|
+
export interface FunnelChartProps extends ShapeChartCommonProps {
|
|
203
|
+
/** Stages: a name, a value and an optional color */
|
|
204
|
+
data: readonly ShapeDatum[];
|
|
205
|
+
/**
|
|
206
|
+
* Order of the stages
|
|
207
|
+
* @default "none" (data order)
|
|
208
|
+
*/
|
|
209
|
+
sort?: "descending" | "ascending" | "none";
|
|
210
|
+
/**
|
|
211
|
+
* Vertical gap between the stages, in pixels
|
|
212
|
+
* @default 4
|
|
213
|
+
*/
|
|
214
|
+
gap?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Shows the conversion rate from the previous stage
|
|
217
|
+
* @default true
|
|
218
|
+
*/
|
|
219
|
+
conversion?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Shape of the stages: trapezoids that narrow to the next stage, or centered bars
|
|
222
|
+
* @default "trapezoid"
|
|
223
|
+
*/
|
|
224
|
+
shape?: "trapezoid" | "bar";
|
|
225
|
+
}
|
|
226
|
+
/** Props of TreemapChart */
|
|
227
|
+
export interface TreemapChartProps extends ShapeChartCommonProps {
|
|
228
|
+
/** Nodes: leaves carry a value, parents sum their children */
|
|
229
|
+
data: readonly TreemapNode[];
|
|
230
|
+
/**
|
|
231
|
+
* Gap between the cells, in pixels
|
|
232
|
+
* @default 2
|
|
233
|
+
*/
|
|
234
|
+
gap?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Draws the names of the parents above their children
|
|
237
|
+
* @default true
|
|
238
|
+
*/
|
|
239
|
+
headers?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Pie chart (or a donut with `innerRadius`, or a Nightingale rose with
|
|
243
|
+
* `rose`): slices with gaps, outside labels with leader lines, legend toggles.
|
|
244
|
+
*/
|
|
245
|
+
export declare function PieChart(props: PieChartProps): import('react').JSX.Element;
|
|
246
|
+
/** Donut chart: a PieChart with a hole and optional center texts */
|
|
247
|
+
export declare function DonutChart(props: DonutChartProps): import('react').JSX.Element;
|
|
248
|
+
/** Radar (spider) chart comparing series over several indicators */
|
|
249
|
+
export declare function RadarChart(props: RadarChartProps): import('react').JSX.Element;
|
|
250
|
+
/** Gauge (speedometer) showing one value on an arc, with colored bands */
|
|
251
|
+
export declare function GaugeChart(props: GaugeChartProps): import('react').JSX.Element;
|
|
252
|
+
/** Funnel chart of the stages of a process, with conversion rates */
|
|
253
|
+
export declare function FunnelChart(props: FunnelChartProps): import('react').JSX.Element;
|
|
254
|
+
/** Treemap: nested rectangles of areas proportional to the values */
|
|
255
|
+
export declare function TreemapChart(props: TreemapChartProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { ChartPadding } from '../engine/types.js';
|
|
3
|
+
import { GaugeBand, RadarIndicator, RadarSeries, ShapeChartInstance, ShapeDatum, ShapeHoverEvent, ShapeLegendOptions, ShapeToggleEvent, ShapeTooltipOptions, TreemapNode } from '../engine/shapes/types.js';
|
|
4
|
+
/** Imperative handle of the shape chart components (`ref`) */
|
|
5
|
+
export interface ShapeChartHandle {
|
|
6
|
+
/** The underlying engine instance (minerva-design/charts/core) */
|
|
7
|
+
getInstance(): ShapeChartInstance | null;
|
|
8
|
+
}
|
|
9
|
+
/** Props shared by PieChart, DonutChart, RadarChart, GaugeChart, FunnelChart and TreemapChart */
|
|
10
|
+
export interface ShapeChartCommonProps {
|
|
11
|
+
/**
|
|
12
|
+
* Height of the chart (the legend included); numbers are pixels
|
|
13
|
+
* @default 320 (GaugeChart: 240)
|
|
14
|
+
*/
|
|
15
|
+
height?: number | string;
|
|
16
|
+
/**
|
|
17
|
+
* Width of the chart; numbers are pixels
|
|
18
|
+
* @default "100%"
|
|
19
|
+
*/
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/** Colors of the marks without `color` (defaults to the `--chart-series-1..8` CSS variables, then the theme colors) */
|
|
22
|
+
palette?: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* Legend; clicking an item hides / shows its slice, stage or series
|
|
25
|
+
* @default shown for pie, donut, funnel and multi-series radar charts
|
|
26
|
+
*/
|
|
27
|
+
legend?: boolean | ShapeLegendOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Tooltip; `false` disables it
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
tooltip?: boolean | ShapeTooltipOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Formats the values of the labels and the tooltip
|
|
35
|
+
* @default compact numbers (1.2k, 3.4M)
|
|
36
|
+
*/
|
|
37
|
+
format?: (value: number) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Formats the shares (labels, conversion rates, tooltip); `share` is 0-1
|
|
40
|
+
* @default one decimal, e.g. "40.0%"
|
|
41
|
+
*/
|
|
42
|
+
percentFormat?: (share: number) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Hidden slices / stages / radar series / top-level treemap nodes, by
|
|
45
|
+
* index. Makes the visibility controlled: legend clicks then only call
|
|
46
|
+
* `onToggle`, whose `hiddenIndexes` should be stored and passed back.
|
|
47
|
+
* Leave undefined to let the legend hide / show entries by itself.
|
|
48
|
+
*/
|
|
49
|
+
hidden?: readonly number[];
|
|
50
|
+
/**
|
|
51
|
+
* Called when a legend item is clicked (or the instance's `toggle()` is
|
|
52
|
+
* called), with the toggled index and every hidden index after the toggle
|
|
53
|
+
*/
|
|
54
|
+
onToggle?: (event: ShapeToggleEvent) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Entry and update animations (skipped when the user prefers reduced motion)
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
animation?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Space around the drawing, in pixels
|
|
62
|
+
* @default 8 on every side
|
|
63
|
+
*/
|
|
64
|
+
padding?: ChartPadding;
|
|
65
|
+
/**
|
|
66
|
+
* Accessible name of the chart
|
|
67
|
+
* @default the chart type, e.g. "Donut chart"
|
|
68
|
+
*/
|
|
69
|
+
ariaLabel?: string;
|
|
70
|
+
/** Called when the hovered (or keyboard-focused) mark changes */
|
|
71
|
+
onHover?: (event: ShapeHoverEvent | null) => void;
|
|
72
|
+
/** Called when a mark is clicked, tapped or activated with Enter */
|
|
73
|
+
onClick?: (event: ShapeHoverEvent) => void;
|
|
74
|
+
/** React content of the tooltip (replaces the default content) */
|
|
75
|
+
renderTooltip?: (event: ShapeHoverEvent) => ReactNode;
|
|
76
|
+
/** Additional class name of the root element */
|
|
77
|
+
className?: string;
|
|
78
|
+
/** Inline styles of the root element */
|
|
79
|
+
style?: CSSProperties;
|
|
80
|
+
/** Imperative handle */
|
|
81
|
+
ref?: Ref<ShapeChartHandle>;
|
|
82
|
+
}
|
|
83
|
+
/** Props of PieChart */
|
|
84
|
+
export interface PieChartProps extends ShapeChartCommonProps {
|
|
85
|
+
/** Slices: a name, a value (negative values count as 0) and an optional color */
|
|
86
|
+
data: readonly ShapeDatum[];
|
|
87
|
+
/**
|
|
88
|
+
* Inner radius as a fraction of the outer radius: 0 = pie, 0.6 = donut
|
|
89
|
+
* @default 0
|
|
90
|
+
*/
|
|
91
|
+
innerRadius?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Angle of the first slice, degrees clockwise from 12 o'clock
|
|
94
|
+
* @default 0
|
|
95
|
+
*/
|
|
96
|
+
startAngle?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Gap between the slices, in pixels
|
|
99
|
+
* @default 1 (pie), 2 (donut)
|
|
100
|
+
*/
|
|
101
|
+
padAngle?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Corner radius of the slices, in pixels
|
|
104
|
+
* @default 0 (pie), 4 (donut)
|
|
105
|
+
*/
|
|
106
|
+
cornerRadius?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Nightingale rose: the radius (instead of the angle) shows the value
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
rose?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Slice labels: `outside` with leader lines, `inside` the slices, or none
|
|
114
|
+
* @default "outside" (up to 12 slices), "none" otherwise
|
|
115
|
+
*/
|
|
116
|
+
labels?: "outside" | "inside" | "none";
|
|
117
|
+
/**
|
|
118
|
+
* What a label shows: name, value, percent (combinable)
|
|
119
|
+
* @default ["name", "percent"]
|
|
120
|
+
*/
|
|
121
|
+
labelContent?: readonly ("name" | "value" | "percent")[];
|
|
122
|
+
/** Big text in the hole of a donut (e.g. the total) */
|
|
123
|
+
centerValue?: string;
|
|
124
|
+
/** Small text under `centerValue` */
|
|
125
|
+
centerLabel?: string;
|
|
126
|
+
}
|
|
127
|
+
/** Props of DonutChart: a PieChart with a hole */
|
|
128
|
+
export interface DonutChartProps extends PieChartProps {
|
|
129
|
+
/**
|
|
130
|
+
* Inner radius as a fraction of the outer radius
|
|
131
|
+
* @default 0.62
|
|
132
|
+
*/
|
|
133
|
+
innerRadius?: number;
|
|
134
|
+
}
|
|
135
|
+
/** Props of RadarChart */
|
|
136
|
+
export interface RadarChartProps extends ShapeChartCommonProps {
|
|
137
|
+
/** Axes of the chart, clockwise from 12 o'clock */
|
|
138
|
+
indicators: readonly RadarIndicator[];
|
|
139
|
+
/** Polygons: one value per indicator */
|
|
140
|
+
series: readonly RadarSeries[];
|
|
141
|
+
/**
|
|
142
|
+
* Grid shape
|
|
143
|
+
* @default "polygon"
|
|
144
|
+
*/
|
|
145
|
+
shape?: "polygon" | "circle";
|
|
146
|
+
/**
|
|
147
|
+
* Number of grid rings
|
|
148
|
+
* @default 4
|
|
149
|
+
*/
|
|
150
|
+
levels?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Dots on the vertices
|
|
153
|
+
* @default true
|
|
154
|
+
*/
|
|
155
|
+
dots?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** Props of GaugeChart */
|
|
158
|
+
export interface GaugeChartProps extends ShapeChartCommonProps {
|
|
159
|
+
/** Value shown by the arc (clamped to `min` - `max` for the drawing) */
|
|
160
|
+
value: number;
|
|
161
|
+
/**
|
|
162
|
+
* Value at the start of the arc
|
|
163
|
+
* @default 0
|
|
164
|
+
*/
|
|
165
|
+
min?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Value at the end of the arc
|
|
168
|
+
* @default 100
|
|
169
|
+
*/
|
|
170
|
+
max?: number;
|
|
171
|
+
/** Caption under the value */
|
|
172
|
+
label?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Total angle of the arc, degrees
|
|
175
|
+
* @default 240
|
|
176
|
+
*/
|
|
177
|
+
sweep?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Thickness of the arc as a fraction of the radius
|
|
180
|
+
* @default 0.16
|
|
181
|
+
*/
|
|
182
|
+
thickness?: number;
|
|
183
|
+
/** Colored ranges of the track; the value arc takes the color of its band */
|
|
184
|
+
bands?: readonly GaugeBand[];
|
|
185
|
+
/**
|
|
186
|
+
* Color of the value arc (when there are no bands)
|
|
187
|
+
* @default the first palette color
|
|
188
|
+
*/
|
|
189
|
+
color?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Draws a needle in addition to the value arc
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
|
+
needle?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Tick labels at the ends (and at the band bounds)
|
|
197
|
+
* @default true
|
|
198
|
+
*/
|
|
199
|
+
ticks?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Props of FunnelChart */
|
|
202
|
+
export interface FunnelChartProps extends ShapeChartCommonProps {
|
|
203
|
+
/** Stages: a name, a value and an optional color */
|
|
204
|
+
data: readonly ShapeDatum[];
|
|
205
|
+
/**
|
|
206
|
+
* Order of the stages
|
|
207
|
+
* @default "none" (data order)
|
|
208
|
+
*/
|
|
209
|
+
sort?: "descending" | "ascending" | "none";
|
|
210
|
+
/**
|
|
211
|
+
* Vertical gap between the stages, in pixels
|
|
212
|
+
* @default 4
|
|
213
|
+
*/
|
|
214
|
+
gap?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Shows the conversion rate from the previous stage
|
|
217
|
+
* @default true
|
|
218
|
+
*/
|
|
219
|
+
conversion?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Shape of the stages: trapezoids that narrow to the next stage, or centered bars
|
|
222
|
+
* @default "trapezoid"
|
|
223
|
+
*/
|
|
224
|
+
shape?: "trapezoid" | "bar";
|
|
225
|
+
}
|
|
226
|
+
/** Props of TreemapChart */
|
|
227
|
+
export interface TreemapChartProps extends ShapeChartCommonProps {
|
|
228
|
+
/** Nodes: leaves carry a value, parents sum their children */
|
|
229
|
+
data: readonly TreemapNode[];
|
|
230
|
+
/**
|
|
231
|
+
* Gap between the cells, in pixels
|
|
232
|
+
* @default 2
|
|
233
|
+
*/
|
|
234
|
+
gap?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Draws the names of the parents above their children
|
|
237
|
+
* @default true
|
|
238
|
+
*/
|
|
239
|
+
headers?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Pie chart (or a donut with `innerRadius`, or a Nightingale rose with
|
|
243
|
+
* `rose`): slices with gaps, outside labels with leader lines, legend toggles.
|
|
244
|
+
*/
|
|
245
|
+
export declare function PieChart(props: PieChartProps): import('react').JSX.Element;
|
|
246
|
+
/** Donut chart: a PieChart with a hole and optional center texts */
|
|
247
|
+
export declare function DonutChart(props: DonutChartProps): import('react').JSX.Element;
|
|
248
|
+
/** Radar (spider) chart comparing series over several indicators */
|
|
249
|
+
export declare function RadarChart(props: RadarChartProps): import('react').JSX.Element;
|
|
250
|
+
/** Gauge (speedometer) showing one value on an arc, with colored bands */
|
|
251
|
+
export declare function GaugeChart(props: GaugeChartProps): import('react').JSX.Element;
|
|
252
|
+
/** Funnel chart of the stages of a process, with conversion rates */
|
|
253
|
+
export declare function FunnelChart(props: FunnelChartProps): import('react').JSX.Element;
|
|
254
|
+
/** Treemap: nested rectangles of areas proportional to the values */
|
|
255
|
+
export declare function TreemapChart(props: TreemapChartProps): import('react').JSX.Element;
|