@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,874 @@
|
|
|
1
|
+
import { createDrawImage } from './chunk-7CMVDIOU.mjs';
|
|
2
|
+
import { measureFontMetrics, measureTextWidth } from './chunk-XTVE4P3L.mjs';
|
|
3
|
+
import { DEFAULT_HOVER_DIM_OPACITY, DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER, DEFAULT_REFERENCE_LINE_STROKE, DEFAULT_REFERENCE_LINE_WIDTH, DEFAULT_REFERENCE_LABEL_OFFSET, DEFAULT_REFERENCE_BAND_FILL, DEFAULT_REFERENCE_BAND_OPACITY, resolveFontFamily, resolveFontSize, DEFAULT_REFERENCE_LABEL_FONT_SIZE, DEFAULT_REFERENCE_LABEL_FONT_WEIGHT } from './chunk-NKUYIWAP.mjs';
|
|
4
|
+
import { resolveAccessor, makeItemContext, resolveSwatchColor, isGradientColor } from './chunk-O2X6FF45.mjs';
|
|
5
|
+
import { createSvgGroup, appendChild, createSvgRect, createSvgText, createSvgLine, withCanvasState } from './chunk-SSLTFJ3U.mjs';
|
|
6
|
+
import { shallowEqual } from './chunk-RQ3CKQOX.mjs';
|
|
7
|
+
|
|
8
|
+
// src/utils/customRender.utils.ts
|
|
9
|
+
function renderCustomMarkersCanvas(ctx, entries, hover, options) {
|
|
10
|
+
for (const entry of entries) {
|
|
11
|
+
const hasEffects = !!entry.effects;
|
|
12
|
+
const hoveredIndex = hover.datasetId === entry.dsId ? hover.index : null;
|
|
13
|
+
const anyHovered = hoveredIndex !== null && hasEffects;
|
|
14
|
+
const dimOpacity = entry.effects?.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY;
|
|
15
|
+
for (const pt of entry.visiblePoints) {
|
|
16
|
+
const isHovered = anyHovered && pt.dataIndex === hoveredIndex;
|
|
17
|
+
const opacity = anyHovered && !isHovered ? dimOpacity : 1;
|
|
18
|
+
const currentSize = isHovered ? entry.effects?.hoverPointRadius ?? entry.markerSize * DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER : entry.markerSize;
|
|
19
|
+
const baseColor = entry.pointBackgroundColor != null ? String(entry.pointBackgroundColor) : entry.color;
|
|
20
|
+
const context = {
|
|
21
|
+
x: pt.x,
|
|
22
|
+
y: pt.y,
|
|
23
|
+
index: pt.dataIndex,
|
|
24
|
+
value: pt.value,
|
|
25
|
+
category: pt.category ?? "",
|
|
26
|
+
data: entry.data?.[pt.dataIndex],
|
|
27
|
+
color: baseColor,
|
|
28
|
+
size: currentSize,
|
|
29
|
+
isHovered,
|
|
30
|
+
opacity,
|
|
31
|
+
ctx,
|
|
32
|
+
drawImage: options?.onImageLoad ? createDrawImage(ctx, options.onImageLoad) : void 0,
|
|
33
|
+
animate: options?.createAnimate?.(entry.dsId, pt.dataIndex)
|
|
34
|
+
};
|
|
35
|
+
ctx.save();
|
|
36
|
+
ctx.translate(pt.x, pt.y);
|
|
37
|
+
ctx.globalAlpha = opacity;
|
|
38
|
+
entry.renderMarker(context);
|
|
39
|
+
ctx.restore();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function buildMarkerRenderItems(entries, hover) {
|
|
44
|
+
const items = [];
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const hasEffects = !!entry.effects;
|
|
47
|
+
const hoveredIndex = hover.datasetId === entry.dsId ? hover.index : null;
|
|
48
|
+
const anyHover = hoveredIndex !== null && hasEffects;
|
|
49
|
+
const dimOpacity = entry.effects?.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY;
|
|
50
|
+
for (const pt of entry.visiblePoints) {
|
|
51
|
+
const isHovered = anyHover && pt.dataIndex === hoveredIndex;
|
|
52
|
+
const opacity = anyHover && !isHovered ? dimOpacity : 1;
|
|
53
|
+
const currentSize = isHovered ? entry.effects?.hoverPointRadius ?? entry.markerSize * DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER : entry.markerSize;
|
|
54
|
+
const baseColor = entry.pointBackgroundColor != null ? String(entry.pointBackgroundColor) : entry.color;
|
|
55
|
+
const context = {
|
|
56
|
+
x: pt.x,
|
|
57
|
+
y: pt.y,
|
|
58
|
+
index: pt.dataIndex,
|
|
59
|
+
value: pt.value,
|
|
60
|
+
category: pt.category ?? "",
|
|
61
|
+
data: entry.data?.[pt.dataIndex],
|
|
62
|
+
color: baseColor,
|
|
63
|
+
size: currentSize,
|
|
64
|
+
isHovered,
|
|
65
|
+
opacity
|
|
66
|
+
};
|
|
67
|
+
items.push({
|
|
68
|
+
key: `marker-${entry.dsId}-${pt.dataIndex}`,
|
|
69
|
+
dsId: entry.dsId,
|
|
70
|
+
x: pt.x,
|
|
71
|
+
y: pt.y,
|
|
72
|
+
opacity,
|
|
73
|
+
context,
|
|
74
|
+
renderMarker: entry.renderMarker
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return items;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/utils/dir.utils.ts
|
|
82
|
+
function resolveDirFromElement(target) {
|
|
83
|
+
if (!target) return "ltr";
|
|
84
|
+
const detected = target.closest("[dir]")?.getAttribute("dir");
|
|
85
|
+
return detected === "rtl" ? "rtl" : "ltr";
|
|
86
|
+
}
|
|
87
|
+
function observeDocumentDir(onChange) {
|
|
88
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
|
|
89
|
+
return () => {
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const observer = new MutationObserver(onChange);
|
|
93
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["dir"] });
|
|
94
|
+
return () => observer.disconnect();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/utils/legend.utils.ts
|
|
98
|
+
function resolveLegendColor(props, index, item, theme, extras) {
|
|
99
|
+
return resolveSwatchColor(props, index, item, theme, extras);
|
|
100
|
+
}
|
|
101
|
+
function resolveLegendGradient(props, index, item, extras) {
|
|
102
|
+
if (props.color == null) return void 0;
|
|
103
|
+
const resolved = resolveAccessor(props.color, makeItemContext(item, index, extras));
|
|
104
|
+
return resolved != null && isGradientColor(resolved) ? resolved : void 0;
|
|
105
|
+
}
|
|
106
|
+
function buildLegendItems(options) {
|
|
107
|
+
const { datasets, datasetVisibility, hiddenItems, isCartesian, hasRadarDatasets, hasPolarDatasets, hasStackedPies, theme } = options;
|
|
108
|
+
const sortedDatasets = Array.from(datasets.entries()).sort(([, a], [, b]) => a.order - b.order);
|
|
109
|
+
if (isCartesian || hasRadarDatasets || hasPolarDatasets) {
|
|
110
|
+
const items2 = [];
|
|
111
|
+
for (const [datasetId, dataset] of sortedDatasets) {
|
|
112
|
+
const visible = datasetVisibility.get(datasetId) ?? true;
|
|
113
|
+
const props = dataset.props;
|
|
114
|
+
const firstItem = props.data?.[0];
|
|
115
|
+
const color = resolveLegendColor(props, dataset.order, firstItem, theme);
|
|
116
|
+
items2.push({
|
|
117
|
+
type: "dataset",
|
|
118
|
+
datasetId,
|
|
119
|
+
label: props.name ?? datasetId,
|
|
120
|
+
color,
|
|
121
|
+
colorGradient: resolveLegendGradient(props, dataset.order, firstItem),
|
|
122
|
+
visible
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return items2;
|
|
126
|
+
}
|
|
127
|
+
const items = [];
|
|
128
|
+
for (const [datasetId, dataset] of sortedDatasets) {
|
|
129
|
+
const props = dataset.props;
|
|
130
|
+
const datasetVisible = datasetVisibility.get(datasetId) ?? true;
|
|
131
|
+
if (hasStackedPies) {
|
|
132
|
+
items.push({
|
|
133
|
+
type: "dataset",
|
|
134
|
+
datasetId,
|
|
135
|
+
label: props.name ?? datasetId,
|
|
136
|
+
color: "",
|
|
137
|
+
visible: datasetVisible
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const data = props.data;
|
|
141
|
+
if (data) {
|
|
142
|
+
const borderColor = typeof props.borderColor === "string" ? props.borderColor : void 0;
|
|
143
|
+
const hasBorder = (typeof props.borderStrokeWidth === "number" ? props.borderStrokeWidth : 0) > 0 && borderColor !== void 0;
|
|
144
|
+
const borderRadiusRaw = props.borderRadius;
|
|
145
|
+
const borderRadius = typeof borderRadiusRaw === "number" ? borderRadiusRaw : typeof borderRadiusRaw === "object" && borderRadiusRaw !== null ? borderRadiusRaw.topLeft ?? borderRadiusRaw.topRight ?? borderRadiusRaw.bottomLeft ?? borderRadiusRaw.bottomRight ?? void 0 : void 0;
|
|
146
|
+
const hiddenSet = hiddenItems.get(datasetId);
|
|
147
|
+
const labelAccessor = props.categoryField ?? props.label;
|
|
148
|
+
const sortProp = props.sort;
|
|
149
|
+
const sortedIndices = Array.from({ length: data.length }, (_, i) => i);
|
|
150
|
+
if (sortProp) {
|
|
151
|
+
const valueAccessor = props.valueField;
|
|
152
|
+
sortedIndices.sort((a, b) => {
|
|
153
|
+
if (sortProp === "value-asc" || sortProp === "value-desc") {
|
|
154
|
+
const va = valueAccessor ? Number(resolveAccessor(valueAccessor, makeItemContext(data[a], a)) ?? 0) : 0;
|
|
155
|
+
const vb = valueAccessor ? Number(resolveAccessor(valueAccessor, makeItemContext(data[b], b)) ?? 0) : 0;
|
|
156
|
+
return sortProp === "value-asc" ? va - vb : vb - va;
|
|
157
|
+
}
|
|
158
|
+
const la = labelAccessor ? String(resolveAccessor(labelAccessor, makeItemContext(data[a], a)) ?? "") : "";
|
|
159
|
+
const lb = labelAccessor ? String(resolveAccessor(labelAccessor, makeItemContext(data[b], b)) ?? "") : "";
|
|
160
|
+
return sortProp === "label-asc" ? la.localeCompare(lb) : lb.localeCompare(la);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const valueAccessorForColor = props.valueField;
|
|
164
|
+
for (const i of sortedIndices) {
|
|
165
|
+
const item = data[i];
|
|
166
|
+
const itemValue = valueAccessorForColor ? resolveAccessor(valueAccessorForColor, makeItemContext(item, i)) ?? null : null;
|
|
167
|
+
const label = labelAccessor ? resolveAccessor(labelAccessor, makeItemContext(item, i)) : void 0;
|
|
168
|
+
const itemExtras = {
|
|
169
|
+
value: itemValue,
|
|
170
|
+
category: label != null ? String(label) : void 0,
|
|
171
|
+
seriesIndex: typeof props.order === "number" ? props.order : 0,
|
|
172
|
+
seriesId: datasetId
|
|
173
|
+
};
|
|
174
|
+
const color = resolveLegendColor(props, i, item, theme, itemExtras);
|
|
175
|
+
items.push({
|
|
176
|
+
type: "item",
|
|
177
|
+
datasetId,
|
|
178
|
+
index: i,
|
|
179
|
+
label: label ? String(label) : `Item ${i + 1}`,
|
|
180
|
+
color,
|
|
181
|
+
colorGradient: resolveLegendGradient(props, i, item, itemExtras),
|
|
182
|
+
visible: datasetVisible && !(hiddenSet?.has(i) ?? false),
|
|
183
|
+
borderColor,
|
|
184
|
+
hasBorder,
|
|
185
|
+
borderRadius
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return items;
|
|
191
|
+
}
|
|
192
|
+
function buildSharedLegendItems(entries, mode, visibilityMap) {
|
|
193
|
+
const items = [];
|
|
194
|
+
if (mode === "dataset" || mode === "both") {
|
|
195
|
+
const seen = /* @__PURE__ */ new Set();
|
|
196
|
+
for (const ds of entries) {
|
|
197
|
+
if (ds.itemIndex !== void 0) continue;
|
|
198
|
+
if (seen.has(ds.label)) continue;
|
|
199
|
+
seen.add(ds.label);
|
|
200
|
+
items.push({
|
|
201
|
+
type: "dataset",
|
|
202
|
+
datasetId: ds.datasetId,
|
|
203
|
+
label: ds.label,
|
|
204
|
+
color: ds.color,
|
|
205
|
+
colorGradient: ds.colorGradient,
|
|
206
|
+
visible: visibilityMap.get(ds.datasetId) ?? true
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (mode === "category" || mode === "both") {
|
|
211
|
+
const seen = /* @__PURE__ */ new Set();
|
|
212
|
+
for (const ds of entries) {
|
|
213
|
+
if (ds.itemIndex === void 0) continue;
|
|
214
|
+
if (seen.has(ds.label)) continue;
|
|
215
|
+
seen.add(ds.label);
|
|
216
|
+
items.push({
|
|
217
|
+
type: "item",
|
|
218
|
+
datasetId: ds.datasetId,
|
|
219
|
+
itemLabel: ds.label,
|
|
220
|
+
label: ds.label,
|
|
221
|
+
color: ds.color,
|
|
222
|
+
colorGradient: ds.colorGradient,
|
|
223
|
+
visible: visibilityMap.get(`item:${ds.label}`) ?? true
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const orderByLabel = /* @__PURE__ */ new Map();
|
|
228
|
+
for (const ds of entries) {
|
|
229
|
+
if (!orderByLabel.has(ds.label)) orderByLabel.set(ds.label, ds.order);
|
|
230
|
+
}
|
|
231
|
+
items.sort((a, b) => (orderByLabel.get(a.label) ?? 0) - (orderByLabel.get(b.label) ?? 0));
|
|
232
|
+
return items;
|
|
233
|
+
}
|
|
234
|
+
function computeLegendStyle(config, legendArea) {
|
|
235
|
+
const position = config.position ?? "bottom";
|
|
236
|
+
const layout = config.layout ?? (position === "left" || position === "right" ? "vertical" : "horizontal");
|
|
237
|
+
const isVertical = position === "left" || position === "right";
|
|
238
|
+
const align = config.align ?? (isVertical ? "start" : "center");
|
|
239
|
+
const baseStyle = {
|
|
240
|
+
position: "absolute",
|
|
241
|
+
display: "flex",
|
|
242
|
+
gap: `${config.itemGap ?? 8}px`,
|
|
243
|
+
padding: "8px",
|
|
244
|
+
flexWrap: "wrap",
|
|
245
|
+
boxSizing: "border-box"
|
|
246
|
+
};
|
|
247
|
+
const alignValue = align === "start" ? "flex-start" : align === "end" ? "flex-end" : "center";
|
|
248
|
+
const defaultMaxWidth = 150;
|
|
249
|
+
switch (position) {
|
|
250
|
+
case "top":
|
|
251
|
+
case "bottom":
|
|
252
|
+
return {
|
|
253
|
+
...baseStyle,
|
|
254
|
+
top: legendArea.y,
|
|
255
|
+
left: legendArea.x,
|
|
256
|
+
width: legendArea.width,
|
|
257
|
+
height: config.height ?? "fit-content",
|
|
258
|
+
// Cap to the reserved strip and scroll the overflow (amCharts-style) so a tall
|
|
259
|
+
// legend never spills past the chart and clips its trailing items. legendArea
|
|
260
|
+
// already reflects any explicit height/maxHeight and the auto-reposition floor
|
|
261
|
+
// (see resolveReservedLegendHeight), so this stays in lockstep with what the
|
|
262
|
+
// layout carved out — mirrors the right/left legend's overflow handling.
|
|
263
|
+
maxHeight: legendArea.height,
|
|
264
|
+
overflowY: "auto",
|
|
265
|
+
justifyContent: alignValue,
|
|
266
|
+
alignItems: "center",
|
|
267
|
+
flexDirection: layout === "vertical" ? "column" : "row"
|
|
268
|
+
};
|
|
269
|
+
case "left":
|
|
270
|
+
case "right": {
|
|
271
|
+
const va = config.verticalAlign ?? "top";
|
|
272
|
+
const sideTop = va === "middle" ? legendArea.y + legendArea.height / 2 : va === "bottom" ? legendArea.y + legendArea.height : legendArea.y;
|
|
273
|
+
const sideTransform = va === "middle" ? "translateY(-50%)" : va === "bottom" ? "translateY(-100%)" : "none";
|
|
274
|
+
return {
|
|
275
|
+
...baseStyle,
|
|
276
|
+
top: sideTop,
|
|
277
|
+
left: legendArea.x,
|
|
278
|
+
width: config.width ?? "fit-content",
|
|
279
|
+
maxWidth: config.maxWidth ?? (typeof config.width === "number" ? config.width : defaultMaxWidth),
|
|
280
|
+
height: "fit-content",
|
|
281
|
+
maxHeight: legendArea.height,
|
|
282
|
+
flexDirection: "column",
|
|
283
|
+
alignItems: alignValue,
|
|
284
|
+
overflowY: "auto",
|
|
285
|
+
transform: sideTransform
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
default:
|
|
289
|
+
return baseStyle;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function resolveLegendClickAction(item, ctx) {
|
|
293
|
+
if (ctx.isCartesian || ctx.isRect || ctx.hasRadarDatasets || ctx.hasPolarDatasets) {
|
|
294
|
+
return { kind: "toggleDataset", datasetId: item.datasetId };
|
|
295
|
+
}
|
|
296
|
+
if (item.type === "dataset") {
|
|
297
|
+
const dataset = ctx.datasets.get(item.datasetId);
|
|
298
|
+
const dataLength = dataset?.props?.data?.length ?? 0;
|
|
299
|
+
if (dataLength === 0) return { kind: "noop" };
|
|
300
|
+
const hidden = ctx.hiddenItems.get(item.datasetId);
|
|
301
|
+
let anyVisible = false;
|
|
302
|
+
for (let i = 0; i < dataLength; i++) {
|
|
303
|
+
if (!hidden?.has(i)) {
|
|
304
|
+
anyVisible = true;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const newVisibility = !anyVisible;
|
|
309
|
+
const indices = [];
|
|
310
|
+
for (let i = 0; i < dataLength; i++) {
|
|
311
|
+
const currentlyVisible = !hidden?.has(i);
|
|
312
|
+
if (currentlyVisible !== newVisibility) indices.push(i);
|
|
313
|
+
}
|
|
314
|
+
return indices.length === 0 ? { kind: "noop" } : { kind: "toggleItems", datasetId: item.datasetId, indices };
|
|
315
|
+
}
|
|
316
|
+
if (item.index !== void 0) {
|
|
317
|
+
return { kind: "toggleItems", datasetId: item.datasetId, indices: [item.index] };
|
|
318
|
+
}
|
|
319
|
+
return { kind: "noop" };
|
|
320
|
+
}
|
|
321
|
+
function resolveLegendHoverTarget(item, ctx) {
|
|
322
|
+
if (!item) return null;
|
|
323
|
+
if (!item.visible) return null;
|
|
324
|
+
if (item.type === "dataset" && (ctx.isCartesian || ctx.hasRadarDatasets || ctx.hasPolarDatasets)) {
|
|
325
|
+
return { datasetId: item.datasetId, index: null };
|
|
326
|
+
}
|
|
327
|
+
if (item.type === "item" && item.index !== void 0) {
|
|
328
|
+
return { datasetId: item.datasetId, index: item.index };
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// src/utils/itemCollector.ts
|
|
334
|
+
var ItemCollector = class {
|
|
335
|
+
constructor() {
|
|
336
|
+
this.items = /* @__PURE__ */ new Map();
|
|
337
|
+
this.counter = 0;
|
|
338
|
+
}
|
|
339
|
+
registerItem(index, props) {
|
|
340
|
+
const existing = this.items.get(index);
|
|
341
|
+
if (existing && shallowEqual(existing, props)) return;
|
|
342
|
+
this.items.set(index, props);
|
|
343
|
+
}
|
|
344
|
+
unregisterItem(index) {
|
|
345
|
+
this.items.delete(index);
|
|
346
|
+
}
|
|
347
|
+
getNextIndex() {
|
|
348
|
+
return this.counter++;
|
|
349
|
+
}
|
|
350
|
+
getItems() {
|
|
351
|
+
return Array.from(this.items.entries()).sort(([a], [b]) => a - b).map(([, props]) => props);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/utils/plotReference/geometry.ts
|
|
356
|
+
function parseDashArray(dash) {
|
|
357
|
+
if (!dash || !Array.isArray(dash) || dash.length === 0) return void 0;
|
|
358
|
+
if (dash.some((n) => typeof n !== "number" || isNaN(n))) return void 0;
|
|
359
|
+
return dash.slice();
|
|
360
|
+
}
|
|
361
|
+
function findValueScale(axisLayouts, yAxisId) {
|
|
362
|
+
for (const [, info] of axisLayouts) {
|
|
363
|
+
if (yAxisId) {
|
|
364
|
+
if (info.id === yAxisId && "invert" in info.scale) return info.scale;
|
|
365
|
+
} else if (info.axis === "y" && info.isPrimary && "invert" in info.scale) {
|
|
366
|
+
return info.scale;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
function findXScale(axisLayouts) {
|
|
372
|
+
for (const [, info] of axisLayouts) {
|
|
373
|
+
if (info.axis === "x" && info.isPrimary && "invert" in info.scale) return info.scale;
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
function computeReferenceLines(referenceLines, axisLayouts, cartesianArea, categoryScale, orientation) {
|
|
378
|
+
const results = [];
|
|
379
|
+
for (const pl of referenceLines) {
|
|
380
|
+
const stroke = pl.stroke ?? DEFAULT_REFERENCE_LINE_STROKE;
|
|
381
|
+
const strokeWidth = pl.lineStrokeWidth ?? DEFAULT_REFERENCE_LINE_WIDTH;
|
|
382
|
+
const dashArray = parseDashArray(pl.strokeDasharray);
|
|
383
|
+
let geo = null;
|
|
384
|
+
if (pl.y != null) {
|
|
385
|
+
const scale = findValueScale(axisLayouts, pl.yAxisId);
|
|
386
|
+
if (!scale) continue;
|
|
387
|
+
const py = scale(pl.y);
|
|
388
|
+
if (orientation === "horizontal") {
|
|
389
|
+
geo = buildLineGeo(py, cartesianArea.y, py, cartesianArea.y + cartesianArea.height, stroke, strokeWidth, dashArray, pl, cartesianArea, "vertical-axis");
|
|
390
|
+
} else {
|
|
391
|
+
geo = buildLineGeo(cartesianArea.x, py, cartesianArea.x + cartesianArea.width, py, stroke, strokeWidth, dashArray, pl, cartesianArea, "horizontal");
|
|
392
|
+
}
|
|
393
|
+
} else if (pl.x != null) {
|
|
394
|
+
let px = null;
|
|
395
|
+
if (typeof pl.x === "string" && categoryScale) {
|
|
396
|
+
const catPos = categoryScale(pl.x);
|
|
397
|
+
if (catPos != null && !isNaN(catPos)) px = catPos + categoryScale.bandwidth() / 2;
|
|
398
|
+
} else if (typeof pl.x === "number") {
|
|
399
|
+
const xScale = findXScale(axisLayouts);
|
|
400
|
+
if (xScale) px = xScale(pl.x);
|
|
401
|
+
}
|
|
402
|
+
if (px == null) continue;
|
|
403
|
+
if (orientation === "horizontal") {
|
|
404
|
+
geo = buildLineGeo(cartesianArea.x, px, cartesianArea.x + cartesianArea.width, px, stroke, strokeWidth, dashArray, pl, cartesianArea, "horizontal");
|
|
405
|
+
} else {
|
|
406
|
+
geo = buildLineGeo(px, cartesianArea.y, px, cartesianArea.y + cartesianArea.height, stroke, strokeWidth, dashArray, pl, cartesianArea, "vertical");
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (geo) results.push(geo);
|
|
410
|
+
}
|
|
411
|
+
return results;
|
|
412
|
+
}
|
|
413
|
+
function buildLineGeo(x1, y1, x2, y2, stroke, strokeWidth, dashArray, pl, area, direction) {
|
|
414
|
+
const pos = pl.labelPosition ?? "end";
|
|
415
|
+
let labelX;
|
|
416
|
+
let labelY;
|
|
417
|
+
let labelAnchor;
|
|
418
|
+
let labelBaseline;
|
|
419
|
+
if (direction === "horizontal") {
|
|
420
|
+
labelY = y1 - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
421
|
+
labelBaseline = "auto";
|
|
422
|
+
if (pos === "start") {
|
|
423
|
+
labelX = area.x + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
424
|
+
labelAnchor = "start";
|
|
425
|
+
} else if (pos === "center") {
|
|
426
|
+
labelX = area.x + area.width / 2;
|
|
427
|
+
labelAnchor = "middle";
|
|
428
|
+
} else {
|
|
429
|
+
labelX = area.x + area.width - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
430
|
+
labelAnchor = "end";
|
|
431
|
+
}
|
|
432
|
+
} else if (direction === "vertical") {
|
|
433
|
+
labelX = x1 + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
434
|
+
labelAnchor = "start";
|
|
435
|
+
if (pos === "start") {
|
|
436
|
+
labelY = area.y + area.height - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
437
|
+
labelBaseline = "auto";
|
|
438
|
+
} else if (pos === "center") {
|
|
439
|
+
labelY = area.y + area.height / 2;
|
|
440
|
+
labelBaseline = "central";
|
|
441
|
+
} else {
|
|
442
|
+
labelY = area.y + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
443
|
+
labelBaseline = "hanging";
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
labelX = x1 + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
447
|
+
labelAnchor = "start";
|
|
448
|
+
if (pos === "start") {
|
|
449
|
+
labelY = area.y + area.height - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
450
|
+
labelBaseline = "auto";
|
|
451
|
+
} else if (pos === "center") {
|
|
452
|
+
labelY = area.y + area.height / 2;
|
|
453
|
+
labelBaseline = "central";
|
|
454
|
+
} else {
|
|
455
|
+
labelY = area.y + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
456
|
+
labelBaseline = "hanging";
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return {
|
|
460
|
+
x1,
|
|
461
|
+
y1,
|
|
462
|
+
x2,
|
|
463
|
+
y2,
|
|
464
|
+
stroke,
|
|
465
|
+
lineStrokeWidth: strokeWidth,
|
|
466
|
+
dashArray,
|
|
467
|
+
label: pl.label,
|
|
468
|
+
labelX,
|
|
469
|
+
labelY,
|
|
470
|
+
labelAnchor,
|
|
471
|
+
labelBaseline,
|
|
472
|
+
labelColor: pl.labelColor,
|
|
473
|
+
labelFontSize: pl.labelFontSize,
|
|
474
|
+
labelFontWeight: pl.labelFontWeight,
|
|
475
|
+
labelBackground: pl.labelBackground,
|
|
476
|
+
labelBackgroundOpacity: pl.labelBackgroundOpacity,
|
|
477
|
+
labelPadding: pl.labelPadding,
|
|
478
|
+
labelBorderRadius: pl.labelBorderRadius
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function computeReferenceBands(referenceBands, axisLayouts, cartesianArea, categoryScale, orientation) {
|
|
482
|
+
const results = [];
|
|
483
|
+
for (const pb of referenceBands) {
|
|
484
|
+
let fill;
|
|
485
|
+
let fillOpacity;
|
|
486
|
+
if (typeof pb.fill === "object" && pb.fill) {
|
|
487
|
+
fill = pb.fill.color;
|
|
488
|
+
fillOpacity = pb.fill.opacity ?? 1;
|
|
489
|
+
} else {
|
|
490
|
+
fill = pb.fill ?? DEFAULT_REFERENCE_BAND_FILL;
|
|
491
|
+
fillOpacity = pb.fillOpacity ?? DEFAULT_REFERENCE_BAND_OPACITY;
|
|
492
|
+
}
|
|
493
|
+
let geo = null;
|
|
494
|
+
if (pb.x1 != null && pb.x2 != null && pb.y1 != null && pb.y2 != null && typeof pb.x1 === "number" && typeof pb.x2 === "number") {
|
|
495
|
+
const yScale = findValueScale(axisLayouts, pb.yAxisId);
|
|
496
|
+
const xScale = findXScale(axisLayouts);
|
|
497
|
+
if (!yScale || !xScale) continue;
|
|
498
|
+
const py1 = yScale(pb.y1);
|
|
499
|
+
const py2 = yScale(pb.y2);
|
|
500
|
+
const px1 = xScale(pb.x1);
|
|
501
|
+
const px2 = xScale(pb.x2);
|
|
502
|
+
const left = Math.min(px1, px2);
|
|
503
|
+
const top = Math.min(py1, py2);
|
|
504
|
+
geo = buildBandGeo(left, top, Math.abs(px2 - px1), Math.abs(py2 - py1), fill, fillOpacity, pb, "box", cartesianArea);
|
|
505
|
+
} else if (pb.y1 != null && pb.y2 != null) {
|
|
506
|
+
const scale = findValueScale(axisLayouts, pb.yAxisId);
|
|
507
|
+
if (!scale) continue;
|
|
508
|
+
const py1 = scale(pb.y1);
|
|
509
|
+
const py2 = scale(pb.y2);
|
|
510
|
+
if (orientation === "horizontal") {
|
|
511
|
+
const left = Math.min(py1, py2);
|
|
512
|
+
const right = Math.max(py1, py2);
|
|
513
|
+
geo = buildBandGeo(left, cartesianArea.y, right - left, cartesianArea.height, fill, fillOpacity, pb, "vertical", cartesianArea);
|
|
514
|
+
} else {
|
|
515
|
+
const top = Math.min(py1, py2);
|
|
516
|
+
const bot = Math.max(py1, py2);
|
|
517
|
+
geo = buildBandGeo(cartesianArea.x, top, cartesianArea.width, bot - top, fill, fillOpacity, pb, "horizontal", cartesianArea);
|
|
518
|
+
}
|
|
519
|
+
} else if (pb.x1 != null && pb.x2 != null) {
|
|
520
|
+
if (typeof pb.x1 === "string" && typeof pb.x2 === "string" && categoryScale) {
|
|
521
|
+
const bw = categoryScale.bandwidth();
|
|
522
|
+
let c1 = categoryScale(pb.x1);
|
|
523
|
+
let c2 = categoryScale(pb.x2);
|
|
524
|
+
if (isNaN(c1) && isNaN(c2)) continue;
|
|
525
|
+
if (isNaN(c1)) c1 = orientation === "horizontal" ? cartesianArea.y : cartesianArea.x;
|
|
526
|
+
if (isNaN(c2)) c2 = (orientation === "horizontal" ? cartesianArea.y + cartesianArea.height : cartesianArea.x + cartesianArea.width) - bw;
|
|
527
|
+
if (c1 != null && c2 != null) {
|
|
528
|
+
const left1 = c1;
|
|
529
|
+
const right2 = c2 + bw;
|
|
530
|
+
if (left1 <= right2) {
|
|
531
|
+
if (orientation === "horizontal") {
|
|
532
|
+
geo = buildBandGeo(cartesianArea.x, left1, cartesianArea.width, right2 - left1, fill, fillOpacity, pb, "horizontal", cartesianArea);
|
|
533
|
+
} else {
|
|
534
|
+
geo = buildBandGeo(left1, cartesianArea.y, right2 - left1, cartesianArea.height, fill, fillOpacity, pb, "vertical", cartesianArea);
|
|
535
|
+
}
|
|
536
|
+
} else {
|
|
537
|
+
const areaEnd = orientation === "horizontal" ? cartesianArea.y + cartesianArea.height : cartesianArea.x + cartesianArea.width;
|
|
538
|
+
if (orientation === "horizontal") {
|
|
539
|
+
results.push(buildBandGeo(cartesianArea.x, left1, cartesianArea.width, areaEnd - left1, fill, fillOpacity, pb, "horizontal", cartesianArea));
|
|
540
|
+
results.push(buildBandGeo(cartesianArea.x, cartesianArea.y, cartesianArea.width, right2 - cartesianArea.y, fill, fillOpacity, { ...pb, label: void 0 }, "horizontal", cartesianArea));
|
|
541
|
+
} else {
|
|
542
|
+
results.push(buildBandGeo(left1, cartesianArea.y, areaEnd - left1, cartesianArea.height, fill, fillOpacity, pb, "vertical", cartesianArea));
|
|
543
|
+
results.push(buildBandGeo(cartesianArea.x, cartesianArea.y, right2 - cartesianArea.x, cartesianArea.height, fill, fillOpacity, { ...pb, label: void 0 }, "vertical", cartesianArea));
|
|
544
|
+
}
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
} else if (typeof pb.x1 === "number" && typeof pb.x2 === "number") {
|
|
549
|
+
const xScale = findXScale(axisLayouts);
|
|
550
|
+
if (xScale) {
|
|
551
|
+
const px1 = xScale(pb.x1);
|
|
552
|
+
const px2 = xScale(pb.x2);
|
|
553
|
+
const left = Math.min(px1, px2);
|
|
554
|
+
const right = Math.max(px1, px2);
|
|
555
|
+
if (orientation === "horizontal") {
|
|
556
|
+
geo = buildBandGeo(cartesianArea.x, left, cartesianArea.width, right - left, fill, fillOpacity, pb, "horizontal", cartesianArea);
|
|
557
|
+
} else {
|
|
558
|
+
geo = buildBandGeo(left, cartesianArea.y, right - left, cartesianArea.height, fill, fillOpacity, pb, "vertical", cartesianArea);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (geo) results.push(geo);
|
|
564
|
+
}
|
|
565
|
+
return results;
|
|
566
|
+
}
|
|
567
|
+
function buildBandGeo(x, y, width, height, fill, fillOpacity, pb, bandDirection, area) {
|
|
568
|
+
const pos = pb.labelPosition ?? "center";
|
|
569
|
+
let labelX;
|
|
570
|
+
let labelY;
|
|
571
|
+
let labelAnchor;
|
|
572
|
+
let labelBaseline;
|
|
573
|
+
if (bandDirection === "box") {
|
|
574
|
+
if (pos === "start") {
|
|
575
|
+
labelX = x + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
576
|
+
labelY = y + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
577
|
+
labelAnchor = "start";
|
|
578
|
+
labelBaseline = "hanging";
|
|
579
|
+
} else if (pos === "end") {
|
|
580
|
+
labelX = x + width - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
581
|
+
labelY = y + height - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
582
|
+
labelAnchor = "end";
|
|
583
|
+
labelBaseline = "auto";
|
|
584
|
+
} else {
|
|
585
|
+
labelX = x + width / 2;
|
|
586
|
+
labelY = y + height / 2;
|
|
587
|
+
labelAnchor = "middle";
|
|
588
|
+
labelBaseline = "central";
|
|
589
|
+
}
|
|
590
|
+
} else if (bandDirection === "horizontal") {
|
|
591
|
+
labelY = y + height / 2;
|
|
592
|
+
labelBaseline = "central";
|
|
593
|
+
if (pos === "start") {
|
|
594
|
+
labelX = area.x + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
595
|
+
labelAnchor = "start";
|
|
596
|
+
} else if (pos === "center") {
|
|
597
|
+
labelX = x + width / 2;
|
|
598
|
+
labelAnchor = "middle";
|
|
599
|
+
} else {
|
|
600
|
+
labelX = area.x + area.width - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
601
|
+
labelAnchor = "end";
|
|
602
|
+
}
|
|
603
|
+
} else {
|
|
604
|
+
labelX = x + width / 2;
|
|
605
|
+
labelAnchor = "middle";
|
|
606
|
+
if (pos === "start") {
|
|
607
|
+
labelY = area.y + DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
608
|
+
labelBaseline = "hanging";
|
|
609
|
+
} else if (pos === "center") {
|
|
610
|
+
labelY = y + height / 2;
|
|
611
|
+
labelBaseline = "central";
|
|
612
|
+
} else {
|
|
613
|
+
labelY = area.y + area.height - DEFAULT_REFERENCE_LABEL_OFFSET;
|
|
614
|
+
labelBaseline = "auto";
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
x,
|
|
619
|
+
y,
|
|
620
|
+
width,
|
|
621
|
+
height,
|
|
622
|
+
fill,
|
|
623
|
+
fillOpacity,
|
|
624
|
+
stroke: pb.stroke,
|
|
625
|
+
label: pb.label,
|
|
626
|
+
labelX,
|
|
627
|
+
labelY,
|
|
628
|
+
labelAnchor,
|
|
629
|
+
labelBaseline,
|
|
630
|
+
labelColor: pb.labelColor,
|
|
631
|
+
labelFontSize: pb.labelFontSize,
|
|
632
|
+
labelFontWeight: pb.labelFontWeight
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
function computeLabelBgRect(labelX, baselineY, anchor, textWidth, fontSize, padding, topToAlpha) {
|
|
636
|
+
const ascent = topToAlpha;
|
|
637
|
+
const descent = fontSize - topToAlpha;
|
|
638
|
+
const w = textWidth + padding * 2;
|
|
639
|
+
const h = ascent + descent + padding * 2;
|
|
640
|
+
const y = baselineY - ascent - padding;
|
|
641
|
+
let x;
|
|
642
|
+
if (anchor === "middle") x = labelX - w / 2;
|
|
643
|
+
else if (anchor === "end") x = labelX + padding - w;
|
|
644
|
+
else x = labelX - padding;
|
|
645
|
+
return { x, y, w, h };
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/utils/plotReference/svg.ts
|
|
649
|
+
function renderReferenceBandsSvg(bands, globalFont) {
|
|
650
|
+
if (bands.length === 0) return null;
|
|
651
|
+
const group = createSvgGroup();
|
|
652
|
+
const fontFamily = resolveFontFamily(void 0, globalFont);
|
|
653
|
+
for (const b of bands) {
|
|
654
|
+
const attrs = { class: "p-chart-reference-band", fill: b.fill, "fill-opacity": b.fillOpacity };
|
|
655
|
+
if (b.stroke) attrs.stroke = b.stroke;
|
|
656
|
+
appendChild(group, createSvgRect(b.x, b.y, b.width, b.height, attrs));
|
|
657
|
+
if (b.label) {
|
|
658
|
+
const fontSize = resolveFontSize(b.labelFontSize ?? DEFAULT_REFERENCE_LABEL_FONT_SIZE, globalFont);
|
|
659
|
+
const weight = b.labelFontWeight != null ? String(b.labelFontWeight) : "normal";
|
|
660
|
+
const { topToAlpha, midToAlpha } = measureFontMetrics(fontSize, fontFamily, weight);
|
|
661
|
+
const dy = b.labelBaseline === "central" ? midToAlpha : b.labelBaseline === "hanging" ? topToAlpha : void 0;
|
|
662
|
+
const labelAttrs = {
|
|
663
|
+
"text-anchor": b.labelAnchor,
|
|
664
|
+
"dominant-baseline": "auto",
|
|
665
|
+
dy,
|
|
666
|
+
"font-size": fontSize,
|
|
667
|
+
"font-family": fontFamily,
|
|
668
|
+
"pointer-events": "none"
|
|
669
|
+
};
|
|
670
|
+
if (b.labelColor) labelAttrs.style = `fill:${b.labelColor}`;
|
|
671
|
+
else labelAttrs.class = "p-chart-annotation";
|
|
672
|
+
if (b.labelFontWeight != null) labelAttrs["font-weight"] = b.labelFontWeight;
|
|
673
|
+
appendChild(group, createSvgText(b.labelX, b.labelY, b.label, labelAttrs));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return group;
|
|
677
|
+
}
|
|
678
|
+
function renderReferenceLinesSvg(lines, globalFont) {
|
|
679
|
+
if (lines.length === 0) return null;
|
|
680
|
+
const group = createSvgGroup();
|
|
681
|
+
const fontFamily = resolveFontFamily(void 0, globalFont);
|
|
682
|
+
for (const l of lines) {
|
|
683
|
+
const attrs = {
|
|
684
|
+
class: "p-chart-reference-line",
|
|
685
|
+
stroke: l.stroke,
|
|
686
|
+
"stroke-width": l.lineStrokeWidth
|
|
687
|
+
};
|
|
688
|
+
if (l.dashArray) attrs["stroke-dasharray"] = l.dashArray.join(" ");
|
|
689
|
+
appendChild(group, createSvgLine(l.x1, l.y1, l.x2, l.y2, attrs));
|
|
690
|
+
if (l.label) {
|
|
691
|
+
const fontSize = resolveFontSize(l.labelFontSize ?? DEFAULT_REFERENCE_LABEL_FONT_SIZE, globalFont);
|
|
692
|
+
const weight = String(l.labelFontWeight ?? DEFAULT_REFERENCE_LABEL_FONT_WEIGHT);
|
|
693
|
+
const { topToAlpha, midToAlpha } = measureFontMetrics(fontSize, fontFamily, weight);
|
|
694
|
+
const dy = l.labelBaseline === "central" ? midToAlpha : l.labelBaseline === "hanging" ? topToAlpha : void 0;
|
|
695
|
+
if (l.labelBackground) {
|
|
696
|
+
const padding = l.labelPadding ?? 5;
|
|
697
|
+
const radius = l.labelBorderRadius ?? 4;
|
|
698
|
+
const textWidth = measureTextWidth(l.label, fontSize, weight, fontFamily);
|
|
699
|
+
const rect = computeLabelBgRect(l.labelX, l.labelY + (dy ?? 0), l.labelAnchor, textWidth, fontSize, padding, topToAlpha);
|
|
700
|
+
const bgAttrs = {
|
|
701
|
+
rx: radius,
|
|
702
|
+
ry: radius,
|
|
703
|
+
fill: l.labelBackground,
|
|
704
|
+
"pointer-events": "none"
|
|
705
|
+
};
|
|
706
|
+
if (l.labelBackgroundOpacity != null) bgAttrs["fill-opacity"] = l.labelBackgroundOpacity;
|
|
707
|
+
appendChild(group, createSvgRect(rect.x, rect.y, rect.w, rect.h, bgAttrs));
|
|
708
|
+
}
|
|
709
|
+
const explicitFill = l.labelColor ?? (l.stroke === "currentColor" ? void 0 : l.stroke);
|
|
710
|
+
const textAttrs = {
|
|
711
|
+
"text-anchor": l.labelAnchor,
|
|
712
|
+
"dominant-baseline": "auto",
|
|
713
|
+
dy,
|
|
714
|
+
"font-size": fontSize,
|
|
715
|
+
"font-family": fontFamily,
|
|
716
|
+
"font-weight": l.labelFontWeight ?? DEFAULT_REFERENCE_LABEL_FONT_WEIGHT,
|
|
717
|
+
"pointer-events": "none"
|
|
718
|
+
};
|
|
719
|
+
if (explicitFill) textAttrs.style = `fill:${explicitFill}`;
|
|
720
|
+
else textAttrs.class = "p-chart-annotation";
|
|
721
|
+
appendChild(group, createSvgText(l.labelX, l.labelY, l.label, textAttrs));
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return group;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/utils/plotReference/canvas.ts
|
|
728
|
+
function renderReferenceBandsCanvas(ctx, bands, globalFont, theme) {
|
|
729
|
+
const fontFamily = resolveFontFamily(void 0, globalFont);
|
|
730
|
+
for (const b of bands) {
|
|
731
|
+
withCanvasState(ctx, () => {
|
|
732
|
+
ctx.globalAlpha = b.fillOpacity;
|
|
733
|
+
ctx.fillStyle = b.fill;
|
|
734
|
+
ctx.fillRect(b.x, b.y, b.width, b.height);
|
|
735
|
+
if (b.stroke) {
|
|
736
|
+
ctx.globalAlpha = 1;
|
|
737
|
+
ctx.strokeStyle = b.stroke;
|
|
738
|
+
ctx.strokeRect(b.x, b.y, b.width, b.height);
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
if (b.label) {
|
|
742
|
+
withCanvasState(ctx, () => {
|
|
743
|
+
const labelFontSize = resolveFontSize(b.labelFontSize ?? DEFAULT_REFERENCE_LABEL_FONT_SIZE, globalFont);
|
|
744
|
+
const weight = b.labelFontWeight != null ? `${b.labelFontWeight} ` : "";
|
|
745
|
+
const { topToAlpha, midToAlpha } = measureFontMetrics(labelFontSize, fontFamily, weight.trim() || "normal");
|
|
746
|
+
const dy = b.labelBaseline === "central" ? midToAlpha : b.labelBaseline === "hanging" ? topToAlpha : 0;
|
|
747
|
+
ctx.font = `${weight}${labelFontSize}px ${fontFamily}`;
|
|
748
|
+
ctx.fillStyle = b.labelColor ?? theme.annotation;
|
|
749
|
+
ctx.textAlign = b.labelAnchor === "middle" ? "center" : b.labelAnchor;
|
|
750
|
+
ctx.textBaseline = "alphabetic";
|
|
751
|
+
ctx.fillText(b.label, b.labelX, b.labelY + dy);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function renderReferenceLinesCanvas(ctx, lines, globalFont, theme) {
|
|
757
|
+
const fontFamily = resolveFontFamily(void 0, globalFont);
|
|
758
|
+
for (const l of lines) {
|
|
759
|
+
withCanvasState(ctx, () => {
|
|
760
|
+
ctx.strokeStyle = l.stroke;
|
|
761
|
+
ctx.lineWidth = l.lineStrokeWidth;
|
|
762
|
+
if (l.dashArray) ctx.setLineDash(l.dashArray);
|
|
763
|
+
ctx.beginPath();
|
|
764
|
+
ctx.moveTo(l.x1, l.y1);
|
|
765
|
+
ctx.lineTo(l.x2, l.y2);
|
|
766
|
+
ctx.stroke();
|
|
767
|
+
});
|
|
768
|
+
if (l.label) {
|
|
769
|
+
withCanvasState(ctx, () => {
|
|
770
|
+
const labelFontSize = resolveFontSize(l.labelFontSize ?? DEFAULT_REFERENCE_LABEL_FONT_SIZE, globalFont);
|
|
771
|
+
const weight = l.labelFontWeight ?? DEFAULT_REFERENCE_LABEL_FONT_WEIGHT;
|
|
772
|
+
const { topToAlpha, midToAlpha } = measureFontMetrics(labelFontSize, fontFamily, String(weight));
|
|
773
|
+
const dy = l.labelBaseline === "central" ? midToAlpha : l.labelBaseline === "hanging" ? topToAlpha : 0;
|
|
774
|
+
ctx.font = `${weight} ${labelFontSize}px ${fontFamily}`;
|
|
775
|
+
if (l.labelBackground) {
|
|
776
|
+
const padding = l.labelPadding ?? 5;
|
|
777
|
+
const radius = l.labelBorderRadius ?? 4;
|
|
778
|
+
const textWidth = ctx.measureText(l.label).width;
|
|
779
|
+
const rect = computeLabelBgRect(l.labelX, l.labelY + dy, l.labelAnchor, textWidth, labelFontSize, padding, topToAlpha);
|
|
780
|
+
const prevAlpha = ctx.globalAlpha;
|
|
781
|
+
if (l.labelBackgroundOpacity != null) ctx.globalAlpha = prevAlpha * l.labelBackgroundOpacity;
|
|
782
|
+
ctx.fillStyle = l.labelBackground;
|
|
783
|
+
ctx.beginPath();
|
|
784
|
+
ctx.roundRect(rect.x, rect.y, rect.w, rect.h, radius);
|
|
785
|
+
ctx.fill();
|
|
786
|
+
ctx.globalAlpha = prevAlpha;
|
|
787
|
+
}
|
|
788
|
+
ctx.fillStyle = l.labelColor ?? (l.stroke === "currentColor" ? theme.annotation : l.stroke);
|
|
789
|
+
ctx.textAlign = l.labelAnchor === "middle" ? "center" : l.labelAnchor;
|
|
790
|
+
ctx.textBaseline = "alphabetic";
|
|
791
|
+
ctx.fillText(l.label, l.labelX, l.labelY + dy);
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function extractReferenceFeatures(features) {
|
|
797
|
+
const referenceLines = [];
|
|
798
|
+
const referenceBands = [];
|
|
799
|
+
for (const [key, feat] of features) {
|
|
800
|
+
if (typeof key === "string" && key.startsWith("referenceLine:")) referenceLines.push(feat.props);
|
|
801
|
+
if (typeof key === "string" && key.startsWith("referenceBand:")) referenceBands.push(feat.props);
|
|
802
|
+
}
|
|
803
|
+
return { referenceLines, referenceBands };
|
|
804
|
+
}
|
|
805
|
+
function withReferenceFeatures(layout, features) {
|
|
806
|
+
const { referenceLines, referenceBands } = extractReferenceFeatures(features);
|
|
807
|
+
return {
|
|
808
|
+
...layout,
|
|
809
|
+
referenceLines: referenceLines.length ? referenceLines : void 0,
|
|
810
|
+
referenceBands: referenceBands.length ? referenceBands : void 0
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// src/utils/styles.ts
|
|
815
|
+
var LEGEND_ITEM_BASE_STYLE = {
|
|
816
|
+
display: "flex",
|
|
817
|
+
alignItems: "center",
|
|
818
|
+
gap: "6px",
|
|
819
|
+
color: "var(--p-chart-legend-color, #374151)",
|
|
820
|
+
padding: "2px 4px",
|
|
821
|
+
borderRadius: "4px",
|
|
822
|
+
transition: "opacity 0.2s, background-color 0.2s"
|
|
823
|
+
};
|
|
824
|
+
var LEGEND_SWATCH_STYLE = {
|
|
825
|
+
width: "12px",
|
|
826
|
+
height: "12px",
|
|
827
|
+
borderRadius: "2px",
|
|
828
|
+
flexShrink: 0
|
|
829
|
+
};
|
|
830
|
+
var TOOLTIP_BASE_STYLE = {
|
|
831
|
+
position: "absolute",
|
|
832
|
+
pointerEvents: "none",
|
|
833
|
+
zIndex: 1e3
|
|
834
|
+
};
|
|
835
|
+
var TOOLTIP_DEFAULT_STYLE = {
|
|
836
|
+
display: "flex",
|
|
837
|
+
flexDirection: "column"
|
|
838
|
+
};
|
|
839
|
+
var TOOLTIP_COLOR_INDICATOR_STYLE = {
|
|
840
|
+
width: "10px",
|
|
841
|
+
height: "10px",
|
|
842
|
+
borderRadius: "2px"
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
// src/utils/annotation.utils.ts
|
|
846
|
+
function buildAnnotationContext(params) {
|
|
847
|
+
const { width, height, chartArea, center, xScale, yScale, getScale, fontFamily, hiddenItems, datasetVisibility, hoveredItem, theme } = params;
|
|
848
|
+
return {
|
|
849
|
+
width,
|
|
850
|
+
height,
|
|
851
|
+
chartArea,
|
|
852
|
+
center,
|
|
853
|
+
xScale,
|
|
854
|
+
yScale,
|
|
855
|
+
getScale,
|
|
856
|
+
fontFamily,
|
|
857
|
+
textColor: theme.annotation,
|
|
858
|
+
isItemVisible: (dsId, idx) => !hiddenItems.get(dsId)?.has(idx),
|
|
859
|
+
isDatasetVisible: (dsId) => datasetVisibility.get(dsId) ?? true,
|
|
860
|
+
hoveredItem: hoveredItem ?? null
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function renderAnnotationsCanvas(ctx, annotations, baseContext) {
|
|
864
|
+
if (annotations.size === 0) return;
|
|
865
|
+
const fullContext = { ...baseContext, ctx };
|
|
866
|
+
annotations.forEach((renderFn) => {
|
|
867
|
+
ctx.save();
|
|
868
|
+
ctx.fillStyle = baseContext.textColor;
|
|
869
|
+
renderFn(fullContext);
|
|
870
|
+
ctx.restore();
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export { ItemCollector, LEGEND_ITEM_BASE_STYLE, LEGEND_SWATCH_STYLE, TOOLTIP_BASE_STYLE, TOOLTIP_COLOR_INDICATOR_STYLE, TOOLTIP_DEFAULT_STYLE, buildAnnotationContext, buildLegendItems, buildMarkerRenderItems, buildSharedLegendItems, computeLegendStyle, computeReferenceBands, computeReferenceLines, extractReferenceFeatures, observeDocumentDir, renderAnnotationsCanvas, renderCustomMarkersCanvas, renderReferenceBandsCanvas, renderReferenceBandsSvg, renderReferenceLinesCanvas, renderReferenceLinesSvg, resolveDirFromElement, resolveLegendClickAction, resolveLegendHoverTarget, withReferenceFeatures };
|