@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,413 @@
|
|
|
1
|
+
import { normalizePadding } from './chunk-NPDZLYIF.mjs';
|
|
2
|
+
import { DEFAULT_NAV_GRIP_LINE_GAP, DEFAULT_NAV_HANDLE_WIDTH, DEFAULT_NAV_MIN_SELECTION_WIDTH, DEFAULT_NAV_STYLE, DEFAULT_NAV_PADDING_X, DEFAULT_NAV_PADDING_Y } from './chunk-NKUYIWAP.mjs';
|
|
3
|
+
import { defaultLightTheme, batchResolveAccessor, FIELD_DEFAULTS } from './chunk-O2X6FF45.mjs';
|
|
4
|
+
import { toTimestamp, createLinearScale, generateNiceTicks, generateTimeTicks, formatTimeTick } from './chunk-RQ3CKQOX.mjs';
|
|
5
|
+
|
|
6
|
+
// src/renderers/navigator/geometry.ts
|
|
7
|
+
var NAV_PADDING_Y = DEFAULT_NAV_PADDING_Y;
|
|
8
|
+
var NAV_PADDING_X = DEFAULT_NAV_PADDING_X;
|
|
9
|
+
var MIN_SELECTION_WIDTH = DEFAULT_NAV_MIN_SELECTION_WIDTH;
|
|
10
|
+
var HANDLE_WIDTH = DEFAULT_NAV_HANDLE_WIDTH;
|
|
11
|
+
var GRIP_LINE_GAP = DEFAULT_NAV_GRIP_LINE_GAP;
|
|
12
|
+
var NAV_DEFAULTS = DEFAULT_NAV_STYLE;
|
|
13
|
+
function resolveNavigatorConfig(config, theme = defaultLightTheme) {
|
|
14
|
+
const padding = normalizePadding(config.padding ?? { top: DEFAULT_NAV_PADDING_Y, right: DEFAULT_NAV_PADDING_X, bottom: DEFAULT_NAV_PADDING_Y, left: DEFAULT_NAV_PADDING_X });
|
|
15
|
+
let animation;
|
|
16
|
+
if (config.animation === false) {
|
|
17
|
+
animation = false;
|
|
18
|
+
} else if (config.animation === true || config.animation === void 0) {
|
|
19
|
+
animation = { duration: 200, easing: "easeOutCubic" };
|
|
20
|
+
} else {
|
|
21
|
+
animation = {
|
|
22
|
+
duration: config.animation.duration ?? 200,
|
|
23
|
+
easing: config.animation.easing ?? "easeOutCubic"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
height: config.height ?? NAV_DEFAULTS.height,
|
|
28
|
+
gap: config.gap ?? NAV_DEFAULTS.gap,
|
|
29
|
+
color: config.color ?? theme.navigatorSeries,
|
|
30
|
+
opacity: config.opacity ?? NAV_DEFAULTS.opacity,
|
|
31
|
+
selectionColor: config.selectionColor ?? theme.navigatorSelectionColor,
|
|
32
|
+
selectionFill: config.selectionFill ?? theme.navigatorSelectionFill,
|
|
33
|
+
maskColor: config.maskColor ?? theme.navigatorMask,
|
|
34
|
+
backgroundColor: config.backgroundColor ?? theme.bandFill,
|
|
35
|
+
gridColor: config.gridColor ?? theme.grid,
|
|
36
|
+
labelColor: config.labelColor ?? theme.tickLabel,
|
|
37
|
+
handleWidth: config.handleWidth ?? DEFAULT_NAV_HANDLE_WIDTH,
|
|
38
|
+
gripLineGap: config.gripLineGap ?? DEFAULT_NAV_GRIP_LINE_GAP,
|
|
39
|
+
padding,
|
|
40
|
+
series: config.series,
|
|
41
|
+
animation
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function extractNavigatorData(datasets, targetSeriesId, isTimeAxis) {
|
|
45
|
+
let targetDs;
|
|
46
|
+
if (targetSeriesId) {
|
|
47
|
+
targetDs = datasets.get(targetSeriesId);
|
|
48
|
+
} else {
|
|
49
|
+
for (const ds of datasets.values()) {
|
|
50
|
+
if (ds.type === "candlestick" || ds.type === "line" || ds.type === "bar" || ds.type === "scatter") {
|
|
51
|
+
targetDs = ds;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!targetDs) return null;
|
|
57
|
+
const props = targetDs.props;
|
|
58
|
+
const data = props.data;
|
|
59
|
+
if (!data?.length) return null;
|
|
60
|
+
let xValues;
|
|
61
|
+
let yValues;
|
|
62
|
+
let isCategoryAxis = false;
|
|
63
|
+
let isNumericAxis = false;
|
|
64
|
+
let catLabels;
|
|
65
|
+
if (targetDs.type === "candlestick") {
|
|
66
|
+
const cp = props;
|
|
67
|
+
const rawTimeValues = batchResolveAccessor(cp.timeField, data);
|
|
68
|
+
if (isTimeAxis) {
|
|
69
|
+
xValues = rawTimeValues.map((v) => toTimestamp(v));
|
|
70
|
+
} else {
|
|
71
|
+
isCategoryAxis = true;
|
|
72
|
+
catLabels = rawTimeValues.map((v) => String(v ?? ""));
|
|
73
|
+
xValues = rawTimeValues.map((_, i) => i);
|
|
74
|
+
}
|
|
75
|
+
yValues = batchResolveAccessor(cp.closeField, data);
|
|
76
|
+
} else if (targetDs.type === "scatter") {
|
|
77
|
+
const xField = props.xField ?? props.x ?? FIELD_DEFAULTS.xField;
|
|
78
|
+
const yField = props.yField ?? props.y ?? FIELD_DEFAULTS.yField;
|
|
79
|
+
xValues = batchResolveAccessor(xField, data);
|
|
80
|
+
yValues = batchResolveAccessor(yField, data);
|
|
81
|
+
isCategoryAxis = false;
|
|
82
|
+
isNumericAxis = true;
|
|
83
|
+
} else {
|
|
84
|
+
const catField = props.time ?? props.timeField ?? props.categoryField ?? props.category ?? FIELD_DEFAULTS.categoryField;
|
|
85
|
+
const valField = props.valueField ?? props.value ?? FIELD_DEFAULTS.valueField;
|
|
86
|
+
const rawXValues = batchResolveAccessor(catField, data);
|
|
87
|
+
if (isTimeAxis) {
|
|
88
|
+
xValues = rawXValues.map((v) => toTimestamp(v));
|
|
89
|
+
} else {
|
|
90
|
+
isCategoryAxis = true;
|
|
91
|
+
catLabels = rawXValues.map((v) => String(v ?? ""));
|
|
92
|
+
xValues = rawXValues.map((_, i) => i);
|
|
93
|
+
}
|
|
94
|
+
yValues = batchResolveAccessor(valField, data);
|
|
95
|
+
}
|
|
96
|
+
const points = [];
|
|
97
|
+
for (let i = 0; i < xValues.length; i++) {
|
|
98
|
+
const x = xValues[i];
|
|
99
|
+
const y = yValues[i];
|
|
100
|
+
if (!isNaN(x) && y != null && !isNaN(y)) {
|
|
101
|
+
points.push({ x, y });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
points.sort((a, b) => a.x - b.x);
|
|
105
|
+
if (points.length === 0) return null;
|
|
106
|
+
const xDomain = [points[0].x, points[points.length - 1].x];
|
|
107
|
+
let yMin = Infinity;
|
|
108
|
+
let yMax = -Infinity;
|
|
109
|
+
for (const p of points) {
|
|
110
|
+
if (p.y < yMin) yMin = p.y;
|
|
111
|
+
if (p.y > yMax) yMax = p.y;
|
|
112
|
+
}
|
|
113
|
+
if (yMin === yMax) {
|
|
114
|
+
yMin -= 1;
|
|
115
|
+
yMax += 1;
|
|
116
|
+
}
|
|
117
|
+
return { points, xDomain, yDomain: [yMin, yMax], isCategory: isCategoryAxis, categoryLabels: catLabels, isNumericAxis, sourceType: targetDs.type };
|
|
118
|
+
}
|
|
119
|
+
function createNavigatorScales(data, width, height, padding) {
|
|
120
|
+
const px = padding?.left ?? NAV_PADDING_X;
|
|
121
|
+
const pxRight = padding?.right ?? NAV_PADDING_X;
|
|
122
|
+
const py = padding?.top ?? NAV_PADDING_Y;
|
|
123
|
+
return {
|
|
124
|
+
x: createLinearScale(data.xDomain, [px, width - pxRight]),
|
|
125
|
+
y: createLinearScale(data.yDomain, [height, py])
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function buildNavigatorPaths(points, scales, height, sourceType) {
|
|
129
|
+
if (points.length === 0) return { linePath: "", areaPath: "" };
|
|
130
|
+
if (sourceType === "scatter") {
|
|
131
|
+
const dots = points.map((p) => ({
|
|
132
|
+
px: scales.x(p.x),
|
|
133
|
+
py: scales.y(p.y)
|
|
134
|
+
}));
|
|
135
|
+
return { linePath: "", areaPath: "", dots };
|
|
136
|
+
}
|
|
137
|
+
if (sourceType === "bar") {
|
|
138
|
+
const barCount = points.length;
|
|
139
|
+
const totalWidth = scales.x(points[points.length - 1].x) - scales.x(points[0].x);
|
|
140
|
+
const barWidth = Math.max(1, totalWidth / barCount * 0.8);
|
|
141
|
+
const bars = points.map((p) => {
|
|
142
|
+
const px = scales.x(p.x) - barWidth / 2;
|
|
143
|
+
const py = scales.y(p.y);
|
|
144
|
+
return { px, width: barWidth, py, height: height - py };
|
|
145
|
+
});
|
|
146
|
+
return { linePath: "", areaPath: "", bars };
|
|
147
|
+
}
|
|
148
|
+
const baseline = height;
|
|
149
|
+
let linePath = "";
|
|
150
|
+
let areaPath = "";
|
|
151
|
+
for (let i = 0; i < points.length; i++) {
|
|
152
|
+
const px = scales.x(points[i].x);
|
|
153
|
+
const py = scales.y(points[i].y);
|
|
154
|
+
const cmd = i === 0 ? "M" : "L";
|
|
155
|
+
linePath += `${cmd}${px},${py}`;
|
|
156
|
+
areaPath += `${cmd}${px},${py}`;
|
|
157
|
+
}
|
|
158
|
+
const lastX = scales.x(points[points.length - 1].x);
|
|
159
|
+
const firstX = scales.x(points[0].x);
|
|
160
|
+
areaPath += `L${lastX},${baseline}L${firstX},${baseline}Z`;
|
|
161
|
+
return { linePath, areaPath };
|
|
162
|
+
}
|
|
163
|
+
function computeNavigatorTicks(xDomain, xScale, width, locale, categoryLabels, isNumericAxis, tickFormat) {
|
|
164
|
+
if (width <= 0 || xDomain[1] <= xDomain[0]) return [];
|
|
165
|
+
if (categoryLabels && categoryLabels.length > 0) {
|
|
166
|
+
const totalCats = categoryLabels.length;
|
|
167
|
+
const formatter = typeof tickFormat === "function" ? tickFormat : void 0;
|
|
168
|
+
const maxTicks = Math.floor(width / 120);
|
|
169
|
+
const step = Math.max(1, Math.ceil(totalCats / maxTicks));
|
|
170
|
+
const ticks2 = [];
|
|
171
|
+
for (let i = 0; i < totalCats; i += step) {
|
|
172
|
+
const raw = categoryLabels[i];
|
|
173
|
+
ticks2.push({ px: xScale(i), label: formatter ? formatter(raw, i) : raw });
|
|
174
|
+
}
|
|
175
|
+
return ticks2;
|
|
176
|
+
}
|
|
177
|
+
if (isNumericAxis) {
|
|
178
|
+
const tickCount = Math.max(2, Math.floor(width / 120));
|
|
179
|
+
const tickValues = generateNiceTicks(xDomain[0], xDomain[1], tickCount);
|
|
180
|
+
return tickValues.map((v) => ({
|
|
181
|
+
px: xScale(v),
|
|
182
|
+
label: String(v)
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
const { ticks, interval } = generateTimeTicks(xDomain[0], xDomain[1], width, {
|
|
186
|
+
minTickSpacing: 120
|
|
187
|
+
});
|
|
188
|
+
return ticks.map((ts) => ({
|
|
189
|
+
px: xScale(ts),
|
|
190
|
+
label: formatTimeTick(ts, interval.unit, void 0, void 0, locale)
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
function computeNavigatorSelection(zoomState, xScale, width, yScale, height) {
|
|
194
|
+
if (!xScale || !zoomState.x) {
|
|
195
|
+
return { x: 0, width, isZoomed: false };
|
|
196
|
+
}
|
|
197
|
+
const minW = Math.min(MIN_SELECTION_WIDTH, width);
|
|
198
|
+
const rawLeft = Math.max(0, xScale(zoomState.x.min));
|
|
199
|
+
const rawRight = Math.min(width, xScale(zoomState.x.max));
|
|
200
|
+
const selW = Math.max(rawRight - rawLeft, minW);
|
|
201
|
+
const selX = Math.min(rawLeft, Math.max(0, width - selW));
|
|
202
|
+
if (yScale && height != null && zoomState.y) {
|
|
203
|
+
const minH = Math.min(MIN_SELECTION_WIDTH, height);
|
|
204
|
+
const rawTop = Math.max(0, yScale(zoomState.y.max));
|
|
205
|
+
const rawBottom = Math.min(height, yScale(zoomState.y.min));
|
|
206
|
+
const selH = Math.max(rawBottom - rawTop, minH);
|
|
207
|
+
const selY = Math.min(rawTop, Math.max(0, height - selH));
|
|
208
|
+
return { x: selX, width: selW, isZoomed: true, y: selY, height: selH, is2D: true };
|
|
209
|
+
}
|
|
210
|
+
return { x: selX, width: selW, isZoomed: true };
|
|
211
|
+
}
|
|
212
|
+
function calculateNavigatorLayout(chartArea, config, datasets, zoomState, isTimeAxis, tickFormat, locale, theme = defaultLightTheme, overrideXDomain) {
|
|
213
|
+
const resolved = resolveNavigatorConfig(config, theme);
|
|
214
|
+
const area = {
|
|
215
|
+
x: chartArea.x,
|
|
216
|
+
y: chartArea.y + chartArea.height + resolved.gap,
|
|
217
|
+
width: chartArea.width,
|
|
218
|
+
height: resolved.height
|
|
219
|
+
};
|
|
220
|
+
const rawSeries = resolved.series;
|
|
221
|
+
let seriesConfigs;
|
|
222
|
+
if (Array.isArray(rawSeries)) {
|
|
223
|
+
seriesConfigs = rawSeries.map((s) => typeof s === "string" ? { id: s } : { id: s.id, color: s.color });
|
|
224
|
+
} else if (rawSeries) {
|
|
225
|
+
seriesConfigs = [{ id: rawSeries }];
|
|
226
|
+
} else {
|
|
227
|
+
seriesConfigs = [];
|
|
228
|
+
}
|
|
229
|
+
if (seriesConfigs.length === 0) {
|
|
230
|
+
for (const [id, ds] of datasets.entries()) {
|
|
231
|
+
if (ds.type === "candlestick" || ds.type === "line" || ds.type === "bar" || ds.type === "scatter") {
|
|
232
|
+
seriesConfigs.push({ id });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const resolveSeriesColor = (entry, ds) => {
|
|
237
|
+
if (entry.color === "series") {
|
|
238
|
+
return ds?.props?.color ?? resolved.color;
|
|
239
|
+
}
|
|
240
|
+
return entry.color ?? resolved.color;
|
|
241
|
+
};
|
|
242
|
+
const primaryConfig = seriesConfigs[0] ?? {};
|
|
243
|
+
const primarySeriesId = primaryConfig.id;
|
|
244
|
+
const additionalConfigs = seriesConfigs.slice(1);
|
|
245
|
+
const data = extractNavigatorData(datasets, primarySeriesId, isTimeAxis);
|
|
246
|
+
if (!data) {
|
|
247
|
+
return {
|
|
248
|
+
area,
|
|
249
|
+
data: null,
|
|
250
|
+
scales: null,
|
|
251
|
+
paths: null,
|
|
252
|
+
allSeries: [],
|
|
253
|
+
ticks: [],
|
|
254
|
+
selection: { x: 0, width: area.width, isZoomed: false },
|
|
255
|
+
config: resolved
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const additionalEntries = [];
|
|
259
|
+
let mergedYMin = data.yDomain[0];
|
|
260
|
+
let mergedYMax = data.yDomain[1];
|
|
261
|
+
for (const cfg of additionalConfigs) {
|
|
262
|
+
const addData = extractNavigatorData(datasets, cfg.id, isTimeAxis);
|
|
263
|
+
if (!addData) continue;
|
|
264
|
+
const ds = cfg.id ? datasets.get(cfg.id) : void 0;
|
|
265
|
+
const color = resolveSeriesColor(cfg, ds);
|
|
266
|
+
if (addData.yDomain[0] < mergedYMin) mergedYMin = addData.yDomain[0];
|
|
267
|
+
if (addData.yDomain[1] > mergedYMax) mergedYMax = addData.yDomain[1];
|
|
268
|
+
additionalEntries.push({ data: addData, color });
|
|
269
|
+
}
|
|
270
|
+
const mergedData = { ...data, yDomain: [mergedYMin, mergedYMax] };
|
|
271
|
+
const effectiveXDomain = overrideXDomain ?? mergedData.xDomain;
|
|
272
|
+
const animatedData = overrideXDomain ? { ...mergedData, xDomain: overrideXDomain } : mergedData;
|
|
273
|
+
const scales = createNavigatorScales(animatedData, area.width, area.height, resolved.padding);
|
|
274
|
+
const paths = buildNavigatorPaths(data.points, scales, area.height, data.sourceType);
|
|
275
|
+
const ticks = computeNavigatorTicks(effectiveXDomain, scales.x, area.width, locale, data.categoryLabels, data.isNumericAxis, tickFormat);
|
|
276
|
+
const selection = computeNavigatorSelection(zoomState, scales.x, area.width, data.isNumericAxis ? scales.y : null, data.isNumericAxis ? area.height : void 0);
|
|
277
|
+
const primaryColor = resolveSeriesColor(primaryConfig, primarySeriesId ? datasets.get(primarySeriesId) : void 0);
|
|
278
|
+
const allSeries = [
|
|
279
|
+
{ points: data.points, paths, color: primaryColor, sourceType: data.sourceType },
|
|
280
|
+
...additionalEntries.map((e) => ({
|
|
281
|
+
points: e.data.points,
|
|
282
|
+
paths: buildNavigatorPaths(e.data.points, scales, area.height, e.data.sourceType),
|
|
283
|
+
color: e.color,
|
|
284
|
+
sourceType: e.data.sourceType
|
|
285
|
+
}))
|
|
286
|
+
];
|
|
287
|
+
return { area, data: animatedData, scales, paths, ticks, selection, config: resolved, allSeries };
|
|
288
|
+
}
|
|
289
|
+
function computeNavigatorPan(startMin, startMax, deltaPixels, xScale, domainBounds) {
|
|
290
|
+
const deltaData = xScale.invert(deltaPixels) - xScale.invert(0);
|
|
291
|
+
const rangeWidth = startMax - startMin;
|
|
292
|
+
const [domainMin, domainMax] = domainBounds;
|
|
293
|
+
let newMin = startMin + deltaData;
|
|
294
|
+
let newMax = startMax + deltaData;
|
|
295
|
+
if (newMin < domainMin) {
|
|
296
|
+
newMin = domainMin;
|
|
297
|
+
newMax = domainMin + rangeWidth;
|
|
298
|
+
}
|
|
299
|
+
if (newMax > domainMax) {
|
|
300
|
+
newMax = domainMax;
|
|
301
|
+
newMin = domainMax - rangeWidth;
|
|
302
|
+
}
|
|
303
|
+
return { min: newMin, max: newMax };
|
|
304
|
+
}
|
|
305
|
+
function computeNavigatorResizeLeft(startMin, max, deltaPixels, xScale, domainBounds) {
|
|
306
|
+
const deltaData = xScale.invert(deltaPixels) - xScale.invert(0);
|
|
307
|
+
const minDataWidth = xScale.invert(MIN_SELECTION_WIDTH) - xScale.invert(0);
|
|
308
|
+
let newMin = Math.max(domainBounds[0], startMin + deltaData);
|
|
309
|
+
if (max - newMin < minDataWidth) {
|
|
310
|
+
newMin = max - minDataWidth;
|
|
311
|
+
}
|
|
312
|
+
return { min: newMin, max };
|
|
313
|
+
}
|
|
314
|
+
function computeNavigatorResizeRight(min, startMax, deltaPixels, xScale, domainBounds) {
|
|
315
|
+
const deltaData = xScale.invert(deltaPixels) - xScale.invert(0);
|
|
316
|
+
const minDataWidth = xScale.invert(MIN_SELECTION_WIDTH) - xScale.invert(0);
|
|
317
|
+
let newMax = Math.min(domainBounds[1], startMax + deltaData);
|
|
318
|
+
if (newMax - min < minDataWidth) {
|
|
319
|
+
newMax = min + minDataWidth;
|
|
320
|
+
}
|
|
321
|
+
return { min, max: newMax };
|
|
322
|
+
}
|
|
323
|
+
function computeNavigatorJump(clickPixelX, currentWidth, xScale, domainBounds) {
|
|
324
|
+
const clickDataX = xScale.invert(clickPixelX);
|
|
325
|
+
const [domainMin, domainMax] = domainBounds;
|
|
326
|
+
const windowWidth = currentWidth ?? (domainMax - domainMin) * 0.2;
|
|
327
|
+
const halfWidth = windowWidth / 2;
|
|
328
|
+
let newMin = clickDataX - halfWidth;
|
|
329
|
+
let newMax = clickDataX + halfWidth;
|
|
330
|
+
if (newMin < domainMin) {
|
|
331
|
+
newMin = domainMin;
|
|
332
|
+
newMax = domainMin + windowWidth;
|
|
333
|
+
}
|
|
334
|
+
if (newMax > domainMax) {
|
|
335
|
+
newMax = domainMax;
|
|
336
|
+
newMin = domainMax - windowWidth;
|
|
337
|
+
}
|
|
338
|
+
return { min: newMin, max: newMax };
|
|
339
|
+
}
|
|
340
|
+
function computeNavigatorPanY(startMin, startMax, deltaPixels, yScale, domainBounds) {
|
|
341
|
+
const deltaData = yScale.invert(deltaPixels) - yScale.invert(0);
|
|
342
|
+
const rangeHeight = startMax - startMin;
|
|
343
|
+
const [domainMin, domainMax] = domainBounds;
|
|
344
|
+
let newMin = startMin + deltaData;
|
|
345
|
+
let newMax = startMax + deltaData;
|
|
346
|
+
if (newMin < domainMin) {
|
|
347
|
+
newMin = domainMin;
|
|
348
|
+
newMax = domainMin + rangeHeight;
|
|
349
|
+
}
|
|
350
|
+
if (newMax > domainMax) {
|
|
351
|
+
newMax = domainMax;
|
|
352
|
+
newMin = domainMax - rangeHeight;
|
|
353
|
+
}
|
|
354
|
+
return { min: newMin, max: newMax };
|
|
355
|
+
}
|
|
356
|
+
function computeNavigatorResizeTop(min, startMax, deltaPixels, yScale, domainBounds) {
|
|
357
|
+
const deltaData = yScale.invert(deltaPixels) - yScale.invert(0);
|
|
358
|
+
const minDataHeight = yScale.invert(0) - yScale.invert(MIN_SELECTION_WIDTH);
|
|
359
|
+
let newMax = Math.min(domainBounds[1], startMax + deltaData);
|
|
360
|
+
if (newMax - min < minDataHeight) {
|
|
361
|
+
newMax = min + minDataHeight;
|
|
362
|
+
}
|
|
363
|
+
return { min, max: newMax };
|
|
364
|
+
}
|
|
365
|
+
function computeNavigatorResizeBottom(startMin, max, deltaPixels, yScale, domainBounds) {
|
|
366
|
+
const deltaData = yScale.invert(deltaPixels) - yScale.invert(0);
|
|
367
|
+
const minDataHeight = yScale.invert(0) - yScale.invert(MIN_SELECTION_WIDTH);
|
|
368
|
+
let newMin = Math.max(domainBounds[0], startMin + deltaData);
|
|
369
|
+
if (max - newMin < minDataHeight) {
|
|
370
|
+
newMin = max - minDataHeight;
|
|
371
|
+
}
|
|
372
|
+
return { min: newMin, max };
|
|
373
|
+
}
|
|
374
|
+
function computeNavigatorJumpY(clickPixelY, currentHeight, yScale, domainBounds) {
|
|
375
|
+
const clickDataY = yScale.invert(clickPixelY);
|
|
376
|
+
const [domainMin, domainMax] = domainBounds;
|
|
377
|
+
const windowHeight = currentHeight ?? (domainMax - domainMin) * 0.2;
|
|
378
|
+
const halfHeight = windowHeight / 2;
|
|
379
|
+
let newMin = clickDataY - halfHeight;
|
|
380
|
+
let newMax = clickDataY + halfHeight;
|
|
381
|
+
if (newMin < domainMin) {
|
|
382
|
+
newMin = domainMin;
|
|
383
|
+
newMax = domainMin + windowHeight;
|
|
384
|
+
}
|
|
385
|
+
if (newMax > domainMax) {
|
|
386
|
+
newMax = domainMax;
|
|
387
|
+
newMin = domainMax - windowHeight;
|
|
388
|
+
}
|
|
389
|
+
return { min: newMin, max: newMax };
|
|
390
|
+
}
|
|
391
|
+
function hitTestNavigator(localX, selection, localY, handleWidth = HANDLE_WIDTH) {
|
|
392
|
+
if (!selection.isZoomed) return null;
|
|
393
|
+
const { x: selX, width: selW } = selection;
|
|
394
|
+
const halfHandle = handleWidth / 2;
|
|
395
|
+
if (selection.is2D && localY != null && selection.y != null && selection.height != null) {
|
|
396
|
+
const selY = selection.y;
|
|
397
|
+
const selH = selection.height;
|
|
398
|
+
const inXRange = localX >= selX - halfHandle && localX <= selX + selW + halfHandle;
|
|
399
|
+
const inYRange = localY >= selY - halfHandle && localY <= selY + selH + halfHandle;
|
|
400
|
+
if (inYRange && localX >= selX - halfHandle && localX <= selX + halfHandle) return "resize-left";
|
|
401
|
+
if (inYRange && localX >= selX + selW - halfHandle && localX <= selX + selW + halfHandle) return "resize-right";
|
|
402
|
+
if (inXRange && localY >= selY - halfHandle && localY <= selY + halfHandle) return "resize-top";
|
|
403
|
+
if (inXRange && localY >= selY + selH - halfHandle && localY <= selY + selH + halfHandle) return "resize-bottom";
|
|
404
|
+
if (localX >= selX && localX <= selX + selW && localY >= selY && localY <= selY + selH) return "pan";
|
|
405
|
+
return "background";
|
|
406
|
+
}
|
|
407
|
+
if (localX >= selX - halfHandle && localX <= selX + halfHandle) return "resize-left";
|
|
408
|
+
if (localX >= selX + selW - halfHandle && localX <= selX + selW + halfHandle) return "resize-right";
|
|
409
|
+
if (localX >= selX && localX <= selX + selW) return "pan";
|
|
410
|
+
return "background";
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export { GRIP_LINE_GAP, HANDLE_WIDTH, MIN_SELECTION_WIDTH, NAV_DEFAULTS, NAV_PADDING_X, NAV_PADDING_Y, buildNavigatorPaths, calculateNavigatorLayout, computeNavigatorJump, computeNavigatorJumpY, computeNavigatorPan, computeNavigatorPanY, computeNavigatorResizeBottom, computeNavigatorResizeLeft, computeNavigatorResizeRight, computeNavigatorResizeTop, computeNavigatorSelection, computeNavigatorTicks, createNavigatorScales, extractNavigatorData, hitTestNavigator, resolveNavigatorConfig };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { DEFAULT_HOVER_BRIGHTNESS, DEFAULT_HOVER_DIM_OPACITY } from './chunk-NKUYIWAP.mjs';
|
|
2
|
+
import { defaultLightTheme, isGradientColor } from './chunk-O2X6FF45.mjs';
|
|
3
|
+
import { adjustBrightness, brightenGradientStops } from './chunk-SSLTFJ3U.mjs';
|
|
4
|
+
|
|
5
|
+
// src/utils/interaction/hover.utils.ts
|
|
6
|
+
function computeItemHoverState(dataIndex, hoveredIndex, hoverEnabled) {
|
|
7
|
+
const hasAnyHover = hoverEnabled && hoveredIndex !== null && hoveredIndex !== void 0;
|
|
8
|
+
const isHovered = hasAnyHover && hoveredIndex === dataIndex;
|
|
9
|
+
return { isHovered, hasAnyHover };
|
|
10
|
+
}
|
|
11
|
+
function applyHoverColorEffect(baseColor, state, effects, theme) {
|
|
12
|
+
let color = baseColor;
|
|
13
|
+
let opacity = 1;
|
|
14
|
+
if (!effects) {
|
|
15
|
+
return { color, opacity };
|
|
16
|
+
}
|
|
17
|
+
const { isHovered, hasAnyHover } = state;
|
|
18
|
+
const isDimmed = hasAnyHover && !isHovered;
|
|
19
|
+
if (isDimmed) {
|
|
20
|
+
const dim = effects.dimOpacity ?? theme.dimOpacity;
|
|
21
|
+
if (dim !== void 0) {
|
|
22
|
+
opacity = dim;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (isHovered) {
|
|
26
|
+
if (effects.hoverBackgroundColor) {
|
|
27
|
+
color = effects.hoverBackgroundColor;
|
|
28
|
+
} else {
|
|
29
|
+
const brightness = effects.hoverBrightness ?? theme.hoverBrightness;
|
|
30
|
+
if (brightness !== void 0) {
|
|
31
|
+
if (typeof color === "string") {
|
|
32
|
+
color = adjustBrightness(color, brightness);
|
|
33
|
+
} else if (isGradientColor(color)) {
|
|
34
|
+
color = brightenGradientStops(color, brightness);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { color, opacity };
|
|
40
|
+
}
|
|
41
|
+
function applyHoverBorderEffect(baseBorderColor, baseBorderWidth, baseBorderDash, baseBorderDashOffset, isHovered, effects, fillColor) {
|
|
42
|
+
let borderColor = baseBorderColor;
|
|
43
|
+
let borderWidth = baseBorderWidth;
|
|
44
|
+
let borderDash = baseBorderDash;
|
|
45
|
+
let borderDashOffset = baseBorderDashOffset;
|
|
46
|
+
if (isHovered && effects) {
|
|
47
|
+
if (effects.hoverBorderColor !== void 0) {
|
|
48
|
+
borderColor = effects.hoverBorderColor;
|
|
49
|
+
} else if (effects.hoverBorderStrokeWidth !== void 0 && borderColor === "transparent" && fillColor !== void 0) {
|
|
50
|
+
borderColor = fillColor;
|
|
51
|
+
}
|
|
52
|
+
if (effects.hoverBorderStrokeWidth !== void 0) {
|
|
53
|
+
borderWidth = effects.hoverBorderStrokeWidth;
|
|
54
|
+
}
|
|
55
|
+
if (effects.hoverBorderDash !== void 0) {
|
|
56
|
+
borderDash = effects.hoverBorderDash;
|
|
57
|
+
}
|
|
58
|
+
if (effects.hoverBorderDashOffset !== void 0) {
|
|
59
|
+
borderDashOffset = effects.hoverBorderDashOffset;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { borderColor, borderStrokeWidth: borderWidth, borderDash, borderDashOffset };
|
|
63
|
+
}
|
|
64
|
+
function applyHoverEffects(baseColor, baseBorderColor, baseBorderWidth, baseBorderDash, baseBorderDashOffset, state, effects, theme = defaultLightTheme) {
|
|
65
|
+
const colorResult = applyHoverColorEffect(baseColor, state, effects, theme);
|
|
66
|
+
const borderResult = applyHoverBorderEffect(baseBorderColor, baseBorderWidth, baseBorderDash, baseBorderDashOffset, state.isHovered, effects, baseColor);
|
|
67
|
+
return {
|
|
68
|
+
...colorResult,
|
|
69
|
+
...borderResult
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function hoverConfigToFullEffect(config) {
|
|
73
|
+
return {
|
|
74
|
+
hoverBrightness: config.brightness,
|
|
75
|
+
dimOpacity: config.dimOpacity,
|
|
76
|
+
hoverOffset: config.offset,
|
|
77
|
+
hoverScale: config.scale,
|
|
78
|
+
hoverBackgroundColor: config.backgroundColor,
|
|
79
|
+
hoverBorderColor: config.borderColor,
|
|
80
|
+
hoverBorderStrokeWidth: config.borderStrokeWidth,
|
|
81
|
+
hoverBorderDash: config.borderDash,
|
|
82
|
+
hoverBorderDashOffset: config.borderDashOffset,
|
|
83
|
+
hoverRadiusMultiplier: config.radiusMultiplier
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function hoverConfigToBaseEffect(config, theme) {
|
|
87
|
+
return {
|
|
88
|
+
hoverBrightness: config.brightness ?? theme.hoverBrightness ?? DEFAULT_HOVER_BRIGHTNESS,
|
|
89
|
+
hoverBackgroundColor: config.backgroundColor,
|
|
90
|
+
dimOpacity: config.dimOpacity,
|
|
91
|
+
hoverBorderColor: config.borderColor,
|
|
92
|
+
hoverBorderStrokeWidth: config.borderStrokeWidth,
|
|
93
|
+
hoverBorderDash: config.borderDash,
|
|
94
|
+
hoverBorderDashOffset: config.borderDashOffset,
|
|
95
|
+
hoverRadiusMultiplier: config.radiusMultiplier
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function computeSliceHoverEffects(baseColor, baseBorderColor, baseBorderWidth, isHovered, hasAnyHover, hoverProps, theme) {
|
|
99
|
+
const effects = hoverProps ? hoverConfigToBaseEffect(hoverProps, theme) : void 0;
|
|
100
|
+
const result = applyHoverEffects(baseColor, baseBorderColor, baseBorderWidth, void 0, 0, { isHovered, hasAnyHover }, effects, theme);
|
|
101
|
+
return {
|
|
102
|
+
fillColor: result.color,
|
|
103
|
+
borderColor: result.borderColor,
|
|
104
|
+
borderStrokeWidth: result.borderStrokeWidth,
|
|
105
|
+
borderDash: result.borderDash,
|
|
106
|
+
opacity: result.opacity
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function computeLeaderLineHoverEffects(baseColor, isHovered, hasAnyHover, hoverProps, theme) {
|
|
110
|
+
let strokeColor = baseColor;
|
|
111
|
+
let strokeWidth = 1;
|
|
112
|
+
if (!hoverProps) {
|
|
113
|
+
return { strokeColor, strokeWidth };
|
|
114
|
+
}
|
|
115
|
+
if (isHovered) {
|
|
116
|
+
const brightness = hoverProps.brightness ?? theme.hoverBrightness ?? DEFAULT_HOVER_BRIGHTNESS;
|
|
117
|
+
strokeColor = adjustBrightness(baseColor, brightness);
|
|
118
|
+
strokeWidth = 2;
|
|
119
|
+
} else if (hasAnyHover) {
|
|
120
|
+
const dimOpacity = hoverProps.dimOpacity ?? theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY;
|
|
121
|
+
strokeColor = adjustBrightness(baseColor, dimOpacity);
|
|
122
|
+
}
|
|
123
|
+
return { strokeColor, strokeWidth };
|
|
124
|
+
}
|
|
125
|
+
function applySvgHoverFill(pathEl, isHovered, hasAnyHover, hoverConfig, applyGradientBrightness, restoreGradientBrightness, theme) {
|
|
126
|
+
if (!hoverConfig) return;
|
|
127
|
+
if (!pathEl.hasAttribute("data-original-fill")) {
|
|
128
|
+
pathEl.setAttribute("data-original-fill", pathEl.getAttribute("fill") || "");
|
|
129
|
+
}
|
|
130
|
+
const originalFill = pathEl.getAttribute("data-original-fill") || "";
|
|
131
|
+
const isGradient = originalFill.startsWith("url(");
|
|
132
|
+
const brightness = hoverConfig.brightness ?? theme.hoverBrightness ?? DEFAULT_HOVER_BRIGHTNESS;
|
|
133
|
+
if (isHovered) {
|
|
134
|
+
if (hoverConfig.backgroundColor) {
|
|
135
|
+
pathEl.setAttribute("fill", hoverConfig.backgroundColor);
|
|
136
|
+
} else if (isGradient && applyGradientBrightness) {
|
|
137
|
+
applyGradientBrightness(pathEl, brightness);
|
|
138
|
+
} else if (originalFill) {
|
|
139
|
+
pathEl.setAttribute("fill", adjustBrightness(originalFill, brightness));
|
|
140
|
+
}
|
|
141
|
+
pathEl.removeAttribute("opacity");
|
|
142
|
+
} else if (hasAnyHover && hoverConfig.dimOpacity !== void 0 && hoverConfig.dimOpacity < 1) {
|
|
143
|
+
pathEl.setAttribute("opacity", String(hoverConfig.dimOpacity));
|
|
144
|
+
if (isGradient && restoreGradientBrightness) {
|
|
145
|
+
restoreGradientBrightness(pathEl);
|
|
146
|
+
} else if (originalFill) {
|
|
147
|
+
pathEl.setAttribute("fill", originalFill);
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
if (isGradient && restoreGradientBrightness) {
|
|
151
|
+
restoreGradientBrightness(pathEl);
|
|
152
|
+
} else if (originalFill) {
|
|
153
|
+
pathEl.setAttribute("fill", originalFill);
|
|
154
|
+
}
|
|
155
|
+
pathEl.removeAttribute("opacity");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function applySvgHoverStroke(pathEl, isHovered, hoverConfig) {
|
|
159
|
+
if (!hoverConfig) return;
|
|
160
|
+
if (!pathEl.hasAttribute("data-original-stroke")) {
|
|
161
|
+
pathEl.setAttribute("data-original-stroke", pathEl.getAttribute("stroke") || "");
|
|
162
|
+
pathEl.setAttribute("data-original-stroke-width", pathEl.getAttribute("stroke-width") || "");
|
|
163
|
+
const dashArray = pathEl.getAttribute("stroke-dasharray");
|
|
164
|
+
if (dashArray) {
|
|
165
|
+
pathEl.setAttribute("data-original-stroke-dasharray", dashArray);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (isHovered && (hoverConfig.borderColor || hoverConfig.borderStrokeWidth !== void 0)) {
|
|
169
|
+
if (hoverConfig.borderColor) {
|
|
170
|
+
pathEl.setAttribute("stroke", hoverConfig.borderColor);
|
|
171
|
+
}
|
|
172
|
+
if (hoverConfig.borderStrokeWidth !== void 0) {
|
|
173
|
+
pathEl.setAttribute("stroke-width", String(hoverConfig.borderStrokeWidth * 2));
|
|
174
|
+
}
|
|
175
|
+
if (hoverConfig.borderDash) {
|
|
176
|
+
pathEl.setAttribute("stroke-dasharray", hoverConfig.borderDash.join(" "));
|
|
177
|
+
}
|
|
178
|
+
if (!pathEl.hasAttribute("paint-order")) {
|
|
179
|
+
pathEl.setAttribute("paint-order", "stroke fill");
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
const originalStroke = pathEl.getAttribute("data-original-stroke");
|
|
183
|
+
const originalWidth = pathEl.getAttribute("data-original-stroke-width");
|
|
184
|
+
const originalDash = pathEl.getAttribute("data-original-stroke-dasharray");
|
|
185
|
+
if (originalStroke) pathEl.setAttribute("stroke", originalStroke);
|
|
186
|
+
else pathEl.removeAttribute("stroke");
|
|
187
|
+
if (originalWidth) pathEl.setAttribute("stroke-width", originalWidth);
|
|
188
|
+
else pathEl.removeAttribute("stroke-width");
|
|
189
|
+
if (originalDash) pathEl.setAttribute("stroke-dasharray", originalDash);
|
|
190
|
+
else pathEl.removeAttribute("stroke-dasharray");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function resolveSvgHoverFill(baseFill, isHovered, overrideColor) {
|
|
194
|
+
if (isHovered && typeof overrideColor === "string") {
|
|
195
|
+
return { fill: overrideColor, overridden: true };
|
|
196
|
+
}
|
|
197
|
+
return { fill: baseFill, overridden: false };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { applyHoverEffects, applySvgHoverFill, applySvgHoverStroke, computeItemHoverState, computeLeaderLineHoverEffects, computeSliceHoverEffects, hoverConfigToBaseEffect, hoverConfigToFullEffect, resolveSvgHoverFill };
|