@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,524 @@
|
|
|
1
|
+
import { CHAR_WIDTH_RATIO } from './chunk-XTVE4P3L.mjs';
|
|
2
|
+
import { DEFAULT_TREEMAP_PADDING, DEFAULT_TREEMAP_GROUP_LABEL_HEIGHT, DEFAULT_TREEMAP_GROUP_COLORS, DEFAULT_TREEMAP_CELL_COLOR, DEFAULT_TREEMAP_HEADER_BG } from './chunk-NKUYIWAP.mjs';
|
|
3
|
+
import { resquarify, sliceDiceLayout, diceLayout, sliceLayout } from './chunk-BETFQBM2.mjs';
|
|
4
|
+
import { resolveColorScaleRange, interpolateColor } from './chunk-QS76E3TD.mjs';
|
|
5
|
+
import { FIELD_DEFAULTS, resolveAccessor, makeItemContext } from './chunk-O2X6FF45.mjs';
|
|
6
|
+
|
|
7
|
+
// src/series/treemap/geometry.layout.ts
|
|
8
|
+
function interpolateColor2(colorScale, colorRange, value) {
|
|
9
|
+
return interpolateColor(colorScale, colorRange, value, DEFAULT_TREEMAP_CELL_COLOR);
|
|
10
|
+
}
|
|
11
|
+
function resolveField(item, field) {
|
|
12
|
+
if (!field) return void 0;
|
|
13
|
+
return item[field];
|
|
14
|
+
}
|
|
15
|
+
function runLayout(algorithm, items, x, y, w, h, depth, previousLayout) {
|
|
16
|
+
switch (algorithm) {
|
|
17
|
+
case "slice":
|
|
18
|
+
return sliceLayout(items, x, y, w, h);
|
|
19
|
+
case "dice":
|
|
20
|
+
return diceLayout(items, x, y, w, h);
|
|
21
|
+
case "sliceDice":
|
|
22
|
+
return sliceDiceLayout(items, x, y, w, h, depth);
|
|
23
|
+
default:
|
|
24
|
+
return resquarify(items, x, y, w, h, previousLayout ?? null);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getLevelConfig(levels, depth) {
|
|
28
|
+
if (!levels) return void 0;
|
|
29
|
+
return levels.find((l) => l.depth === depth);
|
|
30
|
+
}
|
|
31
|
+
function calculateTreemapLayout(props, chartArea, theme, previousLayout) {
|
|
32
|
+
const {
|
|
33
|
+
data,
|
|
34
|
+
categoryField = FIELD_DEFAULTS.categoryField,
|
|
35
|
+
valueField = FIELD_DEFAULTS.valueField,
|
|
36
|
+
nodeId: nodeIdField,
|
|
37
|
+
parentField,
|
|
38
|
+
colorValueField,
|
|
39
|
+
colorScale,
|
|
40
|
+
colorRange,
|
|
41
|
+
color: colorProp,
|
|
42
|
+
layout: algorithm,
|
|
43
|
+
spacing: padding = DEFAULT_TREEMAP_PADDING,
|
|
44
|
+
groupPadding: groupPaddingProp,
|
|
45
|
+
showGroupLabel,
|
|
46
|
+
groupLabelHeight = DEFAULT_TREEMAP_GROUP_LABEL_HEIGHT,
|
|
47
|
+
secondaryLabelField,
|
|
48
|
+
levels,
|
|
49
|
+
drilldown,
|
|
50
|
+
drilldownMode = "nested",
|
|
51
|
+
drilldownParentId
|
|
52
|
+
} = props;
|
|
53
|
+
if (!data || data.length === 0) return { cells: [], groupHeaders: [], groupBackgrounds: [] };
|
|
54
|
+
const cells = [];
|
|
55
|
+
const groupHeaders = [];
|
|
56
|
+
const groupBackgrounds = [];
|
|
57
|
+
let topLevelRects;
|
|
58
|
+
const hasHierarchy = !!nodeIdField && !!parentField;
|
|
59
|
+
let resolvedColorScale = colorScale;
|
|
60
|
+
let resolvedColorRange = colorRange;
|
|
61
|
+
let resolvedValueRange;
|
|
62
|
+
if (colorValueField && (colorRange || colorScale)) {
|
|
63
|
+
let min = Infinity;
|
|
64
|
+
let max = -Infinity;
|
|
65
|
+
for (const item of data) {
|
|
66
|
+
const cv = resolveField(item, colorValueField);
|
|
67
|
+
if (typeof cv === "number" && isFinite(cv)) {
|
|
68
|
+
if (cv < min) min = cv;
|
|
69
|
+
if (cv > max) max = cv;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (isFinite(min) && isFinite(max)) {
|
|
73
|
+
resolvedValueRange = [min, max];
|
|
74
|
+
const result = resolveColorScaleRange({ colorScale, colorRange }, min, max);
|
|
75
|
+
if (result) {
|
|
76
|
+
resolvedColorScale = result.colorScale;
|
|
77
|
+
resolvedColorRange = result.colorRange;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const resolveColor = (item, index, groupIndex, hasParent) => {
|
|
82
|
+
if (colorValueField && resolvedColorScale && resolvedColorRange) {
|
|
83
|
+
const cv = resolveField(item, colorValueField);
|
|
84
|
+
if (typeof cv === "number") {
|
|
85
|
+
return interpolateColor2(resolvedColorScale, resolvedColorRange, cv);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (colorProp != null) {
|
|
89
|
+
const cellValue = Number(resolveField(item, valueField));
|
|
90
|
+
const cat = resolveField(item, categoryField);
|
|
91
|
+
const extras = {
|
|
92
|
+
value: Number.isFinite(cellValue) ? cellValue : null,
|
|
93
|
+
category: cat == null ? void 0 : String(cat),
|
|
94
|
+
// Single-dataset series identity (defaults 0 / '').
|
|
95
|
+
seriesIndex: props.order ?? 0,
|
|
96
|
+
seriesId: props.id ?? ""
|
|
97
|
+
};
|
|
98
|
+
const resolved = resolveAccessor(colorProp, makeItemContext(item, hasParent ? groupIndex : index, extras));
|
|
99
|
+
if (typeof resolved === "string") return resolved;
|
|
100
|
+
}
|
|
101
|
+
if (hasParent) return DEFAULT_TREEMAP_GROUP_COLORS[groupIndex % DEFAULT_TREEMAP_GROUP_COLORS.length];
|
|
102
|
+
return theme?.treemapCell ?? DEFAULT_TREEMAP_CELL_COLOR;
|
|
103
|
+
};
|
|
104
|
+
if (hasHierarchy) {
|
|
105
|
+
let getAggregate2 = function(id) {
|
|
106
|
+
if (aggregateCache.has(id)) return aggregateCache.get(id);
|
|
107
|
+
const node = nodeMap.get(id);
|
|
108
|
+
if (!node) return 0;
|
|
109
|
+
const ownValue = Number(resolveField(node.item, valueField)) || 0;
|
|
110
|
+
if (node.children.length === 0) {
|
|
111
|
+
aggregateCache.set(id, ownValue);
|
|
112
|
+
return ownValue;
|
|
113
|
+
}
|
|
114
|
+
let childSum = 0;
|
|
115
|
+
for (const childId of node.children) {
|
|
116
|
+
childSum += getAggregate2(childId);
|
|
117
|
+
}
|
|
118
|
+
const agg = ownValue > 0 ? ownValue : childSum;
|
|
119
|
+
aggregateCache.set(id, agg);
|
|
120
|
+
return agg;
|
|
121
|
+
}, getAggregateColorValue2 = function(id) {
|
|
122
|
+
if (aggregateColorValueCache.has(id)) return aggregateColorValueCache.get(id);
|
|
123
|
+
const node = nodeMap.get(id);
|
|
124
|
+
if (!node) return void 0;
|
|
125
|
+
if (node.children.length === 0) {
|
|
126
|
+
if (colorValueField) {
|
|
127
|
+
const cv = resolveField(node.item, colorValueField);
|
|
128
|
+
if (typeof cv === "number") {
|
|
129
|
+
aggregateColorValueCache.set(id, cv);
|
|
130
|
+
return cv;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
let totalWeight = 0;
|
|
136
|
+
let weightedSum = 0;
|
|
137
|
+
for (const childId of node.children) {
|
|
138
|
+
const childCV = getAggregateColorValue2(childId);
|
|
139
|
+
const childVal = aggregateCache.get(childId) ?? 0;
|
|
140
|
+
if (childCV !== void 0 && childVal > 0) {
|
|
141
|
+
weightedSum += childCV * childVal;
|
|
142
|
+
totalWeight += childVal;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (totalWeight > 0) {
|
|
146
|
+
const avg = weightedSum / totalWeight;
|
|
147
|
+
aggregateColorValueCache.set(id, avg);
|
|
148
|
+
return avg;
|
|
149
|
+
}
|
|
150
|
+
return void 0;
|
|
151
|
+
}, getAbsoluteDepth2 = function(id) {
|
|
152
|
+
if (depthCache.has(id)) return depthCache.get(id);
|
|
153
|
+
const pid = childToParent.get(id);
|
|
154
|
+
const d = pid ? getAbsoluteDepth2(pid) + 1 : 0;
|
|
155
|
+
depthCache.set(id, d);
|
|
156
|
+
return d;
|
|
157
|
+
};
|
|
158
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
159
|
+
const childToParent = /* @__PURE__ */ new Map();
|
|
160
|
+
for (let i = 0; i < data.length; i++) {
|
|
161
|
+
const item = data[i];
|
|
162
|
+
const id = String(resolveField(item, nodeIdField) ?? i);
|
|
163
|
+
if (!nodeMap.has(id)) {
|
|
164
|
+
nodeMap.set(id, { item, index: i, children: [] });
|
|
165
|
+
} else {
|
|
166
|
+
const existing = nodeMap.get(id);
|
|
167
|
+
existing.item = item;
|
|
168
|
+
existing.index = i;
|
|
169
|
+
}
|
|
170
|
+
const pid = resolveField(item, parentField);
|
|
171
|
+
if (pid != null) {
|
|
172
|
+
const parentIdStr = String(pid);
|
|
173
|
+
childToParent.set(id, parentIdStr);
|
|
174
|
+
if (!nodeMap.has(parentIdStr)) {
|
|
175
|
+
nodeMap.set(parentIdStr, { item: null, index: -1, children: [] });
|
|
176
|
+
}
|
|
177
|
+
nodeMap.get(parentIdStr).children.push(id);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const aggregateCache = /* @__PURE__ */ new Map();
|
|
181
|
+
for (const id of nodeMap.keys()) {
|
|
182
|
+
getAggregate2(id);
|
|
183
|
+
}
|
|
184
|
+
const aggregateColorValueCache = /* @__PURE__ */ new Map();
|
|
185
|
+
if (colorValueField && resolvedColorScale && resolvedColorRange) {
|
|
186
|
+
for (const id of nodeMap.keys()) {
|
|
187
|
+
getAggregateColorValue2(id);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const depthCache = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const id of nodeMap.keys()) {
|
|
192
|
+
getAbsoluteDepth2(id);
|
|
193
|
+
}
|
|
194
|
+
const currentParentId = drilldownParentId ?? null;
|
|
195
|
+
let visibleIds;
|
|
196
|
+
if (currentParentId === null) {
|
|
197
|
+
visibleIds = [];
|
|
198
|
+
for (const [id] of nodeMap) {
|
|
199
|
+
if (!childToParent.has(id)) {
|
|
200
|
+
visibleIds.push(id);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
const parentNode = nodeMap.get(currentParentId);
|
|
205
|
+
visibleIds = parentNode ? parentNode.children : [];
|
|
206
|
+
}
|
|
207
|
+
const visibleDepth = currentParentId === null ? 0 : (() => {
|
|
208
|
+
let depth = 0;
|
|
209
|
+
let pid = currentParentId;
|
|
210
|
+
while (pid && childToParent.has(pid)) {
|
|
211
|
+
pid = childToParent.get(pid);
|
|
212
|
+
depth++;
|
|
213
|
+
}
|
|
214
|
+
return depth;
|
|
215
|
+
})();
|
|
216
|
+
const parentNodes = [];
|
|
217
|
+
const leafNodes = [];
|
|
218
|
+
for (const id of visibleIds) {
|
|
219
|
+
const node = nodeMap.get(id);
|
|
220
|
+
if (!node || !node.item) continue;
|
|
221
|
+
const agg = aggregateCache.get(id) ?? 0;
|
|
222
|
+
if (agg <= 0) continue;
|
|
223
|
+
if (node.children.length > 0) {
|
|
224
|
+
parentNodes.push({ id, item: node.item, index: node.index, aggValue: agg });
|
|
225
|
+
} else {
|
|
226
|
+
leafNodes.push({ id, item: node.item, index: node.index, value: agg });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const levelConfig = getLevelConfig(levels, visibleDepth);
|
|
230
|
+
const effectiveAlgorithm = levelConfig?.layout ?? algorithm;
|
|
231
|
+
const effectivePadding = levelConfig?.spacing ?? padding;
|
|
232
|
+
if (parentNodes.length > 0 && drilldown && drilldownMode === "flat") {
|
|
233
|
+
const allItems = [...parentNodes.map((p) => ({ id: p.id, item: p.item, index: p.index, value: p.aggValue, hasChildren: true })), ...leafNodes.map((l) => ({ id: l.id, item: l.item, index: l.index, value: l.value, hasChildren: false }))];
|
|
234
|
+
const squarifyItems = allItems.map((item, i) => ({
|
|
235
|
+
value: item.value,
|
|
236
|
+
index: i
|
|
237
|
+
}));
|
|
238
|
+
const rects = runLayout(effectiveAlgorithm, squarifyItems, chartArea.x, chartArea.y, chartArea.width, chartArea.height, visibleDepth, previousLayout);
|
|
239
|
+
topLevelRects = rects;
|
|
240
|
+
for (const r of rects) {
|
|
241
|
+
const item = allItems[r.index];
|
|
242
|
+
cells.push({
|
|
243
|
+
x: r.x + effectivePadding / 2,
|
|
244
|
+
y: r.y + effectivePadding / 2,
|
|
245
|
+
width: Math.max(0, r.width - effectivePadding),
|
|
246
|
+
height: Math.max(0, r.height - effectivePadding),
|
|
247
|
+
color: resolveColor(item.item, item.index, r.index, false),
|
|
248
|
+
label: String(resolveField(item.item, categoryField) ?? ""),
|
|
249
|
+
secondaryLabel: secondaryLabelField ? String(resolveField(item.item, secondaryLabelField) ?? "") : void 0,
|
|
250
|
+
value: item.value,
|
|
251
|
+
index: item.index,
|
|
252
|
+
nodeId: item.id,
|
|
253
|
+
hasChildren: item.hasChildren,
|
|
254
|
+
depth: getAbsoluteDepth2(item.id)
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else if (parentNodes.length > 0) {
|
|
258
|
+
let layoutRecursive2 = function(nodeIds, areaX, areaY, areaW, areaH, depth, groupColorIndex) {
|
|
259
|
+
const parents = [];
|
|
260
|
+
const leaves = [];
|
|
261
|
+
for (const id of nodeIds) {
|
|
262
|
+
const node = nodeMap.get(id);
|
|
263
|
+
if (!node || !node.item) continue;
|
|
264
|
+
const agg = aggregateCache.get(id) ?? 0;
|
|
265
|
+
if (agg <= 0) continue;
|
|
266
|
+
if (node.children.length > 0) {
|
|
267
|
+
parents.push({ id, item: node.item, index: node.index, aggValue: agg });
|
|
268
|
+
} else {
|
|
269
|
+
leaves.push({ id, item: node.item, index: node.index, value: agg });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (parents.length === 0 && leaves.length === 0) return;
|
|
273
|
+
const depthConfig = getLevelConfig(levels, depth);
|
|
274
|
+
const depthAlgorithm = depthConfig?.layout ?? algorithm;
|
|
275
|
+
const depthPadding = depthConfig?.spacing ?? padding;
|
|
276
|
+
const depthShowHeaders = depthConfig?.showHeader ?? showGroupLabel ?? parents.length > 0;
|
|
277
|
+
const depthHeaderHeight = depthShowHeaders ? depthConfig?.headerHeight ?? groupLabelHeight : 0;
|
|
278
|
+
if (parents.length === 0) {
|
|
279
|
+
const sqItems2 = leaves.map((l, i) => ({ value: l.value, index: i }));
|
|
280
|
+
const rects = runLayout(depthAlgorithm, sqItems2, areaX, areaY, areaW, areaH, depth);
|
|
281
|
+
for (const r of rects) {
|
|
282
|
+
const leaf = leaves[r.index];
|
|
283
|
+
cells.push({
|
|
284
|
+
x: r.x + depthPadding / 2,
|
|
285
|
+
y: r.y + depthPadding / 2,
|
|
286
|
+
width: Math.max(0, r.width - depthPadding),
|
|
287
|
+
height: Math.max(0, r.height - depthPadding),
|
|
288
|
+
color: resolveColor(leaf.item, leaf.index, groupColorIndex + r.index, depth > 0),
|
|
289
|
+
label: String(resolveField(leaf.item, categoryField) ?? ""),
|
|
290
|
+
secondaryLabel: secondaryLabelField ? String(resolveField(leaf.item, secondaryLabelField) ?? "") : void 0,
|
|
291
|
+
value: leaf.value,
|
|
292
|
+
index: leaf.index,
|
|
293
|
+
nodeId: leaf.id,
|
|
294
|
+
hasChildren: false,
|
|
295
|
+
depth: getAbsoluteDepth2(leaf.id)
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const allItems = [...parents.map((p) => ({ id: p.id, item: p.item, index: p.index, value: p.aggValue, isParent: true })), ...leaves.map((l) => ({ id: l.id, item: l.item, index: l.index, value: l.value, isParent: false }))];
|
|
301
|
+
const sqItems = allItems.map((item, i) => ({ value: item.value, index: i }));
|
|
302
|
+
const containerRects = runLayout(depthAlgorithm, sqItems, areaX, areaY, areaW, areaH, depth);
|
|
303
|
+
for (const cr of containerRects) {
|
|
304
|
+
const item = allItems[cr.index];
|
|
305
|
+
const gapHalf = effectiveGroupPadding / 2;
|
|
306
|
+
if (!item.isParent) {
|
|
307
|
+
cells.push({
|
|
308
|
+
x: cr.x + gapHalf,
|
|
309
|
+
y: cr.y + gapHalf,
|
|
310
|
+
width: Math.max(0, cr.width - effectiveGroupPadding),
|
|
311
|
+
height: Math.max(0, cr.height - effectiveGroupPadding),
|
|
312
|
+
color: resolveColor(item.item, item.index, groupColorIndex + cr.index, depth > 0),
|
|
313
|
+
label: String(resolveField(item.item, categoryField) ?? ""),
|
|
314
|
+
secondaryLabel: secondaryLabelField ? String(resolveField(item.item, secondaryLabelField) ?? "") : void 0,
|
|
315
|
+
value: item.value,
|
|
316
|
+
index: item.index,
|
|
317
|
+
nodeId: item.id,
|
|
318
|
+
hasChildren: false,
|
|
319
|
+
depth: getAbsoluteDepth2(item.id)
|
|
320
|
+
});
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const groupColor = resolveColor(item.item, item.index, groupColorIndex + cr.index, true);
|
|
324
|
+
const containerX = cr.x + gapHalf;
|
|
325
|
+
const containerY = cr.y + gapHalf;
|
|
326
|
+
const containerW = Math.max(0, cr.width - effectiveGroupPadding);
|
|
327
|
+
const containerH = Math.max(0, cr.height - effectiveGroupPadding);
|
|
328
|
+
if (containerW <= 0 || containerH <= 0) continue;
|
|
329
|
+
let containerColor = groupColor;
|
|
330
|
+
if (colorValueField && resolvedColorScale && resolvedColorRange) {
|
|
331
|
+
const aggCV = aggregateColorValueCache.get(item.id);
|
|
332
|
+
if (aggCV !== void 0) {
|
|
333
|
+
containerColor = interpolateColor2(resolvedColorScale, resolvedColorRange, aggCV);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
groupBackgrounds.push({
|
|
337
|
+
x: containerX,
|
|
338
|
+
y: containerY,
|
|
339
|
+
width: containerW,
|
|
340
|
+
height: containerH,
|
|
341
|
+
color: containerColor,
|
|
342
|
+
depth: getAbsoluteDepth2(item.id),
|
|
343
|
+
nodeId: item.id,
|
|
344
|
+
label: String(resolveField(item.item, categoryField) ?? item.id),
|
|
345
|
+
value: item.value,
|
|
346
|
+
index: item.index
|
|
347
|
+
});
|
|
348
|
+
const internalPad = Math.max(1, depthPadding);
|
|
349
|
+
const innerX = containerX + internalPad;
|
|
350
|
+
const innerY = containerY + internalPad + depthHeaderHeight;
|
|
351
|
+
const innerW = containerW - internalPad * 2;
|
|
352
|
+
const innerH = containerH - internalPad * 2 - depthHeaderHeight;
|
|
353
|
+
if (depthShowHeaders && containerW > 20 && containerH > depthHeaderHeight + 10) {
|
|
354
|
+
const headerColor = depth === 0 ? theme?.treemapHeaderBg ?? DEFAULT_TREEMAP_HEADER_BG : containerColor;
|
|
355
|
+
groupHeaders.push({
|
|
356
|
+
x: containerX,
|
|
357
|
+
y: containerY,
|
|
358
|
+
width: containerW,
|
|
359
|
+
height: depthHeaderHeight,
|
|
360
|
+
label: String(resolveField(item.item, categoryField) ?? item.id),
|
|
361
|
+
color: headerColor,
|
|
362
|
+
value: item.value,
|
|
363
|
+
index: item.index,
|
|
364
|
+
nodeId: item.id,
|
|
365
|
+
depth: getAbsoluteDepth2(item.id)
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (innerW <= 0 || innerH <= 0) continue;
|
|
369
|
+
const childIds = nodeMap.get(item.id)?.children ?? [];
|
|
370
|
+
layoutRecursive2(childIds, innerX, innerY, innerW, innerH, depth + 1, groupColorIndex + cr.index);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
const effectiveGroupPadding = groupPaddingProp ?? 3;
|
|
374
|
+
layoutRecursive2(visibleIds, chartArea.x, chartArea.y, chartArea.width, chartArea.height, visibleDepth, 0);
|
|
375
|
+
} else if (leafNodes.length > 0) {
|
|
376
|
+
let drilldownGroupOffset = 0;
|
|
377
|
+
if (currentParentId !== null) {
|
|
378
|
+
const chain = [];
|
|
379
|
+
let cur = currentParentId;
|
|
380
|
+
while (cur) {
|
|
381
|
+
chain.unshift(cur);
|
|
382
|
+
cur = childToParent.get(cur);
|
|
383
|
+
}
|
|
384
|
+
let levelIds = [];
|
|
385
|
+
for (const [id] of nodeMap) {
|
|
386
|
+
if (!childToParent.has(id)) levelIds.push(id);
|
|
387
|
+
}
|
|
388
|
+
for (const targetAtLevel of chain) {
|
|
389
|
+
const parents = [];
|
|
390
|
+
const leaves = [];
|
|
391
|
+
for (const id of levelIds) {
|
|
392
|
+
const node = nodeMap.get(id);
|
|
393
|
+
if (!node || !node.item) continue;
|
|
394
|
+
const agg = aggregateCache.get(id) ?? 0;
|
|
395
|
+
if (agg <= 0) continue;
|
|
396
|
+
if (node.children.length > 0) parents.push(id);
|
|
397
|
+
else leaves.push(id);
|
|
398
|
+
}
|
|
399
|
+
const orderedIds = [...parents, ...leaves];
|
|
400
|
+
const pos = orderedIds.indexOf(targetAtLevel);
|
|
401
|
+
if (pos < 0) break;
|
|
402
|
+
drilldownGroupOffset += pos;
|
|
403
|
+
levelIds = nodeMap.get(targetAtLevel)?.children ?? [];
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const squarifyItems = leafNodes.map((l, i) => ({
|
|
407
|
+
value: l.value,
|
|
408
|
+
index: i
|
|
409
|
+
}));
|
|
410
|
+
const rects = runLayout(effectiveAlgorithm, squarifyItems, chartArea.x, chartArea.y, chartArea.width, chartArea.height, visibleDepth, previousLayout);
|
|
411
|
+
topLevelRects = rects;
|
|
412
|
+
for (const r of rects) {
|
|
413
|
+
const leaf = leafNodes[r.index];
|
|
414
|
+
const hasParent = currentParentId !== null;
|
|
415
|
+
const groupIndex = hasParent ? drilldownGroupOffset + r.index : r.index;
|
|
416
|
+
cells.push({
|
|
417
|
+
x: r.x + effectivePadding / 2,
|
|
418
|
+
y: r.y + effectivePadding / 2,
|
|
419
|
+
width: Math.max(0, r.width - effectivePadding),
|
|
420
|
+
height: Math.max(0, r.height - effectivePadding),
|
|
421
|
+
color: resolveColor(leaf.item, leaf.index, groupIndex, hasParent),
|
|
422
|
+
label: String(resolveField(leaf.item, categoryField) ?? ""),
|
|
423
|
+
secondaryLabel: secondaryLabelField ? String(resolveField(leaf.item, secondaryLabelField) ?? "") : void 0,
|
|
424
|
+
value: leaf.value,
|
|
425
|
+
index: leaf.index,
|
|
426
|
+
nodeId: leaf.id,
|
|
427
|
+
hasChildren: false,
|
|
428
|
+
depth: getAbsoluteDepth2(leaf.id)
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
const items = [];
|
|
434
|
+
for (let i = 0; i < data.length; i++) {
|
|
435
|
+
const val = Number(resolveField(data[i], valueField)) || 0;
|
|
436
|
+
if (val <= 0) continue;
|
|
437
|
+
items.push({ value: val, index: i });
|
|
438
|
+
}
|
|
439
|
+
const rects = runLayout(algorithm, items, chartArea.x, chartArea.y, chartArea.width, chartArea.height, 0, previousLayout);
|
|
440
|
+
topLevelRects = rects;
|
|
441
|
+
for (const r of rects) {
|
|
442
|
+
const item = data[r.index];
|
|
443
|
+
const cellValue = Number(resolveField(item, valueField)) || 0;
|
|
444
|
+
cells.push({
|
|
445
|
+
x: r.x + padding / 2,
|
|
446
|
+
y: r.y + padding / 2,
|
|
447
|
+
width: Math.max(0, r.width - padding),
|
|
448
|
+
height: Math.max(0, r.height - padding),
|
|
449
|
+
color: resolveColor(item, r.index, 0, false),
|
|
450
|
+
label: String(resolveField(item, categoryField) ?? ""),
|
|
451
|
+
secondaryLabel: secondaryLabelField ? String(resolveField(item, secondaryLabelField) ?? "") : void 0,
|
|
452
|
+
value: cellValue,
|
|
453
|
+
index: r.index,
|
|
454
|
+
depth: 0,
|
|
455
|
+
nodeId: item?.id
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return { cells, groupHeaders, groupBackgrounds, resolvedColorScale, resolvedColorRange, valueRange: resolvedValueRange, _squarifyRects: topLevelRects };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/series/treemap/geometry.labels.ts
|
|
463
|
+
var LABEL_TIERS = [
|
|
464
|
+
{ minArea: 25e3, minWidth: 100, minHeight: 60, fontSize: 16, secondaryFontSize: 12, showSecondary: true },
|
|
465
|
+
{ minArea: 1e4, minWidth: 70, minHeight: 45, fontSize: 14, secondaryFontSize: 10, showSecondary: true },
|
|
466
|
+
{ minArea: 4e3, minWidth: 50, minHeight: 35, fontSize: 12, secondaryFontSize: 9, showSecondary: true },
|
|
467
|
+
{ minArea: 1500, minWidth: 38, minHeight: 26, fontSize: 10, secondaryFontSize: 8, showSecondary: true },
|
|
468
|
+
{ minArea: 600, minWidth: 28, minHeight: 20, fontSize: 9, secondaryFontSize: 0, showSecondary: false },
|
|
469
|
+
{ minArea: 250, minWidth: 22, minHeight: 14, fontSize: 8, secondaryFontSize: 0, showSecondary: false }
|
|
470
|
+
];
|
|
471
|
+
function getCellLabelInfo(cell, labelMinSize) {
|
|
472
|
+
const area = cell.width * cell.height;
|
|
473
|
+
const none = { fontSize: 0, secondaryFontSize: 0, showPrimary: false, showSecondary: false, cx: 0, cy: 0, primaryY: 0, secondaryY: 0 };
|
|
474
|
+
const minSize = labelMinSize ?? 30;
|
|
475
|
+
if (cell.width < minSize || cell.height < minSize) return none;
|
|
476
|
+
for (const tier of LABEL_TIERS) {
|
|
477
|
+
if (area >= tier.minArea && cell.width >= tier.minWidth && cell.height >= tier.minHeight) {
|
|
478
|
+
const primaryTextWidth = cell.label.length * CHAR_WIDTH_RATIO * tier.fontSize;
|
|
479
|
+
if (primaryTextWidth > cell.width - 8) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
let showSec = tier.showSecondary && !!cell.secondaryLabel;
|
|
483
|
+
if (showSec) {
|
|
484
|
+
const secTextWidth = (cell.secondaryLabel?.length ?? 0) * CHAR_WIDTH_RATIO * tier.secondaryFontSize;
|
|
485
|
+
if (secTextWidth > cell.width - 8) {
|
|
486
|
+
showSec = false;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const cx = cell.x + cell.width / 2;
|
|
490
|
+
const cy = cell.y + cell.height / 2;
|
|
491
|
+
return {
|
|
492
|
+
fontSize: tier.fontSize,
|
|
493
|
+
secondaryFontSize: tier.secondaryFontSize,
|
|
494
|
+
showPrimary: true,
|
|
495
|
+
showSecondary: showSec,
|
|
496
|
+
cx,
|
|
497
|
+
cy,
|
|
498
|
+
primaryY: showSec ? cy - tier.fontSize * 0.4 : cy,
|
|
499
|
+
secondaryY: cy + tier.fontSize * 0.6
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return none;
|
|
504
|
+
}
|
|
505
|
+
function buildCellExtras(props, item, layout, idx) {
|
|
506
|
+
const seriesIndex = props.order ?? 0;
|
|
507
|
+
const seriesId = props.id ?? "";
|
|
508
|
+
const cell = layout.cells.find((c) => c.index === idx);
|
|
509
|
+
if (cell) {
|
|
510
|
+
return { value: cell.value, category: cell.label, seriesIndex, seriesId };
|
|
511
|
+
}
|
|
512
|
+
const valueField = props.valueField ?? FIELD_DEFAULTS.valueField;
|
|
513
|
+
const categoryField = props.categoryField ?? FIELD_DEFAULTS.categoryField;
|
|
514
|
+
const v = Number(resolveField(item, valueField));
|
|
515
|
+
const cat = resolveField(item, categoryField);
|
|
516
|
+
return {
|
|
517
|
+
value: Number.isFinite(v) ? v : null,
|
|
518
|
+
category: cat == null ? void 0 : String(cat),
|
|
519
|
+
seriesIndex,
|
|
520
|
+
seriesId
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export { buildCellExtras, calculateTreemapLayout, getCellLabelInfo };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { computeSliceRenderStates } from './chunk-53HW45JB.mjs';
|
|
2
|
+
import { drawCanvasArc, CLIP_PIXEL_MARGIN } from './chunk-LVMDQ4OJ.mjs';
|
|
3
|
+
import { isGradientColor, remapStopsForDonut, createCanvasGradientFromColor } from './chunk-O2X6FF45.mjs';
|
|
4
|
+
import { withCanvasState } from './chunk-SSLTFJ3U.mjs';
|
|
5
|
+
|
|
6
|
+
// src/series/pie/canvas/index.ts
|
|
7
|
+
function renderPieCanvas(props, layout, ctx, context) {
|
|
8
|
+
const renderStates = computeSliceRenderStates(props, layout, context.theme);
|
|
9
|
+
const { slices: sliceStates, center, outerRadius, innerRadius, isFullCircle: fullCircle } = renderStates;
|
|
10
|
+
const borderJoinStyle = props.borderJoinStyle ?? "miter";
|
|
11
|
+
const borderAlign = props.borderAlign ?? "inner";
|
|
12
|
+
withCanvasState(ctx, () => {
|
|
13
|
+
for (const state of sliceStates) {
|
|
14
|
+
const { effectColor, effectBorderColor, effectBorderWidth, effectBorderDash, effectBorderDashOffset, opacity, offset, scale, arcConfig } = state;
|
|
15
|
+
const { dx, dy } = offset;
|
|
16
|
+
const cx = center.x + dx;
|
|
17
|
+
const cy = center.y + dy;
|
|
18
|
+
ctx.save();
|
|
19
|
+
if (scale !== 1) {
|
|
20
|
+
ctx.translate(cx, cy);
|
|
21
|
+
ctx.scale(scale, scale);
|
|
22
|
+
ctx.translate(-cx, -cy);
|
|
23
|
+
}
|
|
24
|
+
if (isGradientColor(effectColor)) {
|
|
25
|
+
const gradientColor = innerRadius > 0 && effectColor.radialGradient ? { ...effectColor, stops: remapStopsForDonut(effectColor.stops, innerRadius / outerRadius) } : effectColor;
|
|
26
|
+
ctx.fillStyle = createCanvasGradientFromColor(ctx, gradientColor, { x: cx, y: cy }, outerRadius);
|
|
27
|
+
} else {
|
|
28
|
+
ctx.fillStyle = effectColor;
|
|
29
|
+
}
|
|
30
|
+
ctx.globalAlpha = opacity;
|
|
31
|
+
drawCanvasArc(ctx, cx, cy, arcConfig, fullCircle);
|
|
32
|
+
ctx.fill();
|
|
33
|
+
if (effectBorderWidth > 0 && effectBorderColor !== "transparent") {
|
|
34
|
+
ctx.strokeStyle = typeof effectBorderColor === "string" ? effectBorderColor : context.theme.borderColor;
|
|
35
|
+
ctx.lineJoin = borderJoinStyle;
|
|
36
|
+
if (effectBorderDash && effectBorderDash.length > 0) {
|
|
37
|
+
ctx.setLineDash(effectBorderDash);
|
|
38
|
+
ctx.lineDashOffset = effectBorderDashOffset;
|
|
39
|
+
} else {
|
|
40
|
+
ctx.setLineDash([]);
|
|
41
|
+
}
|
|
42
|
+
if (borderAlign === "inner") {
|
|
43
|
+
ctx.save();
|
|
44
|
+
const _angleDeltaCanvas = arcConfig.outerRadius > 0 ? CLIP_PIXEL_MARGIN / arcConfig.outerRadius * (180 / Math.PI) : 0;
|
|
45
|
+
drawCanvasArc(ctx, cx, cy, { ...arcConfig, rotation: arcConfig.rotation - _angleDeltaCanvas, endAngle: arcConfig.endAngle + _angleDeltaCanvas }, fullCircle);
|
|
46
|
+
ctx.clip();
|
|
47
|
+
ctx.lineWidth = effectBorderWidth * 2;
|
|
48
|
+
drawCanvasArc(ctx, cx, cy, arcConfig, fullCircle);
|
|
49
|
+
ctx.stroke();
|
|
50
|
+
ctx.restore();
|
|
51
|
+
} else {
|
|
52
|
+
ctx.lineWidth = effectBorderWidth;
|
|
53
|
+
drawCanvasArc(ctx, cx, cy, arcConfig, fullCircle);
|
|
54
|
+
ctx.stroke();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ctx.restore();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { renderPieCanvas };
|