@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,272 @@
|
|
|
1
|
+
import { calculateRadiusAndCenter } from './chunk-NPDZLYIF.mjs';
|
|
2
|
+
import { measureText } from './chunk-XTVE4P3L.mjs';
|
|
3
|
+
import { DEFAULT_RADIAL_LABEL_FONT_SIZE, DEFAULT_GRID_LEVELS, resolveFontSize, resolveFontFamily, DEFAULT_RADAR_FILL_OPACITY, DEFAULT_LINE_WIDTH, DEFAULT_RADAR_HIT_RADIUS } from './chunk-NKUYIWAP.mjs';
|
|
4
|
+
import { isGradientColor, resolveSwatchColor, getPrimaryColor, getDefaultColor, batchResolveAccessor, FIELD_DEFAULTS } from './chunk-O2X6FF45.mjs';
|
|
5
|
+
import { calculateNiceDomain, generateNiceTicks, toRad } from './chunk-RQ3CKQOX.mjs';
|
|
6
|
+
|
|
7
|
+
// src/series/radar/geometry.ts
|
|
8
|
+
function calculateRadarLayout(datasets, chartArea, globalFont, sharedCategories, sharedDomain, perAxisDomains, referenceBoundaryValues, perSpokeDomains, tickCount) {
|
|
9
|
+
const categories = sharedCategories ?? extractCategories(datasets);
|
|
10
|
+
const categoryCount = categories.length;
|
|
11
|
+
const angleStep = categoryCount > 0 ? 360 / categoryCount : 0;
|
|
12
|
+
const allValues = [];
|
|
13
|
+
const stackCumulatives = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const ds of datasets) {
|
|
15
|
+
if (!ds.visible) continue;
|
|
16
|
+
if (ds.props.yAxisId) continue;
|
|
17
|
+
const values = resolveValues(ds.props);
|
|
18
|
+
const stackId = ds.props.stackId;
|
|
19
|
+
if (stackId) {
|
|
20
|
+
if (!stackCumulatives.has(stackId)) {
|
|
21
|
+
stackCumulatives.set(stackId, new Array(categoryCount).fill(0));
|
|
22
|
+
}
|
|
23
|
+
const cumulative = stackCumulatives.get(stackId);
|
|
24
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
25
|
+
cumulative[ci] = (cumulative[ci] ?? 0) + (values[ci] ?? 0);
|
|
26
|
+
allValues.push(cumulative[ci]);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
allValues.push(...values);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (allValues.length === 0) {
|
|
33
|
+
for (const ds of datasets) {
|
|
34
|
+
if (ds.visible) allValues.push(...resolveValues(ds.props));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const rawDataMax = allValues.length ? Math.max(...allValues) : 0;
|
|
38
|
+
let [rawDomainMin, rawDomainMax] = sharedDomain ?? calculateNiceDomain(allValues.length ? allValues : [0, 1], { includeZero: true, nice: true });
|
|
39
|
+
if (referenceBoundaryValues?.length) {
|
|
40
|
+
for (const v of referenceBoundaryValues) {
|
|
41
|
+
if (v < rawDomainMin) rawDomainMin = v;
|
|
42
|
+
if (v > rawDomainMax) rawDomainMax = v;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const rawDomain = [rawDomainMin, rawDomainMax];
|
|
46
|
+
const levelValues = generateNiceTicks(rawDomain[0], rawDomain[1], tickCount ?? DEFAULT_GRID_LEVELS);
|
|
47
|
+
const firstTick = levelValues[0] ?? rawDomain[0];
|
|
48
|
+
const lastTick = levelValues[levelValues.length - 1] ?? rawDomain[1];
|
|
49
|
+
const domain = [Math.min(rawDomain[0], firstTick), Math.max(rawDomain[1], lastTick)];
|
|
50
|
+
const resolvedLabelFontSize = resolveFontSize(DEFAULT_RADIAL_LABEL_FONT_SIZE, globalFont);
|
|
51
|
+
const resolvedFontFamily = resolveFontFamily(void 0, globalFont);
|
|
52
|
+
const labelPadding = measureText("Xg", resolvedLabelFontSize).height;
|
|
53
|
+
const labelMargins = calculateLabelMargins(categories, angleStep, labelPadding, resolvedLabelFontSize);
|
|
54
|
+
const adjustedArea = {
|
|
55
|
+
x: chartArea.x + labelMargins.left,
|
|
56
|
+
y: chartArea.y + labelMargins.top,
|
|
57
|
+
width: Math.max(0, chartArea.width - labelMargins.left - labelMargins.right),
|
|
58
|
+
height: Math.max(0, chartArea.height - labelMargins.top - labelMargins.bottom)
|
|
59
|
+
};
|
|
60
|
+
const { center, radius } = calculateRadiusAndCenter(adjustedArea);
|
|
61
|
+
const levelRadii = levelValues.map((v) => {
|
|
62
|
+
if (domain[1] === domain[0]) return 0;
|
|
63
|
+
return (v - domain[0]) / (domain[1] - domain[0]) * radius;
|
|
64
|
+
});
|
|
65
|
+
const grid = {
|
|
66
|
+
shape: "polygon",
|
|
67
|
+
levels: levelValues.length,
|
|
68
|
+
levelValues,
|
|
69
|
+
levelRadii
|
|
70
|
+
};
|
|
71
|
+
const spokeEndpoints = [];
|
|
72
|
+
for (let i = 0; i < categoryCount; i++) {
|
|
73
|
+
const angleDeg = -90 + i * angleStep;
|
|
74
|
+
const angleRad = toRad(angleDeg);
|
|
75
|
+
spokeEndpoints.push({
|
|
76
|
+
x: center.x + Math.cos(angleRad) * radius,
|
|
77
|
+
y: center.y + Math.sin(angleRad) * radius
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const series = [];
|
|
81
|
+
const stackRunning = /* @__PURE__ */ new Map();
|
|
82
|
+
for (let si = 0; si < datasets.length; si++) {
|
|
83
|
+
const ds = datasets[si];
|
|
84
|
+
const gradientColor = ds.props.color && isGradientColor(ds.props.color) ? ds.props.color : void 0;
|
|
85
|
+
const color = typeof ds.props.color === "string" ? ds.props.color : void 0;
|
|
86
|
+
const fillOpacity = ds.props.fillOpacity ?? DEFAULT_RADAR_FILL_OPACITY;
|
|
87
|
+
const lineWidth = ds.props.lineStrokeWidth ?? DEFAULT_LINE_WIDTH;
|
|
88
|
+
const lineStyle = ds.props.lineStyle;
|
|
89
|
+
const lineDash = ds.props.lineDash;
|
|
90
|
+
const curve = ds.props.curve;
|
|
91
|
+
const stackId = ds.props.stackId;
|
|
92
|
+
const values = resolveValues(ds.props);
|
|
93
|
+
const points = [];
|
|
94
|
+
const basePoints = [];
|
|
95
|
+
const isStacked = !!stackId;
|
|
96
|
+
if (isStacked && !stackRunning.has(stackId)) {
|
|
97
|
+
stackRunning.set(stackId, new Array(categoryCount).fill(0));
|
|
98
|
+
}
|
|
99
|
+
const cumulative = isStacked ? stackRunning.get(stackId) : null;
|
|
100
|
+
const yAxisId = ds.props.yAxisId;
|
|
101
|
+
const axisOverride = yAxisId ? perAxisDomains?.get(yAxisId) : void 0;
|
|
102
|
+
const seriesDomain = axisOverride ?? domain;
|
|
103
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
104
|
+
const rawValue = values[ci] ?? 0;
|
|
105
|
+
const baseValue = isStacked ? cumulative[ci] ?? 0 : 0;
|
|
106
|
+
const topValue = baseValue + rawValue;
|
|
107
|
+
const [sMin, sMax] = perSpokeDomains?.get(ci) ?? seriesDomain;
|
|
108
|
+
const domainSpan = sMax - sMin;
|
|
109
|
+
const angleDeg = -90 + ci * angleStep;
|
|
110
|
+
const angleRad = toRad(angleDeg);
|
|
111
|
+
const topR = domainSpan === 0 ? 0 : Math.max(0, (topValue - sMin) / domainSpan) * radius;
|
|
112
|
+
const baseR = domainSpan === 0 ? 0 : Math.max(0, (baseValue - sMin) / domainSpan) * radius;
|
|
113
|
+
points.push({
|
|
114
|
+
x: center.x + Math.cos(angleRad) * topR,
|
|
115
|
+
y: center.y + Math.sin(angleRad) * topR,
|
|
116
|
+
value: rawValue,
|
|
117
|
+
angle: angleDeg,
|
|
118
|
+
categoryIndex: ci
|
|
119
|
+
});
|
|
120
|
+
if (isStacked) {
|
|
121
|
+
basePoints.push({
|
|
122
|
+
x: center.x + Math.cos(angleRad) * baseR,
|
|
123
|
+
y: center.y + Math.sin(angleRad) * baseR,
|
|
124
|
+
value: baseValue,
|
|
125
|
+
angle: angleDeg,
|
|
126
|
+
categoryIndex: ci
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (isStacked && ds.visible) {
|
|
131
|
+
for (let ci = 0; ci < categoryCount; ci++) {
|
|
132
|
+
cumulative[ci] = (cumulative[ci] ?? 0) + (values[ci] ?? 0);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
series.push({
|
|
136
|
+
id: ds.id,
|
|
137
|
+
name: ds.props.name,
|
|
138
|
+
points,
|
|
139
|
+
basePoints: isStacked ? basePoints : void 0,
|
|
140
|
+
color,
|
|
141
|
+
seriesIdx: si,
|
|
142
|
+
gradientColor,
|
|
143
|
+
fillOpacity,
|
|
144
|
+
lineStrokeWidth: lineWidth,
|
|
145
|
+
lineStyle,
|
|
146
|
+
lineDash,
|
|
147
|
+
curve,
|
|
148
|
+
visible: ds.visible
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
center,
|
|
153
|
+
radius,
|
|
154
|
+
categories,
|
|
155
|
+
angleStep,
|
|
156
|
+
domain,
|
|
157
|
+
grid,
|
|
158
|
+
series,
|
|
159
|
+
spokeEndpoints,
|
|
160
|
+
chartArea,
|
|
161
|
+
labelPadding,
|
|
162
|
+
labelFontSize: resolvedLabelFontSize,
|
|
163
|
+
fontFamily: resolvedFontFamily,
|
|
164
|
+
rawDataMax,
|
|
165
|
+
perSpokeDomains: perSpokeDomains ?? null
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function hitTestRadar(x, y, layout, theme) {
|
|
169
|
+
let closest = null;
|
|
170
|
+
let minDist = DEFAULT_RADAR_HIT_RADIUS;
|
|
171
|
+
for (const sd of layout.series) {
|
|
172
|
+
if (!sd.visible) continue;
|
|
173
|
+
for (let pi = 0; pi < sd.points.length; pi++) {
|
|
174
|
+
const pt = sd.points[pi];
|
|
175
|
+
const dx = x - pt.x;
|
|
176
|
+
const dy = y - pt.y;
|
|
177
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
178
|
+
if (dist < minDist) {
|
|
179
|
+
minDist = dist;
|
|
180
|
+
closest = {
|
|
181
|
+
datasetId: sd.id,
|
|
182
|
+
index: pi,
|
|
183
|
+
label: layout.categories[pi] ?? "",
|
|
184
|
+
value: pt.value,
|
|
185
|
+
color: sd.color ?? (sd.gradientColor ? getPrimaryColor(sd.gradientColor) : getDefaultColor(sd.seriesIdx, theme)),
|
|
186
|
+
colorGradient: sd.gradientColor,
|
|
187
|
+
swatchColor: resolveSwatchColor({ color: sd.color ?? sd.gradientColor }, sd.seriesIdx, void 0, theme)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return closest;
|
|
193
|
+
}
|
|
194
|
+
function extractCategories(datasets) {
|
|
195
|
+
const seen = /* @__PURE__ */ new Set();
|
|
196
|
+
const result = [];
|
|
197
|
+
for (const ds of datasets) {
|
|
198
|
+
const props = ds.props;
|
|
199
|
+
if (!props.data) continue;
|
|
200
|
+
const cats = batchResolveAccessor(props.categoryField ?? FIELD_DEFAULTS.categoryField, props.data);
|
|
201
|
+
for (const cat of cats) {
|
|
202
|
+
const str = String(cat);
|
|
203
|
+
if (!seen.has(str)) {
|
|
204
|
+
seen.add(str);
|
|
205
|
+
result.push(str);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
function resolveValues(props) {
|
|
212
|
+
if (!props.data) return [];
|
|
213
|
+
return batchResolveAccessor(props.valueField ?? FIELD_DEFAULTS.valueField, props.data).map((v) => Number(v) || 0);
|
|
214
|
+
}
|
|
215
|
+
function computeRadialComboContext(radarDatasets, polarDatasets) {
|
|
216
|
+
const allEntries = [...radarDatasets, ...polarDatasets];
|
|
217
|
+
const categories = extractCategories(allEntries);
|
|
218
|
+
const allValues = [];
|
|
219
|
+
for (const ds of allEntries) {
|
|
220
|
+
allValues.push(...resolveValues(ds.props));
|
|
221
|
+
}
|
|
222
|
+
const domain = calculateNiceDomain(allValues, { includeZero: true, nice: true });
|
|
223
|
+
return { categories, domain };
|
|
224
|
+
}
|
|
225
|
+
function getCategoryLabelAnchor(angleDeg) {
|
|
226
|
+
const cosA = Math.cos(toRad(angleDeg));
|
|
227
|
+
if (cosA > 0.15) return "start";
|
|
228
|
+
if (cosA < -0.15) return "end";
|
|
229
|
+
return "middle";
|
|
230
|
+
}
|
|
231
|
+
function calculateLabelMargins(categories, angleStep, labelPadding, fontSize = DEFAULT_RADIAL_LABEL_FONT_SIZE) {
|
|
232
|
+
let top = 0;
|
|
233
|
+
let right = 0;
|
|
234
|
+
let bottom = 0;
|
|
235
|
+
let left = 0;
|
|
236
|
+
for (let i = 0; i < categories.length; i++) {
|
|
237
|
+
const angleDeg = -90 + i * angleStep;
|
|
238
|
+
const angleRad = toRad(angleDeg);
|
|
239
|
+
const cosA = Math.cos(angleRad);
|
|
240
|
+
const sinA = Math.sin(angleRad);
|
|
241
|
+
const { width: textWidth, height: textHeight } = measureText(categories[i], fontSize);
|
|
242
|
+
const halfH = textHeight / 2;
|
|
243
|
+
const dx = cosA * labelPadding;
|
|
244
|
+
const dy = sinA * labelPadding;
|
|
245
|
+
const anchor = getCategoryLabelAnchor(angleDeg);
|
|
246
|
+
let textExtentRight;
|
|
247
|
+
let textExtentLeft;
|
|
248
|
+
if (anchor === "start") {
|
|
249
|
+
textExtentRight = textWidth;
|
|
250
|
+
textExtentLeft = 0;
|
|
251
|
+
} else if (anchor === "end") {
|
|
252
|
+
textExtentRight = 0;
|
|
253
|
+
textExtentLeft = textWidth;
|
|
254
|
+
} else {
|
|
255
|
+
textExtentRight = textWidth / 2;
|
|
256
|
+
textExtentLeft = textWidth / 2;
|
|
257
|
+
}
|
|
258
|
+
right = Math.max(right, dx + textExtentRight);
|
|
259
|
+
left = Math.max(left, -dx + textExtentLeft);
|
|
260
|
+
bottom = Math.max(bottom, dy + halfH);
|
|
261
|
+
top = Math.max(top, -dy + halfH);
|
|
262
|
+
}
|
|
263
|
+
const buffer = 4;
|
|
264
|
+
return {
|
|
265
|
+
top: Math.max(top, 0) + buffer,
|
|
266
|
+
right: Math.max(right, 0) + buffer,
|
|
267
|
+
bottom: Math.max(bottom, 0) + buffer,
|
|
268
|
+
left: Math.max(left, 0) + buffer
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export { calculateLabelMargins, calculateRadarLayout, computeRadialComboContext, extractCategories, getCategoryLabelAnchor, hitTestRadar, resolveValues };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/animations/drilldown.ts
|
|
2
|
+
function computeZoomTransform(origin, target, progress) {
|
|
3
|
+
const x = origin.x + (target.x - origin.x) * progress;
|
|
4
|
+
const y = origin.y + (target.y - origin.y) * progress;
|
|
5
|
+
const w = origin.width + (target.width - origin.width) * progress;
|
|
6
|
+
const h = origin.height + (target.height - origin.height) * progress;
|
|
7
|
+
const sx = w / target.width;
|
|
8
|
+
const sy = h / target.height;
|
|
9
|
+
const tx = x - target.x * sx;
|
|
10
|
+
const ty = y - target.y * sy;
|
|
11
|
+
return { tx, ty, sx, sy };
|
|
12
|
+
}
|
|
13
|
+
function computeDrillOutOrigin(area, ratio = 0.15) {
|
|
14
|
+
return {
|
|
15
|
+
x: area.x + area.width * ratio,
|
|
16
|
+
y: area.y + area.height * ratio,
|
|
17
|
+
width: area.width * (1 - 2 * ratio),
|
|
18
|
+
height: area.height * (1 - 2 * ratio)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { computeDrillOutOrigin, computeZoomTransform };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { DEFAULT_MARKER_SHAPE } from './chunk-AP3UYWYT.mjs';
|
|
2
|
+
import { isBoostActive } from './chunk-DTWTCFRG.mjs';
|
|
3
|
+
import { traceMarkerShapeCanvasAt, MARKER_SHAPE_NAMES, drawMarkerCanvas } from './chunk-PRDVPOZX.mjs';
|
|
4
|
+
import { computeItemHoverState, applyHoverEffects } from './chunk-BZN2QHGP.mjs';
|
|
5
|
+
import { DEFAULT_HOVER_DIM_OPACITY, DEFAULT_SCATTER_FILL_OPACITY, DEFAULT_SCATTER_BORDER_WIDTH, DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER } from './chunk-NKUYIWAP.mjs';
|
|
6
|
+
import { resolveAccessor, makeItemContext, getDefaultColor, getPrimaryColor, isGradientColor, createCanvasGradientFromColor, resolveDash } from './chunk-O2X6FF45.mjs';
|
|
7
|
+
|
|
8
|
+
// src/series/scatter/canvas/index.ts
|
|
9
|
+
function renderScatterCanvas(props, layout, ctx, context) {
|
|
10
|
+
const isSeriesDimmed = props.interaction?.isSeriesDimmed ?? false;
|
|
11
|
+
const effects = props.effects;
|
|
12
|
+
const seriesDimOpacity = (isSeriesDimmed ? effects?.dimOpacity ?? context.theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY : 1) * (props.animationOpacity ?? 1);
|
|
13
|
+
const enterGlobalAlpha = ctx.globalAlpha;
|
|
14
|
+
const boostActive = isBoostActive(props, layout.visiblePoints.length);
|
|
15
|
+
const seriesExtras = { seriesIndex: layout.seriesIdx, seriesId: props.id ?? "" };
|
|
16
|
+
const scatterDataArrCanvas = props.data;
|
|
17
|
+
const resolveMarkerShape = (i, size, value, category) => resolveAccessor(props.markerShape, makeItemContext(scatterDataArrCanvas[i], i, { size, value, category, ...seriesExtras }), { arrayMode: "clip" }) ?? DEFAULT_MARKER_SHAPE;
|
|
18
|
+
const seriesLevelMarkerShape = resolveAccessor(props.markerShape, makeItemContext(scatterDataArrCanvas[0], 0, { size: 0, value: layout.points[0]?.yValue, category: layout.points[0] ? String(layout.points[0].xValue) : void 0, ...seriesExtras }), {
|
|
19
|
+
arrayMode: "clip"
|
|
20
|
+
}) ?? DEFAULT_MARKER_SHAPE;
|
|
21
|
+
const hoveredIndex = boostActive ? null : props.interaction?.hoveredIndex ?? null;
|
|
22
|
+
const anyHovered = hoveredIndex !== null;
|
|
23
|
+
const effectiveSeriesColor = layout.seriesColor ?? getDefaultColor(layout.seriesIdx, context.theme);
|
|
24
|
+
const baseBorderColorShared = props.pointBorderColor != null ? props.pointBorderColor : void 0;
|
|
25
|
+
const borderWidthAccessor = props.pointBorderStrokeWidth;
|
|
26
|
+
const dataArr = props.data;
|
|
27
|
+
const resolveBorderWidth = (i, value, category) => resolveAccessor(borderWidthAccessor, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "clip", fallback: DEFAULT_SCATTER_BORDER_WIDTH }) ?? DEFAULT_SCATTER_BORDER_WIDTH;
|
|
28
|
+
const resolvePointDash = (i, value, category) => resolveDash(props.pointBorderDash, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }));
|
|
29
|
+
const resolvePointDashOffset = (i, value, category) => resolveAccessor(props.pointBorderDashOffset, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
30
|
+
const resolvePointOpacity = (i, value, category) => resolveAccessor(props.opacity, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "clip" });
|
|
31
|
+
const resolvePtHoverBgC = (i, value, category) => resolveAccessor(props.pointHoverBackgroundColor, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "cycle" });
|
|
32
|
+
const resolvePtHoverBorderC = (i, value, category) => resolveAccessor(props.pointHoverBorderColor, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "cycle" });
|
|
33
|
+
const resolvePtHoverBorderWidthC = (i, value, category) => resolveAccessor(props.pointHoverBorderStrokeWidth, makeItemContext(dataArr[i], i, { value, category, ...seriesExtras }), { arrayMode: "clip" });
|
|
34
|
+
const fillOpacity = props.pointFillOpacity ?? DEFAULT_SCATTER_FILL_OPACITY;
|
|
35
|
+
const baseEffectConfig = boostActive || !effects ? void 0 : {
|
|
36
|
+
hoverBrightness: effects.hoverBrightness,
|
|
37
|
+
dimOpacity: effects.dimOpacity,
|
|
38
|
+
hoverBackgroundColor: effects.hoverBackgroundColor,
|
|
39
|
+
hoverBorderColor: effects.hoverBorderColor,
|
|
40
|
+
hoverBorderStrokeWidth: effects.hoverBorderStrokeWidth
|
|
41
|
+
};
|
|
42
|
+
const needsHoverCalc = anyHovered || baseEffectConfig;
|
|
43
|
+
if (boostActive && !props.renderMarker && typeof seriesLevelMarkerShape !== "function") {
|
|
44
|
+
const BOOST_CHUNK_SIZE = 5e3;
|
|
45
|
+
const resolvedShape = seriesLevelMarkerShape;
|
|
46
|
+
const baseAlphaFill = seriesDimOpacity * fillOpacity;
|
|
47
|
+
const batches = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const pt of layout.visiblePoints) {
|
|
49
|
+
const c = getPrimaryColor(pt.color ?? effectiveSeriesColor);
|
|
50
|
+
let bucket = batches.get(c);
|
|
51
|
+
if (!bucket) batches.set(c, bucket = []);
|
|
52
|
+
bucket.push(pt);
|
|
53
|
+
}
|
|
54
|
+
for (const [fillColor, pts] of batches) {
|
|
55
|
+
ctx.globalAlpha = baseAlphaFill;
|
|
56
|
+
ctx.fillStyle = fillColor;
|
|
57
|
+
for (let i = 0; i < pts.length; i += BOOST_CHUNK_SIZE) {
|
|
58
|
+
ctx.beginPath();
|
|
59
|
+
for (let j = i, end = Math.min(i + BOOST_CHUNK_SIZE, pts.length); j < end; j++) {
|
|
60
|
+
const pt = pts[j];
|
|
61
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, pt.px, pt.py, pt.radius, pt.rotation);
|
|
62
|
+
}
|
|
63
|
+
ctx.fill();
|
|
64
|
+
}
|
|
65
|
+
const boostBorderWidth = pts.length > 0 ? resolveBorderWidth(pts[0].dataIndex, pts[0].yValue, String(pts[0].xValue)) : DEFAULT_SCATTER_BORDER_WIDTH;
|
|
66
|
+
if (boostBorderWidth > 0) {
|
|
67
|
+
const strokeColor = baseBorderColorShared ? getPrimaryColor(baseBorderColorShared) : fillColor;
|
|
68
|
+
ctx.globalAlpha = seriesDimOpacity;
|
|
69
|
+
ctx.strokeStyle = strokeColor;
|
|
70
|
+
ctx.lineWidth = boostBorderWidth;
|
|
71
|
+
for (let i = 0; i < pts.length; i += BOOST_CHUNK_SIZE) {
|
|
72
|
+
ctx.beginPath();
|
|
73
|
+
for (let j = i, end = Math.min(i + BOOST_CHUNK_SIZE, pts.length); j < end; j++) {
|
|
74
|
+
const pt = pts[j];
|
|
75
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, pt.px, pt.py, pt.radius, pt.rotation);
|
|
76
|
+
}
|
|
77
|
+
ctx.stroke();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
ctx.globalAlpha = enterGlobalAlpha;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const markerShapeIsScalar = typeof props.markerShape === "string" || props.markerShape === void 0;
|
|
85
|
+
const opacityIsScalar = typeof props.opacity === "number" || props.opacity === void 0;
|
|
86
|
+
if (!props.renderMarker && MARKER_SHAPE_NAMES.has(seriesLevelMarkerShape) && !isGradientColor(effectiveSeriesColor) && markerShapeIsScalar && opacityIsScalar) {
|
|
87
|
+
const CHUNK = 5e3;
|
|
88
|
+
const resolvedShape = seriesLevelMarkerShape;
|
|
89
|
+
const baseStrokeStr = baseBorderColorShared ? getPrimaryColor(baseBorderColorShared) : null;
|
|
90
|
+
const dimMult = anyHovered && baseEffectConfig ? baseEffectConfig.dimOpacity ?? 1 : 1;
|
|
91
|
+
const userScalarOpacity = typeof props.opacity === "number" ? props.opacity : 1;
|
|
92
|
+
const normalFillAlpha = dimMult * seriesDimOpacity * fillOpacity * userScalarOpacity;
|
|
93
|
+
const normalStrokeAlpha = dimMult * seriesDimOpacity * userScalarOpacity;
|
|
94
|
+
const colorBatches = /* @__PURE__ */ new Map();
|
|
95
|
+
let hoveredPt = null;
|
|
96
|
+
for (const pt of layout.visiblePoints) {
|
|
97
|
+
if (hoveredIndex !== null && pt.dataIndex === hoveredIndex) {
|
|
98
|
+
hoveredPt = pt;
|
|
99
|
+
} else {
|
|
100
|
+
const c = getPrimaryColor(pt.color ?? effectiveSeriesColor);
|
|
101
|
+
let bucket = colorBatches.get(c);
|
|
102
|
+
if (!bucket) colorBatches.set(c, bucket = []);
|
|
103
|
+
bucket.push(pt);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const [color, pts] of colorBatches) {
|
|
107
|
+
ctx.globalAlpha = normalFillAlpha;
|
|
108
|
+
ctx.fillStyle = color;
|
|
109
|
+
for (let i = 0; i < pts.length; i += CHUNK) {
|
|
110
|
+
ctx.beginPath();
|
|
111
|
+
for (let j = i, end = Math.min(i + CHUNK, pts.length); j < end; j++) {
|
|
112
|
+
const pt = pts[j];
|
|
113
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, pt.px, pt.py, pt.radius, pt.rotation);
|
|
114
|
+
}
|
|
115
|
+
ctx.fill();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const batchBorderWidth = layout.points.length > 0 ? resolveBorderWidth(layout.points[0].dataIndex, layout.points[0].yValue, String(layout.points[0].xValue)) : DEFAULT_SCATTER_BORDER_WIDTH;
|
|
119
|
+
if (batchBorderWidth > 0) {
|
|
120
|
+
for (const [color, pts] of colorBatches) {
|
|
121
|
+
ctx.globalAlpha = normalStrokeAlpha;
|
|
122
|
+
ctx.strokeStyle = baseStrokeStr ?? color;
|
|
123
|
+
ctx.lineWidth = batchBorderWidth;
|
|
124
|
+
for (let i = 0; i < pts.length; i += CHUNK) {
|
|
125
|
+
ctx.beginPath();
|
|
126
|
+
for (let j = i, end = Math.min(i + CHUNK, pts.length); j < end; j++) {
|
|
127
|
+
const pt = pts[j];
|
|
128
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, pt.px, pt.py, pt.radius, pt.rotation);
|
|
129
|
+
}
|
|
130
|
+
ctx.stroke();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (hoveredPt) {
|
|
135
|
+
const hpt = hoveredPt;
|
|
136
|
+
const hoverState = computeItemHoverState(hpt.dataIndex, hoveredIndex, anyHovered);
|
|
137
|
+
const hptColor = hpt.color ?? effectiveSeriesColor;
|
|
138
|
+
const ptHoverBgB = resolvePtHoverBgC(hpt.dataIndex, hpt.yValue, String(hpt.xValue));
|
|
139
|
+
const ptHoverBorderB = resolvePtHoverBorderC(hpt.dataIndex, hpt.yValue, String(hpt.xValue));
|
|
140
|
+
const ptHoverBorderWidthB = resolvePtHoverBorderWidthC(hpt.dataIndex, hpt.yValue, String(hpt.xValue));
|
|
141
|
+
const hoverEffectConfig = baseEffectConfig ? {
|
|
142
|
+
...baseEffectConfig,
|
|
143
|
+
hoverBackgroundColor: ptHoverBgB ?? baseEffectConfig.hoverBackgroundColor,
|
|
144
|
+
hoverBorderColor: ptHoverBorderB ?? baseEffectConfig.hoverBorderColor,
|
|
145
|
+
hoverBorderStrokeWidth: ptHoverBorderWidthB ?? baseEffectConfig.hoverBorderStrokeWidth
|
|
146
|
+
} : void 0;
|
|
147
|
+
const er = applyHoverEffects(hptColor, baseBorderColorShared ?? getPrimaryColor(hptColor), resolveBorderWidth(hpt.dataIndex, hpt.yValue, String(hpt.xValue)), void 0, 0, hoverState, hoverEffectConfig, context.theme);
|
|
148
|
+
const hSize = effects?.hoverPointRadius ?? hpt.radius * (effects?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER);
|
|
149
|
+
const hFill = isGradientColor(er.color) ? createCanvasGradientFromColor(ctx, er.color, { x: 0, y: 0 }, hSize, {
|
|
150
|
+
x: layout.chartArea.x - hpt.px,
|
|
151
|
+
y: layout.chartArea.y - hpt.py,
|
|
152
|
+
width: layout.chartArea.width,
|
|
153
|
+
height: layout.chartArea.height
|
|
154
|
+
}) : er.color;
|
|
155
|
+
ctx.globalAlpha = er.opacity * seriesDimOpacity;
|
|
156
|
+
ctx.fillStyle = hFill;
|
|
157
|
+
ctx.beginPath();
|
|
158
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, hpt.px, hpt.py, hSize, hpt.rotation);
|
|
159
|
+
ctx.fill();
|
|
160
|
+
if (er.borderStrokeWidth > 0) {
|
|
161
|
+
ctx.globalAlpha = er.opacity * seriesDimOpacity;
|
|
162
|
+
ctx.strokeStyle = getPrimaryColor(er.borderColor);
|
|
163
|
+
ctx.lineWidth = er.borderStrokeWidth;
|
|
164
|
+
ctx.beginPath();
|
|
165
|
+
traceMarkerShapeCanvasAt(ctx, resolvedShape, hpt.px, hpt.py, hSize, hpt.rotation);
|
|
166
|
+
ctx.stroke();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
ctx.globalAlpha = enterGlobalAlpha;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
for (const pt of layout.visiblePoints) {
|
|
173
|
+
const baseColor = pt.color ?? effectiveSeriesColor;
|
|
174
|
+
const baseBorderColor = baseBorderColorShared ?? getPrimaryColor(baseColor);
|
|
175
|
+
const ptBorderWidth = resolveBorderWidth(pt.dataIndex, pt.yValue, String(pt.xValue));
|
|
176
|
+
let fillColor = baseColor;
|
|
177
|
+
let strokeColor = baseBorderColor;
|
|
178
|
+
let strokeWidth = ptBorderWidth;
|
|
179
|
+
let opacity = 1;
|
|
180
|
+
let isHovered = false;
|
|
181
|
+
if (needsHoverCalc) {
|
|
182
|
+
const hoverState = computeItemHoverState(pt.dataIndex, hoveredIndex, anyHovered);
|
|
183
|
+
const ptHoverBgN = resolvePtHoverBgC(pt.dataIndex, pt.yValue, String(pt.xValue));
|
|
184
|
+
const ptHoverBorderN = resolvePtHoverBorderC(pt.dataIndex, pt.yValue, String(pt.xValue));
|
|
185
|
+
const ptHoverBorderWidthN = resolvePtHoverBorderWidthC(pt.dataIndex, pt.yValue, String(pt.xValue));
|
|
186
|
+
const effectConfig = baseEffectConfig ? {
|
|
187
|
+
...baseEffectConfig,
|
|
188
|
+
hoverBackgroundColor: ptHoverBgN ?? baseEffectConfig.hoverBackgroundColor,
|
|
189
|
+
hoverBorderColor: ptHoverBorderN ?? baseEffectConfig.hoverBorderColor,
|
|
190
|
+
hoverBorderStrokeWidth: ptHoverBorderWidthN ?? baseEffectConfig.hoverBorderStrokeWidth
|
|
191
|
+
} : void 0;
|
|
192
|
+
const effectResult = applyHoverEffects(baseColor, baseBorderColor, ptBorderWidth, void 0, 0, hoverState, effectConfig, context.theme);
|
|
193
|
+
fillColor = effectResult.color;
|
|
194
|
+
strokeColor = effectResult.borderColor;
|
|
195
|
+
strokeWidth = effectResult.borderStrokeWidth;
|
|
196
|
+
opacity = effectResult.opacity;
|
|
197
|
+
isHovered = hoverState.isHovered;
|
|
198
|
+
}
|
|
199
|
+
const currentSize = isHovered ? effects?.hoverPointRadius ?? pt.radius * (effects?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER) : pt.radius;
|
|
200
|
+
const pointFillOpacity = isHovered ? 1 : fillOpacity;
|
|
201
|
+
const userOpacity = resolvePointOpacity(pt.dataIndex, pt.yValue, String(pt.xValue));
|
|
202
|
+
if (userOpacity !== void 0) opacity *= userOpacity;
|
|
203
|
+
if (!props.renderMarker) {
|
|
204
|
+
const gradientFill = isGradientColor(fillColor) ? createCanvasGradientFromColor(ctx, fillColor, { x: 0, y: 0 }, currentSize, {
|
|
205
|
+
x: layout.chartArea.x - pt.px,
|
|
206
|
+
y: layout.chartArea.y - pt.py,
|
|
207
|
+
width: layout.chartArea.width,
|
|
208
|
+
height: layout.chartArea.height
|
|
209
|
+
}) : fillColor;
|
|
210
|
+
drawMarkerCanvas(ctx, {
|
|
211
|
+
x: pt.px,
|
|
212
|
+
y: pt.py,
|
|
213
|
+
size: currentSize,
|
|
214
|
+
shape: resolveMarkerShape(pt.dataIndex, currentSize, pt.yValue, String(pt.xValue)),
|
|
215
|
+
fillStyle: gradientFill,
|
|
216
|
+
strokeStyle: getPrimaryColor(strokeColor),
|
|
217
|
+
lineStrokeWidth: strokeWidth,
|
|
218
|
+
opacity: opacity * seriesDimOpacity,
|
|
219
|
+
fillOpacity: pointFillOpacity,
|
|
220
|
+
rotation: pt.rotation,
|
|
221
|
+
lineDash: resolvePointDash(pt.dataIndex, pt.yValue, String(pt.xValue)),
|
|
222
|
+
lineDashOffset: resolvePointDashOffset(pt.dataIndex, pt.yValue, String(pt.xValue)),
|
|
223
|
+
lineJoin: props.pointBorderJoinStyle
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
ctx.globalAlpha = enterGlobalAlpha;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { renderScatterCanvas };
|