@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,422 @@
|
|
|
1
|
+
import { resolveBorderRadius, clampRectBorderRadius, isUniformBorderRadius, hasBorderRadius } from './chunk-VGLSBZDN.mjs';
|
|
2
|
+
import { isIndexVisible } from './chunk-5JCI2DEB.mjs';
|
|
3
|
+
import { computeItemHoverState, applyHoverEffects } from './chunk-BZN2QHGP.mjs';
|
|
4
|
+
import { batchResolveRequired, batchResolveAccessor, resolveAccessor, makeItemContext, getDefaultColor, resolveDash } from './chunk-O2X6FF45.mjs';
|
|
5
|
+
import { calculateNiceDomain, createBandScale, createLinearScale } from './chunk-RQ3CKQOX.mjs';
|
|
6
|
+
|
|
7
|
+
// src/series/bar/shared.ts
|
|
8
|
+
var EDGES = ["top", "right", "bottom", "left"];
|
|
9
|
+
var EMPTY_EDGE_SET = /* @__PURE__ */ new Set();
|
|
10
|
+
var TOP_SET = /* @__PURE__ */ new Set(["top"]);
|
|
11
|
+
var BOTTOM_SET = /* @__PURE__ */ new Set(["bottom"]);
|
|
12
|
+
var LEFT_SET = /* @__PURE__ */ new Set(["left"]);
|
|
13
|
+
var RIGHT_SET = /* @__PURE__ */ new Set(["right"]);
|
|
14
|
+
function traceRoundedRect(pb, x, y, w, h, radius) {
|
|
15
|
+
const { topLeft, topRight, bottomLeft, bottomRight } = radius;
|
|
16
|
+
pb.moveTo(x + topLeft, y);
|
|
17
|
+
pb.lineTo(x + w - topRight, y);
|
|
18
|
+
pb.arcTo(x + w, y, x + w, y + topRight, topRight);
|
|
19
|
+
pb.lineTo(x + w, y + h - bottomRight);
|
|
20
|
+
pb.arcTo(x + w, y + h, x + w - bottomRight, y + h, bottomRight);
|
|
21
|
+
pb.lineTo(x + bottomLeft, y + h);
|
|
22
|
+
pb.arcTo(x, y + h, x, y + h - bottomLeft, bottomLeft);
|
|
23
|
+
pb.lineTo(x, y + topLeft);
|
|
24
|
+
pb.arcTo(x, y, x + topLeft, y, topLeft);
|
|
25
|
+
pb.closePath();
|
|
26
|
+
}
|
|
27
|
+
function tracePartialBorder(pb, x, y, w, h, skipped, radius) {
|
|
28
|
+
const { topLeft: tl, topRight: tr, bottomRight: br, bottomLeft: bl } = radius;
|
|
29
|
+
const starts = {
|
|
30
|
+
top: [x + tl, y],
|
|
31
|
+
right: [x + w, y + tr],
|
|
32
|
+
bottom: [x + w - br, y + h],
|
|
33
|
+
left: [x, y + h - bl]
|
|
34
|
+
};
|
|
35
|
+
const ends = {
|
|
36
|
+
top: [x + w - tr, y],
|
|
37
|
+
right: [x + w, y + h - br],
|
|
38
|
+
bottom: [x + bl, y + h],
|
|
39
|
+
left: [x, y + tl]
|
|
40
|
+
};
|
|
41
|
+
const corners = {
|
|
42
|
+
"top\u2192right": { cx: x + w, cy: y, r: tr },
|
|
43
|
+
"right\u2192bottom": { cx: x + w, cy: y + h, r: br },
|
|
44
|
+
"bottom\u2192left": { cx: x, cy: y + h, r: bl },
|
|
45
|
+
"left\u2192top": { cx: x, cy: y, r: tl }
|
|
46
|
+
};
|
|
47
|
+
let firstSkippedIdx = -1;
|
|
48
|
+
for (let i = 0; i < 4; i++) {
|
|
49
|
+
if (skipped.has(EDGES[i])) {
|
|
50
|
+
firstSkippedIdx = i;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (firstSkippedIdx === -1) return;
|
|
55
|
+
let inRun = false;
|
|
56
|
+
let prevEdge = null;
|
|
57
|
+
for (let i = 1; i <= 4; i++) {
|
|
58
|
+
const idx = (firstSkippedIdx + i) % 4;
|
|
59
|
+
const edge = EDGES[idx];
|
|
60
|
+
if (skipped.has(edge)) {
|
|
61
|
+
inRun = false;
|
|
62
|
+
prevEdge = null;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (!inRun) {
|
|
66
|
+
pb.moveTo(starts[edge][0], starts[edge][1]);
|
|
67
|
+
inRun = true;
|
|
68
|
+
} else if (prevEdge) {
|
|
69
|
+
const c = corners[`${prevEdge}\u2192${edge}`];
|
|
70
|
+
pb.arcTo(c.cx, c.cy, starts[edge][0], starts[edge][1], c.r);
|
|
71
|
+
}
|
|
72
|
+
pb.lineTo(ends[edge][0], ends[edge][1]);
|
|
73
|
+
prevEdge = edge;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/series/bar/geom/layout.ts
|
|
78
|
+
var DEFAULT_ORIENTATION = "vertical";
|
|
79
|
+
var DEFAULT_BASE = 0;
|
|
80
|
+
function resolveSkippedEdges(borderSkipped, orientation, isNegative) {
|
|
81
|
+
if (borderSkipped === false || borderSkipped === void 0) return EMPTY_EDGE_SET;
|
|
82
|
+
if (borderSkipped === "start") {
|
|
83
|
+
if (orientation === "vertical") return isNegative ? TOP_SET : BOTTOM_SET;
|
|
84
|
+
return isNegative ? RIGHT_SET : LEFT_SET;
|
|
85
|
+
}
|
|
86
|
+
if (borderSkipped === "end") {
|
|
87
|
+
if (orientation === "vertical") return isNegative ? BOTTOM_SET : TOP_SET;
|
|
88
|
+
return isNegative ? LEFT_SET : RIGHT_SET;
|
|
89
|
+
}
|
|
90
|
+
switch (borderSkipped) {
|
|
91
|
+
case "top":
|
|
92
|
+
return TOP_SET;
|
|
93
|
+
case "bottom":
|
|
94
|
+
return BOTTOM_SET;
|
|
95
|
+
case "left":
|
|
96
|
+
return LEFT_SET;
|
|
97
|
+
case "right":
|
|
98
|
+
return RIGHT_SET;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function calculateBarLayout(props, chartArea, config) {
|
|
102
|
+
const { data, categoryField, valueField, color: colorProp, orientation = DEFAULT_ORIENTATION, visibility } = props;
|
|
103
|
+
const categoryAccessor = categoryField;
|
|
104
|
+
const valueAccessor = valueField;
|
|
105
|
+
const openAccessor = props.openField;
|
|
106
|
+
const base = props.base ?? DEFAULT_BASE;
|
|
107
|
+
const categories = categoryAccessor ? batchResolveRequired(categoryAccessor, data, "categoryField") : data.map((_, i) => String(i));
|
|
108
|
+
const values = valueAccessor ? batchResolveRequired(valueAccessor, data, "valueField") : data.map(() => 0);
|
|
109
|
+
const openValues = openAccessor ? batchResolveAccessor(openAccessor, data) : void 0;
|
|
110
|
+
let valueDomain;
|
|
111
|
+
let categoryScale;
|
|
112
|
+
let valueScale;
|
|
113
|
+
if (config?.categoryScale && config?.valueScale) {
|
|
114
|
+
categoryScale = config.categoryScale;
|
|
115
|
+
valueScale = config.valueScale;
|
|
116
|
+
valueDomain = config.valueScale.domain();
|
|
117
|
+
} else {
|
|
118
|
+
valueDomain = calculateNiceDomain(values, { includeZero: true });
|
|
119
|
+
if (orientation === "vertical") {
|
|
120
|
+
categoryScale = createBandScale(categories, [chartArea.x, chartArea.x + chartArea.width]);
|
|
121
|
+
valueScale = createLinearScale(valueDomain, [chartArea.y + chartArea.height, chartArea.y]);
|
|
122
|
+
} else {
|
|
123
|
+
categoryScale = createBandScale(categories, [chartArea.y, chartArea.y + chartArea.height]);
|
|
124
|
+
valueScale = createLinearScale(valueDomain, [chartArea.x, chartArea.x + chartArea.width]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const borderColorProp = props.borderColor;
|
|
128
|
+
const seriesExtras = { seriesIndex: props.order ?? 0, seriesId: props.id ?? "" };
|
|
129
|
+
const bars = [];
|
|
130
|
+
const colors = [];
|
|
131
|
+
const borderColors = [];
|
|
132
|
+
const effectiveBase = base >= valueDomain[0] && base <= valueDomain[1] ? base : valueDomain[0];
|
|
133
|
+
const defaultBasePosition = valueScale(effectiveBase);
|
|
134
|
+
const bandwidth = categoryScale.bandwidth();
|
|
135
|
+
const slotWidth = config?.groupBarWidth ?? bandwidth;
|
|
136
|
+
const groupOffset = config?.groupOffset ?? 0;
|
|
137
|
+
let hasHiddenBars = false;
|
|
138
|
+
const barThickness = props.barThickness;
|
|
139
|
+
const maxBarThickness = props.maxBarThickness;
|
|
140
|
+
let effectiveBarWidth = slotWidth;
|
|
141
|
+
if (barThickness !== void 0) {
|
|
142
|
+
effectiveBarWidth = barThickness;
|
|
143
|
+
} else if (maxBarThickness !== void 0) {
|
|
144
|
+
effectiveBarWidth = Math.min(slotWidth, maxBarThickness);
|
|
145
|
+
}
|
|
146
|
+
const barCenterOffset = effectiveBarWidth < slotWidth ? (slotWidth - effectiveBarWidth) / 2 : 0;
|
|
147
|
+
const minBarLength = props.minBarLength;
|
|
148
|
+
const connectNulls = props.connectNulls ?? "gap";
|
|
149
|
+
const skipNullEnabled = connectNulls === "gap" || connectNulls === false;
|
|
150
|
+
for (let i = 0; i < data.length; i++) {
|
|
151
|
+
const category = categories[i];
|
|
152
|
+
const rawValue = values[i];
|
|
153
|
+
const visible = isIndexVisible(visibility, i);
|
|
154
|
+
const isNullValue = rawValue === null || rawValue === void 0 || Number.isNaN(rawValue);
|
|
155
|
+
if (skipNullEnabled && isNullValue) {
|
|
156
|
+
bars.push({
|
|
157
|
+
dataIndex: i,
|
|
158
|
+
x: 0,
|
|
159
|
+
y: 0,
|
|
160
|
+
width: 0,
|
|
161
|
+
height: 0,
|
|
162
|
+
value: 0,
|
|
163
|
+
category,
|
|
164
|
+
visible: false,
|
|
165
|
+
isNegative: false
|
|
166
|
+
});
|
|
167
|
+
colors.push("transparent");
|
|
168
|
+
borderColors.push("transparent");
|
|
169
|
+
hasHiddenBars = true;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const value = isNullValue ? 0 : rawValue;
|
|
173
|
+
const barBase = openValues ? openValues[i] ?? base : base;
|
|
174
|
+
const basePosition = openValues ? valueScale(barBase) : defaultBasePosition;
|
|
175
|
+
const isNegative = value < barBase;
|
|
176
|
+
if (!visible) hasHiddenBars = true;
|
|
177
|
+
let x, y, width, height;
|
|
178
|
+
const catPos = config?.categoryPositions?.[i];
|
|
179
|
+
if (orientation === "vertical") {
|
|
180
|
+
if (catPos) {
|
|
181
|
+
const catSlot = catPos.size;
|
|
182
|
+
const catBarWidth = barThickness !== void 0 ? barThickness : maxBarThickness !== void 0 ? Math.min(catSlot, maxBarThickness) : catSlot;
|
|
183
|
+
const catCenterOff = catBarWidth < catSlot ? (catSlot - catBarWidth) / 2 : 0;
|
|
184
|
+
x = catPos.pos + catCenterOff;
|
|
185
|
+
width = catBarWidth;
|
|
186
|
+
} else {
|
|
187
|
+
x = categoryScale(category) + groupOffset + barCenterOffset;
|
|
188
|
+
width = effectiveBarWidth;
|
|
189
|
+
}
|
|
190
|
+
if (config?.stackBases) {
|
|
191
|
+
const stackBase = config.stackBases[i] ?? 0;
|
|
192
|
+
const endPixel = valueScale(stackBase + value);
|
|
193
|
+
const basePixel = valueScale(stackBase);
|
|
194
|
+
y = Math.min(endPixel, basePixel);
|
|
195
|
+
height = Math.abs(endPixel - basePixel);
|
|
196
|
+
} else if (isNegative) {
|
|
197
|
+
y = basePosition;
|
|
198
|
+
height = valueScale(value) - basePosition;
|
|
199
|
+
} else {
|
|
200
|
+
y = valueScale(value);
|
|
201
|
+
height = basePosition - valueScale(value);
|
|
202
|
+
}
|
|
203
|
+
if (minBarLength !== void 0) {
|
|
204
|
+
const absHeight = Math.abs(height);
|
|
205
|
+
if (absHeight < minBarLength && absHeight >= 0) {
|
|
206
|
+
if (isNegative) {
|
|
207
|
+
height = minBarLength;
|
|
208
|
+
} else {
|
|
209
|
+
y = y + absHeight - minBarLength;
|
|
210
|
+
height = minBarLength;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
if (catPos) {
|
|
216
|
+
const catSlot = catPos.size;
|
|
217
|
+
const catBarHeight = barThickness !== void 0 ? barThickness : maxBarThickness !== void 0 ? Math.min(catSlot, maxBarThickness) : catSlot;
|
|
218
|
+
const catCenterOff = catBarHeight < catSlot ? (catSlot - catBarHeight) / 2 : 0;
|
|
219
|
+
y = catPos.pos + catCenterOff;
|
|
220
|
+
height = catBarHeight;
|
|
221
|
+
} else {
|
|
222
|
+
y = categoryScale(category) + groupOffset + barCenterOffset;
|
|
223
|
+
height = effectiveBarWidth;
|
|
224
|
+
}
|
|
225
|
+
if (config?.stackBases) {
|
|
226
|
+
const stackBase = config.stackBases[i] ?? 0;
|
|
227
|
+
const basePixel = valueScale(stackBase);
|
|
228
|
+
const endPixel = valueScale(stackBase + value);
|
|
229
|
+
x = Math.min(basePixel, endPixel);
|
|
230
|
+
width = Math.abs(endPixel - basePixel);
|
|
231
|
+
} else if (isNegative) {
|
|
232
|
+
x = valueScale(value);
|
|
233
|
+
width = basePosition - valueScale(value);
|
|
234
|
+
} else {
|
|
235
|
+
x = basePosition;
|
|
236
|
+
width = valueScale(value) - basePosition;
|
|
237
|
+
}
|
|
238
|
+
if (minBarLength !== void 0) {
|
|
239
|
+
const absWidth = Math.abs(width);
|
|
240
|
+
if (absWidth < minBarLength && absWidth >= 0) {
|
|
241
|
+
if (isNegative) {
|
|
242
|
+
x = x + absWidth - minBarLength;
|
|
243
|
+
width = minBarLength;
|
|
244
|
+
} else {
|
|
245
|
+
width = minBarLength;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (Number.isNaN(x) || Number.isNaN(y) || Number.isNaN(width) || Number.isNaN(height)) {
|
|
251
|
+
bars.push({ dataIndex: i, x: 0, y: 0, width: 0, height: 0, value, category, visible: false, isNegative });
|
|
252
|
+
colors.push("transparent");
|
|
253
|
+
borderColors.push("transparent");
|
|
254
|
+
hasHiddenBars = true;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
bars.push({
|
|
258
|
+
dataIndex: i,
|
|
259
|
+
x: width < 0 ? x + width : x,
|
|
260
|
+
y: height < 0 ? y + height : y,
|
|
261
|
+
width: Math.abs(width),
|
|
262
|
+
height: Math.abs(height),
|
|
263
|
+
value,
|
|
264
|
+
category,
|
|
265
|
+
visible,
|
|
266
|
+
isNegative
|
|
267
|
+
});
|
|
268
|
+
let color;
|
|
269
|
+
let borderColor;
|
|
270
|
+
if (colorProp != null) {
|
|
271
|
+
const resolved = resolveAccessor(colorProp, makeItemContext(data[i], i, { value, category, ...seriesExtras }));
|
|
272
|
+
if (resolved) color = resolved;
|
|
273
|
+
}
|
|
274
|
+
colors.push(color);
|
|
275
|
+
if (borderColorProp) {
|
|
276
|
+
const resolvedBorderColor = resolveAccessor(borderColorProp, makeItemContext(data[i], i, { value, category, ...seriesExtras }));
|
|
277
|
+
if (resolvedBorderColor) {
|
|
278
|
+
borderColor = resolvedBorderColor;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
borderColors.push(borderColor ?? "transparent");
|
|
282
|
+
}
|
|
283
|
+
const visibleBars = hasHiddenBars ? bars.filter((b) => b.visible) : bars;
|
|
284
|
+
return {
|
|
285
|
+
bars,
|
|
286
|
+
visibleBars,
|
|
287
|
+
categoryScale,
|
|
288
|
+
valueScale,
|
|
289
|
+
orientation,
|
|
290
|
+
colors,
|
|
291
|
+
borderColors,
|
|
292
|
+
chartArea,
|
|
293
|
+
valueDomain,
|
|
294
|
+
base,
|
|
295
|
+
openValues
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/series/bar/geom/render-state.ts
|
|
300
|
+
function computeBarRenderStates(props, layout, theme) {
|
|
301
|
+
const { interaction, effects } = props;
|
|
302
|
+
const { visibleBars, colors, borderColors, orientation } = layout;
|
|
303
|
+
const dataArr = props.data;
|
|
304
|
+
const resolveBarBorderRadius = (ctx) => props.borderRadius === void 0 ? 0 : resolveAccessor(props.borderRadius, ctx, { arrayMode: "clip" }) ?? 0;
|
|
305
|
+
const resolveBarBorderWidth = (ctx) => props.borderStrokeWidth === void 0 ? 0 : resolveAccessor(props.borderStrokeWidth, ctx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
306
|
+
const resolveBarBorderDash = (ctx) => props.borderDash === void 0 ? void 0 : resolveDash(props.borderDash, ctx);
|
|
307
|
+
const resolveBarBorderDashOffset = (ctx) => props.borderDashOffset === void 0 ? 0 : resolveAccessor(props.borderDashOffset, ctx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
308
|
+
const resolveBarOpacity = (ctx) => props.opacity === void 0 ? void 0 : resolveAccessor(props.opacity, ctx, { arrayMode: "clip" });
|
|
309
|
+
const resolveBarHoverColor = (ctx) => props.hoverColor === void 0 ? void 0 : resolveAccessor(props.hoverColor, ctx, { arrayMode: "cycle" });
|
|
310
|
+
const resolveBarHoverBorderColor = (ctx) => props.hoverBorderColor === void 0 ? void 0 : resolveAccessor(props.hoverBorderColor, ctx, { arrayMode: "cycle" });
|
|
311
|
+
const borderJoinStyle = props.borderJoinStyle ?? "miter";
|
|
312
|
+
const borderAlign = props.borderAlign ?? "center";
|
|
313
|
+
const resolveBarBorderSkipped = (ctx) => props.borderSkipped === void 0 ? void 0 : resolveAccessor(props.borderSkipped, ctx, { arrayMode: "clip" });
|
|
314
|
+
const hoverEnabled = effects !== void 0;
|
|
315
|
+
const isSeriesDimmed = interaction?.isSeriesDimmed ?? false;
|
|
316
|
+
const isSeriesHovered = interaction?.isSeriesHovered ?? false;
|
|
317
|
+
const seriesIdx = props.order ?? 0;
|
|
318
|
+
const seriesExtras = { seriesIndex: seriesIdx, seriesId: props.id ?? "" };
|
|
319
|
+
const bars = visibleBars.map((bar) => {
|
|
320
|
+
const { dataIndex, width, height, isNegative } = bar;
|
|
321
|
+
const ctx = makeItemContext(dataArr[dataIndex], dataIndex, { value: bar.value, category: bar.category, ...seriesExtras });
|
|
322
|
+
const userFill = colors[dataIndex];
|
|
323
|
+
const borderColor = borderColors[dataIndex];
|
|
324
|
+
const borderWidth = resolveBarBorderWidth(ctx);
|
|
325
|
+
const resolvedRadius = resolveBorderRadius(resolveBarBorderRadius(ctx));
|
|
326
|
+
const canvasFill = userFill ?? getDefaultColor(seriesIdx, theme);
|
|
327
|
+
let hoverState;
|
|
328
|
+
if (hoverEnabled && isSeriesDimmed) {
|
|
329
|
+
hoverState = { isHovered: false, hasAnyHover: true };
|
|
330
|
+
} else if (hoverEnabled && isSeriesHovered) {
|
|
331
|
+
hoverState = { isHovered: true, hasAnyHover: true };
|
|
332
|
+
} else {
|
|
333
|
+
hoverState = computeItemHoverState(dataIndex, interaction?.hoveredIndex, hoverEnabled);
|
|
334
|
+
}
|
|
335
|
+
const isInactive = hoverState.hasAnyHover && !hoverState.isHovered;
|
|
336
|
+
const itemHoverColor = resolveBarHoverColor(ctx);
|
|
337
|
+
const itemHoverBorderColor = resolveBarHoverBorderColor(ctx);
|
|
338
|
+
const itemEffects = hoverEnabled && effects && (itemHoverColor !== void 0 || itemHoverBorderColor !== void 0) ? {
|
|
339
|
+
...effects,
|
|
340
|
+
hoverBackgroundColor: itemHoverColor ?? effects.hoverBackgroundColor,
|
|
341
|
+
hoverBorderColor: itemHoverBorderColor ?? effects.hoverBorderColor
|
|
342
|
+
} : hoverEnabled ? effects : void 0;
|
|
343
|
+
const {
|
|
344
|
+
color: effectColor,
|
|
345
|
+
opacity: hoverOpacity,
|
|
346
|
+
borderColor: effectBorderColor,
|
|
347
|
+
borderStrokeWidth: effectBorderWidth,
|
|
348
|
+
borderDash: effectBorderDash,
|
|
349
|
+
borderDashOffset: effectBorderDashOffset
|
|
350
|
+
} = applyHoverEffects(canvasFill, borderColor, borderWidth, resolveBarBorderDash(ctx), resolveBarBorderDashOffset(ctx), hoverState, itemEffects, theme);
|
|
351
|
+
const userOpacity = resolveBarOpacity(ctx);
|
|
352
|
+
const opacity = userOpacity !== void 0 ? hoverOpacity * userOpacity : hoverOpacity;
|
|
353
|
+
const isItemHovered = hoverEnabled && (isSeriesHovered ? interaction?.hoveredIndex === dataIndex : hoverState.isHovered);
|
|
354
|
+
let offsetX = 0;
|
|
355
|
+
let offsetY = 0;
|
|
356
|
+
if (isItemHovered && effects?.hoverOffset && effects.hoverOffset > 0) {
|
|
357
|
+
if (orientation === "vertical") {
|
|
358
|
+
offsetY = isNegative ? effects.hoverOffset : -effects.hoverOffset;
|
|
359
|
+
} else {
|
|
360
|
+
offsetX = isNegative ? -effects.hoverOffset : effects.hoverOffset;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const hoverScale = isItemHovered && effects?.hoverScale ? effects.hoverScale : 1;
|
|
364
|
+
const drawWidth = width * hoverScale;
|
|
365
|
+
const drawHeight = height * hoverScale;
|
|
366
|
+
const clampedRadius = clampRectBorderRadius(resolvedRadius, drawWidth, drawHeight);
|
|
367
|
+
const skippedEdges = resolveSkippedEdges(resolveBarBorderSkipped(ctx), orientation, isNegative);
|
|
368
|
+
return {
|
|
369
|
+
bar,
|
|
370
|
+
effectColor,
|
|
371
|
+
effectBorderColor,
|
|
372
|
+
effectBorderWidth,
|
|
373
|
+
effectBorderDash,
|
|
374
|
+
effectBorderDashOffset,
|
|
375
|
+
opacity,
|
|
376
|
+
// SVG state — class composition + inline overrides
|
|
377
|
+
userFill,
|
|
378
|
+
hoverColorOverride: itemEffects?.hoverBackgroundColor,
|
|
379
|
+
userBorder: borderColor === "transparent" ? void 0 : borderColor,
|
|
380
|
+
seriesIdx,
|
|
381
|
+
isHovered: hoverState.isHovered,
|
|
382
|
+
isInactive,
|
|
383
|
+
drawX: bar.x + offsetX - (drawWidth - width) / 2,
|
|
384
|
+
drawY: bar.y + offsetY - (drawHeight - height) / 2,
|
|
385
|
+
drawWidth,
|
|
386
|
+
drawHeight,
|
|
387
|
+
clampedRadius,
|
|
388
|
+
hasRadius: hasBorderRadius(clampedRadius),
|
|
389
|
+
uniformRadius: isUniformBorderRadius(clampedRadius),
|
|
390
|
+
skippedEdges
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
return { bars, borderJoinStyle, borderAlign };
|
|
394
|
+
}
|
|
395
|
+
function computeBarLabelPosition(bar, orientation, padding = 6) {
|
|
396
|
+
if (orientation === "vertical") {
|
|
397
|
+
return {
|
|
398
|
+
x: bar.x + bar.width / 2,
|
|
399
|
+
y: bar.isNegative ? bar.y + bar.height + padding : bar.y - padding,
|
|
400
|
+
textAnchor: "middle",
|
|
401
|
+
baseline: bar.isNegative ? "hanging" : "auto"
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
x: bar.isNegative ? bar.x - padding : bar.x + bar.width + padding,
|
|
406
|
+
y: bar.y + bar.height / 2,
|
|
407
|
+
textAnchor: bar.isNegative ? "end" : "start",
|
|
408
|
+
baseline: "central"
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
function hitTestBar(x, y, _props, layout) {
|
|
412
|
+
const { visibleBars } = layout;
|
|
413
|
+
for (let i = visibleBars.length - 1; i >= 0; i--) {
|
|
414
|
+
const bar = visibleBars[i];
|
|
415
|
+
if (x >= bar.x && x <= bar.x + bar.width && y >= bar.y && y <= bar.y + bar.height) {
|
|
416
|
+
return bar.dataIndex;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export { calculateBarLayout, computeBarLabelPosition, computeBarRenderStates, hitTestBar, resolveSkippedEdges, tracePartialBorder, traceRoundedRect };
|