@wello-dev/charts 0.0.0-stage → 1.0.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/LICENSE +47 -0
- package/README.md +155 -3
- package/dist/index.cjs +1999 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +526 -0
- package/dist/index.d.ts +526 -0
- package/dist/index.js +1965 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +281 -0
- package/package.json +85 -6
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties, SVGProps } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Tailwind CSS default palette (v3 hex values, MIT); shades 50–950. */
|
|
5
|
+
declare const DEFAULT_CHART_COLORS: {
|
|
6
|
+
readonly slate: readonly ["#f8fafc", "#f1f5f9", "#e2e8f0", "#cbd5e1", "#94a3b8", "#64748b", "#475569", "#334155", "#1e293b", "#0f172a", "#020617"];
|
|
7
|
+
readonly gray: readonly ["#f9fafb", "#f3f4f6", "#e5e7eb", "#d1d5db", "#9ca3af", "#6b7280", "#4b5563", "#374151", "#1f2937", "#111827", "#030712"];
|
|
8
|
+
readonly zinc: readonly ["#fafafa", "#f4f4f5", "#e4e4e7", "#d4d4d8", "#a1a1aa", "#71717a", "#52525b", "#3f3f46", "#27272a", "#18181b", "#09090b"];
|
|
9
|
+
readonly neutral: readonly ["#fafafa", "#f5f5f5", "#e5e5e5", "#d4d4d4", "#a3a3a3", "#737373", "#525252", "#404040", "#262626", "#171717", "#0a0a0a"];
|
|
10
|
+
readonly stone: readonly ["#fafaf9", "#f5f5f4", "#e7e5e4", "#d6d3d1", "#a8a29e", "#78716c", "#57534e", "#44403c", "#292524", "#1c1917", "#0c0a09"];
|
|
11
|
+
readonly red: readonly ["#fef2f2", "#fee2e2", "#fecaca", "#fca5a5", "#f87171", "#ef4444", "#dc2626", "#b91c1c", "#991b1b", "#7f1d1d", "#450a0a"];
|
|
12
|
+
readonly orange: readonly ["#fff7ed", "#ffedd5", "#fed7aa", "#fdba74", "#fb923c", "#f97316", "#ea580c", "#c2410c", "#9a3412", "#7c2d12", "#431407"];
|
|
13
|
+
readonly amber: readonly ["#fffbeb", "#fef3c7", "#fde68a", "#fcd34d", "#fbbf24", "#f59e0b", "#d97706", "#b45309", "#92400e", "#78350f", "#451a03"];
|
|
14
|
+
readonly yellow: readonly ["#fefce8", "#fef9c3", "#fef08a", "#fde047", "#facc15", "#eab308", "#ca8a04", "#a16207", "#854d0e", "#713f12", "#422006"];
|
|
15
|
+
readonly lime: readonly ["#f7fee7", "#ecfccb", "#d9f99d", "#bef264", "#a3e635", "#84cc16", "#65a30d", "#4d7c0f", "#3f6212", "#365314", "#1a2e05"];
|
|
16
|
+
readonly green: readonly ["#f0fdf4", "#dcfce7", "#bbf7d0", "#86efac", "#4ade80", "#22c55e", "#16a34a", "#15803d", "#166534", "#14532d", "#052e16"];
|
|
17
|
+
readonly emerald: readonly ["#ecfdf5", "#d1fae5", "#a7f3d0", "#6ee7b7", "#34d399", "#10b981", "#059669", "#047857", "#065f46", "#064e3b", "#022c22"];
|
|
18
|
+
readonly teal: readonly ["#f0fdfa", "#ccfbf1", "#99f6e4", "#5eead4", "#2dd4bf", "#14b8a6", "#0d9488", "#0f766e", "#115e59", "#134e4a", "#042f2e"];
|
|
19
|
+
readonly cyan: readonly ["#ecfeff", "#cffafe", "#a5f3fc", "#67e8f9", "#22d3ee", "#06b6d4", "#0891b2", "#0e7490", "#155e75", "#164e63", "#083344"];
|
|
20
|
+
readonly sky: readonly ["#f0f9ff", "#e0f2fe", "#bae6fd", "#7dd3fc", "#38bdf8", "#0ea5e9", "#0284c7", "#0369a1", "#075985", "#0c4a6e", "#082f49"];
|
|
21
|
+
readonly blue: readonly ["#eff6ff", "#dbeafe", "#bfdbfe", "#93c5fd", "#60a5fa", "#3b82f6", "#2563eb", "#1d4ed8", "#1e40af", "#1e3a8a", "#172554"];
|
|
22
|
+
readonly indigo: readonly ["#eef2ff", "#e0e7ff", "#c7d2fe", "#a5b4fc", "#818cf8", "#6366f1", "#4f46e5", "#4338ca", "#3730a3", "#312e81", "#1e1b4b"];
|
|
23
|
+
readonly violet: readonly ["#f5f3ff", "#ede9fe", "#ddd6fe", "#c4b5fd", "#a78bfa", "#8b5cf6", "#7c3aed", "#6d28d9", "#5b21b6", "#4c1d95", "#2e1065"];
|
|
24
|
+
readonly purple: readonly ["#faf5ff", "#f3e8ff", "#e9d5ff", "#d8b4fe", "#c084fc", "#a855f7", "#9333ea", "#7e22ce", "#6b21a8", "#581c87", "#3b0764"];
|
|
25
|
+
readonly fuchsia: readonly ["#fdf4ff", "#fae8ff", "#f5d0fe", "#f0abfc", "#e879f9", "#d946ef", "#c026d3", "#a21caf", "#86198f", "#701a75", "#4a044e"];
|
|
26
|
+
readonly pink: readonly ["#fdf2f8", "#fce7f3", "#fbcfe8", "#f9a8d4", "#f472b6", "#ec4899", "#db2777", "#be185d", "#9d174d", "#831843", "#500724"];
|
|
27
|
+
readonly rose: readonly ["#fff1f2", "#ffe4e6", "#fecdd3", "#fda4af", "#fb7185", "#f43f5e", "#e11d48", "#be123c", "#9f1239", "#881337", "#4c0519"];
|
|
28
|
+
};
|
|
29
|
+
type ChartColorName = keyof typeof DEFAULT_CHART_COLORS;
|
|
30
|
+
type ChartColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
31
|
+
/** `'blue-600'`, `'blue'` (= 500), `'dimmed'`, `'bright'`, or any CSS color / variable. */
|
|
32
|
+
type ChartColor = `${ChartColorName}-${ChartColorShade}` | ChartColorName | "dimmed" | "bright" | (string & {});
|
|
33
|
+
/**
|
|
34
|
+
* Resolves a Tailwind color name to a CSS color: `'blue-600'` → `var(--color-blue-600, #2563eb)`,
|
|
35
|
+
* so a Tailwind v4 theme's own values win and the hex is the fallback. Anything else is returned unchanged.
|
|
36
|
+
*/
|
|
37
|
+
declare function getThemeColor(color: ChartColor | undefined, fallback?: string): string;
|
|
38
|
+
/** Colors given to series and slices without their own `color`, in order. */
|
|
39
|
+
declare const CHART_COLORS: readonly ChartColor[];
|
|
40
|
+
/** `color` if set, otherwise the palette color for this position. */
|
|
41
|
+
declare function seriesColor(color: ChartColor | undefined, index: number, palette?: readonly ChartColor[]): string;
|
|
42
|
+
|
|
43
|
+
interface ChartStateProps {
|
|
44
|
+
/** Show a loading skeleton instead of the chart */
|
|
45
|
+
loading?: boolean;
|
|
46
|
+
/** Shown when there is nothing to draw. Default: `'No data'` */
|
|
47
|
+
emptyLabel?: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface ChartSeries {
|
|
51
|
+
/** Key in each data item that holds this series' values */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Tailwind color (`'blue-600'`, `'blue'` = 500) or any CSS color. Default: the next `CHART_COLORS` entry */
|
|
54
|
+
color?: ChartColor;
|
|
55
|
+
/** Shown in the legend and tooltip instead of `name` */
|
|
56
|
+
label?: string;
|
|
57
|
+
/** `'right'` binds the series to the right y-axis (needs `withRightYAxis`) */
|
|
58
|
+
yAxisId?: "left" | "right";
|
|
59
|
+
/** Dashes the line, e.g. `'5 5'` */
|
|
60
|
+
strokeDasharray?: string | number;
|
|
61
|
+
}
|
|
62
|
+
interface ChartReferenceLine {
|
|
63
|
+
x?: number | string;
|
|
64
|
+
y?: number | string;
|
|
65
|
+
label?: ReactNode;
|
|
66
|
+
color?: ChartColor;
|
|
67
|
+
strokeDasharray?: string;
|
|
68
|
+
yAxisId?: "left" | "right";
|
|
69
|
+
}
|
|
70
|
+
type ChartData = Record<string, any>[];
|
|
71
|
+
type ChartGridAxis = "none" | "x" | "y" | "xy";
|
|
72
|
+
type ChartTickLine = "none" | "x" | "y" | "xy";
|
|
73
|
+
type ChartOrientation = "horizontal" | "vertical";
|
|
74
|
+
type ChartCurveType = "bump" | "linear" | "natural" | "monotone" | "step" | "stepBefore" | "stepAfter";
|
|
75
|
+
interface ChartLegendOptions {
|
|
76
|
+
/** Default: `'top'` */
|
|
77
|
+
verticalAlign?: "top" | "bottom";
|
|
78
|
+
/** Default: `'right'` */
|
|
79
|
+
align?: "left" | "center" | "right";
|
|
80
|
+
/** Hovering an item highlights its series. Default: true */
|
|
81
|
+
highlightOnHover?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** CSS class names for the chart wrapper, plot area, and legend. */
|
|
84
|
+
type ChartClassNames = Partial<Record<"root" | "chart" | "legend", string>>;
|
|
85
|
+
/** Props shared by the cartesian charts (Area, Bar, Line). */
|
|
86
|
+
interface BaseCartesianChartProps extends ChartStateProps {
|
|
87
|
+
data: ChartData;
|
|
88
|
+
/** Key in each data item used for x-axis values */
|
|
89
|
+
dataKey: string;
|
|
90
|
+
series: ChartSeries[];
|
|
91
|
+
/** Chart height. Default: 300 */
|
|
92
|
+
h?: number | string;
|
|
93
|
+
/** Chart width. Default: 100% */
|
|
94
|
+
w?: number | string;
|
|
95
|
+
className?: string;
|
|
96
|
+
/** Classes for the chart wrapper, plot area, and legend */
|
|
97
|
+
classNames?: ChartClassNames;
|
|
98
|
+
style?: CSSProperties;
|
|
99
|
+
/** Default: `'horizontal'` */
|
|
100
|
+
orientation?: ChartOrientation;
|
|
101
|
+
withLegend?: boolean;
|
|
102
|
+
legendProps?: ChartLegendOptions;
|
|
103
|
+
/** Default: true */
|
|
104
|
+
withTooltip?: boolean;
|
|
105
|
+
/** Passed to recharts `Tooltip` */
|
|
106
|
+
tooltipProps?: Record<string, any>;
|
|
107
|
+
/** Default: 0 */
|
|
108
|
+
tooltipAnimationDuration?: number;
|
|
109
|
+
/** Default: true */
|
|
110
|
+
withXAxis?: boolean;
|
|
111
|
+
/** Default: true */
|
|
112
|
+
withYAxis?: boolean;
|
|
113
|
+
xAxisProps?: Record<string, any>;
|
|
114
|
+
yAxisProps?: Record<string, any>;
|
|
115
|
+
xAxisLabel?: string;
|
|
116
|
+
yAxisLabel?: string;
|
|
117
|
+
withRightYAxis?: boolean;
|
|
118
|
+
rightYAxisProps?: Record<string, any>;
|
|
119
|
+
rightYAxisLabel?: string;
|
|
120
|
+
/** Colors for series without their own `color`. Default: `CHART_COLORS` */
|
|
121
|
+
colors?: readonly ChartColor[];
|
|
122
|
+
/** Default: 650 (0 disables) */
|
|
123
|
+
animationDuration?: number;
|
|
124
|
+
/** Grid lines to draw. Default: `'x'` */
|
|
125
|
+
gridAxis?: ChartGridAxis;
|
|
126
|
+
/** Passed to recharts `CartesianGrid` */
|
|
127
|
+
gridProps?: Record<string, any>;
|
|
128
|
+
/** Axes with tick lines. Default: `'none'` */
|
|
129
|
+
tickLine?: ChartTickLine;
|
|
130
|
+
/** Dash pattern of grid and cursor lines. Default: `'5 5'` */
|
|
131
|
+
strokeDasharray?: string | number;
|
|
132
|
+
/** Grid and cursor color. Default: `--wello-chart-grid-color` */
|
|
133
|
+
gridColor?: ChartColor;
|
|
134
|
+
/** Axis tick color. Default: `--wello-chart-text-color` */
|
|
135
|
+
textColor?: ChartColor;
|
|
136
|
+
/** Appended to y-axis ticks and tooltip values */
|
|
137
|
+
unit?: string;
|
|
138
|
+
/** Formats y-axis ticks and tooltip values */
|
|
139
|
+
valueFormatter?: (value: number) => string;
|
|
140
|
+
referenceLines?: ChartReferenceLine[];
|
|
141
|
+
/** Extra recharts elements rendered inside the chart */
|
|
142
|
+
children?: ReactNode;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type AreaChartType = "default" | "stacked" | "percent" | "split";
|
|
146
|
+
interface AreaChartProps extends BaseCartesianChartProps {
|
|
147
|
+
/** Default: `'default'` */
|
|
148
|
+
type?: AreaChartType;
|
|
149
|
+
/** Default: `'monotone'` */
|
|
150
|
+
curveType?: ChartCurveType;
|
|
151
|
+
/** Fade the fill from the line color to transparent. Default: true */
|
|
152
|
+
withGradient?: boolean;
|
|
153
|
+
/** Fill opacity (solid fill, or the top of the gradient). Default: 0.28 */
|
|
154
|
+
fillOpacity?: number;
|
|
155
|
+
/** Default: 2.75 */
|
|
156
|
+
strokeWidth?: number;
|
|
157
|
+
/** Default: false */
|
|
158
|
+
withDots?: boolean;
|
|
159
|
+
dotProps?: Record<string, any>;
|
|
160
|
+
activeDotProps?: Record<string, any>;
|
|
161
|
+
/** Default: true */
|
|
162
|
+
connectNulls?: boolean;
|
|
163
|
+
/** Value labels above every point */
|
|
164
|
+
withPointLabels?: boolean;
|
|
165
|
+
/** `type="split"`: colors above and below zero. Default: `['green-700', 'red-700']` */
|
|
166
|
+
splitColors?: [ChartColor, ChartColor];
|
|
167
|
+
/** `type="split"`: gradient offset, computed from the data when omitted */
|
|
168
|
+
splitOffset?: number;
|
|
169
|
+
/** Passed to recharts `AreaChart` (e.g. `syncId`) */
|
|
170
|
+
areaChartProps?: Record<string, any>;
|
|
171
|
+
/** Passed to every recharts `Area`, or a function per series */
|
|
172
|
+
areaProps?: Record<string, any> | ((series: BaseCartesianChartProps["series"][number]) => Record<string, any>);
|
|
173
|
+
}
|
|
174
|
+
/** Offset (0–1) where the split gradient switches from the positive to the negative color. */
|
|
175
|
+
declare function getSplitOffset(data: Record<string, any>[], key: string): number;
|
|
176
|
+
/**
|
|
177
|
+
* Area chart.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* <AreaChart h={300} data={data} dataKey="date" type="stacked" withLegend
|
|
181
|
+
* series={[{ name: 'Apples', color: 'indigo-600' }, { name: 'Oranges', color: 'blue-600' }]} />
|
|
182
|
+
*/
|
|
183
|
+
declare function AreaChart(props: AreaChartProps): react.JSX.Element;
|
|
184
|
+
|
|
185
|
+
type BarChartType = "default" | "stacked" | "percent" | "waterfall";
|
|
186
|
+
interface BarChartProps extends BaseCartesianChartProps {
|
|
187
|
+
/** `'waterfall'` uses the first series; items with `standalone: true` start at 0 (totals). Default: `'default'` */
|
|
188
|
+
type?: BarChartType;
|
|
189
|
+
/** Default: 1 */
|
|
190
|
+
fillOpacity?: number;
|
|
191
|
+
/** Maximum bar width in px. Default: 26 */
|
|
192
|
+
maxBarWidth?: number;
|
|
193
|
+
/** Minimum bar height in px, so small values stay visible */
|
|
194
|
+
minBarSize?: number;
|
|
195
|
+
/** Value labels on bars */
|
|
196
|
+
withBarValueLabel?: boolean;
|
|
197
|
+
/** Passed to the value `LabelList` */
|
|
198
|
+
valueLabelProps?: Record<string, any>;
|
|
199
|
+
/** Color per bar, e.g. red for negative values. Overrides the series color */
|
|
200
|
+
getBarColor?: (value: number, series: ChartSeries) => ChartColor;
|
|
201
|
+
/** Passed to recharts `BarChart` */
|
|
202
|
+
barChartProps?: Record<string, any>;
|
|
203
|
+
/** Passed to every recharts `Bar`, or a function per series */
|
|
204
|
+
barProps?: Record<string, any> | ((series: ChartSeries) => Record<string, any>);
|
|
205
|
+
}
|
|
206
|
+
/** Turns waterfall rows into `[start, end]` ranges; `standalone` rows start at 0 and reset the running total. */
|
|
207
|
+
declare function getWaterfallData(data: ChartData, key: string): ChartData;
|
|
208
|
+
/**
|
|
209
|
+
* Bar chart.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* <BarChart h={300} data={data} dataKey="month" type="stacked" withLegend
|
|
213
|
+
* series={[{ name: 'Smartphones', color: 'violet-600' }, { name: 'Laptops', color: 'blue-600' }]} />
|
|
214
|
+
*/
|
|
215
|
+
declare function BarChart(props: BarChartProps): react.JSX.Element;
|
|
216
|
+
|
|
217
|
+
type LineChartType = "default" | "gradient";
|
|
218
|
+
interface LineChartGradientStop {
|
|
219
|
+
/** 0–100, from the top of the chart */
|
|
220
|
+
offset: number;
|
|
221
|
+
color: ChartColor;
|
|
222
|
+
}
|
|
223
|
+
interface LineChartProps extends BaseCartesianChartProps {
|
|
224
|
+
/** `'gradient'` colors the line by `gradientStops` (first series only). Default: `'default'` */
|
|
225
|
+
type?: LineChartType;
|
|
226
|
+
/** Default: red → yellow → teal from top to bottom */
|
|
227
|
+
gradientStops?: LineChartGradientStop[];
|
|
228
|
+
/** Default: `'monotone'` */
|
|
229
|
+
curveType?: ChartCurveType;
|
|
230
|
+
/** Default: 2.75 */
|
|
231
|
+
strokeWidth?: number;
|
|
232
|
+
/** Default: false */
|
|
233
|
+
withDots?: boolean;
|
|
234
|
+
dotProps?: Record<string, any>;
|
|
235
|
+
activeDotProps?: Record<string, any>;
|
|
236
|
+
/** Default: true */
|
|
237
|
+
connectNulls?: boolean;
|
|
238
|
+
/** Value labels above every point */
|
|
239
|
+
withPointLabels?: boolean;
|
|
240
|
+
/** Passed to recharts `LineChart` (e.g. `syncId`) */
|
|
241
|
+
lineChartProps?: Record<string, any>;
|
|
242
|
+
/** Passed to every recharts `Line`, or a function per series */
|
|
243
|
+
lineProps?: Record<string, any> | ((series: ChartSeries) => Record<string, any>);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Line chart.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* <LineChart h={300} data={data} dataKey="date" withLegend curveType="linear"
|
|
250
|
+
* series={[{ name: 'Apples', color: 'indigo-600' }, { name: 'Oranges', color: 'teal-600', strokeDasharray: '5 5' }]} />
|
|
251
|
+
*/
|
|
252
|
+
declare function LineChart(props: LineChartProps): react.JSX.Element;
|
|
253
|
+
|
|
254
|
+
interface PieChartCell {
|
|
255
|
+
name: string;
|
|
256
|
+
value: number;
|
|
257
|
+
/** Default: the next `CHART_COLORS` entry */
|
|
258
|
+
color?: ChartColor;
|
|
259
|
+
}
|
|
260
|
+
type PieLabelsType = "value" | "percent";
|
|
261
|
+
/** Props shared by PieChart and DonutChart. */
|
|
262
|
+
interface BasePieChartProps extends ChartStateProps {
|
|
263
|
+
data: PieChartCell[];
|
|
264
|
+
/** Diameter in px. Default: 160 */
|
|
265
|
+
size?: number;
|
|
266
|
+
/** Colors for cells without their own `color`. Default: `CHART_COLORS` */
|
|
267
|
+
colors?: readonly ChartColor[];
|
|
268
|
+
/** Segment labels. Default: false */
|
|
269
|
+
withLabels?: boolean;
|
|
270
|
+
/** Lines from segments to outside labels. Default: true */
|
|
271
|
+
withLabelsLine?: boolean;
|
|
272
|
+
/** Default: `'value'` */
|
|
273
|
+
labelsType?: PieLabelsType;
|
|
274
|
+
labelColor?: ChartColor;
|
|
275
|
+
/** Gap between segments in degrees. Default: 0 */
|
|
276
|
+
paddingAngle?: number;
|
|
277
|
+
/** Default: 0 */
|
|
278
|
+
startAngle?: number;
|
|
279
|
+
/** Default: 360 */
|
|
280
|
+
endAngle?: number;
|
|
281
|
+
/** Segment corner radius in px. Default: 6 */
|
|
282
|
+
cornerRadius?: number;
|
|
283
|
+
/** Segment border width. Default: 3 */
|
|
284
|
+
strokeWidth?: number;
|
|
285
|
+
/** Segment border color. Default: the card background */
|
|
286
|
+
strokeColor?: ChartColor;
|
|
287
|
+
withTooltip?: boolean;
|
|
288
|
+
/** `'segment'` shows the hovered slice with its share, `'all'` lists every slice. Default: `'segment'` */
|
|
289
|
+
tooltipDataSource?: "all" | "segment";
|
|
290
|
+
tooltipProps?: Record<string, any>;
|
|
291
|
+
/** Default: 0 */
|
|
292
|
+
tooltipAnimationDuration?: number;
|
|
293
|
+
/** Legend with hover highlight. Default: false */
|
|
294
|
+
withLegend?: boolean;
|
|
295
|
+
/** Default: `'bottom'` */
|
|
296
|
+
legendPosition?: "top" | "bottom";
|
|
297
|
+
valueFormatter?: (value: number) => string;
|
|
298
|
+
/** Default: 650 (0 disables) */
|
|
299
|
+
animationDuration?: number;
|
|
300
|
+
/** Passed to recharts `Pie` */
|
|
301
|
+
pieProps?: Record<string, any>;
|
|
302
|
+
/** Passed to recharts `PieChart` */
|
|
303
|
+
pieChartProps?: Record<string, any>;
|
|
304
|
+
className?: string;
|
|
305
|
+
/** Classes for the chart wrapper, plot area, and legend */
|
|
306
|
+
classNames?: ChartClassNames;
|
|
307
|
+
style?: CSSProperties;
|
|
308
|
+
children?: ReactNode;
|
|
309
|
+
}
|
|
310
|
+
declare function getPercent(value: number, data: Pick<PieChartCell, "value">[]): number;
|
|
311
|
+
|
|
312
|
+
interface PieChartProps extends BasePieChartProps {
|
|
313
|
+
/** Default: `'outside'` */
|
|
314
|
+
labelsPosition?: "inside" | "outside";
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Pie chart.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* <PieChart withLabels labelsType="percent" withTooltip
|
|
321
|
+
* data={[{ name: 'USA', value: 400, color: 'indigo-600' }, { name: 'India', value: 300, color: 'yellow-600' }]} />
|
|
322
|
+
*/
|
|
323
|
+
declare function PieChart({ labelsPosition, ...props }: PieChartProps): react.JSX.Element;
|
|
324
|
+
|
|
325
|
+
interface DonutChartProps extends BasePieChartProps {
|
|
326
|
+
/** Ring width in px. Default: about a quarter of the radius (20 at the default size) */
|
|
327
|
+
thickness?: number;
|
|
328
|
+
/** Large text in the center, e.g. a total */
|
|
329
|
+
chartLabel?: ReactNode;
|
|
330
|
+
/** Small muted text under `chartLabel` */
|
|
331
|
+
chartSubLabel?: ReactNode;
|
|
332
|
+
/** Keep a muted ring when every value is 0 instead of the empty state */
|
|
333
|
+
emptyRing?: boolean;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Donut chart.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* <DonutChart chartLabel="1,000" chartSubLabel="Users"
|
|
340
|
+
* data={[{ name: 'USA', value: 400 }, { name: 'India', value: 300 }]} />
|
|
341
|
+
*/
|
|
342
|
+
declare function DonutChart({ thickness, chartLabel, chartSubLabel, emptyRing, withTooltip, ...props }: DonutChartProps): react.JSX.Element;
|
|
343
|
+
|
|
344
|
+
interface RadialBarChartProps {
|
|
345
|
+
/** Items with `name`, `color` and the value under `dataKey` */
|
|
346
|
+
data: Record<string, any>[];
|
|
347
|
+
/** Key holding each bar's value */
|
|
348
|
+
dataKey: string;
|
|
349
|
+
/** Chart height. Default: 300 */
|
|
350
|
+
h?: number | string;
|
|
351
|
+
/** Chart width. Default: 100% */
|
|
352
|
+
w?: number | string;
|
|
353
|
+
/** Colors for items without their own `color`. Default: `CHART_COLORS` */
|
|
354
|
+
colors?: readonly ChartColor[];
|
|
355
|
+
/** Default: 650 (0 disables) */
|
|
356
|
+
animationDuration?: number;
|
|
357
|
+
/** Bar thickness in px. Default: 20 */
|
|
358
|
+
barSize?: number;
|
|
359
|
+
/** Draw the empty part of each track. Default: true */
|
|
360
|
+
withBackground?: boolean;
|
|
361
|
+
/** Track color. Default: `--wello-chart-radial-bg` */
|
|
362
|
+
emptyBackgroundColor?: ChartColor;
|
|
363
|
+
/** Default: 90 (top) */
|
|
364
|
+
startAngle?: number;
|
|
365
|
+
/** Default: -270 (full circle, clockwise) */
|
|
366
|
+
endAngle?: number;
|
|
367
|
+
/** Item names at the start of each bar */
|
|
368
|
+
withLabels?: boolean;
|
|
369
|
+
/** Default: false */
|
|
370
|
+
withLegend?: boolean;
|
|
371
|
+
/** Default: `'bottom'` */
|
|
372
|
+
legendPosition?: "top" | "bottom";
|
|
373
|
+
/** Default: true */
|
|
374
|
+
withTooltip?: boolean;
|
|
375
|
+
tooltipProps?: Record<string, any>;
|
|
376
|
+
valueFormatter?: (value: number) => string;
|
|
377
|
+
/** Passed to recharts `RadialBar` */
|
|
378
|
+
radialBarProps?: Record<string, any>;
|
|
379
|
+
/** Passed to recharts `RadialBarChart` */
|
|
380
|
+
radialBarChartProps?: Record<string, any>;
|
|
381
|
+
className?: string;
|
|
382
|
+
/** Classes for the chart wrapper, plot area, and legend */
|
|
383
|
+
classNames?: ChartClassNames;
|
|
384
|
+
style?: CSSProperties;
|
|
385
|
+
children?: ReactNode;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Radial bar chart.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* <RadialBarChart h={260} dataKey="value" withLegend
|
|
392
|
+
* data={[{ name: '18-24', value: 31.47, color: 'blue-700' }, { name: '25-29', value: 26.69, color: 'orange-600' }]} />
|
|
393
|
+
*/
|
|
394
|
+
declare function RadialBarChart({ data, dataKey, h, w, colors, animationDuration, barSize, withBackground, emptyBackgroundColor, startAngle, endAngle, withLabels, withLegend, legendPosition, withTooltip, tooltipProps, valueFormatter, radialBarProps, radialBarChartProps, className, classNames, style, children, }: RadialBarChartProps): react.JSX.Element;
|
|
395
|
+
|
|
396
|
+
interface HeatmapRectData {
|
|
397
|
+
/** `YYYY-MM-DD` */
|
|
398
|
+
date: string;
|
|
399
|
+
/** `null` when the date has no value */
|
|
400
|
+
value: number | null;
|
|
401
|
+
}
|
|
402
|
+
interface HeatmapProps {
|
|
403
|
+
/** Values by UTC day: `{ '2025-02-14': 2 }` */
|
|
404
|
+
data: Record<string, number>;
|
|
405
|
+
/** First day shown. Default: one year before `endDate` */
|
|
406
|
+
startDate?: string | Date;
|
|
407
|
+
/** Last day shown. Default: today */
|
|
408
|
+
endDate?: string | Date;
|
|
409
|
+
/** Colors from low to high. Default: 4 green shades */
|
|
410
|
+
colors?: ChartColor[];
|
|
411
|
+
/** `[min, max]` mapped to the first and last color. Default: from the data */
|
|
412
|
+
domain?: [number, number];
|
|
413
|
+
/** 0 = Sunday … 6 = Saturday. Default: 1 (Monday) */
|
|
414
|
+
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
415
|
+
/** Square size in px. Default: 10 */
|
|
416
|
+
rectSize?: number;
|
|
417
|
+
/** Space between squares in px. Default: 1 */
|
|
418
|
+
gap?: number;
|
|
419
|
+
/** Default: 2 */
|
|
420
|
+
rectRadius?: number;
|
|
421
|
+
/** Label font size in px. Default: 12 */
|
|
422
|
+
fontSize?: number;
|
|
423
|
+
withMonthLabels?: boolean;
|
|
424
|
+
/** 12 names, January first. Default: `Jan` … `Dec` */
|
|
425
|
+
monthLabels?: string[];
|
|
426
|
+
/** Default: `'top'` */
|
|
427
|
+
monthLabelsPosition?: "top" | "bottom";
|
|
428
|
+
/** Default: 14 */
|
|
429
|
+
monthsLabelsHeight?: number;
|
|
430
|
+
withWeekdayLabels?: boolean;
|
|
431
|
+
/** 7 names, Sunday first; empty strings hide rows. Default: Mon, Wed, Fri */
|
|
432
|
+
weekdayLabels?: string[];
|
|
433
|
+
/** Default: 30 */
|
|
434
|
+
weekdaysLabelsWidth?: number;
|
|
435
|
+
/** Empty column between months */
|
|
436
|
+
splitMonths?: boolean;
|
|
437
|
+
/** Show the days around the range (in the first/last week) as empty squares */
|
|
438
|
+
withOutsideDates?: boolean;
|
|
439
|
+
withTooltip?: boolean;
|
|
440
|
+
/** Tooltip content; required for the tooltip to show */
|
|
441
|
+
getTooltipLabel?: (rect: HeatmapRectData) => ReactNode;
|
|
442
|
+
/** Extra props for each square */
|
|
443
|
+
getRectProps?: (rect: HeatmapRectData) => SVGProps<SVGRectElement>;
|
|
444
|
+
/** Color scale below the grid */
|
|
445
|
+
withLegend?: boolean;
|
|
446
|
+
/** Default: `['Less', 'More']` */
|
|
447
|
+
legendLabels?: [string, string];
|
|
448
|
+
className?: string;
|
|
449
|
+
/** Classes for the chart wrapper, plot area, and legend */
|
|
450
|
+
classNames?: ChartClassNames;
|
|
451
|
+
style?: CSSProperties;
|
|
452
|
+
"aria-label"?: string;
|
|
453
|
+
}
|
|
454
|
+
/** UTC midnight for a `YYYY-MM-DD` string or a Date (its local calendar day). */
|
|
455
|
+
declare function toUtcDay(value: string | Date): number;
|
|
456
|
+
declare function formatUtcDay(time: number): string;
|
|
457
|
+
interface HeatmapCell {
|
|
458
|
+
date: string;
|
|
459
|
+
/** Outside `startDate`–`endDate` (only present with `withOutsideDates`) */
|
|
460
|
+
outside: boolean;
|
|
461
|
+
}
|
|
462
|
+
interface HeatmapColumn {
|
|
463
|
+
/** 7 slots ordered from `firstDayOfWeek`; `null` = nothing drawn */
|
|
464
|
+
cells: (HeatmapCell | null)[];
|
|
465
|
+
/** Empty spacer between months */
|
|
466
|
+
spacer?: boolean;
|
|
467
|
+
/** Month index (0–11) whose label starts in this column */
|
|
468
|
+
monthLabel?: number;
|
|
469
|
+
}
|
|
470
|
+
/** Lays the date range out in week columns, like a contribution calendar. */
|
|
471
|
+
declare function getHeatmapColumns({ startDate, endDate, firstDayOfWeek, splitMonths, withOutsideDates, }: {
|
|
472
|
+
startDate: number;
|
|
473
|
+
endDate: number;
|
|
474
|
+
firstDayOfWeek?: number;
|
|
475
|
+
splitMonths?: boolean;
|
|
476
|
+
withOutsideDates?: boolean;
|
|
477
|
+
}): HeatmapColumn[];
|
|
478
|
+
/** Index into `colors` for a value; `-1` for no value. */
|
|
479
|
+
declare function getHeatColorIndex(value: number | null | undefined, domain: [number, number], count: number): number;
|
|
480
|
+
/**
|
|
481
|
+
* Calendar heatmap (contributions-style).
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* <Heatmap data={{ '2025-02-14': 2, '2025-02-11': 3 }} startDate="2025-01-01" endDate="2025-03-31"
|
|
485
|
+
* withMonthLabels withWeekdayLabels withTooltip getTooltipLabel={({ date, value }) => `${date}: ${value ?? 0}`} />
|
|
486
|
+
*/
|
|
487
|
+
declare function Heatmap({ data, startDate, endDate, colors, domain, firstDayOfWeek, rectSize, gap, rectRadius, fontSize, withMonthLabels, monthLabels, monthLabelsPosition, monthsLabelsHeight, withWeekdayLabels, weekdayLabels, weekdaysLabelsWidth, splitMonths, withOutsideDates, withTooltip, getTooltipLabel, getRectProps, withLegend, legendLabels, className, classNames, style, "aria-label": ariaLabel, }: HeatmapProps): react.JSX.Element;
|
|
488
|
+
|
|
489
|
+
interface ChartTooltipItem {
|
|
490
|
+
name: string;
|
|
491
|
+
value: unknown;
|
|
492
|
+
color?: string;
|
|
493
|
+
}
|
|
494
|
+
interface ChartTooltipProps {
|
|
495
|
+
label?: ReactNode;
|
|
496
|
+
items: ChartTooltipItem[];
|
|
497
|
+
series?: ChartSeries[];
|
|
498
|
+
unit?: string;
|
|
499
|
+
valueFormatter?: (value: number) => string;
|
|
500
|
+
className?: string;
|
|
501
|
+
}
|
|
502
|
+
/** Tooltip body used by every chart; also usable in `tooltipProps.content`. */
|
|
503
|
+
declare function ChartTooltip({ label, items, series, unit, valueFormatter, className, }: ChartTooltipProps): react.JSX.Element | null;
|
|
504
|
+
interface ChartSliceTooltipProps {
|
|
505
|
+
name: string;
|
|
506
|
+
value: number;
|
|
507
|
+
color: string;
|
|
508
|
+
/** 0–100 */
|
|
509
|
+
percent: number;
|
|
510
|
+
valueFormatter?: (value: number) => string;
|
|
511
|
+
}
|
|
512
|
+
/** Pie / donut tooltip: the slice name, then its share and value. */
|
|
513
|
+
declare function ChartSliceTooltip({ name, value, color, percent, valueFormatter, }: ChartSliceTooltipProps): react.JSX.Element;
|
|
514
|
+
|
|
515
|
+
interface ChartLegendProps {
|
|
516
|
+
series: Pick<ChartSeries, "name" | "color" | "label">[];
|
|
517
|
+
/** Called with the hovered series name, or `null` when the pointer leaves */
|
|
518
|
+
onHighlight?: (name: string | null) => void;
|
|
519
|
+
align?: "left" | "center" | "right";
|
|
520
|
+
/** Additional class name for the legend container */
|
|
521
|
+
className?: string;
|
|
522
|
+
}
|
|
523
|
+
/** Legend rendered above or below every chart. */
|
|
524
|
+
declare function ChartLegend({ series, onHighlight, align, className }: ChartLegendProps): react.JSX.Element;
|
|
525
|
+
|
|
526
|
+
export { AreaChart, type AreaChartProps, type AreaChartType, BarChart, type BarChartProps, type BarChartType, type BaseCartesianChartProps, type BasePieChartProps, CHART_COLORS, type ChartClassNames, type ChartColor, type ChartColorName, type ChartCurveType, type ChartData, type ChartGridAxis, ChartLegend, type ChartLegendOptions, type ChartLegendProps, type ChartOrientation, type ChartReferenceLine, type ChartSeries, ChartSliceTooltip, type ChartSliceTooltipProps, type ChartStateProps, type ChartTickLine, ChartTooltip, type ChartTooltipItem, type ChartTooltipProps, DEFAULT_CHART_COLORS, DonutChart, type DonutChartProps, Heatmap, type HeatmapCell, type HeatmapColumn, type HeatmapProps, type HeatmapRectData, LineChart, type LineChartGradientStop, type LineChartProps, type LineChartType, PieChart, type PieChartCell, type PieChartProps, type PieLabelsType, RadialBarChart, type RadialBarChartProps, formatUtcDay, getHeatColorIndex, getHeatmapColumns, getPercent, getSplitOffset, getThemeColor, getWaterfallData, seriesColor, toUtcDay };
|