@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,964 @@
|
|
|
1
|
+
import { isPointInSlice } from './chunk-LVMDQ4OJ.mjs';
|
|
2
|
+
import { MARKER_SHAPE_NAMES, renderMarkerShapeSvg, drawMarkerCanvas } from './chunk-PRDVPOZX.mjs';
|
|
3
|
+
import { calculateRadiusAndCenter } from './chunk-NPDZLYIF.mjs';
|
|
4
|
+
import { formatPointDescription } from './chunk-OGJ6IIBW.mjs';
|
|
5
|
+
import { measureText } from './chunk-XTVE4P3L.mjs';
|
|
6
|
+
import { DEFAULT_RADIAL_LABEL_FONT_SIZE, DEFAULT_GRID_LEVELS, resolveFontSize, resolveFontFamily, DEFAULT_RADAR_FILL_OPACITY, DEFAULT_LINE_WIDTH, DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER, DEFAULT_POLAR_GAP_PX, DEFAULT_RADAR_HIT_RADIUS, DEFAULT_LINE_MARKER_SIZE } from './chunk-NKUYIWAP.mjs';
|
|
7
|
+
import { isGradientColor, batchResolveAccessor, FIELD_DEFAULTS, createSvgGradientFromColor, makeItemContext, resolveDash, resolveAccessor, getDefaultColor, createCanvasGradientFromColor, sampleGradientAt, resolveSwatchColor, getPrimaryColor, batchResolveRequired } from './chunk-O2X6FF45.mjs';
|
|
8
|
+
import { createCanvasPathBuilder, traceClosedSpline, createSvgPathBuilder } from './chunk-IEGLX7VL.mjs';
|
|
9
|
+
import { createSvgGroup, setAttr, adjustBrightness, createSvgDefs, appendChild, prependChild, svgClass, createSvgPath, svgNode, withCanvasState } from './chunk-SSLTFJ3U.mjs';
|
|
10
|
+
import { calculateNiceDomain, generateNiceTicks, toRad } from './chunk-RQ3CKQOX.mjs';
|
|
11
|
+
|
|
12
|
+
// src/renderers/radar.layout.ts
|
|
13
|
+
function calculateRadarLayout(datasets, chartArea, globalFont, sharedCategories, sharedDomain, perAxisDomains, referenceBoundaryValues, perSpokeDomains, tickCount) {
|
|
14
|
+
const categories = sharedCategories ?? extractCategories(datasets);
|
|
15
|
+
const categoryCount = categories.length;
|
|
16
|
+
const angleStep = categoryCount > 0 ? 360 / categoryCount : 0;
|
|
17
|
+
const allValues = [];
|
|
18
|
+
const stackCumulatives = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const ds of datasets) {
|
|
20
|
+
if (!ds.visible) continue;
|
|
21
|
+
if (ds.props.yAxisId) continue;
|
|
22
|
+
const values = resolveValues(ds.props);
|
|
23
|
+
const stackId = ds.props.stackId;
|
|
24
|
+
if (stackId) {
|
|
25
|
+
if (!stackCumulatives.has(stackId)) {
|
|
26
|
+
stackCumulatives.set(stackId, new Array(categoryCount).fill(0));
|
|
27
|
+
}
|
|
28
|
+
const cumulative = stackCumulatives.get(stackId);
|
|
29
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
30
|
+
cumulative[ci] = (cumulative[ci] ?? 0) + (values[ci] ?? 0);
|
|
31
|
+
allValues.push(cumulative[ci]);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
allValues.push(...values);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (allValues.length === 0) {
|
|
38
|
+
for (const ds of datasets) {
|
|
39
|
+
if (ds.visible) allValues.push(...resolveValues(ds.props));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const rawDataMax = allValues.length ? Math.max(...allValues) : 0;
|
|
43
|
+
let [rawDomainMin, rawDomainMax] = sharedDomain ?? calculateNiceDomain(allValues.length ? allValues : [0, 1], { includeZero: true, nice: true });
|
|
44
|
+
if (referenceBoundaryValues?.length) {
|
|
45
|
+
for (const v of referenceBoundaryValues) {
|
|
46
|
+
if (v < rawDomainMin) rawDomainMin = v;
|
|
47
|
+
if (v > rawDomainMax) rawDomainMax = v;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const rawDomain = [rawDomainMin, rawDomainMax];
|
|
51
|
+
const levelValues = generateNiceTicks(rawDomain[0], rawDomain[1], tickCount ?? DEFAULT_GRID_LEVELS);
|
|
52
|
+
const firstTick = levelValues[0] ?? rawDomain[0];
|
|
53
|
+
const lastTick = levelValues[levelValues.length - 1] ?? rawDomain[1];
|
|
54
|
+
const domain = [Math.min(rawDomain[0], firstTick), Math.max(rawDomain[1], lastTick)];
|
|
55
|
+
const resolvedLabelFontSize = resolveFontSize(DEFAULT_RADIAL_LABEL_FONT_SIZE, globalFont);
|
|
56
|
+
const resolvedFontFamily = resolveFontFamily(void 0, globalFont);
|
|
57
|
+
const labelPadding = measureText("Xg", resolvedLabelFontSize).height;
|
|
58
|
+
const labelMargins = calculateLabelMargins(categories, angleStep, labelPadding, resolvedLabelFontSize);
|
|
59
|
+
const adjustedArea = {
|
|
60
|
+
x: chartArea.x + labelMargins.left,
|
|
61
|
+
y: chartArea.y + labelMargins.top,
|
|
62
|
+
width: Math.max(0, chartArea.width - labelMargins.left - labelMargins.right),
|
|
63
|
+
height: Math.max(0, chartArea.height - labelMargins.top - labelMargins.bottom)
|
|
64
|
+
};
|
|
65
|
+
const { center, radius } = calculateRadiusAndCenter(adjustedArea);
|
|
66
|
+
const levelRadii = levelValues.map((v) => {
|
|
67
|
+
if (domain[1] === domain[0]) return 0;
|
|
68
|
+
return (v - domain[0]) / (domain[1] - domain[0]) * radius;
|
|
69
|
+
});
|
|
70
|
+
const grid = {
|
|
71
|
+
shape: "polygon",
|
|
72
|
+
levels: levelValues.length,
|
|
73
|
+
levelValues,
|
|
74
|
+
levelRadii
|
|
75
|
+
};
|
|
76
|
+
const spokeEndpoints = [];
|
|
77
|
+
for (let i = 0; i < categoryCount; i++) {
|
|
78
|
+
const angleDeg = -90 + i * angleStep;
|
|
79
|
+
const angleRad = toRad(angleDeg);
|
|
80
|
+
spokeEndpoints.push({
|
|
81
|
+
x: center.x + Math.cos(angleRad) * radius,
|
|
82
|
+
y: center.y + Math.sin(angleRad) * radius
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const series = [];
|
|
86
|
+
const stackRunning = /* @__PURE__ */ new Map();
|
|
87
|
+
for (let si = 0; si < datasets.length; si++) {
|
|
88
|
+
const ds = datasets[si];
|
|
89
|
+
const gradientColor = ds.props.color && isGradientColor(ds.props.color) ? ds.props.color : void 0;
|
|
90
|
+
const color = typeof ds.props.color === "string" ? ds.props.color : void 0;
|
|
91
|
+
const fillOpacity = ds.props.fillOpacity ?? DEFAULT_RADAR_FILL_OPACITY;
|
|
92
|
+
const lineWidth = ds.props.lineStrokeWidth ?? DEFAULT_LINE_WIDTH;
|
|
93
|
+
const lineStyle = ds.props.lineStyle;
|
|
94
|
+
const lineDash = ds.props.lineDash;
|
|
95
|
+
const curve = ds.props.curve;
|
|
96
|
+
const stackId = ds.props.stackId;
|
|
97
|
+
const values = resolveValues(ds.props);
|
|
98
|
+
const points = [];
|
|
99
|
+
const basePoints = [];
|
|
100
|
+
const isStacked = !!stackId;
|
|
101
|
+
if (isStacked && !stackRunning.has(stackId)) {
|
|
102
|
+
stackRunning.set(stackId, new Array(categoryCount).fill(0));
|
|
103
|
+
}
|
|
104
|
+
const cumulative = isStacked ? stackRunning.get(stackId) : null;
|
|
105
|
+
const yAxisId = ds.props.yAxisId;
|
|
106
|
+
const axisOverride = yAxisId ? perAxisDomains?.get(yAxisId) : void 0;
|
|
107
|
+
const seriesDomain = axisOverride ?? domain;
|
|
108
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
109
|
+
const rawValue = values[ci] ?? 0;
|
|
110
|
+
const baseValue = isStacked ? cumulative[ci] ?? 0 : 0;
|
|
111
|
+
const topValue = baseValue + rawValue;
|
|
112
|
+
const [sMin, sMax] = perSpokeDomains?.get(ci) ?? seriesDomain;
|
|
113
|
+
const domainSpan = sMax - sMin;
|
|
114
|
+
const angleDeg = -90 + ci * angleStep;
|
|
115
|
+
const angleRad = toRad(angleDeg);
|
|
116
|
+
const topR = domainSpan === 0 ? 0 : Math.max(0, (topValue - sMin) / domainSpan) * radius;
|
|
117
|
+
const baseR = domainSpan === 0 ? 0 : Math.max(0, (baseValue - sMin) / domainSpan) * radius;
|
|
118
|
+
points.push({
|
|
119
|
+
x: center.x + Math.cos(angleRad) * topR,
|
|
120
|
+
y: center.y + Math.sin(angleRad) * topR,
|
|
121
|
+
value: rawValue,
|
|
122
|
+
angle: angleDeg,
|
|
123
|
+
categoryIndex: ci
|
|
124
|
+
});
|
|
125
|
+
if (isStacked) {
|
|
126
|
+
basePoints.push({
|
|
127
|
+
x: center.x + Math.cos(angleRad) * baseR,
|
|
128
|
+
y: center.y + Math.sin(angleRad) * baseR,
|
|
129
|
+
value: baseValue,
|
|
130
|
+
angle: angleDeg,
|
|
131
|
+
categoryIndex: ci
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (isStacked && ds.visible) {
|
|
136
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
137
|
+
cumulative[ci] = (cumulative[ci] ?? 0) + (values[ci] ?? 0);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
series.push({
|
|
141
|
+
id: ds.id,
|
|
142
|
+
name: ds.props.name,
|
|
143
|
+
points,
|
|
144
|
+
basePoints: isStacked ? basePoints : void 0,
|
|
145
|
+
color,
|
|
146
|
+
seriesIdx: si,
|
|
147
|
+
gradientColor,
|
|
148
|
+
fillOpacity,
|
|
149
|
+
lineStrokeWidth: lineWidth,
|
|
150
|
+
lineStyle,
|
|
151
|
+
lineDash,
|
|
152
|
+
curve,
|
|
153
|
+
visible: ds.visible
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
center,
|
|
158
|
+
radius,
|
|
159
|
+
categories,
|
|
160
|
+
angleStep,
|
|
161
|
+
domain,
|
|
162
|
+
grid,
|
|
163
|
+
series,
|
|
164
|
+
spokeEndpoints,
|
|
165
|
+
chartArea,
|
|
166
|
+
labelPadding,
|
|
167
|
+
labelFontSize: resolvedLabelFontSize,
|
|
168
|
+
fontFamily: resolvedFontFamily,
|
|
169
|
+
rawDataMax,
|
|
170
|
+
perSpokeDomains: perSpokeDomains ?? null
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function extractCategories(datasets) {
|
|
174
|
+
const seen = /* @__PURE__ */ new Set();
|
|
175
|
+
const result = [];
|
|
176
|
+
for (const ds of datasets) {
|
|
177
|
+
const props = ds.props;
|
|
178
|
+
if (!props.data) continue;
|
|
179
|
+
const cats = batchResolveAccessor(props.categoryField ?? FIELD_DEFAULTS.categoryField, props.data);
|
|
180
|
+
for (const cat of cats) {
|
|
181
|
+
const str = String(cat);
|
|
182
|
+
if (!seen.has(str)) {
|
|
183
|
+
seen.add(str);
|
|
184
|
+
result.push(str);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
function resolveValues(props) {
|
|
191
|
+
if (!props.data) return [];
|
|
192
|
+
return batchResolveAccessor(props.valueField ?? FIELD_DEFAULTS.valueField, props.data).map((v) => Number(v) || 0);
|
|
193
|
+
}
|
|
194
|
+
function computeRadialComboContext(radarDatasets, polarDatasets) {
|
|
195
|
+
const allEntries = [...radarDatasets, ...polarDatasets];
|
|
196
|
+
const categories = extractCategories(allEntries);
|
|
197
|
+
const allValues = [];
|
|
198
|
+
for (const ds of allEntries) {
|
|
199
|
+
allValues.push(...resolveValues(ds.props));
|
|
200
|
+
}
|
|
201
|
+
const domain = calculateNiceDomain(allValues, { includeZero: true, nice: true });
|
|
202
|
+
return { categories, domain };
|
|
203
|
+
}
|
|
204
|
+
function getCategoryLabelAnchor(angleDeg) {
|
|
205
|
+
const cosA = Math.cos(toRad(angleDeg));
|
|
206
|
+
if (cosA > 0.15) return "start";
|
|
207
|
+
if (cosA < -0.15) return "end";
|
|
208
|
+
return "middle";
|
|
209
|
+
}
|
|
210
|
+
function calculateLabelMargins(categories, angleStep, labelPadding, fontSize = DEFAULT_RADIAL_LABEL_FONT_SIZE) {
|
|
211
|
+
let top = 0;
|
|
212
|
+
let right = 0;
|
|
213
|
+
let bottom = 0;
|
|
214
|
+
let left = 0;
|
|
215
|
+
for (let i = 0; i < categories.length; i++) {
|
|
216
|
+
const angleDeg = -90 + i * angleStep;
|
|
217
|
+
const angleRad = toRad(angleDeg);
|
|
218
|
+
const cosA = Math.cos(angleRad);
|
|
219
|
+
const sinA = Math.sin(angleRad);
|
|
220
|
+
const { width: textWidth, height: textHeight } = measureText(categories[i], fontSize);
|
|
221
|
+
const halfH = textHeight / 2;
|
|
222
|
+
const dx = cosA * labelPadding;
|
|
223
|
+
const dy = sinA * labelPadding;
|
|
224
|
+
const anchor = getCategoryLabelAnchor(angleDeg);
|
|
225
|
+
let textExtentRight;
|
|
226
|
+
let textExtentLeft;
|
|
227
|
+
if (anchor === "start") {
|
|
228
|
+
textExtentRight = textWidth;
|
|
229
|
+
textExtentLeft = 0;
|
|
230
|
+
} else if (anchor === "end") {
|
|
231
|
+
textExtentRight = 0;
|
|
232
|
+
textExtentLeft = textWidth;
|
|
233
|
+
} else {
|
|
234
|
+
textExtentRight = textWidth / 2;
|
|
235
|
+
textExtentLeft = textWidth / 2;
|
|
236
|
+
}
|
|
237
|
+
right = Math.max(right, dx + textExtentRight);
|
|
238
|
+
left = Math.max(left, -dx + textExtentLeft);
|
|
239
|
+
bottom = Math.max(bottom, dy + halfH);
|
|
240
|
+
top = Math.max(top, -dy + halfH);
|
|
241
|
+
}
|
|
242
|
+
const buffer = 4;
|
|
243
|
+
return {
|
|
244
|
+
top: Math.max(top, 0) + buffer,
|
|
245
|
+
right: Math.max(right, 0) + buffer,
|
|
246
|
+
bottom: Math.max(bottom, 0) + buffer,
|
|
247
|
+
left: Math.max(left, 0) + buffer
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// src/renderers/radar.svg.ts
|
|
252
|
+
function buildSmoothPath(points) {
|
|
253
|
+
if (points.length < 3) return buildPointsPath(points);
|
|
254
|
+
const builder = createSvgPathBuilder();
|
|
255
|
+
traceClosedSpline(builder, points);
|
|
256
|
+
return builder.build();
|
|
257
|
+
}
|
|
258
|
+
function buildPointsPath(points) {
|
|
259
|
+
if (points.length === 0) return "";
|
|
260
|
+
const parts = [];
|
|
261
|
+
for (let i = 0; i < points.length; i++) {
|
|
262
|
+
parts.push(`${i === 0 ? "M" : "L"} ${points[i].x} ${points[i].y}`);
|
|
263
|
+
}
|
|
264
|
+
parts.push("Z");
|
|
265
|
+
return parts.join(" ");
|
|
266
|
+
}
|
|
267
|
+
function buildPointsPathReversed(points) {
|
|
268
|
+
if (points.length === 0) return "";
|
|
269
|
+
const parts = [];
|
|
270
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
271
|
+
parts.push(`${i === points.length - 1 ? "M" : "L"} ${points[i].x} ${points[i].y}`);
|
|
272
|
+
}
|
|
273
|
+
parts.push("Z");
|
|
274
|
+
return parts.join(" ");
|
|
275
|
+
}
|
|
276
|
+
function renderRadarSeriesSvg(layout, seriesIndex, hoverState, theme, effectConfig, seriesProps, a11y, context) {
|
|
277
|
+
const sd = layout.series[seriesIndex];
|
|
278
|
+
if (!sd || !sd.visible || sd.points.length === 0) return createSvgGroup();
|
|
279
|
+
const group = createSvgGroup();
|
|
280
|
+
if (a11y?.enabled) {
|
|
281
|
+
setAttr(group, "role", "region");
|
|
282
|
+
setAttr(group, "aria-label", seriesProps?.name ?? sd.id);
|
|
283
|
+
}
|
|
284
|
+
const sharedAxisIdx = hoverState.axisIndex ?? null;
|
|
285
|
+
const isSharedHover = sharedAxisIdx !== null;
|
|
286
|
+
const isSeriesHovered = isSharedHover ? true : hoverState.datasetId === sd.id;
|
|
287
|
+
const anyHover = hoverState.datasetId !== null || isSharedHover;
|
|
288
|
+
let seriesOpacity = 1;
|
|
289
|
+
if (anyHover && !isSharedHover && !isSeriesHovered && effectConfig?.dimOpacity !== void 0) {
|
|
290
|
+
seriesOpacity = effectConfig.dimOpacity;
|
|
291
|
+
}
|
|
292
|
+
const isSmooth = sd.curve === "smooth";
|
|
293
|
+
const outerPathD = isSmooth ? buildSmoothPath(sd.points) : buildPointsPath(sd.points);
|
|
294
|
+
const isStacked = sd.basePoints && sd.basePoints.length > 0;
|
|
295
|
+
const innerPathD = isStacked ? isSmooth ? buildSmoothPath([...sd.basePoints].reverse()) : buildPointsPathReversed(sd.basePoints) : "";
|
|
296
|
+
const fillPathD = isStacked ? `${outerPathD} ${innerPathD}` : outerPathD;
|
|
297
|
+
const colorClassN = `p-chart-color-${sd.seriesIdx % 10}`;
|
|
298
|
+
const seriesIsHoveredJs = !isSharedHover && isSeriesHovered;
|
|
299
|
+
let fillColor = sd.color;
|
|
300
|
+
let strokeColor = sd.color;
|
|
301
|
+
if (sd.color !== void 0 && seriesIsHoveredJs && effectConfig?.hoverBrightness) {
|
|
302
|
+
fillColor = adjustBrightness(sd.color, effectConfig.hoverBrightness);
|
|
303
|
+
strokeColor = adjustBrightness(sd.color, effectConfig.hoverBrightness);
|
|
304
|
+
}
|
|
305
|
+
let fillValue = fillColor;
|
|
306
|
+
let strokeValue = strokeColor;
|
|
307
|
+
let gradientUrl = null;
|
|
308
|
+
if (sd.gradientColor && context) {
|
|
309
|
+
const defs = createSvgDefs();
|
|
310
|
+
const gradId = `${context.chartId}-radar-${seriesIndex}-grad`;
|
|
311
|
+
const gradNode = createSvgGradientFromColor(sd.gradientColor, gradId, layout.center, layout.radius);
|
|
312
|
+
setAttr(defs, "id", `${gradId}-defs`);
|
|
313
|
+
appendChild(defs, gradNode);
|
|
314
|
+
prependChild(group, defs);
|
|
315
|
+
gradientUrl = `url(#${gradId})`;
|
|
316
|
+
fillValue = gradientUrl;
|
|
317
|
+
strokeValue = sd.gradientColor.stops[0]?.color ?? strokeColor;
|
|
318
|
+
}
|
|
319
|
+
const borderColor = seriesProps?.borderColor && typeof seriesProps.borderColor === "string" ? seriesProps.borderColor : void 0;
|
|
320
|
+
const borderWidth = typeof seriesProps?.borderStrokeWidth === "number" ? seriesProps.borderStrokeWidth : 0;
|
|
321
|
+
const dashAttrs = {};
|
|
322
|
+
const dashPattern = sd.lineDash ?? (sd.lineStyle === "dashed" ? [6, 4] : sd.lineStyle === "dotted" ? [2, 3] : null);
|
|
323
|
+
if (dashPattern?.length) dashAttrs["stroke-dasharray"] = dashPattern.join(" ");
|
|
324
|
+
const fillAreaCls = svgClass("p-chart-area", `p-chart-series-${sd.seriesIdx}`, fillValue === void 0 && colorClassN, seriesIsHoveredJs && "p-chart-point-hover", anyHover && !isSeriesHovered && "p-chart-series-inactive");
|
|
325
|
+
const themedSeriesColor = theme.series[sd.seriesIdx % theme.series.length];
|
|
326
|
+
appendChild(
|
|
327
|
+
group,
|
|
328
|
+
createSvgPath(fillPathD, {
|
|
329
|
+
fill: fillValue ?? themedSeriesColor,
|
|
330
|
+
"fill-opacity": sd.fillOpacity * seriesOpacity,
|
|
331
|
+
"fill-rule": isStacked ? "evenodd" : "nonzero",
|
|
332
|
+
stroke: "none",
|
|
333
|
+
class: fillAreaCls,
|
|
334
|
+
"data-layer": "area"
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
const borderAlign = seriesProps?.borderAlign ?? "center";
|
|
338
|
+
const radarDataArr = seriesProps?.data;
|
|
339
|
+
const radarSeriesDashCtx = makeItemContext(radarDataArr?.[0], 0);
|
|
340
|
+
const borderDash = resolveDash(seriesProps?.borderDash, radarSeriesDashCtx);
|
|
341
|
+
const borderDashOffset = resolveAccessor(seriesProps?.borderDashOffset, radarSeriesDashCtx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
342
|
+
if (borderColor && borderWidth > 0 && borderAlign === "center") {
|
|
343
|
+
const borderAttrs = {
|
|
344
|
+
fill: "none",
|
|
345
|
+
stroke: borderColor,
|
|
346
|
+
"stroke-width": sd.lineStrokeWidth + borderWidth * 2,
|
|
347
|
+
"stroke-opacity": seriesOpacity,
|
|
348
|
+
"stroke-linejoin": seriesProps?.borderJoinStyle ?? "round",
|
|
349
|
+
"data-layer": "center-border"
|
|
350
|
+
};
|
|
351
|
+
if (borderDash && borderDash.length > 0) borderAttrs["stroke-dasharray"] = borderDash.join(" ");
|
|
352
|
+
if (borderDashOffset) borderAttrs["stroke-dashoffset"] = borderDashOffset;
|
|
353
|
+
appendChild(group, createSvgPath(outerPathD, borderAttrs));
|
|
354
|
+
}
|
|
355
|
+
const strokeLineCls = svgClass("p-chart-line", `p-chart-series-${sd.seriesIdx}`, strokeValue === void 0 && colorClassN, seriesIsHoveredJs && "p-chart-point-hover", anyHover && !isSeriesHovered && "p-chart-series-inactive");
|
|
356
|
+
appendChild(
|
|
357
|
+
group,
|
|
358
|
+
createSvgPath(outerPathD, {
|
|
359
|
+
fill: "none",
|
|
360
|
+
stroke: strokeValue ?? themedSeriesColor,
|
|
361
|
+
"stroke-width": sd.lineStrokeWidth,
|
|
362
|
+
"stroke-opacity": seriesOpacity,
|
|
363
|
+
"stroke-linejoin": "round",
|
|
364
|
+
class: strokeLineCls,
|
|
365
|
+
"data-layer": "line",
|
|
366
|
+
...dashAttrs
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
if (borderColor && borderWidth > 0 && borderAlign === "inner") {
|
|
370
|
+
const clipId = context ? `${context.chartId}-radar-${seriesIndex}-border-clip` : `radar-${seriesIndex}-border-clip`;
|
|
371
|
+
const clipPathEl = svgNode("clipPath", { id: clipId });
|
|
372
|
+
appendChild(clipPathEl, createSvgPath(outerPathD, {}));
|
|
373
|
+
const defs = createSvgDefs();
|
|
374
|
+
setAttr(defs, "id", `${clipId}-defs`);
|
|
375
|
+
appendChild(defs, clipPathEl);
|
|
376
|
+
prependChild(group, defs);
|
|
377
|
+
const borderAttrs = {
|
|
378
|
+
fill: "none",
|
|
379
|
+
stroke: borderColor,
|
|
380
|
+
"stroke-width": borderWidth * 2,
|
|
381
|
+
"stroke-opacity": seriesOpacity,
|
|
382
|
+
"stroke-linejoin": seriesProps?.borderJoinStyle ?? "round",
|
|
383
|
+
"clip-path": `url(#${clipId})`,
|
|
384
|
+
"data-layer": "inner-border"
|
|
385
|
+
};
|
|
386
|
+
if (borderDash && borderDash.length > 0) borderAttrs["stroke-dasharray"] = borderDash.join(" ");
|
|
387
|
+
if (borderDashOffset) borderAttrs["stroke-dashoffset"] = borderDashOffset;
|
|
388
|
+
appendChild(group, createSvgPath(outerPathD, borderAttrs));
|
|
389
|
+
}
|
|
390
|
+
const showMarkers = seriesProps?.showMarkers !== false;
|
|
391
|
+
const a11yEnabled = !!(a11y?.enabled && sd.points.length <= (a11y.pointDescriptionThreshold ?? 200));
|
|
392
|
+
const seriesName = seriesProps?.name ?? sd.id;
|
|
393
|
+
const anyPointHovered = isSharedHover ? sharedAxisIdx !== null : isSeriesHovered && hoverState.index !== null;
|
|
394
|
+
if ((showMarkers || anyPointHovered) && !seriesProps?.renderMarker) {
|
|
395
|
+
const dataArr = seriesProps?.data;
|
|
396
|
+
const ptValue = (idx) => sd.points[idx]?.value;
|
|
397
|
+
const ptCategory = (idx) => layout.categories[sd.points[idx]?.categoryIndex ?? idx];
|
|
398
|
+
const seriesExtras = { seriesIndex, seriesId: sd.id ?? "" };
|
|
399
|
+
const resolveMarkerSize = (idx) => resolveAccessor(seriesProps?.markerSize, makeItemContext(dataArr?.[idx], idx, { value: ptValue(idx), category: ptCategory(idx), ...seriesExtras }), { arrayMode: "clip", fallback: DEFAULT_LINE_MARKER_SIZE }) ?? DEFAULT_LINE_MARKER_SIZE;
|
|
400
|
+
const resolveMarkerHoverColor = (idx) => {
|
|
401
|
+
const v = resolveAccessor(seriesProps?.hoverColor, makeItemContext(dataArr?.[idx], idx, { value: ptValue(idx), category: ptCategory(idx), ...seriesExtras }), { arrayMode: "cycle" });
|
|
402
|
+
return typeof v === "string" ? v : v ? getPrimaryColor(v) : void 0;
|
|
403
|
+
};
|
|
404
|
+
const resolveMarkerHoverBorderColor = (idx) => {
|
|
405
|
+
const v = resolveAccessor(seriesProps?.hoverBorderColor, makeItemContext(dataArr?.[idx], idx, { value: ptValue(idx), category: ptCategory(idx), ...seriesExtras }), { arrayMode: "cycle" });
|
|
406
|
+
return typeof v === "string" ? v : v ? getPrimaryColor(v) : void 0;
|
|
407
|
+
};
|
|
408
|
+
const resolveMarkerShape = (idx, size) => resolveAccessor(seriesProps?.markerShape, makeItemContext(dataArr?.[idx], idx, { size, value: ptValue(idx), category: ptCategory(idx), ...seriesExtras }), { arrayMode: "clip" }) ?? "circle";
|
|
409
|
+
const resolvePointRotation = (idx) => resolveAccessor(seriesProps?.pointRotation, makeItemContext(dataArr?.[idx], idx, { value: ptValue(idx), category: ptCategory(idx), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
410
|
+
for (let pi = 0; pi < sd.points.length; pi++) {
|
|
411
|
+
const pt = sd.points[pi];
|
|
412
|
+
const isPointHovered = isSharedHover ? pi === sharedAxisIdx : isSeriesHovered && hoverState.index === pi;
|
|
413
|
+
if (!showMarkers && !isPointHovered) continue;
|
|
414
|
+
const ptMarkerSize = resolveMarkerSize(pi);
|
|
415
|
+
const pointR = isPointHovered ? ptMarkerSize * (effectConfig?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER) : ptMarkerSize;
|
|
416
|
+
let ptColor = gradientUrl ?? strokeColor;
|
|
417
|
+
if (isPointHovered) {
|
|
418
|
+
const ptHoverColor = resolveMarkerHoverColor(pi);
|
|
419
|
+
if (ptHoverColor) {
|
|
420
|
+
ptColor = ptHoverColor;
|
|
421
|
+
} else if (typeof ptColor === "string" && !gradientUrl && effectConfig?.hoverBrightness && effectConfig.hoverBrightness !== 1) {
|
|
422
|
+
ptColor = adjustBrightness(ptColor, effectConfig.hoverBrightness);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const userPointBorder = seriesProps?.pointBorderColor;
|
|
426
|
+
const ptHoverBorderColor = isPointHovered ? resolveMarkerHoverBorderColor(pi) : void 0;
|
|
427
|
+
const markerStrokeStr = ptHoverBorderColor ?? userPointBorder ?? ptColor;
|
|
428
|
+
const markerCls = svgClass("p-chart-marker", `p-chart-series-${sd.seriesIdx}`, ptColor === void 0 && colorClassN, isPointHovered && "p-chart-point-hover", anyHover && !isSeriesHovered && "p-chart-point-inactive");
|
|
429
|
+
const radarMarkerAttrs = {
|
|
430
|
+
fill: ptColor ?? themedSeriesColor,
|
|
431
|
+
stroke: markerStrokeStr ?? themedSeriesColor,
|
|
432
|
+
"stroke-width": resolveAccessor(seriesProps?.pointBorderStrokeWidth, makeItemContext(dataArr?.[pi], pi, { value: pt.value, category: ptCategory(pi), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0,
|
|
433
|
+
"stroke-linejoin": seriesProps?.pointBorderJoinStyle ?? "miter",
|
|
434
|
+
opacity: seriesOpacity,
|
|
435
|
+
class: markerCls
|
|
436
|
+
};
|
|
437
|
+
const ptDash = resolveDash(seriesProps?.pointBorderDash, makeItemContext(dataArr?.[pi], pi, { value: pt.value, category: ptCategory(pi), ...seriesExtras }));
|
|
438
|
+
const ptDashOffset = resolveAccessor(seriesProps?.pointBorderDashOffset, makeItemContext(dataArr?.[pi], pi, { value: pt.value, category: ptCategory(pi), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
439
|
+
if (ptDash && ptDash.length > 0) radarMarkerAttrs["stroke-dasharray"] = ptDash.join(" ");
|
|
440
|
+
if (ptDashOffset) radarMarkerAttrs["stroke-dashoffset"] = ptDashOffset;
|
|
441
|
+
const ptShape = resolveMarkerShape(pi, pointR);
|
|
442
|
+
let markerEl;
|
|
443
|
+
const ptRotation = resolvePointRotation(pi);
|
|
444
|
+
if (MARKER_SHAPE_NAMES.has(ptShape)) {
|
|
445
|
+
if (ptRotation) radarMarkerAttrs.transform = `rotate(${ptRotation}, ${pt.x}, ${pt.y})`;
|
|
446
|
+
markerEl = renderMarkerShapeSvg(ptShape, pt.x, pt.y, pointR, radarMarkerAttrs);
|
|
447
|
+
} else {
|
|
448
|
+
radarMarkerAttrs.transform = ptRotation ? `translate(${pt.x}, ${pt.y}) rotate(${ptRotation})` : `translate(${pt.x}, ${pt.y})`;
|
|
449
|
+
markerEl = createSvgPath(ptShape, radarMarkerAttrs);
|
|
450
|
+
}
|
|
451
|
+
if (a11yEnabled) {
|
|
452
|
+
const category = layout.categories[pt.categoryIndex] ?? `Category ${pt.categoryIndex + 1}`;
|
|
453
|
+
const desc = formatPointDescription({ category, value: pt.value, seriesName, index: pt.categoryIndex }, a11y.pointDescriptionFormatter);
|
|
454
|
+
setAttr(markerEl, "role", "img");
|
|
455
|
+
setAttr(markerEl, "aria-label", desc);
|
|
456
|
+
}
|
|
457
|
+
setAttr(markerEl, "data-index", String(pi));
|
|
458
|
+
appendChild(group, markerEl);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return group;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/renderers/radar.canvas.ts
|
|
465
|
+
function renderRadarSeriesCanvas(ctx, layout, seriesIndex, hoverState, effectConfig, seriesProps, theme) {
|
|
466
|
+
const sd = layout.series[seriesIndex];
|
|
467
|
+
if (!sd || !sd.visible || sd.points.length === 0) return;
|
|
468
|
+
const sharedAxisIdx = hoverState.axisIndex ?? null;
|
|
469
|
+
const isSharedHover = sharedAxisIdx !== null;
|
|
470
|
+
const isSeriesHovered = isSharedHover ? true : hoverState.datasetId === sd.id;
|
|
471
|
+
const anyHover = hoverState.datasetId !== null || isSharedHover;
|
|
472
|
+
let seriesOpacity = 1;
|
|
473
|
+
if (anyHover && !isSharedHover && !isSeriesHovered && effectConfig?.dimOpacity !== void 0) {
|
|
474
|
+
seriesOpacity = effectConfig.dimOpacity;
|
|
475
|
+
}
|
|
476
|
+
const baseColor = sd.color ?? getDefaultColor(sd.seriesIdx, theme);
|
|
477
|
+
let fillColor = baseColor;
|
|
478
|
+
let strokeColor = baseColor;
|
|
479
|
+
if (!isSharedHover && isSeriesHovered && effectConfig?.hoverBrightness) {
|
|
480
|
+
fillColor = adjustBrightness(fillColor, effectConfig.hoverBrightness);
|
|
481
|
+
strokeColor = adjustBrightness(strokeColor, effectConfig.hoverBrightness);
|
|
482
|
+
}
|
|
483
|
+
const isStacked = sd.basePoints && sd.basePoints.length > 0;
|
|
484
|
+
const isSmooth = sd.curve === "smooth";
|
|
485
|
+
const canvasBuilder = createCanvasPathBuilder(ctx);
|
|
486
|
+
const borderColor = seriesProps?.borderColor && typeof seriesProps.borderColor === "string" ? seriesProps.borderColor : void 0;
|
|
487
|
+
const borderWidth = typeof seriesProps?.borderStrokeWidth === "number" ? seriesProps.borderStrokeWidth : 0;
|
|
488
|
+
withCanvasState(ctx, () => {
|
|
489
|
+
ctx.beginPath();
|
|
490
|
+
if (isSmooth) {
|
|
491
|
+
traceClosedSpline(canvasBuilder, sd.points);
|
|
492
|
+
} else {
|
|
493
|
+
for (let i = 0; i < sd.points.length; i++) {
|
|
494
|
+
const pt = sd.points[i];
|
|
495
|
+
if (i === 0) ctx.moveTo(pt.x, pt.y);
|
|
496
|
+
else ctx.lineTo(pt.x, pt.y);
|
|
497
|
+
}
|
|
498
|
+
ctx.closePath();
|
|
499
|
+
}
|
|
500
|
+
if (isStacked) {
|
|
501
|
+
const basePts = sd.basePoints;
|
|
502
|
+
if (isSmooth) {
|
|
503
|
+
traceClosedSpline(canvasBuilder, [...basePts].reverse());
|
|
504
|
+
} else {
|
|
505
|
+
for (let i = basePts.length - 1; i >= 0; i--) {
|
|
506
|
+
const pt = basePts[i];
|
|
507
|
+
if (i === basePts.length - 1) ctx.moveTo(pt.x, pt.y);
|
|
508
|
+
else ctx.lineTo(pt.x, pt.y);
|
|
509
|
+
}
|
|
510
|
+
ctx.closePath();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const resolvedFill = sd.gradientColor ? createCanvasGradientFromColor(ctx, sd.gradientColor, layout.center, layout.radius) : fillColor;
|
|
514
|
+
const resolvedStroke = sd.gradientColor ? sd.gradientColor.stops[0]?.color ?? strokeColor : strokeColor;
|
|
515
|
+
ctx.fillStyle = resolvedFill;
|
|
516
|
+
ctx.globalAlpha = sd.fillOpacity * seriesOpacity;
|
|
517
|
+
ctx.fill(isStacked ? "evenodd" : "nonzero");
|
|
518
|
+
const traceOuterPath = () => {
|
|
519
|
+
ctx.beginPath();
|
|
520
|
+
if (isSmooth) {
|
|
521
|
+
traceClosedSpline(canvasBuilder, sd.points);
|
|
522
|
+
} else {
|
|
523
|
+
for (let i = 0; i < sd.points.length; i++) {
|
|
524
|
+
const pt = sd.points[i];
|
|
525
|
+
if (i === 0) ctx.moveTo(pt.x, pt.y);
|
|
526
|
+
else ctx.lineTo(pt.x, pt.y);
|
|
527
|
+
}
|
|
528
|
+
ctx.closePath();
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
ctx.globalAlpha = seriesOpacity;
|
|
532
|
+
const borderAlign = seriesProps?.borderAlign ?? "center";
|
|
533
|
+
const radarDataArrCanvas = seriesProps?.data;
|
|
534
|
+
const radarSeriesDashCtx = makeItemContext(radarDataArrCanvas?.[0], 0);
|
|
535
|
+
const resolvedSeriesDash = resolveDash(seriesProps?.borderDash, radarSeriesDashCtx);
|
|
536
|
+
const resolvedSeriesDashOffset = resolveAccessor(seriesProps?.borderDashOffset, radarSeriesDashCtx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
537
|
+
const borderDashPattern = resolvedSeriesDash && resolvedSeriesDash.length > 0 ? resolvedSeriesDash : [];
|
|
538
|
+
if (borderColor && borderWidth > 0 && borderAlign === "center") {
|
|
539
|
+
traceOuterPath();
|
|
540
|
+
ctx.strokeStyle = borderColor;
|
|
541
|
+
ctx.lineWidth = sd.lineStrokeWidth + borderWidth * 2;
|
|
542
|
+
ctx.lineJoin = seriesProps?.borderJoinStyle ?? "round";
|
|
543
|
+
ctx.setLineDash(borderDashPattern);
|
|
544
|
+
if (resolvedSeriesDashOffset) ctx.lineDashOffset = resolvedSeriesDashOffset;
|
|
545
|
+
ctx.stroke();
|
|
546
|
+
ctx.setLineDash([]);
|
|
547
|
+
ctx.lineDashOffset = 0;
|
|
548
|
+
}
|
|
549
|
+
traceOuterPath();
|
|
550
|
+
ctx.strokeStyle = resolvedStroke;
|
|
551
|
+
ctx.lineWidth = sd.lineStrokeWidth;
|
|
552
|
+
ctx.lineJoin = "round";
|
|
553
|
+
const dashArray = sd.lineDash ?? (sd.lineStyle === "dashed" ? [6, 4] : sd.lineStyle === "dotted" ? [2, 3] : []);
|
|
554
|
+
ctx.setLineDash(dashArray);
|
|
555
|
+
ctx.stroke();
|
|
556
|
+
if (borderColor && borderWidth > 0 && borderAlign === "inner") {
|
|
557
|
+
ctx.save();
|
|
558
|
+
traceOuterPath();
|
|
559
|
+
ctx.clip();
|
|
560
|
+
traceOuterPath();
|
|
561
|
+
ctx.strokeStyle = borderColor;
|
|
562
|
+
ctx.lineWidth = borderWidth * 2;
|
|
563
|
+
ctx.lineJoin = seriesProps?.borderJoinStyle ?? "round";
|
|
564
|
+
ctx.setLineDash(borderDashPattern);
|
|
565
|
+
if (resolvedSeriesDashOffset) ctx.lineDashOffset = resolvedSeriesDashOffset;
|
|
566
|
+
ctx.stroke();
|
|
567
|
+
ctx.restore();
|
|
568
|
+
ctx.setLineDash([]);
|
|
569
|
+
ctx.lineDashOffset = 0;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
const showMarkers = seriesProps?.showMarkers !== false;
|
|
573
|
+
const dataArrCanvas = seriesProps?.data;
|
|
574
|
+
const ptValueCanvas = (idx) => sd.points[idx]?.value;
|
|
575
|
+
const ptCategoryCanvas = (idx) => layout.categories[sd.points[idx]?.categoryIndex ?? idx];
|
|
576
|
+
const seriesExtras = { seriesIndex, seriesId: sd.id ?? "" };
|
|
577
|
+
const resolveMarkerSize = (idx) => resolveAccessor(seriesProps?.markerSize, makeItemContext(dataArrCanvas?.[idx], idx, { value: ptValueCanvas(idx), category: ptCategoryCanvas(idx), ...seriesExtras }), {
|
|
578
|
+
arrayMode: "clip",
|
|
579
|
+
fallback: DEFAULT_LINE_MARKER_SIZE
|
|
580
|
+
}) ?? DEFAULT_LINE_MARKER_SIZE;
|
|
581
|
+
const resolveMarkerHoverColorCanvas = (idx) => {
|
|
582
|
+
const v = resolveAccessor(seriesProps?.hoverColor, makeItemContext(dataArrCanvas?.[idx], idx, { value: ptValueCanvas(idx), category: ptCategoryCanvas(idx), ...seriesExtras }), { arrayMode: "cycle" });
|
|
583
|
+
return typeof v === "string" ? v : v ? getPrimaryColor(v) : void 0;
|
|
584
|
+
};
|
|
585
|
+
const resolveMarkerHoverBorderColorCanvas = (idx) => {
|
|
586
|
+
const v = resolveAccessor(seriesProps?.hoverBorderColor, makeItemContext(dataArrCanvas?.[idx], idx, { value: ptValueCanvas(idx), category: ptCategoryCanvas(idx), ...seriesExtras }), { arrayMode: "cycle" });
|
|
587
|
+
return typeof v === "string" ? v : v ? getPrimaryColor(v) : void 0;
|
|
588
|
+
};
|
|
589
|
+
const resolveMarkerShapeCanvas = (idx, size) => resolveAccessor(seriesProps?.markerShape, makeItemContext(dataArrCanvas?.[idx], idx, { size, value: ptValueCanvas(idx), category: ptCategoryCanvas(idx), ...seriesExtras }), { arrayMode: "clip" }) ?? "circle";
|
|
590
|
+
const resolvePointRotationCanvas = (idx) => resolveAccessor(seriesProps?.pointRotation, makeItemContext(dataArrCanvas?.[idx], idx, { value: ptValueCanvas(idx), category: ptCategoryCanvas(idx), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
591
|
+
const anyPointHoveredCanvas = isSharedHover ? sharedAxisIdx !== null : isSeriesHovered && hoverState.index !== null;
|
|
592
|
+
if (showMarkers || anyPointHoveredCanvas) {
|
|
593
|
+
for (let pi = 0; pi < sd.points.length; pi++) {
|
|
594
|
+
const pt = sd.points[pi];
|
|
595
|
+
const isPointHovered = isSharedHover ? pi === sharedAxisIdx : isSeriesHovered && hoverState.index === pi;
|
|
596
|
+
if (!showMarkers && !isPointHovered) continue;
|
|
597
|
+
const ptMarkerSize = resolveMarkerSize(pi);
|
|
598
|
+
const pointR = isPointHovered ? ptMarkerSize * (effectConfig?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER) : ptMarkerSize;
|
|
599
|
+
let ptColor = sd.gradientColor ? sampleGradientAt(sd.gradientColor, pt, layout.center, layout.radius) : strokeColor;
|
|
600
|
+
if (isPointHovered) {
|
|
601
|
+
const ptHoverColor = resolveMarkerHoverColorCanvas(pi);
|
|
602
|
+
if (ptHoverColor) {
|
|
603
|
+
ptColor = ptHoverColor;
|
|
604
|
+
} else if (effectConfig?.hoverBrightness && effectConfig.hoverBrightness !== 1) {
|
|
605
|
+
ptColor = adjustBrightness(ptColor, effectConfig.hoverBrightness);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const ptHoverBorderColorCanvas = isPointHovered ? resolveMarkerHoverBorderColorCanvas(pi) : void 0;
|
|
609
|
+
if (!seriesProps?.renderMarker) {
|
|
610
|
+
drawMarkerCanvas(ctx, {
|
|
611
|
+
x: pt.x,
|
|
612
|
+
y: pt.y,
|
|
613
|
+
size: pointR,
|
|
614
|
+
shape: resolveMarkerShapeCanvas(pi, pointR),
|
|
615
|
+
fillStyle: ptColor,
|
|
616
|
+
strokeStyle: ptHoverBorderColorCanvas ?? seriesProps?.pointBorderColor ?? ptColor,
|
|
617
|
+
lineStrokeWidth: resolveAccessor(seriesProps?.pointBorderStrokeWidth, makeItemContext(dataArrCanvas?.[pi], pi, { value: pt.value, category: ptCategoryCanvas(pi), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0,
|
|
618
|
+
opacity: seriesOpacity,
|
|
619
|
+
lineDash: resolveDash(seriesProps?.pointBorderDash, makeItemContext(dataArrCanvas?.[pi], pi, { value: pt.value, category: ptCategoryCanvas(pi), ...seriesExtras })),
|
|
620
|
+
lineDashOffset: resolveAccessor(seriesProps?.pointBorderDashOffset, makeItemContext(dataArrCanvas?.[pi], pi, { value: pt.value, category: ptCategoryCanvas(pi), ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0,
|
|
621
|
+
lineJoin: seriesProps?.pointBorderJoinStyle,
|
|
622
|
+
rotation: resolvePointRotationCanvas(pi)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/renderers/radar.renderer.ts
|
|
630
|
+
function hitTestRadar(x, y, layout, theme) {
|
|
631
|
+
let closest = null;
|
|
632
|
+
let minDist = DEFAULT_RADAR_HIT_RADIUS;
|
|
633
|
+
for (const sd of layout.series) {
|
|
634
|
+
if (!sd.visible) continue;
|
|
635
|
+
for (let pi = 0; pi < sd.points.length; pi++) {
|
|
636
|
+
const pt = sd.points[pi];
|
|
637
|
+
const dx = x - pt.x;
|
|
638
|
+
const dy = y - pt.y;
|
|
639
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
640
|
+
if (dist < minDist) {
|
|
641
|
+
minDist = dist;
|
|
642
|
+
closest = {
|
|
643
|
+
datasetId: sd.id,
|
|
644
|
+
index: pi,
|
|
645
|
+
label: layout.categories[pi] ?? "",
|
|
646
|
+
value: pt.value,
|
|
647
|
+
color: sd.color ?? (sd.gradientColor ? getPrimaryColor(sd.gradientColor) : getDefaultColor(sd.seriesIdx, theme)),
|
|
648
|
+
colorGradient: sd.gradientColor,
|
|
649
|
+
swatchColor: resolveSwatchColor({ color: sd.color ?? sd.gradientColor }, sd.seriesIdx, void 0, theme)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return closest;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/series/polar/geometry.ts
|
|
658
|
+
function resolveBorderProps(props, item, index, value, category, seriesIndex, seriesId) {
|
|
659
|
+
const borderColor = typeof props.borderColor === "string" ? props.borderColor : void 0;
|
|
660
|
+
const borderStrokeWidth = typeof props.borderStrokeWidth === "number" ? props.borderStrokeWidth : void 0;
|
|
661
|
+
const borderRadius = typeof props.borderRadius === "number" ? props.borderRadius : void 0;
|
|
662
|
+
const ctx = makeItemContext(item, index, { value: value ?? null, category, seriesIndex: seriesIndex ?? 0, seriesId: seriesId ?? "" });
|
|
663
|
+
const borderDash = resolveDash(props.borderDash, ctx);
|
|
664
|
+
const borderDashOffset = resolveAccessor(props.borderDashOffset, ctx, { arrayMode: "clip" });
|
|
665
|
+
const hoverColorResolved = resolveAccessor(props.hoverColor, ctx, { arrayMode: "cycle" });
|
|
666
|
+
const hoverBorderColorResolved = resolveAccessor(props.hoverBorderColor, ctx, { arrayMode: "cycle" });
|
|
667
|
+
const hoverColor = typeof hoverColorResolved === "string" ? hoverColorResolved : hoverColorResolved ? getPrimaryColor(hoverColorResolved) : void 0;
|
|
668
|
+
const hoverBorderColor = typeof hoverBorderColorResolved === "string" ? hoverBorderColorResolved : hoverBorderColorResolved ? getPrimaryColor(hoverBorderColorResolved) : void 0;
|
|
669
|
+
const opacity = props.opacity !== void 0 ? resolveAccessor(props.opacity, ctx, { arrayMode: "clip" }) ?? void 0 : void 0;
|
|
670
|
+
if (!borderColor && !borderStrokeWidth && !borderRadius && !borderDash && borderDashOffset === void 0 && !hoverColor && !hoverBorderColor && opacity === void 0) return {};
|
|
671
|
+
return { borderColor, borderStrokeWidth, borderRadius, borderDash, borderDashOffset, hoverColor, hoverBorderColor, opacity };
|
|
672
|
+
}
|
|
673
|
+
function calculatePolarLayout(datasets, chartArea, stackConfig, globalFont, sharedCategories, sharedDomain) {
|
|
674
|
+
const categories = sharedCategories ?? extractCategories(datasets);
|
|
675
|
+
const categoryCount = categories.length;
|
|
676
|
+
const angleStep = categoryCount > 0 ? 360 / categoryCount : 0;
|
|
677
|
+
const firstProps = datasets[0]?.props;
|
|
678
|
+
const innerRadiusRatio = firstProps?.innerRadius ?? 0;
|
|
679
|
+
const allValues = [];
|
|
680
|
+
const visibleDatasets = datasets.filter((ds) => ds.visible);
|
|
681
|
+
const globalDatasetIndex = new Map(visibleDatasets.map((ds) => [ds.id, datasets.indexOf(ds)]));
|
|
682
|
+
const isStacked = visibleDatasets.some((ds) => ds.props.stackId !== void 0);
|
|
683
|
+
const categoryValuesByDataset = [];
|
|
684
|
+
const keysByDataset = [];
|
|
685
|
+
for (const ds of visibleDatasets) {
|
|
686
|
+
const values = resolveValues(ds.props);
|
|
687
|
+
categoryValuesByDataset.push(values);
|
|
688
|
+
allValues.push(...values);
|
|
689
|
+
keysByDataset.push(ds.props.keyField && ds.props.data ? batchResolveRequired(ds.props.keyField, ds.props.data, "keyField") : []);
|
|
690
|
+
}
|
|
691
|
+
const visibleIndexById = new Map(visibleDatasets.map((ds, i) => [ds.id, i]));
|
|
692
|
+
const keysById = /* @__PURE__ */ new Map();
|
|
693
|
+
for (let i = 0; i < visibleDatasets.length; i++) keysById.set(visibleDatasets[i].id, keysByDataset[i]);
|
|
694
|
+
for (const ds of datasets) {
|
|
695
|
+
if (keysById.has(ds.id)) continue;
|
|
696
|
+
keysById.set(ds.id, ds.props.keyField && ds.props.data ? batchResolveRequired(ds.props.keyField, ds.props.data, "keyField") : []);
|
|
697
|
+
}
|
|
698
|
+
const sortProp = firstProps?.sort;
|
|
699
|
+
const originalCategoryIndices = categories.map((_, i) => i);
|
|
700
|
+
if (sortProp && categories.length > 0) {
|
|
701
|
+
const sortIndices = categories.map((_, i) => i);
|
|
702
|
+
if (sortProp === "label-asc") {
|
|
703
|
+
sortIndices.sort((a, b) => categories[a].localeCompare(categories[b]));
|
|
704
|
+
} else if (sortProp === "label-desc") {
|
|
705
|
+
sortIndices.sort((a, b) => categories[b].localeCompare(categories[a]));
|
|
706
|
+
} else {
|
|
707
|
+
const sums = categories.map((_, ci) => categoryValuesByDataset.reduce((s, vals) => s + (vals[ci] ?? 0), 0));
|
|
708
|
+
if (sortProp === "value-asc") sortIndices.sort((a, b) => sums[a] - sums[b]);
|
|
709
|
+
else sortIndices.sort((a, b) => sums[b] - sums[a]);
|
|
710
|
+
}
|
|
711
|
+
const sortedCategories = sortIndices.map((i) => categories[i]);
|
|
712
|
+
const sortedValues = categoryValuesByDataset.map((vals) => sortIndices.map((i) => vals[i] ?? 0));
|
|
713
|
+
categories.splice(0, categories.length, ...sortedCategories);
|
|
714
|
+
for (let di = 0; di < categoryValuesByDataset.length; di++) {
|
|
715
|
+
categoryValuesByDataset[di] = sortedValues[di];
|
|
716
|
+
}
|
|
717
|
+
for (let ci = 0; ci < sortIndices.length; ci++) {
|
|
718
|
+
originalCategoryIndices[ci] = sortIndices[ci];
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
let domain;
|
|
722
|
+
let rawDataMax = 0;
|
|
723
|
+
if (sharedDomain) {
|
|
724
|
+
domain = sharedDomain;
|
|
725
|
+
rawDataMax = sharedDomain[1];
|
|
726
|
+
} else if (isStacked && stackConfig?.mode !== "percent") {
|
|
727
|
+
const categoryTotals = [];
|
|
728
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
729
|
+
let total = 0;
|
|
730
|
+
for (const values of categoryValuesByDataset) {
|
|
731
|
+
total += values[ci] ?? 0;
|
|
732
|
+
}
|
|
733
|
+
categoryTotals.push(total);
|
|
734
|
+
}
|
|
735
|
+
rawDataMax = categoryTotals.length > 0 ? Math.max(...categoryTotals) : 0;
|
|
736
|
+
domain = calculateNiceDomain(categoryTotals, { includeZero: true, nice: true });
|
|
737
|
+
} else if (isStacked && stackConfig?.mode === "percent") {
|
|
738
|
+
domain = [0, 100];
|
|
739
|
+
rawDataMax = 100;
|
|
740
|
+
} else {
|
|
741
|
+
rawDataMax = allValues.length > 0 ? Math.max(...allValues) : 0;
|
|
742
|
+
domain = calculateNiceDomain(allValues, { includeZero: true, nice: true });
|
|
743
|
+
}
|
|
744
|
+
const resolvedLabelFontSize = resolveFontSize(DEFAULT_RADIAL_LABEL_FONT_SIZE, globalFont);
|
|
745
|
+
const resolvedFontFamily = resolveFontFamily(void 0, globalFont);
|
|
746
|
+
const labelPadding = measureText("Xg", resolvedLabelFontSize).height;
|
|
747
|
+
const labelMargins = calculateLabelMargins(categories, angleStep, labelPadding, resolvedLabelFontSize);
|
|
748
|
+
const adjustedArea = {
|
|
749
|
+
x: chartArea.x + labelMargins.left,
|
|
750
|
+
y: chartArea.y + labelMargins.top,
|
|
751
|
+
width: Math.max(0, chartArea.width - labelMargins.left - labelMargins.right),
|
|
752
|
+
height: Math.max(0, chartArea.height - labelMargins.top - labelMargins.bottom)
|
|
753
|
+
};
|
|
754
|
+
const { center, radius: maxRadius } = calculateRadiusAndCenter(adjustedArea);
|
|
755
|
+
const levelValues = generateNiceTicks(domain[0], domain[1]);
|
|
756
|
+
const firstTick = levelValues[0] ?? domain[0];
|
|
757
|
+
const lastTick = levelValues[levelValues.length - 1] ?? domain[1];
|
|
758
|
+
domain = [Math.min(domain[0], firstTick), Math.max(domain[1], lastTick)];
|
|
759
|
+
const levelRadii = levelValues.map((v) => {
|
|
760
|
+
if (domain[1] === domain[0]) return 0;
|
|
761
|
+
return (v - domain[0]) / (domain[1] - domain[0]) * maxRadius;
|
|
762
|
+
});
|
|
763
|
+
const grid = {
|
|
764
|
+
shape: "circle",
|
|
765
|
+
levels: levelValues.length,
|
|
766
|
+
levelValues,
|
|
767
|
+
levelRadii
|
|
768
|
+
};
|
|
769
|
+
const spokeEndpoints = [];
|
|
770
|
+
for (let i = 0; i < categoryCount; i++) {
|
|
771
|
+
const angleDeg = -90 + i * angleStep;
|
|
772
|
+
const angleRad = toRad(angleDeg);
|
|
773
|
+
spokeEndpoints.push({
|
|
774
|
+
x: center.x + Math.cos(angleRad) * maxRadius,
|
|
775
|
+
y: center.y + Math.sin(angleRad) * maxRadius
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
const bars = [];
|
|
779
|
+
const baseInnerRadius = innerRadiusRatio * maxRadius;
|
|
780
|
+
const availableRadius = maxRadius - baseInnerRadius;
|
|
781
|
+
const gapPx = firstProps?.spacing ?? DEFAULT_POLAR_GAP_PX;
|
|
782
|
+
const gapDeg = maxRadius > 0 ? gapPx / maxRadius * (180 / Math.PI) : 0;
|
|
783
|
+
if (isStacked) {
|
|
784
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
785
|
+
const sectorStart = -90 + ci * angleStep;
|
|
786
|
+
const barStart = sectorStart + gapDeg / 2;
|
|
787
|
+
const barEnd = sectorStart + angleStep - gapDeg / 2;
|
|
788
|
+
let categoryTotal = 0;
|
|
789
|
+
if (stackConfig?.mode === "percent") {
|
|
790
|
+
for (const values of categoryValuesByDataset) {
|
|
791
|
+
categoryTotal += values[ci] ?? 0;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
let currentInner = baseInnerRadius;
|
|
795
|
+
for (const ds of datasets) {
|
|
796
|
+
const dsSeriesIdx = globalDatasetIndex.get(ds.id) ?? datasets.indexOf(ds);
|
|
797
|
+
if (!ds.visible) {
|
|
798
|
+
if (ds.props.stackId === void 0) continue;
|
|
799
|
+
const color2 = resolveBarColor(ds.props, originalCategoryIndices[ci], dsSeriesIdx, ds.props.data?.[originalCategoryIndices[ci]], 0, categories[ci], ds.id ?? "");
|
|
800
|
+
const border2 = resolveBorderProps(ds.props, ds.props.data?.[originalCategoryIndices[ci]], originalCategoryIndices[ci], 0, categories[ci], dsSeriesIdx, ds.id ?? "");
|
|
801
|
+
bars.push({
|
|
802
|
+
datasetId: ds.id,
|
|
803
|
+
name: ds.props.name,
|
|
804
|
+
category: categories[ci],
|
|
805
|
+
categoryIndex: ci,
|
|
806
|
+
dataIndex: ci,
|
|
807
|
+
dataKey: keysById.get(ds.id)?.[ci],
|
|
808
|
+
startAngle: barStart,
|
|
809
|
+
endAngle: barEnd,
|
|
810
|
+
innerRadius: currentInner,
|
|
811
|
+
outerRadius: currentInner,
|
|
812
|
+
value: 0,
|
|
813
|
+
color: color2,
|
|
814
|
+
seriesIdx: dsSeriesIdx,
|
|
815
|
+
hidden: true,
|
|
816
|
+
...border2
|
|
817
|
+
});
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const rawValue = categoryValuesByDataset[visibleIndexById.get(ds.id)][ci] ?? 0;
|
|
821
|
+
let valueRadius;
|
|
822
|
+
if (stackConfig?.mode === "percent" && categoryTotal > 0) {
|
|
823
|
+
const pct = rawValue / categoryTotal * 100;
|
|
824
|
+
valueRadius = pct / (domain[1] - domain[0]) * availableRadius;
|
|
825
|
+
} else {
|
|
826
|
+
valueRadius = domain[1] === domain[0] ? 0 : rawValue / (domain[1] - domain[0]) * availableRadius;
|
|
827
|
+
}
|
|
828
|
+
const outerRadius = currentInner + valueRadius;
|
|
829
|
+
const color = resolveBarColor(ds.props, originalCategoryIndices[ci], dsSeriesIdx, ds.props.data?.[originalCategoryIndices[ci]], rawValue, categories[ci], ds.id ?? "");
|
|
830
|
+
const border = resolveBorderProps(ds.props, ds.props.data?.[originalCategoryIndices[ci]], originalCategoryIndices[ci], rawValue, categories[ci], dsSeriesIdx, ds.id ?? "");
|
|
831
|
+
bars.push({
|
|
832
|
+
datasetId: ds.id,
|
|
833
|
+
name: ds.props.name,
|
|
834
|
+
category: categories[ci],
|
|
835
|
+
categoryIndex: ci,
|
|
836
|
+
dataIndex: ci,
|
|
837
|
+
dataKey: keysById.get(ds.id)?.[ci],
|
|
838
|
+
startAngle: barStart,
|
|
839
|
+
endAngle: barEnd,
|
|
840
|
+
innerRadius: currentInner,
|
|
841
|
+
outerRadius,
|
|
842
|
+
value: rawValue,
|
|
843
|
+
color,
|
|
844
|
+
seriesIdx: dsSeriesIdx,
|
|
845
|
+
...border
|
|
846
|
+
});
|
|
847
|
+
currentInner = outerRadius;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
} else if (visibleDatasets.length > 1) {
|
|
851
|
+
const datasetCount = visibleDatasets.length;
|
|
852
|
+
const sectorWidth = angleStep - gapDeg;
|
|
853
|
+
const subBarWidth = sectorWidth / datasetCount;
|
|
854
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
855
|
+
const sectorStart = -90 + ci * angleStep + gapDeg / 2;
|
|
856
|
+
for (let di = 0; di < visibleDatasets.length; di++) {
|
|
857
|
+
const ds = visibleDatasets[di];
|
|
858
|
+
const rawValue = categoryValuesByDataset[di][ci] ?? 0;
|
|
859
|
+
const valueRadius = domain[1] === domain[0] ? 0 : (rawValue - domain[0]) / (domain[1] - domain[0]) * availableRadius;
|
|
860
|
+
const dsSeriesIdx = globalDatasetIndex.get(ds.id);
|
|
861
|
+
const color = resolveBarColor(ds.props, originalCategoryIndices[ci], dsSeriesIdx, ds.props.data?.[originalCategoryIndices[ci]], rawValue, categories[ci], ds.id ?? "");
|
|
862
|
+
const border = resolveBorderProps(ds.props, ds.props.data?.[originalCategoryIndices[ci]], originalCategoryIndices[ci], rawValue, categories[ci], dsSeriesIdx, ds.id ?? "");
|
|
863
|
+
bars.push({
|
|
864
|
+
datasetId: ds.id,
|
|
865
|
+
name: ds.props.name,
|
|
866
|
+
category: categories[ci],
|
|
867
|
+
categoryIndex: ci,
|
|
868
|
+
dataIndex: ci,
|
|
869
|
+
dataKey: keysByDataset[di]?.[ci],
|
|
870
|
+
startAngle: sectorStart + di * subBarWidth,
|
|
871
|
+
endAngle: sectorStart + (di + 1) * subBarWidth,
|
|
872
|
+
innerRadius: baseInnerRadius,
|
|
873
|
+
outerRadius: baseInnerRadius + valueRadius,
|
|
874
|
+
value: rawValue,
|
|
875
|
+
color,
|
|
876
|
+
seriesIdx: dsSeriesIdx,
|
|
877
|
+
...border
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
} else {
|
|
882
|
+
const ds = visibleDatasets[0];
|
|
883
|
+
if (ds) {
|
|
884
|
+
const values = categoryValuesByDataset[0];
|
|
885
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
886
|
+
const sectorStart = -90 + ci * angleStep;
|
|
887
|
+
const rawValue = values[ci] ?? 0;
|
|
888
|
+
const valueRadius = domain[1] === domain[0] ? 0 : (rawValue - domain[0]) / (domain[1] - domain[0]) * availableRadius;
|
|
889
|
+
const dsSeriesIdx = globalDatasetIndex.get(ds.id);
|
|
890
|
+
const color = resolveBarColor(ds.props, originalCategoryIndices[ci], dsSeriesIdx, ds.props.data?.[originalCategoryIndices[ci]], rawValue, categories[ci], ds.id ?? "");
|
|
891
|
+
const border = resolveBorderProps(ds.props, ds.props.data?.[originalCategoryIndices[ci]], originalCategoryIndices[ci], rawValue, categories[ci], dsSeriesIdx, ds.id ?? "");
|
|
892
|
+
bars.push({
|
|
893
|
+
datasetId: ds.id,
|
|
894
|
+
name: ds.props.name,
|
|
895
|
+
category: categories[ci],
|
|
896
|
+
categoryIndex: ci,
|
|
897
|
+
dataIndex: ci,
|
|
898
|
+
dataKey: keysByDataset[0]?.[ci],
|
|
899
|
+
startAngle: sectorStart + gapDeg / 2,
|
|
900
|
+
endAngle: sectorStart + angleStep - gapDeg / 2,
|
|
901
|
+
innerRadius: baseInnerRadius,
|
|
902
|
+
outerRadius: baseInnerRadius + valueRadius,
|
|
903
|
+
value: rawValue,
|
|
904
|
+
color,
|
|
905
|
+
seriesIdx: dsSeriesIdx,
|
|
906
|
+
...border
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
const gradientColors = /* @__PURE__ */ new Map();
|
|
912
|
+
for (const ds of visibleDatasets) {
|
|
913
|
+
const c = ds.props.color;
|
|
914
|
+
if (c != null && typeof c === "object" && !Array.isArray(c) && typeof c !== "function" && isGradientColor(c)) {
|
|
915
|
+
gradientColors.set(ds.id, c);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return {
|
|
919
|
+
center,
|
|
920
|
+
maxRadius,
|
|
921
|
+
innerRadiusRatio,
|
|
922
|
+
categories,
|
|
923
|
+
angleStep,
|
|
924
|
+
domain,
|
|
925
|
+
grid,
|
|
926
|
+
bars,
|
|
927
|
+
spokeEndpoints,
|
|
928
|
+
chartArea,
|
|
929
|
+
labelPadding,
|
|
930
|
+
labelFontSize: resolvedLabelFontSize,
|
|
931
|
+
fontFamily: resolvedFontFamily,
|
|
932
|
+
gradientColors,
|
|
933
|
+
rawDataMax
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function hitTestPolar(x, y, layout, theme) {
|
|
937
|
+
const relX = x - layout.center.x;
|
|
938
|
+
const relY = y - layout.center.y;
|
|
939
|
+
for (let i = layout.bars.length - 1; i >= 0; i--) {
|
|
940
|
+
const bar = layout.bars[i];
|
|
941
|
+
if (bar.outerRadius <= bar.innerRadius) continue;
|
|
942
|
+
const hit = isPointInSlice(relX, relY, { rotation: bar.startAngle, endAngle: bar.endAngle }, bar.outerRadius, bar.innerRadius);
|
|
943
|
+
if (hit) {
|
|
944
|
+
const gradColor = layout.gradientColors.get(bar.datasetId);
|
|
945
|
+
return {
|
|
946
|
+
datasetId: bar.datasetId,
|
|
947
|
+
index: bar.categoryIndex,
|
|
948
|
+
label: layout.categories[bar.categoryIndex] ?? "",
|
|
949
|
+
value: bar.value,
|
|
950
|
+
color: bar.color ?? getDefaultColor(bar.seriesIdx, theme),
|
|
951
|
+
colorGradient: gradColor,
|
|
952
|
+
swatchColor: resolveSwatchColor({ color: bar.color ?? gradColor }, bar.seriesIdx, void 0, theme)
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return null;
|
|
957
|
+
}
|
|
958
|
+
function resolveBarColor(props, categoryIndex, datasetIndex, dataItem, value, category, seriesId) {
|
|
959
|
+
if (props.color == null) return void 0;
|
|
960
|
+
const color = resolveAccessor(props.color, makeItemContext(dataItem, categoryIndex, { value: value ?? null, category, seriesIndex: datasetIndex, seriesId: seriesId ?? "" }));
|
|
961
|
+
return typeof color === "string" ? color : void 0;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
export { calculateLabelMargins, calculatePolarLayout, calculateRadarLayout, computeRadialComboContext, extractCategories, getCategoryLabelAnchor, hitTestPolar, hitTestRadar, renderRadarSeriesCanvas, renderRadarSeriesSvg, resolveValues };
|