@automattic/charts 0.56.3 → 0.56.5
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 +14 -0
- package/dist/charts/bar-chart/index.cjs +5 -5
- package/dist/charts/bar-chart/index.css +12 -0
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.js +4 -4
- package/dist/charts/bar-list-chart/index.cjs +6 -6
- package/dist/charts/bar-list-chart/index.css +12 -0
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.js +5 -5
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -3
- package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.css +14 -1
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +2 -0
- package/dist/charts/conversion-funnel-chart/index.d.ts +2 -0
- package/dist/charts/conversion-funnel-chart/index.js +4 -2
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +12 -0
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +5 -5
- package/dist/charts/leaderboard-chart/index.css +12 -0
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.js +4 -4
- package/dist/charts/line-chart/index.cjs +5 -5
- package/dist/charts/line-chart/index.css +12 -0
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.js +4 -4
- package/dist/charts/pie-chart/index.cjs +7 -7
- package/dist/charts/pie-chart/index.css +12 -0
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.js +6 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs +7 -7
- package/dist/charts/pie-semi-circle-chart/index.css +12 -0
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.js +6 -6
- package/dist/charts/sparkline/index.cjs +6 -6
- package/dist/charts/sparkline/index.css +12 -0
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +5 -5
- package/dist/{chunk-OTZT3MC2.cjs → chunk-2A34OA5O.cjs} +19 -20
- package/dist/chunk-2A34OA5O.cjs.map +1 -0
- package/dist/{chunk-H34CJSR6.js → chunk-32ESS4MV.js} +406 -363
- package/dist/chunk-32ESS4MV.js.map +1 -0
- package/dist/{chunk-CEZGL6YP.js → chunk-6CCZL2JJ.js} +15 -7
- package/dist/chunk-6CCZL2JJ.js.map +1 -0
- package/dist/{chunk-NW3RUYK2.cjs → chunk-7QDEU3KN.cjs} +15 -22
- package/dist/chunk-7QDEU3KN.cjs.map +1 -0
- package/dist/chunk-7TQSPLIN.js +351 -0
- package/dist/chunk-7TQSPLIN.js.map +1 -0
- package/dist/{chunk-T4J6TI55.js → chunk-AFWQR3SM.js} +102 -79
- package/dist/chunk-AFWQR3SM.js.map +1 -0
- package/dist/{chunk-5XI443YP.js → chunk-BPYKWMI7.js} +72 -64
- package/dist/chunk-BPYKWMI7.js.map +1 -0
- package/dist/{chunk-TNRKEBTA.js → chunk-DBY6C4O2.js} +148 -164
- package/dist/{chunk-TNRKEBTA.js.map → chunk-DBY6C4O2.js.map} +1 -1
- package/dist/chunk-DLSUC7RN.js +1065 -0
- package/dist/chunk-DLSUC7RN.js.map +1 -0
- package/dist/{chunk-TVV7ZI7C.cjs → chunk-EJJO2QNB.cjs} +399 -356
- package/dist/chunk-EJJO2QNB.cjs.map +1 -0
- package/dist/{chunk-ODF5O5PV.cjs → chunk-FIFSYVN6.cjs} +154 -170
- package/dist/chunk-FIFSYVN6.cjs.map +1 -0
- package/dist/chunk-FY325WQ4.cjs +1065 -0
- package/dist/chunk-FY325WQ4.cjs.map +1 -0
- package/dist/{chunk-SRXJLAKG.cjs → chunk-I2276W3I.cjs} +28 -37
- package/dist/chunk-I2276W3I.cjs.map +1 -0
- package/dist/{chunk-7UJPVCMB.cjs → chunk-IHESL7H5.cjs} +265 -262
- package/dist/chunk-IHESL7H5.cjs.map +1 -0
- package/dist/chunk-JL4ZKKZU.cjs +375 -0
- package/dist/chunk-JL4ZKKZU.cjs.map +1 -0
- package/dist/chunk-KHRPRH4V.js +165 -0
- package/dist/chunk-KHRPRH4V.js.map +1 -0
- package/dist/{chunk-A3AEEGKR.js → chunk-KXRWNFQJ.js} +20 -21
- package/dist/chunk-KXRWNFQJ.js.map +1 -0
- package/dist/{chunk-2VPPTJS2.js → chunk-KXSLMOW5.js} +256 -253
- package/dist/chunk-KXSLMOW5.js.map +1 -0
- package/dist/chunk-LT4YOIMM.js +375 -0
- package/dist/chunk-LT4YOIMM.js.map +1 -0
- package/dist/chunk-LTPJPIDP.cjs +165 -0
- package/dist/chunk-LTPJPIDP.cjs.map +1 -0
- package/dist/chunk-NGHXTIUE.cjs +120 -0
- package/dist/chunk-NGHXTIUE.cjs.map +1 -0
- package/dist/chunk-PCOI2GT5.js +120 -0
- package/dist/chunk-PCOI2GT5.js.map +1 -0
- package/dist/{chunk-YYQ4IK5V.cjs → chunk-Q6G3BGCL.cjs} +103 -80
- package/dist/chunk-Q6G3BGCL.cjs.map +1 -0
- package/dist/{chunk-HIWNB5PK.cjs → chunk-RCY6XLGU.cjs} +13 -5
- package/dist/chunk-RCY6XLGU.cjs.map +1 -0
- package/dist/chunk-TKPK4RFS.cjs +351 -0
- package/dist/chunk-TKPK4RFS.cjs.map +1 -0
- package/dist/{chunk-C33AQZEC.js → chunk-TYIH5LMV.js} +16 -23
- package/dist/chunk-TYIH5LMV.js.map +1 -0
- package/dist/chunk-X6GX4QUJ.js +421 -0
- package/dist/chunk-X6GX4QUJ.js.map +1 -0
- package/dist/chunk-XCXAWMJQ.cjs +421 -0
- package/dist/chunk-XCXAWMJQ.cjs.map +1 -0
- package/dist/chunk-XWYZIFZW.js +66 -0
- package/dist/chunk-XWYZIFZW.js.map +1 -0
- package/dist/{chunk-7HROSZRS.cjs → chunk-Y3NNQMAX.cjs} +70 -62
- package/dist/chunk-Y3NNQMAX.cjs.map +1 -0
- package/dist/components/legend/index.cjs +2 -2
- package/dist/components/legend/index.css +12 -0
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.js +1 -1
- package/dist/components/tooltip/index.cjs +2 -2
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/trend-indicator/index.cjs +2 -2
- package/dist/components/trend-indicator/index.js +1 -1
- package/dist/hooks/index.cjs +4 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +12 -0
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +28 -2
- package/dist/hooks/index.d.ts +28 -2
- package/dist/hooks/index.js +3 -1
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +14 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -17
- package/dist/providers/index.cjs +2 -2
- package/dist/providers/index.css +12 -0
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/{themes-DQs9rbN5.d.cts → themes-BDVaIfBz.d.cts} +9 -0
- package/dist/{themes-CRV5fVzJ.d.ts → themes-mcS8QNkQ.d.ts} +9 -0
- package/package.json +6 -2
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +2 -1
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +16 -6
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +34 -0
- package/src/charts/conversion-funnel-chart/types.ts +2 -0
- package/src/charts/pie-chart/pie-chart.tsx +2 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/test/use-chart-margin.test.tsx +44 -0
- package/src/hooks/test/use-tooltip-portal-relocator.test.ts +216 -0
- package/src/hooks/use-chart-margin.tsx +92 -6
- package/src/hooks/use-tooltip-portal-relocator.module.scss +10 -0
- package/src/hooks/use-tooltip-portal-relocator.ts +177 -0
- package/src/providers/chart-context/global-charts-provider.tsx +18 -1
- package/tsup.config.ts +11 -0
- package/dist/chunk-2VPPTJS2.js.map +0 -1
- package/dist/chunk-5XI443YP.js.map +0 -1
- package/dist/chunk-7HROSZRS.cjs.map +0 -1
- package/dist/chunk-7UJPVCMB.cjs.map +0 -1
- package/dist/chunk-A3AEEGKR.js.map +0 -1
- package/dist/chunk-C33AQZEC.js.map +0 -1
- package/dist/chunk-CEZGL6YP.js.map +0 -1
- package/dist/chunk-COOC2TVQ.js +0 -167
- package/dist/chunk-COOC2TVQ.js.map +0 -1
- package/dist/chunk-EJHLLXBV.js +0 -362
- package/dist/chunk-EJHLLXBV.js.map +0 -1
- package/dist/chunk-FWMJ2FR2.js +0 -121
- package/dist/chunk-FWMJ2FR2.js.map +0 -1
- package/dist/chunk-GRYNIPWH.cjs +0 -385
- package/dist/chunk-GRYNIPWH.cjs.map +0 -1
- package/dist/chunk-H34CJSR6.js.map +0 -1
- package/dist/chunk-HIWNB5PK.cjs.map +0 -1
- package/dist/chunk-IZWC33YN.cjs +0 -357
- package/dist/chunk-IZWC33YN.cjs.map +0 -1
- package/dist/chunk-KOF32DBL.cjs +0 -1058
- package/dist/chunk-KOF32DBL.cjs.map +0 -1
- package/dist/chunk-LHWRZMF7.cjs +0 -362
- package/dist/chunk-LHWRZMF7.cjs.map +0 -1
- package/dist/chunk-MFRS2PEY.cjs +0 -121
- package/dist/chunk-MFRS2PEY.cjs.map +0 -1
- package/dist/chunk-MMDLXS6O.js +0 -75
- package/dist/chunk-MMDLXS6O.js.map +0 -1
- package/dist/chunk-NW3RUYK2.cjs.map +0 -1
- package/dist/chunk-ODF5O5PV.cjs.map +0 -1
- package/dist/chunk-OTZT3MC2.cjs.map +0 -1
- package/dist/chunk-SBRMWDWM.js +0 -357
- package/dist/chunk-SBRMWDWM.js.map +0 -1
- package/dist/chunk-SRXJLAKG.cjs.map +0 -1
- package/dist/chunk-T4J6TI55.js.map +0 -1
- package/dist/chunk-TVV7ZI7C.cjs.map +0 -1
- package/dist/chunk-XVMXWV3C.cjs +0 -167
- package/dist/chunk-XVMXWV3C.cjs.map +0 -1
- package/dist/chunk-YYQ4IK5V.cjs.map +0 -1
- package/dist/chunk-ZDNCF642.js +0 -1058
- package/dist/chunk-ZDNCF642.js.map +0 -1
- package/dist/chunk-ZWBUEHKF.js +0 -385
- package/dist/chunk-ZWBUEHKF.js.map +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LineChart
|
|
3
|
+
} from "./chunk-DLSUC7RN.js";
|
|
4
|
+
import {
|
|
5
|
+
withResponsive
|
|
6
|
+
} from "./chunk-TYIH5LMV.js";
|
|
7
|
+
import {
|
|
8
|
+
useGlobalChartsTheme
|
|
9
|
+
} from "./chunk-32ESS4MV.js";
|
|
10
|
+
|
|
11
|
+
// src/charts/sparkline/sparkline.tsx
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
import { useMemo, forwardRef } from "react";
|
|
14
|
+
|
|
15
|
+
// src/charts/sparkline/sparkline.module.scss
|
|
16
|
+
var sparkline_module_default = {
|
|
17
|
+
"sparkline": "a8ccharts-o-3Z8B",
|
|
18
|
+
"sparkline--empty": "a8ccharts-CbLbcd"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/charts/sparkline/sparkline.tsx
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
var DEFAULT_WIDTH = 100;
|
|
24
|
+
var DEFAULT_HEIGHT = 40;
|
|
25
|
+
var transformToSeriesData = (data, color, strokeWidth) => {
|
|
26
|
+
const baseDate = new Date(2e3, 0, 1);
|
|
27
|
+
return [{
|
|
28
|
+
label: "sparkline",
|
|
29
|
+
data: data.map((value, index) => ({
|
|
30
|
+
date: new Date(baseDate.getTime() + index * 864e5),
|
|
31
|
+
// Add days
|
|
32
|
+
value
|
|
33
|
+
})),
|
|
34
|
+
options: {
|
|
35
|
+
stroke: color,
|
|
36
|
+
seriesLineStyle: strokeWidth ? {
|
|
37
|
+
strokeWidth
|
|
38
|
+
} : void 0
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
};
|
|
42
|
+
var SparklineComponent = /* @__PURE__ */ forwardRef(({
|
|
43
|
+
data,
|
|
44
|
+
width = DEFAULT_WIDTH,
|
|
45
|
+
height = DEFAULT_HEIGHT,
|
|
46
|
+
color,
|
|
47
|
+
strokeWidth: strokeWidthProp,
|
|
48
|
+
withGradientFill = true,
|
|
49
|
+
gradient,
|
|
50
|
+
className,
|
|
51
|
+
chartId,
|
|
52
|
+
margin: marginProp,
|
|
53
|
+
animation
|
|
54
|
+
}, ref) => {
|
|
55
|
+
const theme = useGlobalChartsTheme();
|
|
56
|
+
const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
|
|
57
|
+
const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
|
|
58
|
+
const seriesData = useMemo(() => {
|
|
59
|
+
if (!data || data.length === 0) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return transformToSeriesData(data, color, strokeWidth);
|
|
63
|
+
}, [data, color, strokeWidth]);
|
|
64
|
+
const finalMargin = useMemo(() => {
|
|
65
|
+
const themeMargin = theme.sparkline?.margin ?? {
|
|
66
|
+
top: 2,
|
|
67
|
+
right: 2,
|
|
68
|
+
bottom: 2,
|
|
69
|
+
left: 2
|
|
70
|
+
};
|
|
71
|
+
const margin = marginProp ?? themeMargin;
|
|
72
|
+
return {
|
|
73
|
+
...themeMargin,
|
|
74
|
+
...margin
|
|
75
|
+
};
|
|
76
|
+
}, [marginProp, theme.sparkline?.margin]);
|
|
77
|
+
const seriesWithGradient = useMemo(() => {
|
|
78
|
+
if (!gradient || seriesData.length === 0) {
|
|
79
|
+
return seriesData;
|
|
80
|
+
}
|
|
81
|
+
return seriesData.map((series) => ({
|
|
82
|
+
...series,
|
|
83
|
+
options: {
|
|
84
|
+
...series.options,
|
|
85
|
+
gradient: {
|
|
86
|
+
from: gradient.from || color || "#000000",
|
|
87
|
+
to: gradient.to || "#ffffff",
|
|
88
|
+
fromOpacity: gradient.fromOpacity ?? 0.5,
|
|
89
|
+
toOpacity: gradient.toOpacity ?? 0
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
}, [seriesData, gradient, color]);
|
|
94
|
+
if (!data || data.length === 0) {
|
|
95
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
96
|
+
ref,
|
|
97
|
+
className: clsx("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--empty"], className),
|
|
98
|
+
style: {
|
|
99
|
+
width,
|
|
100
|
+
height
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (data.length === 1) {
|
|
105
|
+
const cx = width / 2;
|
|
106
|
+
const cy = height / 2;
|
|
107
|
+
const resolvedColor = color || "#000000";
|
|
108
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
109
|
+
ref,
|
|
110
|
+
className: clsx("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
|
|
111
|
+
style: {
|
|
112
|
+
width,
|
|
113
|
+
height
|
|
114
|
+
},
|
|
115
|
+
children: /* @__PURE__ */ _jsx("svg", {
|
|
116
|
+
width,
|
|
117
|
+
height,
|
|
118
|
+
"aria-hidden": "true",
|
|
119
|
+
children: /* @__PURE__ */ _jsx("circle", {
|
|
120
|
+
cx,
|
|
121
|
+
cy,
|
|
122
|
+
r: strokeWidth * 1.5,
|
|
123
|
+
fill: resolvedColor
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
129
|
+
ref,
|
|
130
|
+
className: clsx("sparkline", sparkline_module_default.sparkline, className),
|
|
131
|
+
children: /* @__PURE__ */ _jsx(LineChart, {
|
|
132
|
+
data: seriesWithGradient,
|
|
133
|
+
width,
|
|
134
|
+
height,
|
|
135
|
+
margin: finalMargin,
|
|
136
|
+
chartId,
|
|
137
|
+
withGradientFill,
|
|
138
|
+
withTooltips: false,
|
|
139
|
+
showLegend: false,
|
|
140
|
+
gridVisibility: "none",
|
|
141
|
+
options: {
|
|
142
|
+
axis: {
|
|
143
|
+
x: {
|
|
144
|
+
display: false
|
|
145
|
+
},
|
|
146
|
+
y: {
|
|
147
|
+
display: false
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
curveType: "monotone",
|
|
152
|
+
animation
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
SparklineComponent.displayName = "SparklineComponent";
|
|
157
|
+
var SparklineUnresponsive = SparklineComponent;
|
|
158
|
+
SparklineUnresponsive.displayName = "SparklineUnresponsive";
|
|
159
|
+
var Sparkline = withResponsive(SparklineUnresponsive);
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
SparklineUnresponsive,
|
|
163
|
+
Sparkline
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=chunk-KHRPRH4V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/sparkline/sparkline.tsx","../src/charts/sparkline/sparkline.module.scss"],"sourcesContent":["import clsx from 'clsx';\nimport { useMemo, forwardRef } from 'react';\nimport { useGlobalChartsTheme } from '../../providers';\nimport { LineChartUnresponsive } from '../line-chart';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './sparkline.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst DEFAULT_WIDTH = 100;\nconst DEFAULT_HEIGHT = 40;\n\n/**\n * Transforms a simple number array into SeriesData format for LineChart.\n * Uses index-based dates to create a linear x-axis.\n *\n * @param data - Array of numeric values to plot\n * @param color - Optional color for the line stroke\n * @param strokeWidth - Optional stroke width for the line\n * @return SeriesData array suitable for LineChart\n */\nconst transformToSeriesData = (data, color, strokeWidth) => {\n // Use a fixed base date and increment by index to create linear spacing\n const baseDate = new Date(2000, 0, 1);\n return [{\n label: 'sparkline',\n data: data.map((value, index) => ({\n date: new Date(baseDate.getTime() + index * 86400000),\n // Add days\n value\n })),\n options: {\n stroke: color,\n seriesLineStyle: strokeWidth ? {\n strokeWidth\n } : undefined\n }\n }];\n};\nconst SparklineComponent = /*#__PURE__*/forwardRef(({\n data,\n width = DEFAULT_WIDTH,\n height = DEFAULT_HEIGHT,\n color,\n strokeWidth: strokeWidthProp,\n withGradientFill = true,\n gradient,\n className,\n chartId,\n margin: marginProp,\n animation\n}, ref) => {\n const theme = useGlobalChartsTheme();\n\n // Get theme defaults for sparkline\n const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;\n\n // Use prop values or fall back to theme defaults\n const strokeWidth = strokeWidthProp ?? themeStrokeWidth;\n\n // Transform number[] to SeriesData[] for LineChart\n const seriesData = useMemo(() => {\n if (!data || data.length === 0) {\n return [];\n }\n return transformToSeriesData(data, color, strokeWidth);\n }, [data, color, strokeWidth]);\n\n // Merge margins with theme defaults\n const finalMargin = useMemo(() => {\n const themeMargin = theme.sparkline?.margin ?? {\n top: 2,\n right: 2,\n bottom: 2,\n left: 2\n };\n const margin = marginProp ?? themeMargin;\n return {\n ...themeMargin,\n ...margin\n };\n }, [marginProp, theme.sparkline?.margin]);\n\n // Build gradient options for the series if custom gradient is provided\n // Note: This must be called before any early returns to follow React hooks rules\n const seriesWithGradient = useMemo(() => {\n if (!gradient || seriesData.length === 0) {\n return seriesData;\n }\n return seriesData.map(series => ({\n ...series,\n options: {\n ...series.options,\n gradient: {\n from: gradient.from || color || '#000000',\n to: gradient.to || '#ffffff',\n fromOpacity: gradient.fromOpacity ?? 0.5,\n toOpacity: gradient.toOpacity ?? 0.0\n }\n }\n }));\n }, [seriesData, gradient, color]);\n\n // Handle empty data\n if (!data || data.length === 0) {\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, styles['sparkline--empty'], className),\n style: {\n width,\n height\n }\n });\n }\n\n // Handle single data point - render a simple dot\n if (data.length === 1) {\n const cx = width / 2;\n const cy = height / 2;\n const resolvedColor = color || '#000000';\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, styles['sparkline--single-point'], className),\n style: {\n width,\n height\n },\n children: /*#__PURE__*/_jsx(\"svg\", {\n width: width,\n height: height,\n \"aria-hidden\": \"true\",\n children: /*#__PURE__*/_jsx(\"circle\", {\n cx: cx,\n cy: cy,\n r: strokeWidth * 1.5,\n fill: resolvedColor\n })\n })\n });\n }\n return /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n className: clsx('sparkline', styles.sparkline, className),\n children: /*#__PURE__*/_jsx(LineChartUnresponsive, {\n data: seriesWithGradient,\n width: width,\n height: height,\n margin: finalMargin,\n chartId: chartId,\n withGradientFill: withGradientFill,\n withTooltips: false,\n showLegend: false,\n gridVisibility: \"none\",\n options: {\n axis: {\n x: {\n display: false\n },\n y: {\n display: false\n }\n }\n },\n curveType: \"monotone\",\n animation: animation\n })\n });\n});\nSparklineComponent.displayName = 'SparklineComponent';\n\n/**\n * Sparkline - A minimal line chart for inline data visualization.\n *\n * Sparklines are compact charts designed to be embedded inline with text or\n * displayed in small spaces like table cells or dashboards. They show trends\n * without axes, labels, or other chart chrome.\n *\n * This component is built on top of LineChart with preconfigured settings\n * for minimal display (no axes, grid, tooltips, or legend).\n */\nconst SparklineUnresponsive = SparklineComponent;\nSparklineUnresponsive.displayName = 'SparklineUnresponsive';\n\n/**\n * Responsive Sparkline chart component\n */\nconst Sparkline = withResponsive(SparklineUnresponsive);\nexport { Sparkline as default, SparklineUnresponsive };","import 'css-chunk:src/charts/sparkline/sparkline.module.scss';export default {\n \"sparkline\": \"a8ccharts-o-3Z8B\",\n \"sparkline--empty\": \"a8ccharts-CbLbcd\"\n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MAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACA,SAAoB,qBAAK,OAAO;AAAA,IAC9B;AAAA,IACA,WAAW,KAAK,aAAa,yBAAO,WAAW,SAAS;AAAA,IACxD,UAAuB,qBAAK,WAAuB;AAAA,MACjD,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACP,MAAM;AAAA,UACJ,GAAG;AAAA,YACD,SAAS;AAAA,UACX;AAAA,UACA,GAAG;AAAA,YACD,SAAS;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,MACA,WAAW;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;AACD,mBAAmB,cAAc;AAYjC,IAAM,wBAAwB;AAC9B,sBAAsB,cAAc;AAKpC,IAAM,YAAY,eAAe,qBAAqB;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
function RadialWipeAnimation({
|
|
4
4
|
id,
|
|
5
5
|
radius,
|
|
@@ -15,9 +15,9 @@ function RadialWipeAnimation({
|
|
|
15
15
|
const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;
|
|
16
16
|
const animationDuration = `${// If wipePercentage is invalid, set animation duration to 0 to disable animation.
|
|
17
17
|
isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
|
|
20
|
-
{
|
|
18
|
+
return /* @__PURE__ */ _jsx("mask", {
|
|
19
|
+
id,
|
|
20
|
+
children: /* @__PURE__ */ _jsx("circle", {
|
|
21
21
|
cx: 0,
|
|
22
22
|
cy: 0,
|
|
23
23
|
r: radius,
|
|
@@ -27,26 +27,25 @@ function RadialWipeAnimation({
|
|
|
27
27
|
strokeWidth,
|
|
28
28
|
strokeDasharray: "100, 1000",
|
|
29
29
|
strokeDashoffset: "0",
|
|
30
|
-
style: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
) });
|
|
30
|
+
style: {
|
|
31
|
+
transform: `rotate(${startAngle}) scaleY(${scaleY})`
|
|
32
|
+
},
|
|
33
|
+
children: /* @__PURE__ */ _jsx("animate", {
|
|
34
|
+
attributeName: "stroke-dashoffset",
|
|
35
|
+
from: "0",
|
|
36
|
+
to: "100.1",
|
|
37
|
+
dur: animationDuration,
|
|
38
|
+
fill: "freeze",
|
|
39
|
+
calcMode: "spline",
|
|
40
|
+
keySplines: "0.42 0 0.58 1;0 0 1 1",
|
|
41
|
+
keyTimes: `0;${wipePercentage / 100};1`
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
});
|
|
46
45
|
}
|
|
47
46
|
var radial_wipe_animation_default = RadialWipeAnimation;
|
|
48
47
|
|
|
49
48
|
export {
|
|
50
49
|
radial_wipe_animation_default
|
|
51
50
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-KXRWNFQJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * This animation uses the SVG self-drawing technique (source: https://www.joshwcomeau.com/svg/friendly-introduction-to-svg/),\n * leveraging stroke-dasharray and stroke-dashoffset properties to create the effect.\n *\n * Here, we reverse the animation to \"un-draw\" the circle for the revealing / radial wipe effect:\n * - Initially, the entire circle is drawn with a white mask.\n * - The circle's border (stroke) is drawn with a black stroke, wide enough to cover the circle.\n * - The stroke is then \"un-drawn,\" creating the wipe animation.\n * - A white mask makes the area visible, while a black mask makes the area invisible.\n */\n\n/**\n * RadialWipeAnimationProps - SVG mask props that requires a radial wipe animation effect.\n *\n * @param {object} props - The properties object.\n * @param {string} props.id - The unique ID for the mask.\n * @param {number} props.radius - The outer radius of the radial wipe.\n * @param {number} [props.innerRadius=0] - The inner radius of the radial wipe.\n * @param {number} [props.durationMs=1000] - The duration of the animation in milliseconds.\n * @param {number} [props.wipePercentage=100] - The percentage of the wipe animation to complete.\n * @param {'clockwise' | 'counter-clockwise'} [props.direction='clockwise'] - The direction of the wipe animation.\n * @param {Angle} [props.startAngle='-90deg'] - The starting angle of the wipe animation.\n *\n * @return {JSX.Element} The radial wipe mask element.\n */\n\n/**\n * Renders a SVG mask that creates a radial wipe animation effect.\n *\n * @param {RadialWipeAnimationProps} props - Component props\n * @return {JSX.Element} The rendered mask component\n */\nfunction RadialWipeAnimation({\n id,\n radius,\n innerRadius = 0,\n durationMs = 1000,\n wipePercentage = 100,\n direction = 'clockwise',\n startAngle = '-90deg'\n}) {\n const strokeWidth = (radius - innerRadius) * 2 +\n // The stroke is centered on the circumference, so we need to double the width.\n 1; // Added 1 to prevent sub-pixel rendering issues.\n\n const scaleY = direction === 'clockwise' ? -1 : 1;\n const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;\n const animationDuration = `${\n // If wipePercentage is invalid, set animation duration to 0 to disable animation.\n isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;\n return /*#__PURE__*/_jsx(\"mask\", {\n id: id,\n children: /*#__PURE__*/_jsx(\"circle\", {\n cx: 0,\n cy: 0,\n r: radius,\n pathLength: \"100\",\n fill: \"white\",\n stroke: \"black\" // The stroke will be un-drawn, hence 'black' mask.\n ,\n strokeWidth: strokeWidth,\n strokeDasharray: \"100, 1000\",\n strokeDashoffset: \"0\",\n style: {\n transform: `rotate(${startAngle}) scaleY(${scaleY})`\n },\n children: /*#__PURE__*/_jsx(\"animate\", {\n attributeName: \"stroke-dashoffset\",\n from: \"0\",\n to: \"100.1\",\n dur: animationDuration,\n fill: \"freeze\" // Same as CSS 'forwards' to retain the final state after animation.\n ,\n calcMode: \"spline\" // custom easing\n ,\n keySplines: \"0.42 0 0.58 1;0 0 1 1\" // ease-in-out ; linear (unimportant)\n ,\n keyTimes: `0;${wipePercentage / 100};1`\n })\n })\n });\n}\nexport default RadialWipeAnimation;"],"mappings":";AAAA,SAAS,OAAO,YAAY;AAiC5B,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa;AACf,GAAG;AACD,QAAM,eAAe,SAAS,eAAe;AAAA,EAE7C;AAEA,QAAM,SAAS,cAAc,cAAc,KAAK;AAChD,QAAM,wBAAwB,IAAI,kBAAkB,kBAAkB;AACtE,QAAM,oBAAoB;AAAA,EAE1B,wBAAwB,cAAc,MAAM,kBAAkB,CAAC;AAC/D,SAAoB,qBAAK,QAAQ;AAAA,IAC/B;AAAA,IACA,UAAuB,qBAAK,UAAU;AAAA,MACpC,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,GAAG;AAAA,MACH,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,QAAQ;AAAA,MAER;AAAA,MACA,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,OAAO;AAAA,QACL,WAAW,UAAU,UAAU,YAAY,MAAM;AAAA,MACnD;AAAA,MACA,UAAuB,qBAAK,WAAW;AAAA,QACrC,eAAe;AAAA,QACf,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,MAAM;AAAA,QAEN,UAAU;AAAA,QAEV,YAAY;AAAA,QAEZ,UAAU,KAAK,iBAAiB,GAAG;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AACA,IAAO,gCAAQ;","names":[]}
|