@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,92 @@
|
|
|
1
|
+
import { toTimestamp } from './chunk-RQ3CKQOX.mjs';
|
|
2
|
+
|
|
3
|
+
// src/cartesian/hittest.ts
|
|
4
|
+
function resolveValueAxisId(barProps, layoutData) {
|
|
5
|
+
if (barProps.yAxisId) return barProps.yAxisId;
|
|
6
|
+
const firstId = layoutData.valueScales.keys().next().value;
|
|
7
|
+
return firstId ?? "default";
|
|
8
|
+
}
|
|
9
|
+
function resolveValueAxisFormat(barProps, orientation, layoutData) {
|
|
10
|
+
if (!layoutData) return null;
|
|
11
|
+
const axisId = resolveValueAxisId(barProps, layoutData);
|
|
12
|
+
const valAxisKey = orientation === "vertical" ? `y:${axisId}` : `x:${axisId}`;
|
|
13
|
+
const valAxisInfo = layoutData.axisLayouts.get(valAxisKey);
|
|
14
|
+
return typeof valAxisInfo?.props?.tickFormat === "function" ? valAxisInfo.props.tickFormat : null;
|
|
15
|
+
}
|
|
16
|
+
function formatHitValue(value, barProps, orientation, layoutData) {
|
|
17
|
+
const tickFmt = resolveValueAxisFormat(barProps, orientation, layoutData);
|
|
18
|
+
return tickFmt ? tickFmt(value) : String(value);
|
|
19
|
+
}
|
|
20
|
+
function formatCursorValue(cursorX, cursorY, barProps, orientation, layoutData) {
|
|
21
|
+
if (!layoutData) return "";
|
|
22
|
+
const axisId = resolveValueAxisId(barProps, layoutData);
|
|
23
|
+
const valueScale = layoutData.valueScales.get(axisId);
|
|
24
|
+
if (!valueScale) return "";
|
|
25
|
+
const cursorPixel = orientation === "vertical" ? cursorY : cursorX;
|
|
26
|
+
const cursorValue = valueScale.invert(cursorPixel);
|
|
27
|
+
const tickFmt = resolveValueAxisFormat(barProps, orientation, layoutData);
|
|
28
|
+
const rounded = Math.round(cursorValue);
|
|
29
|
+
return tickFmt ? tickFmt(rounded) : String(rounded);
|
|
30
|
+
}
|
|
31
|
+
var TOOLTIP_DATE_FORMAT = {
|
|
32
|
+
weekday: "long",
|
|
33
|
+
year: "numeric",
|
|
34
|
+
month: "short",
|
|
35
|
+
day: "numeric",
|
|
36
|
+
hour: "2-digit",
|
|
37
|
+
minute: "2-digit",
|
|
38
|
+
hour12: true
|
|
39
|
+
};
|
|
40
|
+
var TOOLTIP_DATE_ONLY_FORMAT = {
|
|
41
|
+
weekday: "long",
|
|
42
|
+
year: "numeric",
|
|
43
|
+
month: "short",
|
|
44
|
+
day: "numeric"
|
|
45
|
+
};
|
|
46
|
+
var TOOLTIP_SECONDS_SPAN_MS = 10 * 60 * 1e3;
|
|
47
|
+
var TOOLTIP_TIME_SECONDS_FORMAT = {
|
|
48
|
+
hour: "2-digit",
|
|
49
|
+
minute: "2-digit",
|
|
50
|
+
second: "2-digit",
|
|
51
|
+
hour12: true
|
|
52
|
+
};
|
|
53
|
+
var _tooltipDateFmt = null;
|
|
54
|
+
var _tooltipDateOnlyFmt = null;
|
|
55
|
+
var _tooltipSecondsFmt = null;
|
|
56
|
+
var _tooltipFmtTimezone;
|
|
57
|
+
var _tooltipFmtLocale;
|
|
58
|
+
function formatTimeLabel(rawLabel, layoutData, locale) {
|
|
59
|
+
if (!layoutData?.sharedTimeScale) return rawLabel;
|
|
60
|
+
const ts = toTimestamp(rawLabel);
|
|
61
|
+
if (isNaN(ts)) return rawLabel;
|
|
62
|
+
const tz = layoutData.timeAxisTimezone;
|
|
63
|
+
const d = new Date(ts);
|
|
64
|
+
const isMidnight = d.getUTCHours() === 0 && d.getUTCMinutes() === 0 && d.getUTCSeconds() === 0 && d.getUTCMilliseconds() === 0;
|
|
65
|
+
if (tz !== _tooltipFmtTimezone || locale !== _tooltipFmtLocale) {
|
|
66
|
+
_tooltipDateFmt = null;
|
|
67
|
+
_tooltipDateOnlyFmt = null;
|
|
68
|
+
_tooltipSecondsFmt = null;
|
|
69
|
+
_tooltipFmtTimezone = tz;
|
|
70
|
+
_tooltipFmtLocale = locale;
|
|
71
|
+
}
|
|
72
|
+
const [minTs, maxTs] = layoutData.sharedTimeScale.domain();
|
|
73
|
+
const spanMs = maxTs - minTs;
|
|
74
|
+
if (spanMs > 0 && spanMs <= TOOLTIP_SECONDS_SPAN_MS) {
|
|
75
|
+
if (!_tooltipSecondsFmt) {
|
|
76
|
+
_tooltipSecondsFmt = new Intl.DateTimeFormat(locale, { timeZone: tz ?? "UTC", ...TOOLTIP_TIME_SECONDS_FORMAT });
|
|
77
|
+
}
|
|
78
|
+
return _tooltipSecondsFmt.format(d);
|
|
79
|
+
}
|
|
80
|
+
if (isMidnight) {
|
|
81
|
+
if (!_tooltipDateOnlyFmt) {
|
|
82
|
+
_tooltipDateOnlyFmt = new Intl.DateTimeFormat(locale, { timeZone: tz ?? "UTC", ...TOOLTIP_DATE_ONLY_FORMAT });
|
|
83
|
+
}
|
|
84
|
+
return _tooltipDateOnlyFmt.format(d);
|
|
85
|
+
}
|
|
86
|
+
if (!_tooltipDateFmt) {
|
|
87
|
+
_tooltipDateFmt = new Intl.DateTimeFormat(locale, { timeZone: tz ?? "UTC", ...TOOLTIP_DATE_FORMAT });
|
|
88
|
+
}
|
|
89
|
+
return _tooltipDateFmt.format(d);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { formatCursorValue, formatHitValue, formatTimeLabel, resolveValueAxisFormat, resolveValueAxisId };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { resolveBoostActive } from './chunk-PRDVPOZX.mjs';
|
|
2
|
+
import { SCATTER_BOOST_AUTO_THRESHOLD, DEFAULT_MIN_BUBBLE_SIZE, DEFAULT_MAX_BUBBLE_SIZE, DEFAULT_SCATTER_MARKER_SIZE, DEFAULT_SCATTER_HIT_RADIUS, SCATTER_SPATIAL_INDEX_THRESHOLD } from './chunk-NKUYIWAP.mjs';
|
|
3
|
+
import { buildQuadtree } from './chunk-C36VWQ7A.mjs';
|
|
4
|
+
import { batchResolveAccessor, resolveAccessor, makeItemContext } from './chunk-O2X6FF45.mjs';
|
|
5
|
+
|
|
6
|
+
// src/series/scatter/geometry.ts
|
|
7
|
+
function isBoostActive(props, visibleCount) {
|
|
8
|
+
return resolveBoostActive(props.boost, visibleCount, SCATTER_BOOST_AUTO_THRESHOLD);
|
|
9
|
+
}
|
|
10
|
+
function calculateScatterLayout(props, chartArea, config) {
|
|
11
|
+
const { data = [] } = props;
|
|
12
|
+
const { xScale, yScale, stackBases } = config ?? { xScale: void 0, yScale: void 0, stackBases: void 0 };
|
|
13
|
+
const markerSizeAccessor = props.markerSize;
|
|
14
|
+
const minSize = props.minSize ?? DEFAULT_MIN_BUBBLE_SIZE;
|
|
15
|
+
const maxSize = props.maxSize ?? DEFAULT_MAX_BUBBLE_SIZE;
|
|
16
|
+
const seriesIdx = props.order ?? 0;
|
|
17
|
+
const seriesExtras = { seriesIndex: seriesIdx, seriesId: props.id ?? "" };
|
|
18
|
+
const xValues = batchResolveAccessor(props.xField, data);
|
|
19
|
+
const yValues = batchResolveAccessor(props.yField, data);
|
|
20
|
+
const seriesColor = props.color != null && data.length > 0 ? resolveAccessor(props.color, makeItemContext(data[0], 0, { value: yValues[0], category: String(xValues[0]), ...seriesExtras })) : void 0;
|
|
21
|
+
let sizeValues;
|
|
22
|
+
let sizeMin = Infinity;
|
|
23
|
+
let sizeMax = -Infinity;
|
|
24
|
+
if (props.sizeField) {
|
|
25
|
+
sizeValues = batchResolveAccessor(props.sizeField, data);
|
|
26
|
+
for (const s of sizeValues) {
|
|
27
|
+
if (s != null && !isNaN(s)) {
|
|
28
|
+
if (s < sizeMin) sizeMin = s;
|
|
29
|
+
if (s > sizeMax) sizeMax = s;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (sizeMin === sizeMax) {
|
|
33
|
+
sizeMin = 0;
|
|
34
|
+
sizeMax = sizeMax || 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const treatNullAsZero = props.connectNulls === "zero";
|
|
38
|
+
const colorAccessor = props.color;
|
|
39
|
+
const rotationAccessor = props.pointRotation;
|
|
40
|
+
const points = data.map((item, i) => {
|
|
41
|
+
const rawX = xValues[i];
|
|
42
|
+
const rawY = yValues[i];
|
|
43
|
+
const xVal = (rawX == null || isNaN(rawX)) && treatNullAsZero ? 0 : rawX;
|
|
44
|
+
const yVal = (rawY == null || isNaN(rawY)) && treatNullAsZero ? 0 : rawY;
|
|
45
|
+
const visible = props.visibility ? props.visibility.get(i) !== false : true;
|
|
46
|
+
const stackBase = stackBases?.[i] ?? 0;
|
|
47
|
+
const px = xScale(xVal);
|
|
48
|
+
const py = yScale(yVal == null || typeof yVal === "number" && isNaN(yVal) ? yVal : stackBase + yVal);
|
|
49
|
+
const ctx = makeItemContext(item, i, { value: yVal, category: String(xVal), ...seriesExtras });
|
|
50
|
+
let radius = resolveAccessor(markerSizeAccessor, ctx, { arrayMode: "clip", fallback: DEFAULT_SCATTER_MARKER_SIZE }) ?? DEFAULT_SCATTER_MARKER_SIZE;
|
|
51
|
+
if (sizeValues) {
|
|
52
|
+
const sizeVal = sizeValues[i];
|
|
53
|
+
if (sizeVal != null && !isNaN(sizeVal)) {
|
|
54
|
+
const normalized = (sizeVal - sizeMin) / (sizeMax - sizeMin);
|
|
55
|
+
radius = Math.sqrt(normalized) * (maxSize - minSize) + minSize;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const rotation = resolveAccessor(rotationAccessor, ctx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
59
|
+
let color;
|
|
60
|
+
if (colorAccessor != null) {
|
|
61
|
+
const resolved = resolveAccessor(colorAccessor, ctx);
|
|
62
|
+
if (resolved != null) color = resolved;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
dataIndex: i,
|
|
66
|
+
px,
|
|
67
|
+
py,
|
|
68
|
+
xValue: xVal,
|
|
69
|
+
yValue: yVal,
|
|
70
|
+
radius,
|
|
71
|
+
rotation,
|
|
72
|
+
...sizeValues ? { sizeValue: sizeValues[i] } : {},
|
|
73
|
+
color,
|
|
74
|
+
visible
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
const visiblePoints = points.filter((p) => p.visible && !isNaN(p.px) && !isNaN(p.py) && isFinite(p.px) && isFinite(p.py));
|
|
78
|
+
return {
|
|
79
|
+
datasetId: "",
|
|
80
|
+
points,
|
|
81
|
+
visiblePoints,
|
|
82
|
+
chartArea,
|
|
83
|
+
seriesColor,
|
|
84
|
+
seriesIdx
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function hitTestScatter(x, y, _props, layout) {
|
|
88
|
+
const baseRadius = _props.pointHitRadius ?? DEFAULT_SCATTER_HIT_RADIUS;
|
|
89
|
+
if (layout.visiblePoints.length > SCATTER_SPATIAL_INDEX_THRESHOLD) {
|
|
90
|
+
if (!layout.spatialIndex) {
|
|
91
|
+
const area = layout.chartArea;
|
|
92
|
+
const quadPoints = new Array(layout.visiblePoints.length);
|
|
93
|
+
const map = /* @__PURE__ */ new Map();
|
|
94
|
+
for (let i = 0; i < layout.visiblePoints.length; i++) {
|
|
95
|
+
const pt = layout.visiblePoints[i];
|
|
96
|
+
quadPoints[i] = { x: pt.px, y: pt.py, idx: pt.dataIndex, r: pt.radius };
|
|
97
|
+
map.set(pt.dataIndex, pt);
|
|
98
|
+
}
|
|
99
|
+
layout.spatialIndex = buildQuadtree(quadPoints, { x0: area.x, y0: area.y, x1: area.x + area.width, y1: area.y + area.height });
|
|
100
|
+
layout.pointByDataIndex = map;
|
|
101
|
+
}
|
|
102
|
+
return layout.spatialIndex.queryNearest(x, y, baseRadius)?.idx ?? null;
|
|
103
|
+
}
|
|
104
|
+
let nearestIndex = null;
|
|
105
|
+
let minDistSq = Infinity;
|
|
106
|
+
for (const pt of layout.visiblePoints) {
|
|
107
|
+
const hitRadius = Math.max(baseRadius, pt.radius);
|
|
108
|
+
const dx = pt.px - x;
|
|
109
|
+
const dy = pt.py - y;
|
|
110
|
+
const distSq = dx * dx + dy * dy;
|
|
111
|
+
if (distSq <= hitRadius * hitRadius && distSq < minDistSq) {
|
|
112
|
+
minDistSq = distSq;
|
|
113
|
+
nearestIndex = pt.dataIndex;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return nearestIndex;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { calculateScatterLayout, hitTestScatter, isBoostActive };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/renderers/navigator/canvas.ts
|
|
2
|
+
function traceRoundedRect(ctx, x, y, w, h, r) {
|
|
3
|
+
const mr = Math.min(r, w / 2, h / 2);
|
|
4
|
+
ctx.beginPath();
|
|
5
|
+
ctx.moveTo(x + mr, y);
|
|
6
|
+
ctx.lineTo(x + w - mr, y);
|
|
7
|
+
ctx.arcTo(x + w, y, x + w, y + mr, mr);
|
|
8
|
+
ctx.lineTo(x + w, y + h - mr);
|
|
9
|
+
ctx.arcTo(x + w, y + h, x + w - mr, y + h, mr);
|
|
10
|
+
ctx.lineTo(x + mr, y + h);
|
|
11
|
+
ctx.arcTo(x, y + h, x, y + h - mr, mr);
|
|
12
|
+
ctx.lineTo(x, y + mr);
|
|
13
|
+
ctx.arcTo(x, y, x + mr, y, mr);
|
|
14
|
+
ctx.closePath();
|
|
15
|
+
}
|
|
16
|
+
function renderNavigatorCanvas(ctx, layout) {
|
|
17
|
+
const { area, data, scales, allSeries, ticks, selection, config } = layout;
|
|
18
|
+
const w = area.width;
|
|
19
|
+
const h = area.height;
|
|
20
|
+
ctx.save();
|
|
21
|
+
traceRoundedRect(ctx, 0, 0, w, h, 3);
|
|
22
|
+
ctx.fillStyle = config.backgroundColor;
|
|
23
|
+
ctx.fill();
|
|
24
|
+
traceRoundedRect(ctx, 0, 0, w, h, 3);
|
|
25
|
+
ctx.clip();
|
|
26
|
+
if (data && scales) {
|
|
27
|
+
ctx.strokeStyle = config.gridColor;
|
|
28
|
+
ctx.lineWidth = 1;
|
|
29
|
+
for (const tick of ticks) {
|
|
30
|
+
ctx.beginPath();
|
|
31
|
+
ctx.moveTo(tick.px, 0);
|
|
32
|
+
ctx.lineTo(tick.px, h);
|
|
33
|
+
ctx.stroke();
|
|
34
|
+
}
|
|
35
|
+
for (let si = 0; si < allSeries.length; si++) {
|
|
36
|
+
const entry = allSeries[si];
|
|
37
|
+
const isPrimary = si === 0;
|
|
38
|
+
const { points } = entry;
|
|
39
|
+
if (entry.paths.dots) {
|
|
40
|
+
ctx.fillStyle = entry.color;
|
|
41
|
+
ctx.globalAlpha = 0.7;
|
|
42
|
+
for (const dot of entry.paths.dots) {
|
|
43
|
+
ctx.beginPath();
|
|
44
|
+
ctx.arc(dot.px, dot.py, 2, 0, Math.PI * 2);
|
|
45
|
+
ctx.fill();
|
|
46
|
+
}
|
|
47
|
+
ctx.globalAlpha = 1;
|
|
48
|
+
} else if (entry.paths.bars) {
|
|
49
|
+
ctx.fillStyle = entry.color;
|
|
50
|
+
ctx.globalAlpha = config.opacity;
|
|
51
|
+
for (const bar of entry.paths.bars) {
|
|
52
|
+
ctx.fillRect(bar.px, bar.py, bar.width, bar.height);
|
|
53
|
+
}
|
|
54
|
+
ctx.globalAlpha = 1;
|
|
55
|
+
} else if (points.length > 0) {
|
|
56
|
+
if (isPrimary) {
|
|
57
|
+
ctx.beginPath();
|
|
58
|
+
ctx.moveTo(scales.x(points[0].x), scales.y(points[0].y));
|
|
59
|
+
for (let i = 1; i < points.length; i++) {
|
|
60
|
+
ctx.lineTo(scales.x(points[i].x), scales.y(points[i].y));
|
|
61
|
+
}
|
|
62
|
+
ctx.lineTo(scales.x(points[points.length - 1].x), h);
|
|
63
|
+
ctx.lineTo(scales.x(points[0].x), h);
|
|
64
|
+
ctx.closePath();
|
|
65
|
+
ctx.globalAlpha = config.opacity;
|
|
66
|
+
ctx.fillStyle = entry.color;
|
|
67
|
+
ctx.fill();
|
|
68
|
+
ctx.globalAlpha = 1;
|
|
69
|
+
}
|
|
70
|
+
ctx.beginPath();
|
|
71
|
+
ctx.moveTo(scales.x(points[0].x), scales.y(points[0].y));
|
|
72
|
+
for (let i = 1; i < points.length; i++) {
|
|
73
|
+
ctx.lineTo(scales.x(points[i].x), scales.y(points[i].y));
|
|
74
|
+
}
|
|
75
|
+
ctx.strokeStyle = entry.color;
|
|
76
|
+
ctx.lineWidth = 1.5;
|
|
77
|
+
ctx.stroke();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
ctx.fillStyle = config.labelColor;
|
|
81
|
+
ctx.font = "10px sans-serif";
|
|
82
|
+
ctx.textBaseline = "alphabetic";
|
|
83
|
+
ctx.textAlign = "start";
|
|
84
|
+
for (const tick of ticks) {
|
|
85
|
+
ctx.fillText(tick.label, tick.px + 3, h - 3);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const { x: selX, width: selW, isZoomed, is2D, y: selY, height: selH } = selection;
|
|
89
|
+
if (isZoomed) {
|
|
90
|
+
if (is2D && selY != null && selH != null) {
|
|
91
|
+
ctx.fillStyle = config.maskColor;
|
|
92
|
+
if (selY > 0) ctx.fillRect(0, 0, w, selY);
|
|
93
|
+
if (selY + selH < h) ctx.fillRect(0, selY + selH, w, h - selY - selH);
|
|
94
|
+
if (selX > 0) ctx.fillRect(0, selY, selX, selH);
|
|
95
|
+
if (selX + selW < w) ctx.fillRect(selX + selW, selY, w - selX - selW, selH);
|
|
96
|
+
ctx.fillStyle = config.selectionFill;
|
|
97
|
+
ctx.fillRect(selX, selY, selW, selH);
|
|
98
|
+
ctx.strokeStyle = config.selectionColor;
|
|
99
|
+
ctx.lineWidth = 1;
|
|
100
|
+
ctx.strokeRect(selX, selY, selW, selH);
|
|
101
|
+
ctx.strokeStyle = config.selectionColor;
|
|
102
|
+
ctx.lineCap = "round";
|
|
103
|
+
const midX = selX + selW / 2;
|
|
104
|
+
const midY = selY + selH / 2;
|
|
105
|
+
const gripLen = Math.min(selW * 0.3, 12);
|
|
106
|
+
const gripLenV = Math.min(selH * 0.3, 12);
|
|
107
|
+
ctx.lineWidth = 2;
|
|
108
|
+
ctx.beginPath();
|
|
109
|
+
ctx.moveTo(selX, midY - gripLenV);
|
|
110
|
+
ctx.lineTo(selX, midY + gripLenV);
|
|
111
|
+
ctx.stroke();
|
|
112
|
+
ctx.beginPath();
|
|
113
|
+
ctx.moveTo(selX + selW, midY - gripLenV);
|
|
114
|
+
ctx.lineTo(selX + selW, midY + gripLenV);
|
|
115
|
+
ctx.stroke();
|
|
116
|
+
ctx.beginPath();
|
|
117
|
+
ctx.moveTo(midX - gripLen, selY);
|
|
118
|
+
ctx.lineTo(midX + gripLen, selY);
|
|
119
|
+
ctx.stroke();
|
|
120
|
+
ctx.beginPath();
|
|
121
|
+
ctx.moveTo(midX - gripLen, selY + selH);
|
|
122
|
+
ctx.lineTo(midX + gripLen, selY + selH);
|
|
123
|
+
ctx.stroke();
|
|
124
|
+
} else {
|
|
125
|
+
if (selX > 0) {
|
|
126
|
+
traceRoundedRect(ctx, 0, 0, selX, h, 3);
|
|
127
|
+
ctx.fillStyle = config.maskColor;
|
|
128
|
+
ctx.fill();
|
|
129
|
+
}
|
|
130
|
+
if (selX + selW < w) {
|
|
131
|
+
ctx.fillStyle = config.maskColor;
|
|
132
|
+
ctx.fillRect(selX + selW, 0, w - selX - selW, h);
|
|
133
|
+
}
|
|
134
|
+
ctx.fillStyle = config.selectionFill;
|
|
135
|
+
ctx.fillRect(selX, 0, selW, h);
|
|
136
|
+
ctx.strokeStyle = config.selectionColor;
|
|
137
|
+
ctx.lineWidth = 1;
|
|
138
|
+
ctx.strokeRect(selX, 0, selW, h);
|
|
139
|
+
const gripY1 = h * 0.3;
|
|
140
|
+
const gripY2 = h * 0.7;
|
|
141
|
+
ctx.strokeStyle = config.selectionColor;
|
|
142
|
+
ctx.lineWidth = 2;
|
|
143
|
+
ctx.lineCap = "round";
|
|
144
|
+
ctx.beginPath();
|
|
145
|
+
ctx.moveTo(selX, gripY1);
|
|
146
|
+
ctx.lineTo(selX, gripY2);
|
|
147
|
+
ctx.stroke();
|
|
148
|
+
ctx.globalAlpha = 0.5;
|
|
149
|
+
ctx.lineWidth = 1;
|
|
150
|
+
ctx.beginPath();
|
|
151
|
+
ctx.moveTo(selX + config.gripLineGap, gripY1 + 2);
|
|
152
|
+
ctx.lineTo(selX + config.gripLineGap, gripY2 - 2);
|
|
153
|
+
ctx.stroke();
|
|
154
|
+
ctx.globalAlpha = 1;
|
|
155
|
+
ctx.lineWidth = 2;
|
|
156
|
+
ctx.beginPath();
|
|
157
|
+
ctx.moveTo(selX + selW, gripY1);
|
|
158
|
+
ctx.lineTo(selX + selW, gripY2);
|
|
159
|
+
ctx.stroke();
|
|
160
|
+
ctx.globalAlpha = 0.5;
|
|
161
|
+
ctx.lineWidth = 1;
|
|
162
|
+
ctx.beginPath();
|
|
163
|
+
ctx.moveTo(selX + selW - config.gripLineGap, gripY1 + 2);
|
|
164
|
+
ctx.lineTo(selX + selW - config.gripLineGap, gripY2 - 2);
|
|
165
|
+
ctx.stroke();
|
|
166
|
+
ctx.globalAlpha = 1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
ctx.restore();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export { renderNavigatorCanvas };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/animations/frameScheduler.ts
|
|
2
|
+
var browserScheduler = {
|
|
3
|
+
raf: (cb) => globalThis.requestAnimationFrame(cb),
|
|
4
|
+
cancelRaf: (id) => globalThis.cancelAnimationFrame(id)
|
|
5
|
+
};
|
|
6
|
+
var activeScheduler = browserScheduler;
|
|
7
|
+
function setFrameScheduler(api) {
|
|
8
|
+
activeScheduler = api ?? browserScheduler;
|
|
9
|
+
}
|
|
10
|
+
function raf(callback) {
|
|
11
|
+
return activeScheduler.raf(callback);
|
|
12
|
+
}
|
|
13
|
+
function cancelRaf(id) {
|
|
14
|
+
activeScheduler.cancelRaf(id);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { cancelRaf, raf, setFrameScheduler };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { drawCanvasArc } from './chunk-LVMDQ4OJ.mjs';
|
|
2
|
+
import { getDefaultColor, createCanvasGradientFromColor } from './chunk-O2X6FF45.mjs';
|
|
3
|
+
import { adjustBrightness, withCanvasState } from './chunk-SSLTFJ3U.mjs';
|
|
4
|
+
|
|
5
|
+
// src/series/polar/canvas/index.ts
|
|
6
|
+
function renderPolarBarsCanvas(ctx, layout, hoverState, effectConfig, theme) {
|
|
7
|
+
const { center } = layout;
|
|
8
|
+
const sharedAxisIdx = hoverState.axisIndex ?? null;
|
|
9
|
+
const anyHover = hoverState.datasetId !== null || sharedAxisIdx !== null;
|
|
10
|
+
for (const bar of layout.bars) {
|
|
11
|
+
if (bar.outerRadius <= bar.innerRadius) continue;
|
|
12
|
+
const isSeriesHover = sharedAxisIdx === null && hoverState.datasetId !== null && hoverState.index == null;
|
|
13
|
+
const isHovered = sharedAxisIdx !== null ? bar.categoryIndex === sharedAxisIdx : isSeriesHover ? hoverState.datasetId === bar.datasetId : hoverState.datasetId === bar.datasetId && hoverState.index === bar.categoryIndex;
|
|
14
|
+
const gradColor = layout.gradientColors.get(bar.datasetId);
|
|
15
|
+
const baseColor = bar.color ?? getDefaultColor(bar.seriesIdx, theme);
|
|
16
|
+
let fillColor = baseColor;
|
|
17
|
+
let opacity = bar.opacity ?? 1;
|
|
18
|
+
if (anyHover) {
|
|
19
|
+
if (isHovered && bar.hoverColor !== void 0) {
|
|
20
|
+
fillColor = bar.hoverColor;
|
|
21
|
+
} else if (isHovered && effectConfig.hoverBrightness && !gradColor) {
|
|
22
|
+
fillColor = adjustBrightness(baseColor, effectConfig.hoverBrightness);
|
|
23
|
+
} else if (!isHovered && effectConfig.dimOpacity !== void 0) {
|
|
24
|
+
opacity = opacity * effectConfig.dimOpacity;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
withCanvasState(ctx, () => {
|
|
28
|
+
if (opacity < 1) {
|
|
29
|
+
ctx.globalAlpha = opacity;
|
|
30
|
+
}
|
|
31
|
+
drawCanvasArc(
|
|
32
|
+
ctx,
|
|
33
|
+
center.x,
|
|
34
|
+
center.y,
|
|
35
|
+
{
|
|
36
|
+
rotation: bar.startAngle,
|
|
37
|
+
endAngle: bar.endAngle,
|
|
38
|
+
outerRadius: bar.outerRadius,
|
|
39
|
+
innerRadius: bar.innerRadius,
|
|
40
|
+
borderRadius: bar.borderRadius
|
|
41
|
+
},
|
|
42
|
+
false
|
|
43
|
+
);
|
|
44
|
+
ctx.fillStyle = gradColor ? createCanvasGradientFromColor(ctx, gradColor, center, layout.maxRadius) : fillColor;
|
|
45
|
+
ctx.fill();
|
|
46
|
+
if (bar.borderStrokeWidth && bar.borderColor) {
|
|
47
|
+
ctx.strokeStyle = (isHovered ? bar.hoverBorderColor : void 0) ?? bar.borderColor;
|
|
48
|
+
ctx.lineWidth = bar.borderStrokeWidth;
|
|
49
|
+
if (bar.borderDash && bar.borderDash.length > 0) ctx.setLineDash(bar.borderDash);
|
|
50
|
+
if (bar.borderDashOffset) ctx.lineDashOffset = bar.borderDashOffset;
|
|
51
|
+
ctx.stroke();
|
|
52
|
+
if (bar.borderDash && bar.borderDash.length > 0) ctx.setLineDash([]);
|
|
53
|
+
if (bar.borderDashOffset) ctx.lineDashOffset = 0;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { renderPolarBarsCanvas };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/utils/data/collect.utils.ts
|
|
2
|
+
function collectItems(sortedDatasets, datasetVisibility) {
|
|
3
|
+
const result = {
|
|
4
|
+
bar: [],
|
|
5
|
+
line: [],
|
|
6
|
+
scatter: [],
|
|
7
|
+
candlestick: [],
|
|
8
|
+
heatmap: [],
|
|
9
|
+
radar: [],
|
|
10
|
+
polar: [],
|
|
11
|
+
pie: []
|
|
12
|
+
};
|
|
13
|
+
for (const [id, dataset] of sortedDatasets) {
|
|
14
|
+
const visible = datasetVisibility.get(id) ?? true;
|
|
15
|
+
switch (dataset.type) {
|
|
16
|
+
case "bar":
|
|
17
|
+
result.bar.push({
|
|
18
|
+
id,
|
|
19
|
+
props: dataset.props,
|
|
20
|
+
order: dataset.order,
|
|
21
|
+
visible,
|
|
22
|
+
stackId: dataset.props.stackId
|
|
23
|
+
});
|
|
24
|
+
break;
|
|
25
|
+
case "line":
|
|
26
|
+
result.line.push({
|
|
27
|
+
id,
|
|
28
|
+
props: dataset.props,
|
|
29
|
+
order: dataset.order,
|
|
30
|
+
visible,
|
|
31
|
+
type: "line",
|
|
32
|
+
stackId: dataset.props.stackId,
|
|
33
|
+
rangeId: dataset.props.rangeId
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case "scatter":
|
|
37
|
+
result.scatter.push({
|
|
38
|
+
id,
|
|
39
|
+
props: dataset.props,
|
|
40
|
+
order: dataset.order,
|
|
41
|
+
visible,
|
|
42
|
+
stackId: dataset.props.stackId
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
case "candlestick":
|
|
46
|
+
result.candlestick.push({
|
|
47
|
+
id,
|
|
48
|
+
props: dataset.props,
|
|
49
|
+
order: dataset.order,
|
|
50
|
+
visible
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
case "heatmap":
|
|
54
|
+
result.heatmap.push({
|
|
55
|
+
id,
|
|
56
|
+
props: dataset.props,
|
|
57
|
+
order: dataset.order,
|
|
58
|
+
visible
|
|
59
|
+
});
|
|
60
|
+
break;
|
|
61
|
+
case "radar":
|
|
62
|
+
result.radar.push({
|
|
63
|
+
id,
|
|
64
|
+
props: dataset.props,
|
|
65
|
+
order: dataset.order,
|
|
66
|
+
visible
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
case "polar":
|
|
70
|
+
result.polar.push({
|
|
71
|
+
id,
|
|
72
|
+
props: dataset.props,
|
|
73
|
+
order: dataset.order,
|
|
74
|
+
visible
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
case "pie":
|
|
78
|
+
case "donut":
|
|
79
|
+
result.pie.push({
|
|
80
|
+
id,
|
|
81
|
+
props: dataset.props,
|
|
82
|
+
order: dataset.order,
|
|
83
|
+
visible,
|
|
84
|
+
type: dataset.type
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { collectItems };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { traceRoundedRect } from './chunk-CHW4RKY3.mjs';
|
|
2
|
+
import { resolveBorderRadius, clampRectBorderRadius, hasBorderRadius } from './chunk-VGLSBZDN.mjs';
|
|
3
|
+
import { DEFAULT_HOVER_DIM_OPACITY } from './chunk-NKUYIWAP.mjs';
|
|
4
|
+
import { resolveAccessor, makeItemContext } from './chunk-O2X6FF45.mjs';
|
|
5
|
+
|
|
6
|
+
// src/series/candlestick/canvas/index.ts
|
|
7
|
+
var DEFAULT_BAR_WIDTH_RATIO = 0.7;
|
|
8
|
+
function createCanvasArcPathBuilder(ctx) {
|
|
9
|
+
return {
|
|
10
|
+
moveTo: (x, y) => ctx.moveTo(x, y),
|
|
11
|
+
lineTo: (x, y) => ctx.lineTo(x, y),
|
|
12
|
+
arcTo: (cx, cy, toX, toY, r) => {
|
|
13
|
+
if (r > 0) ctx.arcTo(cx, cy, toX, toY, r);
|
|
14
|
+
},
|
|
15
|
+
closePath: () => ctx.closePath()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function drawCandleBodyAndWicksCanvas(ctx, candle, wickWidth, borderStyle) {
|
|
19
|
+
const { borderStrokeWidth: borderWidth, borderJoinStyle, borderAlign } = borderStyle;
|
|
20
|
+
const borderDash = candle.borderDash ?? borderStyle.borderDash;
|
|
21
|
+
const borderDashOffset = candle.borderDashOffset ?? borderStyle.borderDashOffset;
|
|
22
|
+
const inset = borderAlign === "inner" ? borderWidth / 2 : 0;
|
|
23
|
+
const halfBody = candle.bodyWidth / 2;
|
|
24
|
+
const bodyLeft = candle.x - halfBody + inset;
|
|
25
|
+
const bodyTop = candle.bodyTop + inset;
|
|
26
|
+
const bodyWidth = Math.max(0, candle.bodyWidth - inset * 2);
|
|
27
|
+
const bodyHeight = Math.max(1, candle.bodyBottom - candle.bodyTop - inset * 2);
|
|
28
|
+
ctx.strokeStyle = candle.wickColor;
|
|
29
|
+
ctx.lineWidth = wickWidth;
|
|
30
|
+
ctx.setLineDash([]);
|
|
31
|
+
ctx.beginPath();
|
|
32
|
+
if (candle.bodyTop > candle.wickTop) {
|
|
33
|
+
ctx.moveTo(candle.x, candle.wickTop);
|
|
34
|
+
ctx.lineTo(candle.x, candle.bodyTop);
|
|
35
|
+
}
|
|
36
|
+
if (candle.wickBottom > candle.bodyBottom) {
|
|
37
|
+
ctx.moveTo(candle.x, candle.bodyBottom);
|
|
38
|
+
ctx.lineTo(candle.x, candle.wickBottom);
|
|
39
|
+
}
|
|
40
|
+
ctx.stroke();
|
|
41
|
+
ctx.strokeStyle = candle.bodyStroke;
|
|
42
|
+
ctx.lineWidth = borderWidth;
|
|
43
|
+
ctx.lineJoin = borderJoinStyle;
|
|
44
|
+
ctx.setLineDash(borderDash);
|
|
45
|
+
ctx.lineDashOffset = borderDashOffset;
|
|
46
|
+
const resolvedRadius = resolveBorderRadius(borderStyle.borderRadius);
|
|
47
|
+
const clampedRadius = clampRectBorderRadius(resolvedRadius, bodyWidth, bodyHeight);
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
if (hasBorderRadius(clampedRadius)) {
|
|
50
|
+
traceRoundedRect(createCanvasArcPathBuilder(ctx), bodyLeft, bodyTop, bodyWidth, bodyHeight, clampedRadius);
|
|
51
|
+
} else {
|
|
52
|
+
ctx.rect(bodyLeft, bodyTop, bodyWidth, bodyHeight);
|
|
53
|
+
}
|
|
54
|
+
if (candle.bodyFill !== null) {
|
|
55
|
+
ctx.fillStyle = candle.bodyFill;
|
|
56
|
+
ctx.fill();
|
|
57
|
+
}
|
|
58
|
+
ctx.stroke();
|
|
59
|
+
ctx.setLineDash([]);
|
|
60
|
+
ctx.lineDashOffset = 0;
|
|
61
|
+
}
|
|
62
|
+
function drawOhlcTicksCanvas(ctx, candle, tickWidth, wickWidth) {
|
|
63
|
+
ctx.strokeStyle = candle.bodyStroke;
|
|
64
|
+
ctx.lineWidth = wickWidth;
|
|
65
|
+
ctx.setLineDash([]);
|
|
66
|
+
ctx.beginPath();
|
|
67
|
+
ctx.moveTo(candle.x, candle.wickTop);
|
|
68
|
+
ctx.lineTo(candle.x, candle.wickBottom);
|
|
69
|
+
ctx.moveTo(candle.x - tickWidth, candle.openY);
|
|
70
|
+
ctx.lineTo(candle.x, candle.openY);
|
|
71
|
+
ctx.moveTo(candle.x, candle.closeY);
|
|
72
|
+
ctx.lineTo(candle.x + tickWidth, candle.closeY);
|
|
73
|
+
ctx.stroke();
|
|
74
|
+
}
|
|
75
|
+
function renderCandlestickCanvas(props, layout, ctx, context) {
|
|
76
|
+
const { borderStyle, variant } = layout;
|
|
77
|
+
const tickWidth = layout.categoryScale.bandwidth() * (props.barWidthRatio ?? DEFAULT_BAR_WIDTH_RATIO) / 2;
|
|
78
|
+
const baseAlpha = ctx.globalAlpha;
|
|
79
|
+
const dataArr = props.data;
|
|
80
|
+
const hoveredIdx = props.hoveredIndex ?? null;
|
|
81
|
+
const seriesExtras = { seriesIndex: props.order ?? 0, seriesId: props.id ?? "" };
|
|
82
|
+
for (const candle of layout.visibleCandles) {
|
|
83
|
+
ctx.save();
|
|
84
|
+
if (props.effects && hoveredIdx !== null && hoveredIdx !== candle.dataIndex) {
|
|
85
|
+
ctx.globalAlpha = baseAlpha * (props.effects.dimOpacity ?? context.theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY);
|
|
86
|
+
}
|
|
87
|
+
const isHovered = hoveredIdx !== null && hoveredIdx === candle.dataIndex;
|
|
88
|
+
const hoverFill = isHovered ? resolveAccessor(props.hoverColor, makeItemContext(dataArr?.[candle.dataIndex], candle.dataIndex, { value: candle.close, category: candle.label, ...seriesExtras }), { arrayMode: "cycle" }) : void 0;
|
|
89
|
+
const hoverBorder = isHovered ? resolveAccessor(props.hoverBorderColor, makeItemContext(dataArr?.[candle.dataIndex], candle.dataIndex, { value: candle.close, category: candle.label, ...seriesExtras }), { arrayMode: "cycle" }) : void 0;
|
|
90
|
+
const hoverFillStr = hoverFill !== void 0 ? typeof hoverFill === "string" ? hoverFill : String(hoverFill) : void 0;
|
|
91
|
+
const hoverBorderStr = hoverBorder !== void 0 ? typeof hoverBorder === "string" ? hoverBorder : String(hoverBorder) : void 0;
|
|
92
|
+
const renderCandle = hoverFillStr !== void 0 || hoverBorderStr !== void 0 ? { ...candle, bodyFill: hoverFillStr ?? candle.bodyFill, bodyStroke: hoverBorderStr ?? candle.bodyStroke, wickColor: hoverFillStr ?? candle.wickColor} : candle;
|
|
93
|
+
if (variant === "ohlc") {
|
|
94
|
+
drawOhlcTicksCanvas(ctx, renderCandle, tickWidth, renderCandle.wickStrokeWidth);
|
|
95
|
+
} else {
|
|
96
|
+
drawCandleBodyAndWicksCanvas(ctx, renderCandle, renderCandle.wickStrokeWidth, borderStyle);
|
|
97
|
+
}
|
|
98
|
+
ctx.restore();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { renderCandlestickCanvas };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/animations/bar.ts
|
|
2
|
+
function animatableBarToComputedBar(bar) {
|
|
3
|
+
return {
|
|
4
|
+
dataIndex: bar.dataIndex,
|
|
5
|
+
x: bar.x,
|
|
6
|
+
y: bar.y,
|
|
7
|
+
width: bar.width,
|
|
8
|
+
height: bar.height,
|
|
9
|
+
value: bar.value,
|
|
10
|
+
category: bar.category,
|
|
11
|
+
visible: true,
|
|
12
|
+
isNegative: bar.isNegative
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { animatableBarToComputedBar };
|