@primeui/chart-core 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +1 -0
- package/dist/animations/index.d.mts +136 -0
- package/dist/animations/index.mjs +18 -0
- package/dist/annotation.utils-Bm0lOO1o.d.mts +290 -0
- package/dist/borderRadius.utils-Cz73LLR_.d.mts +54 -0
- package/dist/canvas-D4vigq47.d.mts +34 -0
- package/dist/canvas.utils-D2WHi2gL.d.mts +167 -0
- package/dist/cartesian/index.d.mts +94 -0
- package/dist/cartesian/index.mjs +93 -0
- package/dist/chunk-22ST6YPP.mjs +304 -0
- package/dist/chunk-2QK2KOBN.mjs +10 -0
- package/dist/chunk-2QRS4YQ5.mjs +18 -0
- package/dist/chunk-3FFJEX4A.mjs +261 -0
- package/dist/chunk-3IYSJ2U7.mjs +567 -0
- package/dist/chunk-3OZLP4I4.mjs +190 -0
- package/dist/chunk-3WEMHXZI.mjs +198 -0
- package/dist/chunk-3Z62EUJN.mjs +138 -0
- package/dist/chunk-4C6EVJ54.mjs +362 -0
- package/dist/chunk-53HW45JB.mjs +102 -0
- package/dist/chunk-55Y3WI6S.mjs +186 -0
- package/dist/chunk-5JCI2DEB.mjs +97 -0
- package/dist/chunk-66T4MRC5.mjs +113 -0
- package/dist/chunk-6HSEJLSR.mjs +376 -0
- package/dist/chunk-6STOLMCA.mjs +187 -0
- package/dist/chunk-7CMVDIOU.mjs +54 -0
- package/dist/chunk-7QQ6ETB4.mjs +228 -0
- package/dist/chunk-A6ZQZFL2.mjs +272 -0
- package/dist/chunk-ADKLH73T.mjs +1 -0
- package/dist/chunk-AGU3NG6D.mjs +22 -0
- package/dist/chunk-AHYIS6EB.mjs +230 -0
- package/dist/chunk-AP3UYWYT.mjs +4 -0
- package/dist/chunk-ARB5T6MP.mjs +326 -0
- package/dist/chunk-ARRGOEFX.mjs +585 -0
- package/dist/chunk-AUF4CHDP.mjs +422 -0
- package/dist/chunk-B4FTADAZ.mjs +561 -0
- package/dist/chunk-BABQKA6K.mjs +339 -0
- package/dist/chunk-BETFQBM2.mjs +197 -0
- package/dist/chunk-BKP26M4K.mjs +413 -0
- package/dist/chunk-BZN2QHGP.mjs +200 -0
- package/dist/chunk-C36VWQ7A.mjs +86 -0
- package/dist/chunk-CHW4RKY3.mjs +16 -0
- package/dist/chunk-CINXJIRR.mjs +120 -0
- package/dist/chunk-DN6AXQYZ.mjs +667 -0
- package/dist/chunk-DP2IZNN3.mjs +92 -0
- package/dist/chunk-DTWTCFRG.mjs +119 -0
- package/dist/chunk-EAMUNLRU.mjs +172 -0
- package/dist/chunk-EDAKJLNA.mjs +17 -0
- package/dist/chunk-ERVQB2VZ.mjs +59 -0
- package/dist/chunk-FFMT6OCO.mjs +92 -0
- package/dist/chunk-FHTC2YDB.mjs +102 -0
- package/dist/chunk-FRST55HY.mjs +16 -0
- package/dist/chunk-HDFGCN2F.mjs +132 -0
- package/dist/chunk-IEGLX7VL.mjs +42 -0
- package/dist/chunk-ILUWFYGY.mjs +220 -0
- package/dist/chunk-IXOWSEHO.mjs +114 -0
- package/dist/chunk-J4RI2C2G.mjs +172 -0
- package/dist/chunk-J65DBT4R.mjs +13 -0
- package/dist/chunk-JGOVWSKH.mjs +179 -0
- package/dist/chunk-JO7VACY2.mjs +25 -0
- package/dist/chunk-JWFBOPM6.mjs +122 -0
- package/dist/chunk-KNDZP446.mjs +895 -0
- package/dist/chunk-KP2TWD4Z.mjs +90 -0
- package/dist/chunk-KQIFO5I3.mjs +225 -0
- package/dist/chunk-KVDEROP6.mjs +59 -0
- package/dist/chunk-LKC7MZKK.mjs +87 -0
- package/dist/chunk-LVMDQ4OJ.mjs +305 -0
- package/dist/chunk-M7B3JF43.mjs +90 -0
- package/dist/chunk-MTGMXRNF.mjs +136 -0
- package/dist/chunk-N3TIT3OH.mjs +1040 -0
- package/dist/chunk-NHRK5KU2.mjs +890 -0
- package/dist/chunk-NKUYIWAP.mjs +243 -0
- package/dist/chunk-NPDZLYIF.mjs +238 -0
- package/dist/chunk-O2X6FF45.mjs +499 -0
- package/dist/chunk-OGJ6IIBW.mjs +176 -0
- package/dist/chunk-OHGCZZPZ.mjs +403 -0
- package/dist/chunk-OWW3K55O.mjs +351 -0
- package/dist/chunk-OXTFAWSK.mjs +60 -0
- package/dist/chunk-PLSDU3C2.mjs +890 -0
- package/dist/chunk-PRDVPOZX.mjs +223 -0
- package/dist/chunk-Q6PPVIHU.mjs +21 -0
- package/dist/chunk-QQBXUDM4.mjs +885 -0
- package/dist/chunk-QS76E3TD.mjs +111 -0
- package/dist/chunk-QWQ6HY4I.mjs +209 -0
- package/dist/chunk-R6Y3R7EW.mjs +135 -0
- package/dist/chunk-RBLZRT5K.mjs +190 -0
- package/dist/chunk-RO4N6YFS.mjs +167 -0
- package/dist/chunk-RQ3CKQOX.mjs +984 -0
- package/dist/chunk-SALTGZFR.mjs +208 -0
- package/dist/chunk-SANZPAJ4.mjs +14 -0
- package/dist/chunk-SDBPQ5CF.mjs +624 -0
- package/dist/chunk-SSLTFJ3U.mjs +364 -0
- package/dist/chunk-SXHVDJGF.mjs +77 -0
- package/dist/chunk-TA4MVAEX.mjs +243 -0
- package/dist/chunk-TAHCOZHF.mjs +1772 -0
- package/dist/chunk-TQ6S34QZ.mjs +152 -0
- package/dist/chunk-UPRXABX5.mjs +90 -0
- package/dist/chunk-VGLSBZDN.mjs +71 -0
- package/dist/chunk-VN7CKCSE.mjs +364 -0
- package/dist/chunk-VVI3OBPJ.mjs +524 -0
- package/dist/chunk-VWF57TS3.mjs +62 -0
- package/dist/chunk-WA3OVISZ.mjs +179 -0
- package/dist/chunk-WCG35U6M.mjs +964 -0
- package/dist/chunk-WFTX4AQJ.mjs +194 -0
- package/dist/chunk-WFVOQ2QZ.mjs +18 -0
- package/dist/chunk-WH3C3Y7P.mjs +149 -0
- package/dist/chunk-WPFUV7K3.mjs +488 -0
- package/dist/chunk-WRULPWHD.mjs +492 -0
- package/dist/chunk-WS64BZXT.mjs +1 -0
- package/dist/chunk-WY4AURRE.mjs +2419 -0
- package/dist/chunk-WYLILAOO.mjs +167 -0
- package/dist/chunk-X4D7FKUS.mjs +62 -0
- package/dist/chunk-X7T34OLW.mjs +139 -0
- package/dist/chunk-XIHBK5D3.mjs +68 -0
- package/dist/chunk-XQQCGFYB.mjs +50 -0
- package/dist/chunk-XTVE4P3L.mjs +214 -0
- package/dist/chunk-XUAASRXW.mjs +579 -0
- package/dist/chunk-Y3L3D4GQ.mjs +685 -0
- package/dist/chunk-YBJ56XJS.mjs +132 -0
- package/dist/chunk-ZQFK6CAE.mjs +1 -0
- package/dist/chunk-ZT2Z7ERM.mjs +874 -0
- package/dist/chunk-ZTL2FQEW.mjs +714 -0
- package/dist/circular/arc/index.d.mts +8 -0
- package/dist/circular/arc/index.mjs +3 -0
- package/dist/circular/index.d.mts +44 -0
- package/dist/circular/index.mjs +13 -0
- package/dist/collect.utils-DiKB4ciO.d.mts +12 -0
- package/dist/computeChartState-BTVIqwyO.d.mts +304 -0
- package/dist/controller-BJE1AZ3q.d.mts +82 -0
- package/dist/controller-BoNigQJr.d.mts +63 -0
- package/dist/controllers/index.d.mts +16 -0
- package/dist/controllers/index.mjs +110 -0
- package/dist/datalabel.utils-CkjGeB8S.d.mts +122 -0
- package/dist/decimation.utils-CcvJVhI4.d.mts +244 -0
- package/dist/geometry-DUUQJXVM.d.mts +60 -0
- package/dist/index-DseIZa1j.d.mts +167 -0
- package/dist/index.d.mts +88 -0
- package/dist/index.mjs +110 -0
- package/dist/orchestrator/index.d.mts +264 -0
- package/dist/orchestrator/index.mjs +33 -0
- package/dist/plugins/index.d.mts +18 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/property-animations-D433wXzz.d.mts +580 -0
- package/dist/property-store-NORUWFND.d.mts +17 -0
- package/dist/radial/index.d.mts +14 -0
- package/dist/radial/index.mjs +37 -0
- package/dist/renderers/axis/index.d.mts +39 -0
- package/dist/renderers/axis/index.mjs +8 -0
- package/dist/renderers/circular/index.d.mts +13 -0
- package/dist/renderers/circular/index.mjs +13 -0
- package/dist/renderers/index.d.mts +83 -0
- package/dist/renderers/index.mjs +75 -0
- package/dist/renderers/navigator/index.d.mts +103 -0
- package/dist/renderers/navigator/index.mjs +8 -0
- package/dist/resize.utils-D_2qm6rv.d.mts +142 -0
- package/dist/ring.utils-DXvrxMkU.d.mts +138 -0
- package/dist/scale-KFv30jqZ.d.mts +307 -0
- package/dist/scales-Drf8AIhL.d.mts +75 -0
- package/dist/series/bar/canvas/index.d.mts +8 -0
- package/dist/series/bar/canvas/index.mjs +10 -0
- package/dist/series/bar/controller/index.d.mts +105 -0
- package/dist/series/bar/controller/index.mjs +44 -0
- package/dist/series/bar/controller-canvas/index.d.mts +7 -0
- package/dist/series/bar/controller-canvas/index.mjs +49 -0
- package/dist/series/bar/controller-svg/index.d.mts +7 -0
- package/dist/series/bar/controller-svg/index.mjs +49 -0
- package/dist/series/bar/index.d.mts +60 -0
- package/dist/series/bar/index.mjs +13 -0
- package/dist/series/bar/svg/index.d.mts +8 -0
- package/dist/series/bar/svg/index.mjs +11 -0
- package/dist/series/candlestick/canvas/index.d.mts +8 -0
- package/dist/series/candlestick/canvas/index.mjs +8 -0
- package/dist/series/candlestick/controller/index.d.mts +123 -0
- package/dist/series/candlestick/controller/index.mjs +40 -0
- package/dist/series/candlestick/controller-canvas/index.d.mts +7 -0
- package/dist/series/candlestick/controller-canvas/index.mjs +45 -0
- package/dist/series/candlestick/controller-svg/index.d.mts +7 -0
- package/dist/series/candlestick/controller-svg/index.mjs +45 -0
- package/dist/series/candlestick/index.d.mts +11 -0
- package/dist/series/candlestick/index.mjs +10 -0
- package/dist/series/candlestick/svg/index.d.mts +8 -0
- package/dist/series/candlestick/svg/index.mjs +8 -0
- package/dist/series/heatmap/canvas/index.d.mts +16 -0
- package/dist/series/heatmap/canvas/index.mjs +9 -0
- package/dist/series/heatmap/controller/index.d.mts +110 -0
- package/dist/series/heatmap/controller/index.mjs +23 -0
- package/dist/series/heatmap/controller-canvas/index.d.mts +7 -0
- package/dist/series/heatmap/controller-canvas/index.mjs +28 -0
- package/dist/series/heatmap/controller-svg/index.d.mts +7 -0
- package/dist/series/heatmap/controller-svg/index.mjs +28 -0
- package/dist/series/heatmap/index.d.mts +34 -0
- package/dist/series/heatmap/index.mjs +13 -0
- package/dist/series/heatmap/svg/index.d.mts +15 -0
- package/dist/series/heatmap/svg/index.mjs +10 -0
- package/dist/series/line/canvas/index.d.mts +6 -0
- package/dist/series/line/canvas/index.mjs +9 -0
- package/dist/series/line/controller/index.d.mts +111 -0
- package/dist/series/line/controller/index.mjs +47 -0
- package/dist/series/line/controller-canvas/index.d.mts +7 -0
- package/dist/series/line/controller-canvas/index.mjs +54 -0
- package/dist/series/line/controller-svg/index.d.mts +7 -0
- package/dist/series/line/controller-svg/index.mjs +54 -0
- package/dist/series/line/index.d.mts +49 -0
- package/dist/series/line/index.mjs +13 -0
- package/dist/series/line/svg/index.d.mts +6 -0
- package/dist/series/line/svg/index.mjs +9 -0
- package/dist/series/pie/canvas/index.d.mts +8 -0
- package/dist/series/pie/canvas/index.mjs +10 -0
- package/dist/series/pie/controller/index.d.mts +174 -0
- package/dist/series/pie/controller/index.mjs +110 -0
- package/dist/series/pie/controller-canvas/index.d.mts +8 -0
- package/dist/series/pie/controller-canvas/index.mjs +119 -0
- package/dist/series/pie/controller-svg/index.d.mts +8 -0
- package/dist/series/pie/controller-svg/index.mjs +118 -0
- package/dist/series/pie/index.d.mts +59 -0
- package/dist/series/pie/index.mjs +15 -0
- package/dist/series/pie/svg/index.d.mts +6 -0
- package/dist/series/pie/svg/index.mjs +11 -0
- package/dist/series/polar/canvas/index.d.mts +6 -0
- package/dist/series/polar/canvas/index.mjs +7 -0
- package/dist/series/polar/controller/index.d.mts +102 -0
- package/dist/series/polar/controller/index.mjs +46 -0
- package/dist/series/polar/controller-canvas/index.d.mts +8 -0
- package/dist/series/polar/controller-canvas/index.mjs +52 -0
- package/dist/series/polar/controller-svg/index.d.mts +8 -0
- package/dist/series/polar/controller-svg/index.mjs +52 -0
- package/dist/series/polar/index.d.mts +25 -0
- package/dist/series/polar/index.mjs +16 -0
- package/dist/series/polar/svg/index.d.mts +10 -0
- package/dist/series/polar/svg/index.mjs +8 -0
- package/dist/series/radar/canvas/index.d.mts +6 -0
- package/dist/series/radar/canvas/index.mjs +8 -0
- package/dist/series/radar/controller/index.d.mts +121 -0
- package/dist/series/radar/controller/index.mjs +43 -0
- package/dist/series/radar/controller-canvas/index.d.mts +8 -0
- package/dist/series/radar/controller-canvas/index.mjs +51 -0
- package/dist/series/radar/controller-svg/index.d.mts +8 -0
- package/dist/series/radar/controller-svg/index.mjs +51 -0
- package/dist/series/radar/index.d.mts +40 -0
- package/dist/series/radar/index.mjs +13 -0
- package/dist/series/radar/svg/index.d.mts +12 -0
- package/dist/series/radar/svg/index.mjs +9 -0
- package/dist/series/scatter/canvas/index.d.mts +8 -0
- package/dist/series/scatter/canvas/index.mjs +11 -0
- package/dist/series/scatter/controller/index.d.mts +124 -0
- package/dist/series/scatter/controller/index.mjs +44 -0
- package/dist/series/scatter/controller-canvas/index.d.mts +7 -0
- package/dist/series/scatter/controller-canvas/index.mjs +51 -0
- package/dist/series/scatter/controller-svg/index.d.mts +7 -0
- package/dist/series/scatter/controller-svg/index.mjs +51 -0
- package/dist/series/scatter/index.d.mts +25 -0
- package/dist/series/scatter/index.mjs +14 -0
- package/dist/series/scatter/svg/index.d.mts +8 -0
- package/dist/series/scatter/svg/index.mjs +12 -0
- package/dist/series/treemap/canvas/index.d.mts +50 -0
- package/dist/series/treemap/canvas/index.mjs +10 -0
- package/dist/series/treemap/controller/index.d.mts +130 -0
- package/dist/series/treemap/controller/index.mjs +20 -0
- package/dist/series/treemap/controller-canvas/index.d.mts +7 -0
- package/dist/series/treemap/controller-canvas/index.mjs +25 -0
- package/dist/series/treemap/controller-svg/index.d.mts +7 -0
- package/dist/series/treemap/controller-svg/index.mjs +25 -0
- package/dist/series/treemap/index.d.mts +15 -0
- package/dist/series/treemap/index.mjs +12 -0
- package/dist/series/treemap/svg/index.d.mts +15 -0
- package/dist/series/treemap/svg/index.mjs +9 -0
- package/dist/slices-DtewiwJx.d.mts +72 -0
- package/dist/spatialIndex.utils-B_GJkotZ.d.mts +5 -0
- package/dist/squarify.utils-B9CQBpa1.d.mts +50 -0
- package/dist/stacking-CChuAcLN.d.mts +319 -0
- package/dist/streaming.utils-DH-g1gNP.d.mts +49 -0
- package/dist/sync/index.d.mts +130 -0
- package/dist/sync/index.mjs +5 -0
- package/dist/tooltip.renderer-D5wpSlBa.d.mts +210 -0
- package/dist/utils/color/index.d.mts +58 -0
- package/dist/utils/color/index.mjs +4 -0
- package/dist/utils/data/index.d.mts +180 -0
- package/dist/utils/data/index.mjs +7 -0
- package/dist/utils/export/index.d.mts +14 -0
- package/dist/utils/export/index.mjs +6 -0
- package/dist/utils/index.d.mts +49 -0
- package/dist/utils/index.mjs +29 -0
- package/dist/utils/interaction/index.d.mts +255 -0
- package/dist/utils/interaction/index.mjs +9 -0
- package/dist/utils/layout/index.d.mts +3 -0
- package/dist/utils/layout/index.mjs +10 -0
- package/dist/utils/math/index.d.mts +162 -0
- package/dist/utils/math/index.mjs +1 -0
- package/dist/utils/render/index.d.mts +19 -0
- package/dist/utils/render/index.mjs +3 -0
- package/dist/utils/specialized/index.d.mts +37 -0
- package/dist/utils/specialized/index.mjs +66 -0
- package/dist/utils/text/index.d.mts +39 -0
- package/dist/utils/text/index.mjs +8 -0
- package/dist/utils/theme/index.d.mts +295 -0
- package/dist/utils/theme/index.mjs +5 -0
- package/dist/utils/zoom/index.d.mts +90 -0
- package/dist/utils/zoom/index.mjs +3 -0
- package/package.json +56 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { getHeatmapLabelInfo, resolveLabelMidToAlpha } from './chunk-3Z62EUJN.mjs';
|
|
2
|
+
import { createDrawImage } from './chunk-7CMVDIOU.mjs';
|
|
3
|
+
import { resolveFontFamily, DEFAULT_HOVER_DIM_OPACITY, DEFAULT_HOVER_BRIGHTNESS } from './chunk-NKUYIWAP.mjs';
|
|
4
|
+
import { getContrastColor } from './chunk-QS76E3TD.mjs';
|
|
5
|
+
import { resolveAccessor, makeItemContext, resolveDash } from './chunk-O2X6FF45.mjs';
|
|
6
|
+
import { withCanvasState, adjustBrightness } from './chunk-SSLTFJ3U.mjs';
|
|
7
|
+
|
|
8
|
+
// src/series/heatmap/canvas/index.ts
|
|
9
|
+
function makeCellExtras(props, cell) {
|
|
10
|
+
return { value: cell.value, category: cell.xLabel, seriesIndex: props.order ?? 0, seriesId: props.id ?? "" };
|
|
11
|
+
}
|
|
12
|
+
function renderHeatmapCanvas(props, layout, ctx, context) {
|
|
13
|
+
const { cells } = layout;
|
|
14
|
+
const fontFamily = resolveFontFamily(void 0, context.font);
|
|
15
|
+
const borderRadius = props.borderRadius ?? 0;
|
|
16
|
+
const borderJoinStyle = props.borderJoinStyle;
|
|
17
|
+
const borderAlign = props.borderAlign ?? "center";
|
|
18
|
+
const hoveredIndex = props.interaction?.hoveredIndex ?? null;
|
|
19
|
+
const dimOpacity = props.effects?.dimOpacity ?? context.theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY;
|
|
20
|
+
const hoverBrightness = props.effects?.hoverBrightness ?? context.theme.hoverBrightness ?? DEFAULT_HOVER_BRIGHTNESS;
|
|
21
|
+
const hoverEnabled = props.effects !== void 0;
|
|
22
|
+
const anyHover = hoverEnabled && hoveredIndex !== null;
|
|
23
|
+
const showLabels = props.showLabels === true;
|
|
24
|
+
const dataArr = props.data;
|
|
25
|
+
const labelMidToAlpha = /* @__PURE__ */ new Map();
|
|
26
|
+
const resolveLabelColor = (cell) => {
|
|
27
|
+
const v = resolveAccessor(props.labelColor, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)));
|
|
28
|
+
return typeof v === "string" ? v : void 0;
|
|
29
|
+
};
|
|
30
|
+
const resolveCellBorderDash = (cell) => resolveDash(props.borderDash, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)));
|
|
31
|
+
const resolveCellBorderDashOffset = (cell) => resolveAccessor(props.borderDashOffset, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)), { arrayMode: "clip" });
|
|
32
|
+
const resolveCellOpacity = (cell) => resolveAccessor(props.opacity, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)), { arrayMode: "clip" });
|
|
33
|
+
const resolveCellBorderColor = (cell) => resolveAccessor(props.borderColor, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)));
|
|
34
|
+
const resolveCellBorderWidth = (cell) => resolveAccessor(props.borderStrokeWidth, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)), { arrayMode: "clip" });
|
|
35
|
+
const resolveCellHoverColor = (cell) => resolveAccessor(props.hoverColor, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)), { arrayMode: "cycle" });
|
|
36
|
+
const resolveCellHoverBorderColor = (cell) => resolveAccessor(props.hoverBorderColor, makeItemContext(dataArr?.[cell.index], cell.index, makeCellExtras(props, cell)), { arrayMode: "cycle" });
|
|
37
|
+
withCanvasState(ctx, () => {
|
|
38
|
+
if (borderJoinStyle) ctx.lineJoin = borderJoinStyle;
|
|
39
|
+
let curFill = "";
|
|
40
|
+
let curAlpha = -1;
|
|
41
|
+
for (const cell of cells) {
|
|
42
|
+
if (cell.width <= 0 || cell.height <= 0) continue;
|
|
43
|
+
const isHovered = hoverEnabled && cell.index === hoveredIndex;
|
|
44
|
+
const hoverOpacity = anyHover && !isHovered ? dimOpacity : 1;
|
|
45
|
+
const userCellOpacity = resolveCellOpacity(cell);
|
|
46
|
+
const cellOpacity = (cell.opacity ?? 1) * hoverOpacity * (userCellOpacity ?? 1);
|
|
47
|
+
const hoverFill = isHovered ? resolveCellHoverColor(cell) : void 0;
|
|
48
|
+
const hoverBorder = isHovered ? resolveCellHoverBorderColor(cell) : void 0;
|
|
49
|
+
const cellBorderColor = hoverBorder ?? resolveCellBorderColor(cell);
|
|
50
|
+
const cellBorderColorStr = typeof cellBorderColor === "string" ? cellBorderColor : cellBorderColor !== void 0 ? String(cellBorderColor) : void 0;
|
|
51
|
+
const cellBorderWidth = resolveCellBorderWidth(cell);
|
|
52
|
+
const effectiveBW = cellBorderColorStr ? cellBorderWidth ?? 1 : cell.isEmpty ? 0.5 : 0;
|
|
53
|
+
const inset = cellBorderColorStr && borderAlign === "inner" && effectiveBW > 0 ? effectiveBW / 2 : 0;
|
|
54
|
+
const cellBorderDash = resolveCellBorderDash(cell);
|
|
55
|
+
const cellBorderDashOffset = resolveCellBorderDashOffset(cell);
|
|
56
|
+
const baseFill = isHovered && hoverBrightness ? adjustBrightness(cell.color, hoverBrightness) : cell.color;
|
|
57
|
+
const fillStr = hoverFill !== void 0 ? typeof hoverFill === "string" ? hoverFill : String(hoverFill) : baseFill;
|
|
58
|
+
const centreX = Math.round(cell.x + cell.width / 2);
|
|
59
|
+
const centreY = Math.round(cell.y + cell.height / 2);
|
|
60
|
+
const halfW = Math.round(cell.width / 2 - inset);
|
|
61
|
+
const halfH = Math.round(cell.height / 2 - inset);
|
|
62
|
+
const left = centreX - halfW;
|
|
63
|
+
const top = centreY - halfH;
|
|
64
|
+
const cw = Math.max(0, halfW * 2);
|
|
65
|
+
const ch = Math.max(0, halfH * 2);
|
|
66
|
+
if (curAlpha !== cellOpacity) {
|
|
67
|
+
ctx.globalAlpha = cellOpacity;
|
|
68
|
+
curAlpha = cellOpacity;
|
|
69
|
+
}
|
|
70
|
+
if (curFill !== fillStr) {
|
|
71
|
+
ctx.fillStyle = fillStr;
|
|
72
|
+
curFill = fillStr;
|
|
73
|
+
}
|
|
74
|
+
const drawsBorder = !!cellBorderColorStr || cell.isEmpty;
|
|
75
|
+
if (borderRadius > 0) {
|
|
76
|
+
const r = Math.min(borderRadius, cw / 2, ch / 2);
|
|
77
|
+
ctx.beginPath();
|
|
78
|
+
ctx.roundRect(left, top, cw, ch, r);
|
|
79
|
+
ctx.fill();
|
|
80
|
+
} else {
|
|
81
|
+
ctx.fillRect(left, top, cw, ch);
|
|
82
|
+
}
|
|
83
|
+
if (drawsBorder) {
|
|
84
|
+
ctx.strokeStyle = cellBorderColorStr ?? context.theme.heatEmpty;
|
|
85
|
+
ctx.lineWidth = effectiveBW;
|
|
86
|
+
ctx.setLineDash(cellBorderDash && cellBorderDash.length > 0 ? cellBorderDash : cell.isEmpty ? [2, 2] : []);
|
|
87
|
+
ctx.lineDashOffset = cellBorderDashOffset ?? 0;
|
|
88
|
+
if (borderRadius > 0) {
|
|
89
|
+
ctx.stroke();
|
|
90
|
+
} else {
|
|
91
|
+
ctx.strokeRect(left, top, cw, ch);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (showLabels && !cell.isEmpty) {
|
|
95
|
+
const info = getHeatmapLabelInfo(cell);
|
|
96
|
+
if (info.show) {
|
|
97
|
+
const cx = Math.round(cell.x + cell.width / 2);
|
|
98
|
+
const cy = cell.y + cell.height / 2;
|
|
99
|
+
const textColor = resolveLabelColor(cell) ?? getContrastColor(cell.color);
|
|
100
|
+
const midToAlpha = resolveLabelMidToAlpha(labelMidToAlpha, info.fontSize, fontFamily);
|
|
101
|
+
const finalY = Math.round(cy + midToAlpha);
|
|
102
|
+
ctx.globalAlpha = 1;
|
|
103
|
+
ctx.fillStyle = textColor;
|
|
104
|
+
ctx.font = `600 ${info.fontSize}px ${fontFamily}`;
|
|
105
|
+
ctx.textAlign = "center";
|
|
106
|
+
ctx.textBaseline = "alphabetic";
|
|
107
|
+
ctx.fillText(cell.label, cx, finalY);
|
|
108
|
+
curAlpha = 1;
|
|
109
|
+
curFill = textColor;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function renderCanvasHeatmapContent(ctx, layouts, getProps, onImageLoad) {
|
|
116
|
+
const drawImage = createDrawImage(ctx, onImageLoad ?? (() => {
|
|
117
|
+
}));
|
|
118
|
+
for (const [dsId, hmLayout] of layouts) {
|
|
119
|
+
const dsProps = getProps(dsId);
|
|
120
|
+
const renderFn = dsProps?.renderContent;
|
|
121
|
+
if (!renderFn || !dsProps?.data) continue;
|
|
122
|
+
for (const cell of hmLayout.cells) {
|
|
123
|
+
if (cell.isEmpty) continue;
|
|
124
|
+
const dataItem = dsProps.data[cell.index];
|
|
125
|
+
if (!dataItem) continue;
|
|
126
|
+
ctx.save();
|
|
127
|
+
ctx.beginPath();
|
|
128
|
+
ctx.rect(cell.x, cell.y, cell.width, cell.height);
|
|
129
|
+
ctx.clip();
|
|
130
|
+
renderFn({
|
|
131
|
+
data: dataItem,
|
|
132
|
+
index: cell.index,
|
|
133
|
+
value: cell.value,
|
|
134
|
+
xLabel: cell.xLabel,
|
|
135
|
+
yLabel: cell.yLabel,
|
|
136
|
+
color: cell.color,
|
|
137
|
+
x: cell.x,
|
|
138
|
+
y: cell.y,
|
|
139
|
+
width: cell.width,
|
|
140
|
+
height: cell.height,
|
|
141
|
+
row: cell.row,
|
|
142
|
+
col: cell.col,
|
|
143
|
+
isEmpty: cell.isEmpty,
|
|
144
|
+
ctx,
|
|
145
|
+
drawImage
|
|
146
|
+
});
|
|
147
|
+
ctx.restore();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { renderCanvasHeatmapContent, renderHeatmapCanvas };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { BASELINE_TO_CANVAS } from './chunk-66T4MRC5.mjs';
|
|
2
|
+
import { formatDataLabelText } from './chunk-OXTFAWSK.mjs';
|
|
3
|
+
import { svgAnchorToCanvasAlign } from './chunk-XTVE4P3L.mjs';
|
|
4
|
+
import { DEFAULT_LABEL_SPACING } from './chunk-NKUYIWAP.mjs';
|
|
5
|
+
import { makeItemContext, resolveAccessor } from './chunk-O2X6FF45.mjs';
|
|
6
|
+
import { toRad } from './chunk-RQ3CKQOX.mjs';
|
|
7
|
+
|
|
8
|
+
// src/radial/label.ts
|
|
9
|
+
function resolvePolarLabels(bars, datasetTotal, center, config, data) {
|
|
10
|
+
const labels = [];
|
|
11
|
+
const offset = DEFAULT_LABEL_SPACING;
|
|
12
|
+
for (const bar of bars) {
|
|
13
|
+
if (bar.outerRadius <= bar.innerRadius) continue;
|
|
14
|
+
const percentage = datasetTotal > 0 ? Math.abs(bar.value) / datasetTotal * 100 : 0;
|
|
15
|
+
if (config.minPercentage > 0 && percentage < config.minPercentage) continue;
|
|
16
|
+
const text = formatDataLabelText(bar.value, percentage, config.display, config.formatter);
|
|
17
|
+
if (!text) continue;
|
|
18
|
+
const midAngleDeg = (bar.startAngle + bar.endAngle) / 2;
|
|
19
|
+
const midAngleRad = toRad(midAngleDeg);
|
|
20
|
+
const labelRadius = bar.outerRadius + offset;
|
|
21
|
+
const x = center.x + Math.cos(midAngleRad) * labelRadius;
|
|
22
|
+
const y = center.y + Math.sin(midAngleRad) * labelRadius;
|
|
23
|
+
const cosA = Math.cos(midAngleRad);
|
|
24
|
+
const textAnchor = cosA > 0.15 ? "start" : cosA < -0.15 ? "end" : "middle";
|
|
25
|
+
const labelCtx = makeItemContext(data?.[bar.dataIndex], bar.dataIndex);
|
|
26
|
+
const perLabelFontSize = config.fontSizeAccessor ? resolveAccessor(config.fontSizeAccessor, labelCtx, { arrayMode: "cycle" }) : void 0;
|
|
27
|
+
const perLabelColorRaw = config.colorAccessor ? resolveAccessor(config.colorAccessor, labelCtx, { arrayMode: "cycle" }) : void 0;
|
|
28
|
+
const perLabelColor = typeof perLabelColorRaw === "string" ? perLabelColorRaw : void 0;
|
|
29
|
+
labels.push({
|
|
30
|
+
dataIndex: bar.dataIndex,
|
|
31
|
+
value: bar.value,
|
|
32
|
+
percentage,
|
|
33
|
+
text,
|
|
34
|
+
category: bar.category,
|
|
35
|
+
color: config.color ?? "",
|
|
36
|
+
x,
|
|
37
|
+
y,
|
|
38
|
+
textAnchor,
|
|
39
|
+
baseline: "central",
|
|
40
|
+
canvasTextAlign: svgAnchorToCanvasAlign(textAnchor),
|
|
41
|
+
canvasTextBaseline: BASELINE_TO_CANVAS["central"] ?? "middle",
|
|
42
|
+
fontSize: perLabelFontSize,
|
|
43
|
+
textColor: perLabelColor
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return labels;
|
|
47
|
+
}
|
|
48
|
+
function resolveRadarLabels(points, categories, seriesColor, datasetTotal, center, config, data) {
|
|
49
|
+
const labels = [];
|
|
50
|
+
const offset = DEFAULT_LABEL_SPACING;
|
|
51
|
+
for (const pt of points) {
|
|
52
|
+
if (pt.value == null || !isFinite(pt.x) || !isFinite(pt.y)) continue;
|
|
53
|
+
const percentage = datasetTotal > 0 ? Math.abs(pt.value) / datasetTotal * 100 : 0;
|
|
54
|
+
if (config.minPercentage > 0 && percentage < config.minPercentage) continue;
|
|
55
|
+
const text = formatDataLabelText(pt.value, percentage, config.display, config.formatter);
|
|
56
|
+
if (!text) continue;
|
|
57
|
+
const dx = pt.x - center.x;
|
|
58
|
+
const dy = pt.y - center.y;
|
|
59
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
60
|
+
const nx = dist > 0 ? dx / dist : 0;
|
|
61
|
+
const ny = dist > 0 ? dy / dist : -1;
|
|
62
|
+
const x = pt.x + nx * offset;
|
|
63
|
+
const y = pt.y + ny * offset;
|
|
64
|
+
const textAnchor = nx > 0.15 ? "start" : nx < -0.15 ? "end" : "middle";
|
|
65
|
+
const baseline = ny > 0.15 ? "hanging" : ny < -0.15 ? "auto" : "central";
|
|
66
|
+
const labelCtx = makeItemContext(data?.[pt.categoryIndex], pt.categoryIndex);
|
|
67
|
+
const perLabelFontSize = config.fontSizeAccessor ? resolveAccessor(config.fontSizeAccessor, labelCtx, { arrayMode: "cycle" }) : void 0;
|
|
68
|
+
const perLabelColorRaw = config.colorAccessor ? resolveAccessor(config.colorAccessor, labelCtx, { arrayMode: "cycle" }) : void 0;
|
|
69
|
+
const perLabelColor = typeof perLabelColorRaw === "string" ? perLabelColorRaw : void 0;
|
|
70
|
+
labels.push({
|
|
71
|
+
dataIndex: pt.categoryIndex,
|
|
72
|
+
value: pt.value,
|
|
73
|
+
percentage,
|
|
74
|
+
text,
|
|
75
|
+
category: categories[pt.categoryIndex] ?? "",
|
|
76
|
+
color: seriesColor,
|
|
77
|
+
x,
|
|
78
|
+
y,
|
|
79
|
+
textAnchor,
|
|
80
|
+
baseline,
|
|
81
|
+
canvasTextAlign: svgAnchorToCanvasAlign(textAnchor),
|
|
82
|
+
canvasTextBaseline: BASELINE_TO_CANVAS[baseline] ?? "middle",
|
|
83
|
+
fontSize: perLabelFontSize,
|
|
84
|
+
textColor: perLabelColor
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return labels;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { resolvePolarLabels, resolveRadarLabels };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { clamp } from './chunk-RQ3CKQOX.mjs';
|
|
2
|
+
|
|
3
|
+
// src/utils/layout/borderRadius.utils.ts
|
|
4
|
+
function resolveBorderRadius(borderRadius) {
|
|
5
|
+
if (borderRadius === void 0 || borderRadius === 0) {
|
|
6
|
+
return { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 };
|
|
7
|
+
}
|
|
8
|
+
if (typeof borderRadius === "number") {
|
|
9
|
+
return {
|
|
10
|
+
topLeft: borderRadius,
|
|
11
|
+
topRight: borderRadius,
|
|
12
|
+
bottomLeft: borderRadius,
|
|
13
|
+
bottomRight: borderRadius
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const config = borderRadius;
|
|
17
|
+
return {
|
|
18
|
+
topLeft: config.topLeft ?? 0,
|
|
19
|
+
topRight: config.topRight ?? 0,
|
|
20
|
+
bottomLeft: config.bottomLeft ?? 0,
|
|
21
|
+
bottomRight: config.bottomRight ?? 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function hasBorderRadius(radius) {
|
|
25
|
+
return radius.topLeft > 0 || radius.topRight > 0 || radius.bottomLeft > 0 || radius.bottomRight > 0;
|
|
26
|
+
}
|
|
27
|
+
function isUniformBorderRadius(radius) {
|
|
28
|
+
return radius.topLeft === radius.topRight && radius.topRight === radius.bottomLeft && radius.bottomLeft === radius.bottomRight;
|
|
29
|
+
}
|
|
30
|
+
function clampRectBorderRadius(radius, width, height) {
|
|
31
|
+
const maxHorizontal = width / 2;
|
|
32
|
+
const maxVertical = height / 2;
|
|
33
|
+
return {
|
|
34
|
+
topLeft: Math.min(radius.topLeft, maxHorizontal, maxVertical),
|
|
35
|
+
topRight: Math.min(radius.topRight, maxHorizontal, maxVertical),
|
|
36
|
+
bottomLeft: Math.min(radius.bottomLeft, maxHorizontal, maxVertical),
|
|
37
|
+
bottomRight: Math.min(radius.bottomRight, maxHorizontal, maxVertical)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveArcBorderRadius(borderRadius) {
|
|
41
|
+
const resolved = resolveBorderRadius(borderRadius);
|
|
42
|
+
return {
|
|
43
|
+
outerStart: resolved.topLeft,
|
|
44
|
+
outerEnd: resolved.topRight,
|
|
45
|
+
innerStart: resolved.bottomLeft,
|
|
46
|
+
innerEnd: resolved.bottomRight
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function hasArcBorderRadius(radius) {
|
|
50
|
+
return radius.outerStart > 0 || radius.outerEnd > 0 || radius.innerStart > 0 || radius.innerEnd > 0;
|
|
51
|
+
}
|
|
52
|
+
function clampArcBorderRadius(borderRadius, innerRadius, outerRadius, angleDelta) {
|
|
53
|
+
const resolved = resolveArcBorderRadius(borderRadius);
|
|
54
|
+
if (outerRadius <= innerRadius || angleDelta <= 0) {
|
|
55
|
+
return { outerStart: 0, outerEnd: 0, innerStart: 0, innerEnd: 0 };
|
|
56
|
+
}
|
|
57
|
+
const halfThickness = (outerRadius - innerRadius) / 2;
|
|
58
|
+
const innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);
|
|
59
|
+
const computeOuterLimit = (val) => {
|
|
60
|
+
const outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2;
|
|
61
|
+
return clamp(val, 0, Math.min(halfThickness, outerArcLimit));
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
outerStart: computeOuterLimit(resolved.outerStart),
|
|
65
|
+
outerEnd: computeOuterLimit(resolved.outerEnd),
|
|
66
|
+
innerStart: clamp(resolved.innerStart, 0, innerLimit),
|
|
67
|
+
innerEnd: clamp(resolved.innerEnd, 0, innerLimit)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { clampArcBorderRadius, clampRectBorderRadius, hasArcBorderRadius, hasBorderRadius, isUniformBorderRadius, resolveArcBorderRadius, resolveBorderRadius };
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { lerpColor } from './chunk-QS76E3TD.mjs';
|
|
2
|
+
|
|
3
|
+
// src/animations/animated-element.ts
|
|
4
|
+
function lerpNumber(from, to, t) {
|
|
5
|
+
return from + (to - from) * t;
|
|
6
|
+
}
|
|
7
|
+
var AnimatedElement = class {
|
|
8
|
+
constructor(id, initial, registry) {
|
|
9
|
+
this.phase = "idle";
|
|
10
|
+
this.tweens = /* @__PURE__ */ new Map();
|
|
11
|
+
this.overrides = /* @__PURE__ */ new Set();
|
|
12
|
+
/** Most recent PerGroupOptions — retained so releaseOverride can restart tweens. */
|
|
13
|
+
this._lastOpts = null;
|
|
14
|
+
/** Set to true when exit() completes, signalling scene to remove this element. */
|
|
15
|
+
this._readyForRemoval = false;
|
|
16
|
+
this.id = id;
|
|
17
|
+
this.current = { ...initial };
|
|
18
|
+
this.target = { ...initial };
|
|
19
|
+
this.registry = registry;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Target-write path. For each changed field in newTarget:
|
|
23
|
+
* - if overridden: target is updated but no tween starts
|
|
24
|
+
* - otherwise: tween captures current[field] as start, animates over the group's duration
|
|
25
|
+
*/
|
|
26
|
+
setTarget(newTarget, opts) {
|
|
27
|
+
this._lastOpts = opts;
|
|
28
|
+
for (const key of Object.keys(newTarget)) {
|
|
29
|
+
const newValue = newTarget[key];
|
|
30
|
+
const hadTween = this.tweens.has(key);
|
|
31
|
+
this.target[key] = newValue;
|
|
32
|
+
if (this.overrides.has(key)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const currentValue = this.current[key];
|
|
36
|
+
if (Object.is(currentValue, newValue)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const groupOpts = this._groupOptsFor(key, opts);
|
|
40
|
+
if (!groupOpts || groupOpts.duration <= 0) {
|
|
41
|
+
if (hadTween && this.phase === "enter") continue;
|
|
42
|
+
this.current[key] = newValue;
|
|
43
|
+
this.tweens.delete(key);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const startValue = this.current[key];
|
|
47
|
+
const customFn = this.registry.custom?.[key];
|
|
48
|
+
const isColor = this.registry.color.includes(key);
|
|
49
|
+
const interpolator = customFn ?? (isColor ? lerpColor : lerpNumber);
|
|
50
|
+
this.tweens.set(key, {
|
|
51
|
+
start: startValue,
|
|
52
|
+
startTime: -1,
|
|
53
|
+
// set on first tick
|
|
54
|
+
duration: groupOpts.duration,
|
|
55
|
+
easing: groupOpts.easing,
|
|
56
|
+
interpolator
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (this.tweens.size > 0 && this.phase === "idle") {
|
|
60
|
+
this.phase = "update";
|
|
61
|
+
} else if (this.tweens.size === 0 && this.phase !== "idle") {
|
|
62
|
+
if (this.phase === "exit") this._readyForRemoval = true;
|
|
63
|
+
this.phase = "idle";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Direct-write path for explicit looping animations. */
|
|
67
|
+
overrideCurrent(prop, value) {
|
|
68
|
+
this.current[prop] = value;
|
|
69
|
+
this.overrides.add(prop);
|
|
70
|
+
this.tweens.delete(prop);
|
|
71
|
+
}
|
|
72
|
+
/** Release the override; tween (if any) resumes toward latest target. */
|
|
73
|
+
releaseOverride(prop) {
|
|
74
|
+
if (!this.overrides.has(prop)) return;
|
|
75
|
+
this.overrides.delete(prop);
|
|
76
|
+
if (this._lastOpts) {
|
|
77
|
+
const groupOpts = this._groupOptsFor(prop, this._lastOpts);
|
|
78
|
+
if (groupOpts && groupOpts.duration > 0) {
|
|
79
|
+
const startValue = this.current[prop];
|
|
80
|
+
const customFn = this.registry.custom?.[prop];
|
|
81
|
+
const isColor = this.registry.color.includes(prop);
|
|
82
|
+
const interpolator = customFn ?? (isColor ? lerpColor : lerpNumber);
|
|
83
|
+
this.tweens.set(prop, {
|
|
84
|
+
start: startValue,
|
|
85
|
+
startTime: -1,
|
|
86
|
+
duration: groupOpts.duration,
|
|
87
|
+
easing: groupOpts.easing,
|
|
88
|
+
interpolator
|
|
89
|
+
});
|
|
90
|
+
if (this.phase === "idle") {
|
|
91
|
+
this.phase = "update";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Enter animation: emptyState → target. */
|
|
97
|
+
enter(target, emptyState, opts) {
|
|
98
|
+
this.current = { ...emptyState };
|
|
99
|
+
this.target = { ...emptyState };
|
|
100
|
+
this.phase = "enter";
|
|
101
|
+
this.setTarget(target, opts);
|
|
102
|
+
if (this.tweens.size === 0) {
|
|
103
|
+
this.current = { ...target };
|
|
104
|
+
this.phase = "idle";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Exit animation: current → emptyState. After tick completes, marks ready for removal. */
|
|
108
|
+
exit(emptyState, opts) {
|
|
109
|
+
this.phase = "exit";
|
|
110
|
+
this.setTarget(emptyState, opts);
|
|
111
|
+
if (this.tweens.size === 0) {
|
|
112
|
+
this.current = { ...emptyState };
|
|
113
|
+
this._readyForRemoval = true;
|
|
114
|
+
this.phase = "idle";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Advance one frame. Returns true if any property is still tweening. */
|
|
118
|
+
tick(now) {
|
|
119
|
+
if (this.tweens.size === 0) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const completed = [];
|
|
123
|
+
for (const [key, tween] of this.tweens) {
|
|
124
|
+
if (this.overrides.has(key)) {
|
|
125
|
+
completed.push(key);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (tween.startTime === -1) {
|
|
129
|
+
tween.startTime = now;
|
|
130
|
+
}
|
|
131
|
+
const elapsed = now - tween.startTime;
|
|
132
|
+
const rawProgress = Math.max(0, Math.min(1, elapsed / tween.duration));
|
|
133
|
+
const easedProgress = tween.easing(rawProgress);
|
|
134
|
+
const targetValue = this.target[key];
|
|
135
|
+
const interpolated = tween.interpolator(tween.start, targetValue, easedProgress);
|
|
136
|
+
this.current[key] = interpolated;
|
|
137
|
+
if (rawProgress >= 1) {
|
|
138
|
+
completed.push(key);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
for (const key of completed) {
|
|
142
|
+
this.tweens.delete(key);
|
|
143
|
+
}
|
|
144
|
+
if (this.tweens.size === 0) {
|
|
145
|
+
if (this.phase === "exit") {
|
|
146
|
+
this._readyForRemoval = true;
|
|
147
|
+
}
|
|
148
|
+
this.phase = "idle";
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
/** True if exit() has completed and this element should be removed from the scene. */
|
|
154
|
+
isReadyForRemoval() {
|
|
155
|
+
return this._readyForRemoval;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Cancel an in-progress exit. Called by AnimatedScene when an exit-phase element
|
|
159
|
+
* reappears in targets (e.g. quick legend toggle off → on).
|
|
160
|
+
*/
|
|
161
|
+
resurrect() {
|
|
162
|
+
this._readyForRemoval = false;
|
|
163
|
+
if (this.phase === "exit") {
|
|
164
|
+
this.phase = "update";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
_groupOptsFor(key, opts) {
|
|
168
|
+
const hasCustom = this.registry.custom?.[key] != null;
|
|
169
|
+
if (hasCustom) {
|
|
170
|
+
return opts.numbers ?? null;
|
|
171
|
+
}
|
|
172
|
+
const isColor = this.registry.color.includes(key);
|
|
173
|
+
if (isColor) {
|
|
174
|
+
return opts.colors ?? null;
|
|
175
|
+
}
|
|
176
|
+
const isNumber = this.registry.number.includes(key);
|
|
177
|
+
if (isNumber) {
|
|
178
|
+
return opts.numbers ?? null;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/animations/animated-scene.ts
|
|
185
|
+
var NO_OPTS = { easing: (t) => t };
|
|
186
|
+
var AnimatedScene = class {
|
|
187
|
+
constructor(opts) {
|
|
188
|
+
this.elements = /* @__PURE__ */ new Map();
|
|
189
|
+
this.activeElements = /* @__PURE__ */ new Set();
|
|
190
|
+
this.emptyState = opts.emptyState;
|
|
191
|
+
this.exitEmptyState = opts.exitEmptyState ?? opts.emptyState;
|
|
192
|
+
this.registry = opts.registry;
|
|
193
|
+
const respectReducedMotion = opts.respectReducedMotion ?? true;
|
|
194
|
+
this.reducedMotion = respectReducedMotion && typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* D3-style data join. For each id in `targets`:
|
|
198
|
+
* - not in scene → create element, enter from emptyState
|
|
199
|
+
* - already in scene → setTarget (interrupts any in-flight tween)
|
|
200
|
+
* For each id in scene but not in targets:
|
|
201
|
+
* - exit toward emptyState; pruned by tick() after completion
|
|
202
|
+
*/
|
|
203
|
+
diff(targets, opts) {
|
|
204
|
+
const effectiveOpts = this.reducedMotion ? this._zeroDurationOpts(opts) : opts;
|
|
205
|
+
for (const [id, target] of targets) {
|
|
206
|
+
const existing = this.elements.get(id);
|
|
207
|
+
if (existing) {
|
|
208
|
+
if (existing.phase === "exit") existing.resurrect();
|
|
209
|
+
existing.setTarget(target, effectiveOpts);
|
|
210
|
+
this.activeElements.add(existing);
|
|
211
|
+
} else {
|
|
212
|
+
const empty = this.emptyState(target);
|
|
213
|
+
const el = new AnimatedElement(id, empty, this.registry);
|
|
214
|
+
el.enter(target, empty, effectiveOpts);
|
|
215
|
+
this.elements.set(id, el);
|
|
216
|
+
this.activeElements.add(el);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
for (const [id, el] of this.elements) {
|
|
220
|
+
if (targets.has(id)) continue;
|
|
221
|
+
if (el.phase === "exit") continue;
|
|
222
|
+
const empty = this.exitEmptyState(el.target);
|
|
223
|
+
el.exit(empty, effectiveOpts);
|
|
224
|
+
this.activeElements.add(el);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Advance all active elements one frame. Auto-removes elements whose
|
|
229
|
+
* exit animation has completed.
|
|
230
|
+
*/
|
|
231
|
+
tick(now) {
|
|
232
|
+
const toDeactivate = [];
|
|
233
|
+
const toRemove = [];
|
|
234
|
+
for (const el of this.activeElements) {
|
|
235
|
+
const stillAnimating = el.tick(now);
|
|
236
|
+
if (!stillAnimating) {
|
|
237
|
+
toDeactivate.push(el);
|
|
238
|
+
}
|
|
239
|
+
if (el.isReadyForRemoval()) {
|
|
240
|
+
toRemove.push(el);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
for (const el of toDeactivate) {
|
|
244
|
+
this.activeElements.delete(el);
|
|
245
|
+
}
|
|
246
|
+
for (const el of toRemove) {
|
|
247
|
+
this.elements.delete(el.id);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
allIdle: this.activeElements.size === 0
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
getElements() {
|
|
254
|
+
return Array.from(this.elements.values());
|
|
255
|
+
}
|
|
256
|
+
getElement(id) {
|
|
257
|
+
return this.elements.get(id);
|
|
258
|
+
}
|
|
259
|
+
/** Clear all elements. Used by StrictMode reset / unmount. */
|
|
260
|
+
reset() {
|
|
261
|
+
this.elements.clear();
|
|
262
|
+
this.activeElements.clear();
|
|
263
|
+
}
|
|
264
|
+
_zeroDurationOpts(opts) {
|
|
265
|
+
return {
|
|
266
|
+
numbers: { duration: 0, easing: opts.numbers?.easing ?? NO_OPTS.easing },
|
|
267
|
+
colors: { duration: 0, easing: opts.colors?.easing ?? NO_OPTS.easing }
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// src/animations/property-animations.ts
|
|
273
|
+
var LINE_ANIMATABLE_PROPS = {
|
|
274
|
+
number: ["tension", "lineStrokeWidth", "markerSize", "fillOpacity", "lineDashOffset", "opacity"],
|
|
275
|
+
color: []
|
|
276
|
+
};
|
|
277
|
+
var BAR_ANIMATABLE_PROPS = {
|
|
278
|
+
number: ["opacity", "borderStrokeWidth", "borderRadius"],
|
|
279
|
+
color: []
|
|
280
|
+
};
|
|
281
|
+
var PIE_ANIMATABLE_PROPS = {
|
|
282
|
+
number: ["innerRadius", "outerRadius", "startAngle", "endAngle", "spacing", "cornerRadius", "offset", "opacity", "borderStrokeWidth"],
|
|
283
|
+
color: []
|
|
284
|
+
};
|
|
285
|
+
var POLAR_ANIMATABLE_PROPS = {
|
|
286
|
+
number: ["innerRadius", "outerRadius", "valueRadius", "startAngle", "endAngle", "spacing", "opacity", "borderStrokeWidth"],
|
|
287
|
+
color: []
|
|
288
|
+
};
|
|
289
|
+
var RADAR_ANIMATABLE_PROPS = {
|
|
290
|
+
number: ["tension", "lineStrokeWidth", "markerSize", "fillOpacity", "lineDashOffset", "opacity", "borderStrokeWidth"],
|
|
291
|
+
color: []
|
|
292
|
+
};
|
|
293
|
+
var SCATTER_ANIMATABLE_PROPS = {
|
|
294
|
+
number: ["markerSize", "borderStrokeWidth", "opacity", "rotation"],
|
|
295
|
+
color: []
|
|
296
|
+
};
|
|
297
|
+
var HEATMAP_ANIMATABLE_PROPS = {
|
|
298
|
+
number: ["opacity", "borderStrokeWidth"],
|
|
299
|
+
color: []
|
|
300
|
+
};
|
|
301
|
+
var CANDLESTICK_ANIMATABLE_PROPS = {
|
|
302
|
+
number: ["opacity", "borderStrokeWidth", "wickStrokeWidth"],
|
|
303
|
+
color: []
|
|
304
|
+
};
|
|
305
|
+
var TREEMAP_ANIMATABLE_PROPS = {
|
|
306
|
+
number: ["opacity", "borderStrokeWidth"],
|
|
307
|
+
color: []
|
|
308
|
+
};
|
|
309
|
+
function setupPropertyAnimations(configs, registry, store, onPropertyComplete) {
|
|
310
|
+
const cleanups = configs.map((config) => {
|
|
311
|
+
const storeKey = config.datasetId ? `${config.datasetId}:${config.property}` : config.chartType ? `${config.chartType}:${config.property}` : config.property;
|
|
312
|
+
return registry.register({
|
|
313
|
+
id: `prop:${storeKey}`,
|
|
314
|
+
key: config.property,
|
|
315
|
+
from: config.from,
|
|
316
|
+
to: config.to,
|
|
317
|
+
duration: config.duration,
|
|
318
|
+
easing: config.easing,
|
|
319
|
+
loops: config.loop ? Infinity : 1,
|
|
320
|
+
alternate: config.alternate,
|
|
321
|
+
delay: config.delay,
|
|
322
|
+
onTick: (value) => {
|
|
323
|
+
store.set(storeKey, value);
|
|
324
|
+
},
|
|
325
|
+
onComplete: () => {
|
|
326
|
+
store.delete(storeKey);
|
|
327
|
+
onPropertyComplete?.(storeKey);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
return () => cleanups.forEach((fn) => fn());
|
|
332
|
+
}
|
|
333
|
+
function resolveAnimatedProps(store, chartType, datasetId, registry) {
|
|
334
|
+
const properties = Array.isArray(registry) ? registry : [...registry.number, ...registry.color];
|
|
335
|
+
const overrides = {};
|
|
336
|
+
for (const prop of properties) {
|
|
337
|
+
const value = store.get(`${datasetId}:${prop}`) ?? store.get(`${chartType}:${prop}`) ?? store.get(prop);
|
|
338
|
+
if (value !== void 0) overrides[prop] = value;
|
|
339
|
+
}
|
|
340
|
+
return overrides;
|
|
341
|
+
}
|
|
342
|
+
function normalizeAnimationsMap(map, scope = {}) {
|
|
343
|
+
if (!map) return [];
|
|
344
|
+
const out = [];
|
|
345
|
+
for (const entry of Object.values(map)) {
|
|
346
|
+
for (const property of entry.properties) {
|
|
347
|
+
out.push({
|
|
348
|
+
property,
|
|
349
|
+
...scope.datasetId ? { datasetId: scope.datasetId } : {},
|
|
350
|
+
...scope.chartType ? { chartType: scope.chartType } : {},
|
|
351
|
+
from: entry.from,
|
|
352
|
+
to: entry.to,
|
|
353
|
+
duration: entry.duration ?? 0,
|
|
354
|
+
easing: entry.easing,
|
|
355
|
+
loop: entry.loop,
|
|
356
|
+
alternate: entry.alternate,
|
|
357
|
+
delay: entry.delay
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export { AnimatedElement, AnimatedScene, BAR_ANIMATABLE_PROPS, CANDLESTICK_ANIMATABLE_PROPS, HEATMAP_ANIMATABLE_PROPS, LINE_ANIMATABLE_PROPS, PIE_ANIMATABLE_PROPS, POLAR_ANIMATABLE_PROPS, RADAR_ANIMATABLE_PROPS, SCATTER_ANIMATABLE_PROPS, TREEMAP_ANIMATABLE_PROPS, normalizeAnimationsMap, resolveAnimatedProps, setupPropertyAnimations };
|