@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,187 @@
|
|
|
1
|
+
import { DEFAULT_MARKER_SHAPE } from './chunk-AP3UYWYT.mjs';
|
|
2
|
+
import { isBoostActive } from './chunk-DTWTCFRG.mjs';
|
|
3
|
+
import { MARKER_SHAPE_NAMES, buildMarkerShapePath, renderMarkerShapeSvg } from './chunk-PRDVPOZX.mjs';
|
|
4
|
+
import { computeItemHoverState, applyHoverEffects, resolveSvgHoverFill } from './chunk-BZN2QHGP.mjs';
|
|
5
|
+
import { formatPointDescription } from './chunk-OGJ6IIBW.mjs';
|
|
6
|
+
import { DEFAULT_HOVER_DIM_OPACITY, SCATTER_SVG_CEILING_WARNING, DEFAULT_SCATTER_FILL_OPACITY, DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER, DEFAULT_SCATTER_BORDER_WIDTH } from './chunk-NKUYIWAP.mjs';
|
|
7
|
+
import { getPrimaryColor, makeItemContext, isGradientColor, createSvgGradientFromColor, resolveAccessor, resolveDash } from './chunk-O2X6FF45.mjs';
|
|
8
|
+
import { createSvgGroup, createSvgDefs, svgClass, appendChild, createSvgPath, setAttr } from './chunk-SSLTFJ3U.mjs';
|
|
9
|
+
import { warnChartDevOnce } from './chunk-RQ3CKQOX.mjs';
|
|
10
|
+
|
|
11
|
+
// src/series/scatter/svg/index.ts
|
|
12
|
+
function renderScatterSvg(props, layout, context) {
|
|
13
|
+
const isSeriesDimmed = props.interaction?.isSeriesDimmed ?? false;
|
|
14
|
+
const effects = props.effects;
|
|
15
|
+
const seriesDimOpacity = isSeriesDimmed ? effects?.dimOpacity ?? context.theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY : 1;
|
|
16
|
+
const animationOpacity = props.animationOpacity ?? 1;
|
|
17
|
+
const groupOpacity = seriesDimOpacity * animationOpacity;
|
|
18
|
+
const boostActive = isBoostActive(props, layout.visiblePoints.length);
|
|
19
|
+
const seriesExtras = { seriesIndex: layout.seriesIdx, seriesId: props.id ?? "" };
|
|
20
|
+
if (layout.visiblePoints.length >= SCATTER_SVG_CEILING_WARNING) {
|
|
21
|
+
warnChartDevOnce(
|
|
22
|
+
"scatter-svg-ceiling",
|
|
23
|
+
`SVG scatter is rendering ${layout.visiblePoints.length.toLocaleString()} points. Above ~10k points, prefer <ChartCanvas> or wrap the dataset in <ChartDecimation> for materially better performance.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const group = createSvgGroup(void 0, { class: "scatter-series", ...groupOpacity < 1 && { opacity: String(groupOpacity) } });
|
|
27
|
+
const scatterDataArr = props.data;
|
|
28
|
+
const resolveMarkerShape = (i, size, value, category) => resolveAccessor(props.markerShape, makeItemContext(scatterDataArr[i], i, { size, value, category, ...seriesExtras }), { arrayMode: "clip" }) ?? DEFAULT_MARKER_SHAPE;
|
|
29
|
+
const resolvePointOpacity = (ctx) => resolveAccessor(props.opacity, ctx, { arrayMode: "clip" });
|
|
30
|
+
const seriesIdx = layout.seriesIdx;
|
|
31
|
+
const colorClassN = `p-chart-color-${seriesIdx % 10}`;
|
|
32
|
+
const hoveredIndex = boostActive ? null : props.interaction?.hoveredIndex ?? null;
|
|
33
|
+
const anyHovered = hoveredIndex !== null;
|
|
34
|
+
const a11y = context.accessibility;
|
|
35
|
+
const a11yEnabled = !!(a11y?.enabled && layout.visiblePoints.length <= (a11y.pointDescriptionThreshold ?? 200));
|
|
36
|
+
if (props.renderMarker) return group;
|
|
37
|
+
const defs = createSvgDefs();
|
|
38
|
+
const markerGroup = createSvgGroup(void 0, { class: "scatter-markers" });
|
|
39
|
+
let hasDefs = false;
|
|
40
|
+
const baseBorderColorShared = props.pointBorderColor != null ? props.pointBorderColor : void 0;
|
|
41
|
+
const borderWidthAccessor = props.pointBorderStrokeWidth;
|
|
42
|
+
const dataArr = props.data;
|
|
43
|
+
const resolveBorderWidth = (ctx) => resolveAccessor(borderWidthAccessor, ctx, { arrayMode: "clip", fallback: DEFAULT_SCATTER_BORDER_WIDTH }) ?? DEFAULT_SCATTER_BORDER_WIDTH;
|
|
44
|
+
const resolvePointDash = (ctx) => resolveDash(props.pointBorderDash, ctx);
|
|
45
|
+
const resolvePointDashOffset = (ctx) => resolveAccessor(props.pointBorderDashOffset, ctx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
46
|
+
const resolvePtHoverBg = (ctx) => resolveAccessor(props.pointHoverBackgroundColor, ctx, { arrayMode: "cycle" });
|
|
47
|
+
const resolvePtHoverBorder = (ctx) => resolveAccessor(props.pointHoverBorderColor, ctx, { arrayMode: "cycle" });
|
|
48
|
+
const resolvePtHoverBorderWidth = (ctx) => resolveAccessor(props.pointHoverBorderStrokeWidth, ctx, { arrayMode: "clip" });
|
|
49
|
+
const fillOpacity = props.pointFillOpacity ?? DEFAULT_SCATTER_FILL_OPACITY;
|
|
50
|
+
const baseEffectConfig = boostActive || !effects ? void 0 : {
|
|
51
|
+
hoverBrightness: effects.hoverBrightness,
|
|
52
|
+
dimOpacity: effects.dimOpacity,
|
|
53
|
+
hoverBackgroundColor: effects.hoverBackgroundColor,
|
|
54
|
+
hoverBorderColor: effects.hoverBorderColor,
|
|
55
|
+
hoverBorderStrokeWidth: effects.hoverBorderStrokeWidth
|
|
56
|
+
};
|
|
57
|
+
const needsHoverCalc = anyHovered || baseEffectConfig;
|
|
58
|
+
if (boostActive && typeof props.markerShape !== "function" && layout.visiblePoints.length > 0) {
|
|
59
|
+
const first = layout.visiblePoints[0];
|
|
60
|
+
const seriesShape = resolveMarkerShape(first.dataIndex, first.radius, first.yValue, String(first.xValue));
|
|
61
|
+
if (MARKER_SHAPE_NAMES.has(seriesShape)) {
|
|
62
|
+
const themedSeriesColor = context.theme.series[seriesIdx % context.theme.series.length];
|
|
63
|
+
const CLASS_KEY = "__class__";
|
|
64
|
+
const batches = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const pt of layout.visiblePoints) {
|
|
66
|
+
const key = pt.color !== void 0 ? getPrimaryColor(pt.color) : CLASS_KEY;
|
|
67
|
+
let bucket = batches.get(key);
|
|
68
|
+
if (!bucket) batches.set(key, bucket = []);
|
|
69
|
+
bucket.push(pt);
|
|
70
|
+
}
|
|
71
|
+
const boostBorderWidth = resolveBorderWidth(makeItemContext(dataArr[first.dataIndex], first.dataIndex, { value: first.yValue, category: String(first.xValue), ...seriesExtras }));
|
|
72
|
+
const boostBorderColor = baseBorderColorShared ? getPrimaryColor(baseBorderColorShared) : void 0;
|
|
73
|
+
for (const [key, pts] of batches) {
|
|
74
|
+
let d = "";
|
|
75
|
+
for (const pt of pts) d += buildMarkerShapePath(seriesShape, pt.px, pt.py, pt.radius);
|
|
76
|
+
const classDriven = key === CLASS_KEY;
|
|
77
|
+
const pathAttrs = {
|
|
78
|
+
"fill-opacity": fillOpacity,
|
|
79
|
+
"stroke-width": boostBorderWidth,
|
|
80
|
+
fill: classDriven ? themedSeriesColor : key,
|
|
81
|
+
stroke: boostBorderWidth <= 0 ? "none" : classDriven ? themedSeriesColor : boostBorderColor ?? key,
|
|
82
|
+
class: svgClass("p-chart-marker", `p-chart-series-${seriesIdx}`, classDriven && colorClassN)
|
|
83
|
+
};
|
|
84
|
+
appendChild(markerGroup, createSvgPath(d, pathAttrs));
|
|
85
|
+
}
|
|
86
|
+
appendChild(group, markerGroup);
|
|
87
|
+
return group;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const pt of layout.visiblePoints) {
|
|
91
|
+
const itemCtx = makeItemContext(dataArr[pt.dataIndex], pt.dataIndex, { value: pt.yValue, category: String(pt.xValue), ...seriesExtras });
|
|
92
|
+
const userFill = pt.color;
|
|
93
|
+
const userBorder = baseBorderColorShared ?? (userFill !== void 0 ? getPrimaryColor(userFill) : void 0);
|
|
94
|
+
const ptBorderWidth = resolveBorderWidth(itemCtx);
|
|
95
|
+
let fillColor = userFill;
|
|
96
|
+
let strokeColor = userBorder;
|
|
97
|
+
let strokeWidth = ptBorderWidth;
|
|
98
|
+
let opacity = 1;
|
|
99
|
+
let isHovered = false;
|
|
100
|
+
let isInactive = false;
|
|
101
|
+
let hoverBgOverride;
|
|
102
|
+
if (needsHoverCalc) {
|
|
103
|
+
const hoverState = computeItemHoverState(pt.dataIndex, hoveredIndex, anyHovered);
|
|
104
|
+
isHovered = hoverState.isHovered;
|
|
105
|
+
isInactive = hoverState.hasAnyHover && !isHovered;
|
|
106
|
+
const ptHoverBg = resolvePtHoverBg(itemCtx);
|
|
107
|
+
const ptHoverBorder = resolvePtHoverBorder(itemCtx);
|
|
108
|
+
const ptHoverBorderWidth = resolvePtHoverBorderWidth(itemCtx);
|
|
109
|
+
const effectConfig = baseEffectConfig ? {
|
|
110
|
+
...baseEffectConfig,
|
|
111
|
+
hoverBackgroundColor: ptHoverBg ?? baseEffectConfig.hoverBackgroundColor,
|
|
112
|
+
hoverBorderColor: ptHoverBorder ?? baseEffectConfig.hoverBorderColor,
|
|
113
|
+
hoverBorderStrokeWidth: ptHoverBorderWidth ?? baseEffectConfig.hoverBorderStrokeWidth
|
|
114
|
+
} : void 0;
|
|
115
|
+
hoverBgOverride = effectConfig?.hoverBackgroundColor;
|
|
116
|
+
if (userFill !== void 0) {
|
|
117
|
+
const effectResult = applyHoverEffects(userFill, userBorder ?? userFill, ptBorderWidth, void 0, 0, hoverState, effectConfig, context.theme);
|
|
118
|
+
fillColor = effectResult.color;
|
|
119
|
+
strokeColor = effectResult.borderColor;
|
|
120
|
+
strokeWidth = effectResult.borderStrokeWidth;
|
|
121
|
+
opacity = effectResult.opacity;
|
|
122
|
+
} else if (isHovered && effectConfig?.hoverBorderStrokeWidth !== void 0) {
|
|
123
|
+
strokeWidth = effectConfig.hoverBorderStrokeWidth;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const currentSize = isHovered ? effects?.hoverPointRadius ?? pt.radius * (effects?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER) : pt.radius;
|
|
127
|
+
const userOpacity = resolvePointOpacity(itemCtx);
|
|
128
|
+
if (userOpacity !== void 0) opacity *= userOpacity;
|
|
129
|
+
const pointFillOpacity = isHovered ? 1 : fillOpacity;
|
|
130
|
+
let fillAttr;
|
|
131
|
+
if (fillColor !== void 0) {
|
|
132
|
+
if (isGradientColor(fillColor)) {
|
|
133
|
+
const gradientId = `${context.chartId}-scatter-${layout.datasetIndex}-grad-${pt.dataIndex}`;
|
|
134
|
+
appendChild(defs, createSvgGradientFromColor(fillColor, gradientId, { x: pt.px, y: pt.py }, currentSize, layout.chartArea));
|
|
135
|
+
fillAttr = `url(#${gradientId})`;
|
|
136
|
+
hasDefs = true;
|
|
137
|
+
} else {
|
|
138
|
+
fillAttr = fillColor;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const { fill: ovFillAttr, overridden: fillOverridden } = resolveSvgHoverFill(fillAttr, isHovered, hoverBgOverride);
|
|
142
|
+
fillAttr = ovFillAttr;
|
|
143
|
+
const markerCls = svgClass("p-chart-marker", `p-chart-series-${seriesIdx}`, fillAttr === void 0 && colorClassN, isHovered && !fillOverridden && "p-chart-point-hover", isInactive && "p-chart-point-inactive");
|
|
144
|
+
const themedSeriesColor = context.theme.series[seriesIdx % context.theme.series.length];
|
|
145
|
+
const strokeStr = strokeColor === void 0 ? void 0 : strokeColor;
|
|
146
|
+
const useInlineStroke = fillAttr === void 0 && baseBorderColorShared !== void 0 && strokeStr !== void 0;
|
|
147
|
+
const markerAttrs = {
|
|
148
|
+
"fill-opacity": pointFillOpacity,
|
|
149
|
+
"stroke-width": strokeWidth,
|
|
150
|
+
"stroke-linejoin": props.pointBorderJoinStyle ?? "miter",
|
|
151
|
+
fill: fillAttr ?? themedSeriesColor,
|
|
152
|
+
stroke: strokeStr ?? themedSeriesColor,
|
|
153
|
+
...useInlineStroke && { style: `stroke: ${strokeStr}` },
|
|
154
|
+
...opacity < 1 && { opacity },
|
|
155
|
+
class: markerCls
|
|
156
|
+
};
|
|
157
|
+
const ptDash = resolvePointDash(itemCtx);
|
|
158
|
+
const ptDashOffset = resolvePointDashOffset(itemCtx);
|
|
159
|
+
if (ptDash && ptDash.length > 0) markerAttrs["stroke-dasharray"] = ptDash.join(" ");
|
|
160
|
+
if (ptDashOffset) markerAttrs["stroke-dashoffset"] = ptDashOffset;
|
|
161
|
+
let markerEl;
|
|
162
|
+
const ptShape = resolveMarkerShape(pt.dataIndex, currentSize, pt.yValue, String(pt.xValue));
|
|
163
|
+
if (MARKER_SHAPE_NAMES.has(ptShape)) {
|
|
164
|
+
if (pt.rotation !== 0) {
|
|
165
|
+
markerAttrs.transform = `rotate(${pt.rotation}, ${pt.px}, ${pt.py})`;
|
|
166
|
+
}
|
|
167
|
+
markerEl = renderMarkerShapeSvg(ptShape, pt.px, pt.py, currentSize, markerAttrs);
|
|
168
|
+
} else {
|
|
169
|
+
const transformParts = [`translate(${pt.px}, ${pt.py})`];
|
|
170
|
+
if (pt.rotation !== 0) transformParts.push(`rotate(${pt.rotation})`);
|
|
171
|
+
markerAttrs.transform = transformParts.join(" ");
|
|
172
|
+
markerEl = createSvgPath(ptShape, markerAttrs);
|
|
173
|
+
}
|
|
174
|
+
if (a11yEnabled) {
|
|
175
|
+
const desc = formatPointDescription({ category: `(${pt.xValue}, ${pt.yValue})`, value: pt.yValue, seriesName: props.name ?? "Series", index: pt.dataIndex }, a11y.pointDescriptionFormatter);
|
|
176
|
+
setAttr(markerEl, "role", "img");
|
|
177
|
+
setAttr(markerEl, "aria-label", desc);
|
|
178
|
+
}
|
|
179
|
+
setAttr(markerEl, "data-index", String(pt.dataIndex));
|
|
180
|
+
appendChild(markerGroup, markerEl);
|
|
181
|
+
}
|
|
182
|
+
if (hasDefs) appendChild(group, defs);
|
|
183
|
+
appendChild(group, markerGroup);
|
|
184
|
+
return group;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { renderScatterSvg };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/utils/image.cache.ts
|
|
2
|
+
var MAX_CACHE = 100;
|
|
3
|
+
var imageCache = /* @__PURE__ */ new Map();
|
|
4
|
+
var corsFailedUrls = /* @__PURE__ */ new Set();
|
|
5
|
+
function evictIfFull() {
|
|
6
|
+
if (imageCache.size >= MAX_CACHE) {
|
|
7
|
+
const first = imageCache.keys().next().value;
|
|
8
|
+
if (first !== void 0) imageCache.delete(first);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function rememberCorsFailure(url) {
|
|
12
|
+
if (corsFailedUrls.size >= MAX_CACHE) {
|
|
13
|
+
const first = corsFailedUrls.values().next().value;
|
|
14
|
+
if (first !== void 0) corsFailedUrls.delete(first);
|
|
15
|
+
}
|
|
16
|
+
corsFailedUrls.add(url);
|
|
17
|
+
}
|
|
18
|
+
function createDrawImage(ctx, onImageLoad) {
|
|
19
|
+
return (url, x, y, w, h) => {
|
|
20
|
+
let img = imageCache.get(url);
|
|
21
|
+
if (img && img.complete && img.naturalWidth > 0) {
|
|
22
|
+
const nw = img.naturalWidth;
|
|
23
|
+
const nh = img.naturalHeight;
|
|
24
|
+
const scale = Math.min(w / nw, h / nh);
|
|
25
|
+
const dw = nw * scale;
|
|
26
|
+
const dh = nh * scale;
|
|
27
|
+
ctx.drawImage(img, x + (w - dw) / 2, y + (h - dh) / 2, dw, dh);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!img) {
|
|
31
|
+
img = new Image();
|
|
32
|
+
img.onload = onImageLoad;
|
|
33
|
+
if (corsFailedUrls.has(url)) {
|
|
34
|
+
img.src = url;
|
|
35
|
+
} else {
|
|
36
|
+
img.crossOrigin = "anonymous";
|
|
37
|
+
img.onerror = () => {
|
|
38
|
+
rememberCorsFailure(url);
|
|
39
|
+
imageCache.delete(url);
|
|
40
|
+
const retryImg = new Image();
|
|
41
|
+
retryImg.onload = onImageLoad;
|
|
42
|
+
retryImg.src = url;
|
|
43
|
+
evictIfFull();
|
|
44
|
+
imageCache.set(url, retryImg);
|
|
45
|
+
};
|
|
46
|
+
img.src = url;
|
|
47
|
+
}
|
|
48
|
+
evictIfFull();
|
|
49
|
+
imageCache.set(url, img);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { createDrawImage };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { renderBarCanvas } from './chunk-X7T34OLW.mjs';
|
|
2
|
+
import { renderBarSvg } from './chunk-SALTGZFR.mjs';
|
|
3
|
+
import { hitTestBar, calculateBarLayout } from './chunk-AUF4CHDP.mjs';
|
|
4
|
+
import { DEFAULT_HOVER_OFFSET, DEFAULT_HOVER_DIM_OPACITY, DEFAULT_HOVER_BRIGHTNESS } from './chunk-NKUYIWAP.mjs';
|
|
5
|
+
import { batchResolveAccessor, batchResolveRequired } from './chunk-O2X6FF45.mjs';
|
|
6
|
+
|
|
7
|
+
// src/series/bar/geom/visual-layout.ts
|
|
8
|
+
function computeBarVisualLayout(input) {
|
|
9
|
+
const { intermediate, sharedCategoryScale, valueScales, valueDomains, cartesianArea, orientation, axisLayouts, hover, hoverConfig, theme } = input;
|
|
10
|
+
const { barDatasets, visibleBarDatasets, mode, valuesPerDataset, stackBasesMap, groupLayout, fullGroupLayout, isVariwide, barGap, datasetAxisMap, firstValueAxisId } = intermediate;
|
|
11
|
+
const categories = sharedCategoryScale.domain();
|
|
12
|
+
const sharedValueScale = valueScales.get(firstValueAxisId) ?? valueScales.values().next().value;
|
|
13
|
+
const layouts = /* @__PURE__ */ new Map();
|
|
14
|
+
const renderPropsMap = /* @__PURE__ */ new Map();
|
|
15
|
+
const allTargets = [];
|
|
16
|
+
const base = barDatasets[0]?.props?.base ?? 0;
|
|
17
|
+
const syntheticDataMap = /* @__PURE__ */ new Map();
|
|
18
|
+
if (mode.isPercentStacked || mode.isWaterfall) {
|
|
19
|
+
for (let dsIdx = 0; dsIdx < barDatasets.length; dsIdx++) {
|
|
20
|
+
const ds = barDatasets[dsIdx];
|
|
21
|
+
syntheticDataMap.set(
|
|
22
|
+
ds.id,
|
|
23
|
+
ds.props.data.map((item, i) => ({
|
|
24
|
+
...item,
|
|
25
|
+
[ds.props.valueField]: valuesPerDataset[dsIdx][i]
|
|
26
|
+
}))
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const valueAxisPrefix = orientation === "vertical" ? "y" : "x";
|
|
31
|
+
let visibleSeriesIdx = 0;
|
|
32
|
+
const visibleGroupIdxMap = /* @__PURE__ */ new Map();
|
|
33
|
+
const allGroupIdxMap = /* @__PURE__ */ new Map();
|
|
34
|
+
if (mode.isGrouped && mode.isStacked) {
|
|
35
|
+
let vIdx = 0;
|
|
36
|
+
let aIdx = 0;
|
|
37
|
+
for (const ds of barDatasets) {
|
|
38
|
+
const sid = ds.stackId;
|
|
39
|
+
if (!allGroupIdxMap.has(sid)) allGroupIdxMap.set(sid, aIdx++);
|
|
40
|
+
}
|
|
41
|
+
for (const ds of visibleBarDatasets) {
|
|
42
|
+
const sid = ds.stackId;
|
|
43
|
+
if (!visibleGroupIdxMap.has(sid)) visibleGroupIdxMap.set(sid, vIdx++);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (let dsIdx = 0; dsIdx < barDatasets.length; dsIdx++) {
|
|
47
|
+
const ds = barDatasets[dsIdx];
|
|
48
|
+
const barProps = ds.props;
|
|
49
|
+
const renderProps = {
|
|
50
|
+
...barProps,
|
|
51
|
+
...syntheticDataMap.has(ds.id) ? { data: syntheticDataMap.get(ds.id) } : {},
|
|
52
|
+
categoryField: barProps.categoryField,
|
|
53
|
+
valueField: barProps.valueField,
|
|
54
|
+
interaction: {
|
|
55
|
+
hoveredIndex: hover.datasetId === ds.id ? hover.index : null
|
|
56
|
+
},
|
|
57
|
+
effects: hoverConfig ? {
|
|
58
|
+
...hoverConfig,
|
|
59
|
+
hoverBrightness: hoverConfig.hoverBrightness ?? theme.hoverBrightness ?? DEFAULT_HOVER_BRIGHTNESS,
|
|
60
|
+
dimOpacity: hoverConfig.dimOpacity ?? theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY,
|
|
61
|
+
hoverOffset: hoverConfig.hoverOffset ?? DEFAULT_HOVER_OFFSET
|
|
62
|
+
} : void 0
|
|
63
|
+
};
|
|
64
|
+
const targetAxisId = datasetAxisMap.get(ds.id) ?? firstValueAxisId;
|
|
65
|
+
const targetValueScale = valueScales.get(targetAxisId) ?? sharedValueScale;
|
|
66
|
+
const axisKey = `${valueAxisPrefix}:${targetAxisId}`;
|
|
67
|
+
const axisInfo = axisLayouts.get(axisKey);
|
|
68
|
+
const targetAxisType = axisInfo?.props?.type;
|
|
69
|
+
const effectiveBase = targetAxisType === "logarithmic" ? valueDomains.get(targetAxisId)?.[0] ?? base : base;
|
|
70
|
+
if (targetAxisType === "logarithmic") {
|
|
71
|
+
renderProps.base = effectiveBase;
|
|
72
|
+
}
|
|
73
|
+
const multiConfig = {
|
|
74
|
+
categoryScale: sharedCategoryScale,
|
|
75
|
+
valueScale: targetValueScale,
|
|
76
|
+
stackBases: stackBasesMap?.get(ds.id),
|
|
77
|
+
groupOffset: mode.isGrouped && ds.visible ? groupLayout.getOffset(mode.isStacked ? visibleGroupIdxMap.get(ds.stackId) : visibleSeriesIdx) : void 0,
|
|
78
|
+
groupBarWidth: mode.isGrouped && ds.visible ? groupLayout.barWidth : void 0
|
|
79
|
+
};
|
|
80
|
+
if (mode.isOverlap && ds.visible) {
|
|
81
|
+
const totalVisible = visibleBarDatasets.length;
|
|
82
|
+
const bandwidth = sharedCategoryScale.bandwidth();
|
|
83
|
+
if (totalVisible === 1) {
|
|
84
|
+
multiConfig.groupBarWidth = bandwidth;
|
|
85
|
+
multiConfig.groupOffset = 0;
|
|
86
|
+
} else {
|
|
87
|
+
const minRatio = Math.max(0.3, 1 - (totalVisible - 1) * 0.3);
|
|
88
|
+
const widthRatio = 1 - visibleSeriesIdx / (totalVisible - 1) * (1 - minRatio);
|
|
89
|
+
const barWidth = bandwidth * widthRatio;
|
|
90
|
+
multiConfig.groupBarWidth = barWidth;
|
|
91
|
+
multiConfig.groupOffset = (bandwidth - barWidth) / 2;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isVariwide && sharedCategoryScale.bandwidthAt) {
|
|
95
|
+
const catPositions = [];
|
|
96
|
+
for (let i = 0; i < categories.length; i++) {
|
|
97
|
+
const catLeft = sharedCategoryScale(categories[i]);
|
|
98
|
+
const catBw = sharedCategoryScale.bandwidthAt(i);
|
|
99
|
+
if (mode.isGrouped && ds.visible) {
|
|
100
|
+
const groupCount = mode.isStacked ? visibleGroupIdxMap.size : visibleBarDatasets.length;
|
|
101
|
+
const groupSlot = mode.isStacked ? visibleGroupIdxMap.get(ds.stackId) : visibleSeriesIdx;
|
|
102
|
+
const barGapRatio = barGap ?? 0.02;
|
|
103
|
+
const gapPx = catBw * barGapRatio;
|
|
104
|
+
const totalGapPx = gapPx * (groupCount - 1);
|
|
105
|
+
const perSeriesWidth = (catBw - totalGapPx) / groupCount;
|
|
106
|
+
const seriesOffset = groupSlot * (perSeriesWidth + gapPx);
|
|
107
|
+
catPositions.push({ pos: catLeft + seriesOffset, size: perSeriesWidth });
|
|
108
|
+
} else if (mode.isOverlap && ds.visible) {
|
|
109
|
+
const totalVisible = visibleBarDatasets.length;
|
|
110
|
+
if (totalVisible === 1) {
|
|
111
|
+
catPositions.push({ pos: catLeft, size: catBw });
|
|
112
|
+
} else {
|
|
113
|
+
const minRatio = Math.max(0.3, 1 - (totalVisible - 1) * 0.3);
|
|
114
|
+
const widthRatio = 1 - visibleSeriesIdx / (totalVisible - 1) * (1 - minRatio);
|
|
115
|
+
const overlapWidth = catBw * widthRatio;
|
|
116
|
+
catPositions.push({ pos: catLeft + (catBw - overlapWidth) / 2, size: overlapWidth });
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
catPositions.push({ pos: catLeft, size: catBw });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
multiConfig.categoryPositions = catPositions;
|
|
123
|
+
}
|
|
124
|
+
const baseLayout = calculateBarLayout(renderProps, cartesianArea, multiConfig);
|
|
125
|
+
const layout = { ...baseLayout, datasetIndex: dsIdx };
|
|
126
|
+
layouts.set(ds.id, layout);
|
|
127
|
+
renderPropsMap.set(ds.id, renderProps);
|
|
128
|
+
if (ds.visible) {
|
|
129
|
+
const dsStackBases = stackBasesMap?.get(ds.id);
|
|
130
|
+
for (const bar of layout.visibleBars) {
|
|
131
|
+
const barBaseValue = dsStackBases ? dsStackBases[bar.dataIndex] ?? effectiveBase : layout.openValues ? layout.openValues[bar.dataIndex] ?? effectiveBase : effectiveBase;
|
|
132
|
+
const barBasePosition = dsStackBases || layout.openValues ? targetValueScale(barBaseValue) : targetValueScale(effectiveBase);
|
|
133
|
+
allTargets.push({
|
|
134
|
+
dataIndex: bar.dataIndex,
|
|
135
|
+
datasetId: ds.id,
|
|
136
|
+
x: bar.x,
|
|
137
|
+
y: bar.y,
|
|
138
|
+
width: bar.width,
|
|
139
|
+
height: bar.height,
|
|
140
|
+
value: bar.value,
|
|
141
|
+
category: bar.category,
|
|
142
|
+
isNegative: bar.isNegative,
|
|
143
|
+
baseX: orientation === "horizontal" ? barBasePosition : bar.x,
|
|
144
|
+
baseY: orientation === "vertical" ? barBasePosition : bar.y,
|
|
145
|
+
orientation
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
visibleSeriesIdx++;
|
|
149
|
+
} else {
|
|
150
|
+
const stackBases = stackBasesMap?.get(ds.id);
|
|
151
|
+
const collapseGroupSlot = mode.isStacked && allGroupIdxMap.size > 0 ? allGroupIdxMap.get(ds.stackId) : dsIdx;
|
|
152
|
+
const groupedCollapseOffset = fullGroupLayout ? fullGroupLayout.getOffset(collapseGroupSlot) : 0;
|
|
153
|
+
const groupedCollapseDefaultWidth = fullGroupLayout ? fullGroupLayout.barWidth : sharedCategoryScale.bandwidth();
|
|
154
|
+
const groupStillVisible = mode.isGrouped && mode.isStacked && visibleGroupIdxMap.has(ds.stackId);
|
|
155
|
+
const visibleGroupSlot = groupStillVisible ? visibleGroupIdxMap.get(ds.stackId) : void 0;
|
|
156
|
+
const stackedCollapseOffset = groupStillVisible && groupLayout ? groupLayout.getOffset(visibleGroupSlot) : 0;
|
|
157
|
+
const stackedCollapseBarWidth = groupStillVisible && groupLayout ? groupLayout.barWidth : sharedCategoryScale.bandwidth();
|
|
158
|
+
for (let i = 0; i < categories.length; i++) {
|
|
159
|
+
const catPos = sharedCategoryScale(categories[i]);
|
|
160
|
+
const bw = sharedCategoryScale.bandwidthAt?.(i) ?? sharedCategoryScale.bandwidth();
|
|
161
|
+
if (orientation === "vertical") {
|
|
162
|
+
const collapseY = stackBases ? targetValueScale(stackBases[i]) : targetValueScale(effectiveBase);
|
|
163
|
+
const collapseX = !mode.isGrouped ? catPos : groupStillVisible ? catPos + stackedCollapseOffset : catPos + groupedCollapseOffset + groupedCollapseDefaultWidth / 2;
|
|
164
|
+
const collapseW = !mode.isGrouped ? bw : groupStillVisible ? stackedCollapseBarWidth : 0;
|
|
165
|
+
allTargets.push({
|
|
166
|
+
dataIndex: i,
|
|
167
|
+
datasetId: ds.id,
|
|
168
|
+
x: collapseX,
|
|
169
|
+
y: collapseY,
|
|
170
|
+
width: collapseW,
|
|
171
|
+
height: 0,
|
|
172
|
+
value: 0,
|
|
173
|
+
category: categories[i],
|
|
174
|
+
isNegative: false,
|
|
175
|
+
baseX: collapseX,
|
|
176
|
+
baseY: collapseY,
|
|
177
|
+
orientation
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
const collapseX = stackBases ? targetValueScale(stackBases[i]) : targetValueScale(effectiveBase);
|
|
181
|
+
const collapseYPos = !mode.isGrouped ? catPos : groupStillVisible ? catPos + stackedCollapseOffset : catPos + groupedCollapseOffset + groupedCollapseDefaultWidth / 2;
|
|
182
|
+
const collapseH = !mode.isGrouped ? bw : groupStillVisible ? stackedCollapseBarWidth : 0;
|
|
183
|
+
allTargets.push({
|
|
184
|
+
dataIndex: i,
|
|
185
|
+
datasetId: ds.id,
|
|
186
|
+
x: collapseX,
|
|
187
|
+
y: collapseYPos,
|
|
188
|
+
width: 0,
|
|
189
|
+
height: collapseH,
|
|
190
|
+
value: 0,
|
|
191
|
+
category: categories[i],
|
|
192
|
+
isNegative: false,
|
|
193
|
+
baseX: collapseX,
|
|
194
|
+
baseY: collapseYPos,
|
|
195
|
+
orientation
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { layouts, renderProps: renderPropsMap, allTargets };
|
|
202
|
+
}
|
|
203
|
+
function computeBarDatasetTotals(barDatasets, barRawResolved) {
|
|
204
|
+
const datasetTotals = /* @__PURE__ */ new Map();
|
|
205
|
+
for (let i = 0; i < barDatasets.length; i++) {
|
|
206
|
+
const values = barRawResolved?.[i] ?? batchResolveAccessor(barDatasets[i].props.valueField, barDatasets[i].props.data);
|
|
207
|
+
let total = 0;
|
|
208
|
+
for (const v of values) total += Math.abs(v);
|
|
209
|
+
datasetTotals.set(barDatasets[i].id, total);
|
|
210
|
+
}
|
|
211
|
+
return datasetTotals;
|
|
212
|
+
}
|
|
213
|
+
function getBarAxisHints(props, data) {
|
|
214
|
+
const categoryLabels = props.categoryField ? batchResolveRequired(props.categoryField, data, "categoryField") : void 0;
|
|
215
|
+
const categoryWeights = props.weightField ? batchResolveRequired(props.weightField, data, "weightField") : void 0;
|
|
216
|
+
return { categoryLabels, categoryWeights };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/series/bar/index.ts
|
|
220
|
+
var barRenderer = {
|
|
221
|
+
calculateLayout: calculateBarLayout,
|
|
222
|
+
renderSvg: renderBarSvg,
|
|
223
|
+
renderCanvas: renderBarCanvas,
|
|
224
|
+
hitTest: hitTestBar,
|
|
225
|
+
getAxisHints: getBarAxisHints
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export { barRenderer, computeBarDatasetTotals, computeBarVisualLayout, getBarAxisHints };
|