@tabler/charts 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +258 -2
- package/dist/annotations-Bp7HwtF5.d.ts +86 -0
- package/dist/annotations-BszTTjf9.js +202 -0
- package/dist/annotations-BszTTjf9.js.map +1 -0
- package/dist/annotations-DpETO8dE.cjs +213 -0
- package/dist/annotations-DpETO8dE.cjs.map +1 -0
- package/dist/annotations-lyt0I3HU.d.cts +86 -0
- package/dist/annotations.cjs +14 -0
- package/dist/annotations.cjs.map +1 -0
- package/dist/annotations.d.cts +2 -0
- package/dist/annotations.d.ts +2 -0
- package/dist/annotations.js +12 -0
- package/dist/annotations.js.map +1 -0
- package/dist/arc-BXpLrt9b.cjs +301 -0
- package/dist/arc-BXpLrt9b.cjs.map +1 -0
- package/dist/arc-a1tRTEw7.js +278 -0
- package/dist/arc-a1tRTEw7.js.map +1 -0
- package/dist/area-CF__HOwL.d.ts +20 -0
- package/dist/area-DIxaAbYZ.d.cts +20 -0
- package/dist/area-DQsLERhx.js +26 -0
- package/dist/area-DQsLERhx.js.map +1 -0
- package/dist/area-sHCE3pg5.cjs +31 -0
- package/dist/area-sHCE3pg5.cjs.map +1 -0
- package/dist/area.cjs +3 -0
- package/dist/area.d.cts +2 -0
- package/dist/area.d.ts +2 -0
- package/dist/area.js +2 -0
- package/dist/band-DTcNDAFO.d.cts +50 -0
- package/dist/band-DTcNDAFO.d.ts +50 -0
- package/dist/bar-BBM8RhoL.d.ts +43 -0
- package/dist/bar-C-7zR2qp.cjs +243 -0
- package/dist/bar-C-7zR2qp.cjs.map +1 -0
- package/dist/bar-CRKLDg98.d.cts +43 -0
- package/dist/bar-DGuUN3nc.cjs +67 -0
- package/dist/bar-DGuUN3nc.cjs.map +1 -0
- package/dist/bar-DM16NUvV.js +56 -0
- package/dist/bar-DM16NUvV.js.map +1 -0
- package/dist/bar-jZEoao74.js +238 -0
- package/dist/bar-jZEoao74.js.map +1 -0
- package/dist/bar.cjs +3 -0
- package/dist/bar.d.cts +2 -0
- package/dist/bar.d.ts +2 -0
- package/dist/bar.js +2 -0
- package/dist/candlestick-B5r1w3kc.cjs +150 -0
- package/dist/candlestick-B5r1w3kc.cjs.map +1 -0
- package/dist/candlestick-D_vV0_XZ.d.ts +44 -0
- package/dist/candlestick-DuXwAFID.js +145 -0
- package/dist/candlestick-DuXwAFID.js.map +1 -0
- package/dist/candlestick-__pXl_pV.d.cts +44 -0
- package/dist/candlestick.cjs +11 -0
- package/dist/candlestick.cjs.map +1 -0
- package/dist/candlestick.d.cts +2 -0
- package/dist/candlestick.d.ts +2 -0
- package/dist/candlestick.js +10 -0
- package/dist/candlestick.js.map +1 -0
- package/dist/cartesian-BoDfgBCV.cjs +900 -0
- package/dist/cartesian-BoDfgBCV.cjs.map +1 -0
- package/dist/cartesian-Cr0AF0nG.js +709 -0
- package/dist/cartesian-Cr0AF0nG.js.map +1 -0
- package/dist/chart-BF2CK9I_.js +790 -0
- package/dist/chart-BF2CK9I_.js.map +1 -0
- package/dist/chart-CowF_lWY.cjs +903 -0
- package/dist/chart-CowF_lWY.cjs.map +1 -0
- package/dist/chart-D7ooEFnk.d.cts +933 -0
- package/dist/chart-DyN7bcx8.d.ts +933 -0
- package/dist/circle-BQMuAfls.cjs +12 -0
- package/dist/circle-BQMuAfls.cjs.map +1 -0
- package/dist/circle-Z7YfCoCM.js +7 -0
- package/dist/circle-Z7YfCoCM.js.map +1 -0
- package/dist/clean-Byl6kzf0.cjs +115 -0
- package/dist/clean-Byl6kzf0.cjs.map +1 -0
- package/dist/clean-o1vDEhFV.js +56 -0
- package/dist/clean-o1vDEhFV.js.map +1 -0
- package/dist/core-CegR_j55.js +884 -0
- package/dist/core-CegR_j55.js.map +1 -0
- package/dist/core-D1vO1LrC.d.cts +220 -0
- package/dist/core-DcbemzGf.d.ts +220 -0
- package/dist/core-RzS9IQO5.cjs +985 -0
- package/dist/core-RzS9IQO5.cjs.map +1 -0
- package/dist/core.cjs +115 -0
- package/dist/core.d.cts +21 -0
- package/dist/core.d.ts +21 -0
- package/dist/core.js +25 -0
- package/dist/dates-Btm7Zm6W.cjs +32 -0
- package/dist/dates-Btm7Zm6W.cjs.map +1 -0
- package/dist/dates-CG-FvioW.js +27 -0
- package/dist/dates-CG-FvioW.js.map +1 -0
- package/dist/decimate-BGg9XgF0.d.ts +17 -0
- package/dist/decimate-C87cl_Sp.js +84 -0
- package/dist/decimate-C87cl_Sp.js.map +1 -0
- package/dist/decimate-CNSpgGa5.d.cts +17 -0
- package/dist/decimate-tLhDk1ys.cjs +95 -0
- package/dist/decimate-tLhDk1ys.cjs.map +1 -0
- package/dist/decimate.cjs +14 -0
- package/dist/decimate.cjs.map +1 -0
- package/dist/decimate.d.cts +2 -0
- package/dist/decimate.d.ts +2 -0
- package/dist/decimate.js +12 -0
- package/dist/decimate.js.map +1 -0
- package/dist/dom-CLF868Qs.cjs +222 -0
- package/dist/dom-CLF868Qs.cjs.map +1 -0
- package/dist/dom-vP3IcMak.js +175 -0
- package/dist/dom-vP3IcMak.js.map +1 -0
- package/dist/export-chart-9w8t3rjZ.js +232 -0
- package/dist/export-chart-9w8t3rjZ.js.map +1 -0
- package/dist/export-chart-BhhYgksr.cjs +249 -0
- package/dist/export-chart-BhhYgksr.cjs.map +1 -0
- package/dist/export.cjs +18 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +2 -0
- package/dist/export.d.ts +2 -0
- package/dist/export.js +15 -0
- package/dist/export.js.map +1 -0
- package/dist/extent-BAMZo0Nq.js +19 -0
- package/dist/extent-BAMZo0Nq.js.map +1 -0
- package/dist/extent-DsFWvAHJ.cjs +24 -0
- package/dist/extent-DsFWvAHJ.cjs.map +1 -0
- package/dist/fade-Cs74puQS.cjs +217 -0
- package/dist/fade-Cs74puQS.cjs.map +1 -0
- package/dist/fade-D3NxH5Qg.js +200 -0
- package/dist/fade-D3NxH5Qg.js.map +1 -0
- package/dist/features-BclHgg2W.cjs +48 -0
- package/dist/features-BclHgg2W.cjs.map +1 -0
- package/dist/features-wASyHGic.js +25 -0
- package/dist/features-wASyHGic.js.map +1 -0
- package/dist/format-B0yKXBTH.cjs +183 -0
- package/dist/format-B0yKXBTH.cjs.map +1 -0
- package/dist/format-lStwuc1L.js +142 -0
- package/dist/format-lStwuc1L.js.map +1 -0
- package/dist/gauge-D-FYhuds.cjs +236 -0
- package/dist/gauge-D-FYhuds.cjs.map +1 -0
- package/dist/gauge-DP_EB2z3.d.cts +65 -0
- package/dist/gauge-Dh423FHh.js +231 -0
- package/dist/gauge-Dh423FHh.js.map +1 -0
- package/dist/gauge-zpia05t2.d.ts +65 -0
- package/dist/gauge.cjs +3 -0
- package/dist/gauge.d.cts +2 -0
- package/dist/gauge.d.ts +2 -0
- package/dist/gauge.js +2 -0
- package/dist/heatmap-BK18EBgJ.cjs +247 -0
- package/dist/heatmap-BK18EBgJ.cjs.map +1 -0
- package/dist/heatmap-BectCEeE.d.ts +81 -0
- package/dist/heatmap-CCso6m61.d.cts +81 -0
- package/dist/heatmap-DSZ2bVIa.js +242 -0
- package/dist/heatmap-DSZ2bVIa.js.map +1 -0
- package/dist/heatmap.cjs +3 -0
- package/dist/heatmap.d.cts +2 -0
- package/dist/heatmap.d.ts +2 -0
- package/dist/heatmap.js +2 -0
- package/dist/hydrate-CTTmQy0x.d.cts +10 -0
- package/dist/hydrate-CxwTXDqO.cjs +60 -0
- package/dist/hydrate-CxwTXDqO.cjs.map +1 -0
- package/dist/hydrate-CzfxLfTv.d.ts +10 -0
- package/dist/hydrate-DDNIHYv_.js +55 -0
- package/dist/hydrate-DDNIHYv_.js.map +1 -0
- package/dist/hydrate.cjs +13 -0
- package/dist/hydrate.cjs.map +1 -0
- package/dist/hydrate.d.cts +2 -0
- package/dist/hydrate.d.ts +2 -0
- package/dist/hydrate.js +12 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index.cjs +214 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -0
- package/dist/layout-B3hiqVEw.js +69 -0
- package/dist/layout-B3hiqVEw.js.map +1 -0
- package/dist/layout-CtMBhNd9.cjs +98 -0
- package/dist/layout-CtMBhNd9.cjs.map +1 -0
- package/dist/line-B3Ed6u7j.js +120 -0
- package/dist/line-B3Ed6u7j.js.map +1 -0
- package/dist/line-CN4uZ9ZX.d.ts +47 -0
- package/dist/line-W7VD_qs1.d.cts +47 -0
- package/dist/line-fQbtP_jL.cjs +131 -0
- package/dist/line-fQbtP_jL.cjs.map +1 -0
- package/dist/line.cjs +14 -0
- package/dist/line.cjs.map +1 -0
- package/dist/line.d.cts +2 -0
- package/dist/line.d.ts +2 -0
- package/dist/line.js +13 -0
- package/dist/line.js.map +1 -0
- package/dist/log-CaofN3-n.d.cts +48 -0
- package/dist/log-CaofN3-n.d.ts +48 -0
- package/dist/log-axis-83rSpvL5.cjs +130 -0
- package/dist/log-axis-83rSpvL5.cjs.map +1 -0
- package/dist/log-axis-B_uvvOFc.js +113 -0
- package/dist/log-axis-B_uvvOFc.js.map +1 -0
- package/dist/log.cjs +17 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.d.cts +2 -0
- package/dist/log.d.ts +2 -0
- package/dist/log.js +16 -0
- package/dist/log.js.map +1 -0
- package/dist/morph-BMxz3X2b.d.cts +10 -0
- package/dist/morph-BMxz3X2b.d.ts +10 -0
- package/dist/morph-Bgg-24l8.js +36 -0
- package/dist/morph-Bgg-24l8.js.map +1 -0
- package/dist/morph-CqYDu1bY.cjs +41 -0
- package/dist/morph-CqYDu1bY.cjs.map +1 -0
- package/dist/morph.cjs +14 -0
- package/dist/morph.cjs.map +1 -0
- package/dist/morph.d.cts +2 -0
- package/dist/morph.d.ts +2 -0
- package/dist/morph.js +13 -0
- package/dist/morph.js.map +1 -0
- package/dist/named-BWWb5LQJ.cjs +50 -0
- package/dist/named-BWWb5LQJ.cjs.map +1 -0
- package/dist/named-DE15TOgh.js +33 -0
- package/dist/named-DE15TOgh.js.map +1 -0
- package/dist/parliament-1Zv2Xh0D.d.ts +69 -0
- package/dist/parliament-CpWnoEvG.cjs +308 -0
- package/dist/parliament-CpWnoEvG.cjs.map +1 -0
- package/dist/parliament-DdrLVZwt.d.cts +69 -0
- package/dist/parliament-Dw0sOERi.js +303 -0
- package/dist/parliament-Dw0sOERi.js.map +1 -0
- package/dist/parliament.cjs +3 -0
- package/dist/parliament.d.cts +2 -0
- package/dist/parliament.d.ts +2 -0
- package/dist/parliament.js +2 -0
- package/dist/path-CwB28da0.d.cts +29 -0
- package/dist/path-CwB28da0.d.ts +29 -0
- package/dist/patterns-DtgcnA8o.js +85 -0
- package/dist/patterns-DtgcnA8o.js.map +1 -0
- package/dist/patterns-LfcQAWCy.cjs +102 -0
- package/dist/patterns-LfcQAWCy.cjs.map +1 -0
- package/dist/patterns.cjs +15 -0
- package/dist/patterns.cjs.map +1 -0
- package/dist/patterns.d.cts +2 -0
- package/dist/patterns.d.ts +2 -0
- package/dist/patterns.js +12 -0
- package/dist/patterns.js.map +1 -0
- package/dist/pie-5z1fDdKO.d.ts +58 -0
- package/dist/pie-BF9yI5mE.d.cts +58 -0
- package/dist/pie-BxTZt6Go.cjs +212 -0
- package/dist/pie-BxTZt6Go.cjs.map +1 -0
- package/dist/pie-DzUXDTcn.js +201 -0
- package/dist/pie-DzUXDTcn.js.map +1 -0
- package/dist/pie.cjs +4 -0
- package/dist/pie.d.cts +2 -0
- package/dist/pie.d.ts +2 -0
- package/dist/pie.js +2 -0
- package/dist/point-shapes-CGl4dugc.cjs +166 -0
- package/dist/point-shapes-CGl4dugc.cjs.map +1 -0
- package/dist/point-shapes-DI84NNpI.js +155 -0
- package/dist/point-shapes-DI84NNpI.js.map +1 -0
- package/dist/point-shapes.cjs +15 -0
- package/dist/point-shapes.cjs.map +1 -0
- package/dist/point-shapes.d.cts +2 -0
- package/dist/point-shapes.d.ts +2 -0
- package/dist/point-shapes.js +13 -0
- package/dist/point-shapes.js.map +1 -0
- package/dist/radar-1-EryihA.d.ts +60 -0
- package/dist/radar-CYPab_I4.js +285 -0
- package/dist/radar-CYPab_I4.js.map +1 -0
- package/dist/radar-CoGUNNSb.cjs +290 -0
- package/dist/radar-CoGUNNSb.cjs.map +1 -0
- package/dist/radar-DBW4O0Vt.d.cts +60 -0
- package/dist/radar.cjs +3 -0
- package/dist/radar.d.cts +2 -0
- package/dist/radar.d.ts +2 -0
- package/dist/radar.js +2 -0
- package/dist/sankey-B4PNKusJ.js +420 -0
- package/dist/sankey-B4PNKusJ.js.map +1 -0
- package/dist/sankey-Bacx4fVe.cjs +425 -0
- package/dist/sankey-Bacx4fVe.cjs.map +1 -0
- package/dist/sankey-DuGI3Qc5.d.cts +67 -0
- package/dist/sankey-OV_WoPrl.d.ts +67 -0
- package/dist/sankey.cjs +3 -0
- package/dist/sankey.d.cts +2 -0
- package/dist/sankey.d.ts +2 -0
- package/dist/sankey.js +2 -0
- package/dist/scatter-BqzgJqdX.d.ts +61 -0
- package/dist/scatter-DbxLyZX0.d.cts +61 -0
- package/dist/scatter-DgMN9zRy.cjs +250 -0
- package/dist/scatter-DgMN9zRy.cjs.map +1 -0
- package/dist/scatter-kgtgR318.js +245 -0
- package/dist/scatter-kgtgR318.js.map +1 -0
- package/dist/scatter.cjs +3 -0
- package/dist/scatter.d.cts +2 -0
- package/dist/scatter.d.ts +2 -0
- package/dist/scatter.js +2 -0
- package/dist/sparkline-BQzt27Fr.js +171 -0
- package/dist/sparkline-BQzt27Fr.js.map +1 -0
- package/dist/sparkline-BS9-hltA.cjs +176 -0
- package/dist/sparkline-BS9-hltA.cjs.map +1 -0
- package/dist/sparkline-BfyO_oNM.d.ts +43 -0
- package/dist/sparkline-CWlJDKyh.d.cts +43 -0
- package/dist/sparkline.cjs +3 -0
- package/dist/sparkline.d.cts +2 -0
- package/dist/sparkline.d.ts +2 -0
- package/dist/sparkline.js +2 -0
- package/dist/stack-CpR6RGKd.d.cts +6 -0
- package/dist/stack-CpR6RGKd.d.ts +6 -0
- package/dist/stack-DRbwTeF3.js +66 -0
- package/dist/stack-DRbwTeF3.js.map +1 -0
- package/dist/stack-DVhJWaki.cjs +77 -0
- package/dist/stack-DVhJWaki.cjs.map +1 -0
- package/dist/style.css +2 -0
- package/dist/sweep-CbfR7--d.js +60 -0
- package/dist/sweep-CbfR7--d.js.map +1 -0
- package/dist/sweep-DaTEDDuC.cjs +71 -0
- package/dist/sweep-DaTEDDuC.cjs.map +1 -0
- package/dist/time-CHjiY9Q4.d.ts +112 -0
- package/dist/time-CNVnt-B2.d.cts +112 -0
- package/dist/time-axis-Bc9eHX1r.js +365 -0
- package/dist/time-axis-Bc9eHX1r.js.map +1 -0
- package/dist/time-axis-VSX34_Tb.cjs +382 -0
- package/dist/time-axis-VSX34_Tb.cjs.map +1 -0
- package/dist/time.cjs +22 -0
- package/dist/time.cjs.map +1 -0
- package/dist/time.d.cts +2 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +20 -0
- package/dist/time.js.map +1 -0
- package/dist/tween-BCYd0RTY.js +40 -0
- package/dist/tween-BCYd0RTY.js.map +1 -0
- package/dist/tween-CIGBlryn.cjs +51 -0
- package/dist/tween-CIGBlryn.cjs.map +1 -0
- package/dist/value-labels-B0WJoJ7x.cjs +134 -0
- package/dist/value-labels-B0WJoJ7x.cjs.map +1 -0
- package/dist/value-labels-IZIQPhfk.js +123 -0
- package/dist/value-labels-IZIQPhfk.js.map +1 -0
- package/dist/value-labels.cjs +14 -0
- package/dist/value-labels.cjs.map +1 -0
- package/dist/value-labels.d.cts +2 -0
- package/dist/value-labels.d.ts +2 -0
- package/dist/value-labels.js +12 -0
- package/dist/value-labels.js.map +1 -0
- package/dist/vnode-BUflsBsa.d.cts +66 -0
- package/dist/vnode-BUflsBsa.d.ts +66 -0
- package/dist/vnode-CkQ27Cxe.cjs +110 -0
- package/dist/vnode-CkQ27Cxe.cjs.map +1 -0
- package/dist/vnode-tCWItoUH.js +93 -0
- package/dist/vnode-tCWItoUH.js.map +1 -0
- package/package.json +320 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { f as seriesKey } from "./cartesian-Cr0AF0nG.js";
|
|
2
|
+
//#region src/charts/stack.ts
|
|
3
|
+
/**
|
|
4
|
+
* Stack series per category: positive values grow up from zero and
|
|
5
|
+
* negative values down from zero, each on their own running total (like
|
|
6
|
+
* d3's diverging offset), so gains and losses never interleave. Returns one
|
|
7
|
+
* array per series with a segment per category, or `null` for no segment.
|
|
8
|
+
*/
|
|
9
|
+
function stackSeries(series, count, options = {}) {
|
|
10
|
+
const { percent = false, nullAsZero = false, hidden } = options;
|
|
11
|
+
const visible = series.map((s) => !hidden?.has(seriesKey(s)));
|
|
12
|
+
const out = series.map(() => new Array(count).fill(null));
|
|
13
|
+
for (let i = 0; i < count; i++) {
|
|
14
|
+
let total = 0;
|
|
15
|
+
if (percent) series.forEach((s, j) => {
|
|
16
|
+
const v = s.values[i];
|
|
17
|
+
if (visible[j] && v != null) total += Math.abs(v);
|
|
18
|
+
});
|
|
19
|
+
let up = 0;
|
|
20
|
+
let down = 0;
|
|
21
|
+
let lastUp;
|
|
22
|
+
let lastDown;
|
|
23
|
+
for (let j = 0; j < series.length; j++) {
|
|
24
|
+
const s = series[j];
|
|
25
|
+
if (!visible[j]) continue;
|
|
26
|
+
const raw = s.values[i];
|
|
27
|
+
const valid = raw != null;
|
|
28
|
+
if (!valid && !nullAsZero) continue;
|
|
29
|
+
let v = valid ? raw : 0;
|
|
30
|
+
if (percent) v = total === 0 ? 0 : v / total;
|
|
31
|
+
const row = out[j];
|
|
32
|
+
if (v < 0) {
|
|
33
|
+
const segment = {
|
|
34
|
+
y0: down,
|
|
35
|
+
y1: down + v
|
|
36
|
+
};
|
|
37
|
+
row[i] = segment;
|
|
38
|
+
down += v;
|
|
39
|
+
lastDown = segment;
|
|
40
|
+
} else {
|
|
41
|
+
const segment = {
|
|
42
|
+
y0: up,
|
|
43
|
+
y1: up + v
|
|
44
|
+
};
|
|
45
|
+
row[i] = segment;
|
|
46
|
+
up += v;
|
|
47
|
+
lastUp = segment;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (percent) {
|
|
51
|
+
if (lastUp && Math.abs(up - 1) < 1e-9) lastUp.y1 = 1;
|
|
52
|
+
if (lastDown && Math.abs(down + 1) < 1e-9) lastDown.y1 = -1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Every segment boundary, for the value domain. */
|
|
58
|
+
function stackBounds(stacks) {
|
|
59
|
+
const values = [];
|
|
60
|
+
for (const row of stacks) for (const segment of row) if (segment) values.push(segment.y0, segment.y1);
|
|
61
|
+
return values;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { stackSeries as n, stackBounds as t };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=stack-DRbwTeF3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-DRbwTeF3.js","names":[],"sources":["../src/charts/stack.ts"],"sourcesContent":["import { type Series, seriesKey } from './cartesian.ts'\n\n/** Stack series on top of each other; `'percent'` normalizes every category to 100%. */\nexport type StackMode = boolean | 'percent'\n\n/** A stacked segment from `y0` to `y1` (in data units). */\nexport interface Segment {\n y0: number\n y1: number\n}\n\nexport interface StackOptions {\n /** Normalize each category by the sum of absolute values. */\n percent?: boolean\n /** Count missing values as zero (areas) instead of leaving no segment (bars). */\n nullAsZero?: boolean\n /** Keys of hidden series, which get no segment and do not stack. */\n hidden?: ReadonlySet<string>\n}\n\n/**\n * Stack series per category: positive values grow up from zero and\n * negative values down from zero, each on their own running total (like\n * d3's diverging offset), so gains and losses never interleave. Returns one\n * array per series with a segment per category, or `null` for no segment.\n */\nexport function stackSeries(\n series: readonly Series[],\n count: number,\n options: StackOptions = {},\n): (Segment | null)[][] {\n const { percent = false, nullAsZero = false, hidden } = options\n const visible = series.map((s) => !hidden?.has(seriesKey(s)))\n const out = series.map(() => new Array<Segment | null>(count).fill(null))\n\n for (let i = 0; i < count; i++) {\n let total = 0\n if (percent) {\n series.forEach((s, j) => {\n const v = s.values[i]\n if (visible[j] && v != null) total += Math.abs(v)\n })\n }\n let up = 0\n let down = 0\n let lastUp: Segment | undefined\n let lastDown: Segment | undefined\n for (let j = 0; j < series.length; j++) {\n const s = series[j] as Series\n if (!visible[j]) continue\n const raw = s.values[i]\n const valid = raw != null\n if (!valid && !nullAsZero) continue\n let v = valid ? (raw as number) : 0\n if (percent) v = total === 0 ? 0 : v / total\n const row = out[j] as (Segment | null)[]\n if (v < 0) {\n const segment: Segment = { y0: down, y1: down + v }\n row[i] = segment\n down += v\n lastDown = segment\n } else {\n const segment: Segment = { y0: up, y1: up + v }\n row[i] = segment\n up += v\n lastUp = segment\n }\n }\n // Shares must end exactly at ±100%: floating point drift (1.0000000000000002)\n // would otherwise make nice() stretch the axis to 120%, or leave a hairline gap.\n if (percent) {\n if (lastUp && Math.abs(up - 1) < 1e-9) lastUp.y1 = 1\n if (lastDown && Math.abs(down + 1) < 1e-9) lastDown.y1 = -1\n }\n }\n return out\n}\n\n/** Every segment boundary, for the value domain. */\nexport function stackBounds(stacks: readonly (Segment | null)[][]): number[] {\n const values: number[] = []\n for (const row of stacks) {\n for (const segment of row) if (segment) values.push(segment.y0, segment.y1)\n }\n return values\n}\n"],"mappings":";;;;;;;;AA0BA,SAAgB,YACd,QACA,OACA,UAAwB,CAAC,GACH;CACtB,MAAM,EAAE,UAAU,OAAO,aAAa,OAAO,WAAW;CACxD,MAAM,UAAU,OAAO,KAAK,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC;CAC5D,MAAM,MAAM,OAAO,UAAU,IAAI,MAAsB,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;CAExE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK;EAC9B,IAAI,QAAQ;EACZ,IAAI,SACF,OAAO,SAAS,GAAG,MAAM;GACvB,MAAM,IAAI,EAAE,OAAO;GACnB,IAAI,QAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,IAAI,CAAC;EAClD,CAAC;EAEH,IAAI,KAAK;EACT,IAAI,OAAO;EACX,IAAI;EACJ,IAAI;EACJ,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,IAAI,OAAO;GACjB,IAAI,CAAC,QAAQ,IAAI;GACjB,MAAM,MAAM,EAAE,OAAO;GACrB,MAAM,QAAQ,OAAO;GACrB,IAAI,CAAC,SAAS,CAAC,YAAY;GAC3B,IAAI,IAAI,QAAS,MAAiB;GAClC,IAAI,SAAS,IAAI,UAAU,IAAI,IAAI,IAAI;GACvC,MAAM,MAAM,IAAI;GAChB,IAAI,IAAI,GAAG;IACT,MAAM,UAAmB;KAAE,IAAI;KAAM,IAAI,OAAO;IAAE;IAClD,IAAI,KAAK;IACT,QAAQ;IACR,WAAW;GACb,OAAO;IACL,MAAM,UAAmB;KAAE,IAAI;KAAI,IAAI,KAAK;IAAE;IAC9C,IAAI,KAAK;IACT,MAAM;IACN,SAAS;GACX;EACF;EAGA,IAAI,SAAS;GACX,IAAI,UAAU,KAAK,IAAI,KAAK,CAAC,IAAI,MAAM,OAAO,KAAK;GACnD,IAAI,YAAY,KAAK,IAAI,OAAO,CAAC,IAAI,MAAM,SAAS,KAAK;EAC3D;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,YAAY,QAAiD;CAC3E,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,OAAO,QAChB,KAAK,MAAM,WAAW,KAAK,IAAI,SAAS,OAAO,KAAK,QAAQ,IAAI,QAAQ,EAAE;CAE5E,OAAO;AACT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const require_cartesian = require("./cartesian-BoDfgBCV.cjs");
|
|
2
|
+
//#region src/charts/stack.ts
|
|
3
|
+
/**
|
|
4
|
+
* Stack series per category: positive values grow up from zero and
|
|
5
|
+
* negative values down from zero, each on their own running total (like
|
|
6
|
+
* d3's diverging offset), so gains and losses never interleave. Returns one
|
|
7
|
+
* array per series with a segment per category, or `null` for no segment.
|
|
8
|
+
*/
|
|
9
|
+
function stackSeries(series, count, options = {}) {
|
|
10
|
+
const { percent = false, nullAsZero = false, hidden } = options;
|
|
11
|
+
const visible = series.map((s) => !hidden?.has(require_cartesian.seriesKey(s)));
|
|
12
|
+
const out = series.map(() => new Array(count).fill(null));
|
|
13
|
+
for (let i = 0; i < count; i++) {
|
|
14
|
+
let total = 0;
|
|
15
|
+
if (percent) series.forEach((s, j) => {
|
|
16
|
+
const v = s.values[i];
|
|
17
|
+
if (visible[j] && v != null) total += Math.abs(v);
|
|
18
|
+
});
|
|
19
|
+
let up = 0;
|
|
20
|
+
let down = 0;
|
|
21
|
+
let lastUp;
|
|
22
|
+
let lastDown;
|
|
23
|
+
for (let j = 0; j < series.length; j++) {
|
|
24
|
+
const s = series[j];
|
|
25
|
+
if (!visible[j]) continue;
|
|
26
|
+
const raw = s.values[i];
|
|
27
|
+
const valid = raw != null;
|
|
28
|
+
if (!valid && !nullAsZero) continue;
|
|
29
|
+
let v = valid ? raw : 0;
|
|
30
|
+
if (percent) v = total === 0 ? 0 : v / total;
|
|
31
|
+
const row = out[j];
|
|
32
|
+
if (v < 0) {
|
|
33
|
+
const segment = {
|
|
34
|
+
y0: down,
|
|
35
|
+
y1: down + v
|
|
36
|
+
};
|
|
37
|
+
row[i] = segment;
|
|
38
|
+
down += v;
|
|
39
|
+
lastDown = segment;
|
|
40
|
+
} else {
|
|
41
|
+
const segment = {
|
|
42
|
+
y0: up,
|
|
43
|
+
y1: up + v
|
|
44
|
+
};
|
|
45
|
+
row[i] = segment;
|
|
46
|
+
up += v;
|
|
47
|
+
lastUp = segment;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (percent) {
|
|
51
|
+
if (lastUp && Math.abs(up - 1) < 1e-9) lastUp.y1 = 1;
|
|
52
|
+
if (lastDown && Math.abs(down + 1) < 1e-9) lastDown.y1 = -1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Every segment boundary, for the value domain. */
|
|
58
|
+
function stackBounds(stacks) {
|
|
59
|
+
const values = [];
|
|
60
|
+
for (const row of stacks) for (const segment of row) if (segment) values.push(segment.y0, segment.y1);
|
|
61
|
+
return values;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
Object.defineProperty(exports, "stackBounds", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function() {
|
|
67
|
+
return stackBounds;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "stackSeries", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return stackSeries;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=stack-DVhJWaki.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-DVhJWaki.cjs","names":["seriesKey"],"sources":["../src/charts/stack.ts"],"sourcesContent":["import { type Series, seriesKey } from './cartesian.ts'\n\n/** Stack series on top of each other; `'percent'` normalizes every category to 100%. */\nexport type StackMode = boolean | 'percent'\n\n/** A stacked segment from `y0` to `y1` (in data units). */\nexport interface Segment {\n y0: number\n y1: number\n}\n\nexport interface StackOptions {\n /** Normalize each category by the sum of absolute values. */\n percent?: boolean\n /** Count missing values as zero (areas) instead of leaving no segment (bars). */\n nullAsZero?: boolean\n /** Keys of hidden series, which get no segment and do not stack. */\n hidden?: ReadonlySet<string>\n}\n\n/**\n * Stack series per category: positive values grow up from zero and\n * negative values down from zero, each on their own running total (like\n * d3's diverging offset), so gains and losses never interleave. Returns one\n * array per series with a segment per category, or `null` for no segment.\n */\nexport function stackSeries(\n series: readonly Series[],\n count: number,\n options: StackOptions = {},\n): (Segment | null)[][] {\n const { percent = false, nullAsZero = false, hidden } = options\n const visible = series.map((s) => !hidden?.has(seriesKey(s)))\n const out = series.map(() => new Array<Segment | null>(count).fill(null))\n\n for (let i = 0; i < count; i++) {\n let total = 0\n if (percent) {\n series.forEach((s, j) => {\n const v = s.values[i]\n if (visible[j] && v != null) total += Math.abs(v)\n })\n }\n let up = 0\n let down = 0\n let lastUp: Segment | undefined\n let lastDown: Segment | undefined\n for (let j = 0; j < series.length; j++) {\n const s = series[j] as Series\n if (!visible[j]) continue\n const raw = s.values[i]\n const valid = raw != null\n if (!valid && !nullAsZero) continue\n let v = valid ? (raw as number) : 0\n if (percent) v = total === 0 ? 0 : v / total\n const row = out[j] as (Segment | null)[]\n if (v < 0) {\n const segment: Segment = { y0: down, y1: down + v }\n row[i] = segment\n down += v\n lastDown = segment\n } else {\n const segment: Segment = { y0: up, y1: up + v }\n row[i] = segment\n up += v\n lastUp = segment\n }\n }\n // Shares must end exactly at ±100%: floating point drift (1.0000000000000002)\n // would otherwise make nice() stretch the axis to 120%, or leave a hairline gap.\n if (percent) {\n if (lastUp && Math.abs(up - 1) < 1e-9) lastUp.y1 = 1\n if (lastDown && Math.abs(down + 1) < 1e-9) lastDown.y1 = -1\n }\n }\n return out\n}\n\n/** Every segment boundary, for the value domain. */\nexport function stackBounds(stacks: readonly (Segment | null)[][]): number[] {\n const values: number[] = []\n for (const row of stacks) {\n for (const segment of row) if (segment) values.push(segment.y0, segment.y1)\n }\n return values\n}\n"],"mappings":";;;;;;;;AA0BA,SAAgB,YACd,QACA,OACA,UAAwB,CAAC,GACH;CACtB,MAAM,EAAE,UAAU,OAAO,aAAa,OAAO,WAAW;CACxD,MAAM,UAAU,OAAO,KAAK,MAAM,CAAC,QAAQ,IAAIA,kBAAAA,UAAU,CAAC,CAAC,CAAC;CAC5D,MAAM,MAAM,OAAO,UAAU,IAAI,MAAsB,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;CAExE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK;EAC9B,IAAI,QAAQ;EACZ,IAAI,SACF,OAAO,SAAS,GAAG,MAAM;GACvB,MAAM,IAAI,EAAE,OAAO;GACnB,IAAI,QAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,IAAI,CAAC;EAClD,CAAC;EAEH,IAAI,KAAK;EACT,IAAI,OAAO;EACX,IAAI;EACJ,IAAI;EACJ,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,IAAI,OAAO;GACjB,IAAI,CAAC,QAAQ,IAAI;GACjB,MAAM,MAAM,EAAE,OAAO;GACrB,MAAM,QAAQ,OAAO;GACrB,IAAI,CAAC,SAAS,CAAC,YAAY;GAC3B,IAAI,IAAI,QAAS,MAAiB;GAClC,IAAI,SAAS,IAAI,UAAU,IAAI,IAAI,IAAI;GACvC,MAAM,MAAM,IAAI;GAChB,IAAI,IAAI,GAAG;IACT,MAAM,UAAmB;KAAE,IAAI;KAAM,IAAI,OAAO;IAAE;IAClD,IAAI,KAAK;IACT,QAAQ;IACR,WAAW;GACb,OAAO;IACL,MAAM,UAAmB;KAAE,IAAI;KAAI,IAAI,KAAK;IAAE;IAC9C,IAAI,KAAK;IACT,MAAM;IACN,SAAS;GACX;EACF;EAGA,IAAI,SAAS;GACX,IAAI,UAAU,KAAK,IAAI,KAAK,CAAC,IAAI,MAAM,OAAO,KAAK;GACnD,IAAI,YAAY,KAAK,IAAI,OAAO,CAAC,IAAI,MAAM,SAAS,KAAK;EAC3D;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,YAAY,QAAiD;CAC3E,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,OAAO,QAChB,KAAK,MAAM,WAAW,KAAK,IAAI,SAAS,OAAO,KAAK,QAAQ,IAAI,QAAQ,EAAE;CAE5E,OAAO;AACT"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @tabler/charts | MIT */
|
|
2
|
+
:where(:root),:where([data-theme=light]){--tc-color-1:var(--tblr-primary,#2a78d6);--tc-color-2:var(--tblr-orange,#eb6834);--tc-color-3:var(--tblr-teal,#1baf7a);--tc-color-4:var(--tblr-yellow,#eda100);--tc-color-5:var(--tblr-pink,#e87ba4);--tc-color-6:var(--tblr-green,#008300);--tc-color-7:var(--tblr-indigo,#4a3aa7);--tc-color-8:var(--tblr-red,#e34948);--tc-color-other:var(--tblr-secondary,#8a8983);--tc-surface:var(--tblr-bg-surface,#fff);--tc-text-color:var(--tblr-body-color,#0b0b0b);--tc-text-muted:var(--tblr-secondary,#6f6e69);--tc-grid-color:var(--tblr-border-color-translucent,#e1e0d9);--tc-baseline-color:var(--tblr-border-color,#c3c2b7);--tc-hover-color:rgba(var(--tblr-emphasis-color-rgb,11, 11, 11), .04);--tc-tooltip-bg:var(--tblr-dark,#0b0b0b);--tc-tooltip-color:#fff;--tc-tooltip-muted:#ffffffb3;--tc-tooltip-border:#ffffff1f;--tc-tooltip-shadow:var(--tblr-box-shadow,0 4px 16px #0b0b0b1f);--tc-tooltip-radius:var(--tblr-border-radius,6px);--tc-tooltip-light-bg:#fff;--tc-tooltip-light-color:#0b0b0b;--tc-tooltip-light-muted:#6f6e69;--tc-tooltip-light-border:#0b0b0b1a;--tc-focus-color:var(--tc-color-1);--tc-font-family:var(--tblr-body-font-family,inherit);--tc-font-size:12px;--tc-stroke-width:2px;--tc-grid-width:1px;--tc-area-opacity:.1;--tc-area-gradient-start:.24;--tc-area-gradient-end:0;--tc-pie-value-size:1.75em;--tc-bubble-opacity:.7;--tc-point-ring:2px;--tc-duration:.4s;--tc-duration-fast:.12s;--tc-easing:cubic-bezier(.4, 0, .2, 1)}@media (prefers-color-scheme:dark){:where(:root:not([data-theme=light])){--tc-color-1:var(--tblr-primary,#3987e5);--tc-color-2:var(--tblr-orange,#d95926);--tc-color-3:var(--tblr-teal,#199e70);--tc-color-4:var(--tblr-yellow,#c98500);--tc-color-5:var(--tblr-pink,#d55181);--tc-color-6:var(--tblr-green,#008300);--tc-color-7:var(--tblr-indigo,#9085e9);--tc-color-8:var(--tblr-red,#e66767);--tc-color-other:var(--tblr-secondary,#7c7b76);--tc-surface:var(--tblr-bg-surface,#1a1a19);--tc-text-color:var(--tblr-body-color,#fff);--tc-text-muted:var(--tblr-secondary,#a3a29c);--tc-grid-color:var(--tblr-border-color-translucent,#2c2c2a);--tc-baseline-color:var(--tblr-border-color,#4a4a46);--tc-hover-color:rgba(var(--tblr-emphasis-color-rgb,255, 255, 255), .06);--tc-tooltip-bg:var(--tblr-dark,#262625);--tc-tooltip-shadow:var(--tblr-box-shadow,0 4px 16px #0006);--tc-focus-color:var(--tc-color-1)}}:where([data-theme=dark]){--tc-color-1:var(--tblr-primary,#3987e5);--tc-color-2:var(--tblr-orange,#d95926);--tc-color-3:var(--tblr-teal,#199e70);--tc-color-4:var(--tblr-yellow,#c98500);--tc-color-5:var(--tblr-pink,#d55181);--tc-color-6:var(--tblr-green,#008300);--tc-color-7:var(--tblr-indigo,#9085e9);--tc-color-8:var(--tblr-red,#e66767);--tc-color-other:var(--tblr-secondary,#7c7b76);--tc-surface:var(--tblr-bg-surface,#1a1a19);--tc-text-color:var(--tblr-body-color,#fff);--tc-text-muted:var(--tblr-secondary,#a3a29c);--tc-grid-color:var(--tblr-border-color-translucent,#2c2c2a);--tc-baseline-color:var(--tblr-border-color,#4a4a46);--tc-hover-color:rgba(var(--tblr-emphasis-color-rgb,255, 255, 255), .06);--tc-tooltip-bg:var(--tblr-dark,#262625);--tc-tooltip-shadow:var(--tblr-box-shadow,0 4px 16px #0006);--tc-focus-color:var(--tc-color-1)}.tc-chart{max-width:100%;height:auto;font-family:var(--tc-font-family);font-size:var(--tc-font-size);letter-spacing:normal;word-spacing:normal;text-transform:none;color:var(--tc-text-color);-webkit-tap-highlight-color:transparent;display:block;overflow:visible}.tc-chart :where(text){font:inherit}.tc-series{--tc-series-color:var(--tc-color-other);--tc-series-pattern:var(--tc-pattern-other);--tc-pattern-dash:1 3;--tc-pattern-ink:var(--tc-pattern-color,var(--tc-surface));--tc-swatch-pattern:repeating-linear-gradient(45deg, var(--tc-pattern-ink) 0 1px, #0000 0 3px)}.tc-series-1{--tc-series-color:var(--tc-color-1);--tc-series-pattern:var(--tc-pattern-1);--tc-pattern-dash:none;--tc-swatch-pattern:repeating-linear-gradient(45deg, var(--tc-pattern-ink) 0 1.5px, #0000 0 4px)}.tc-series-2{--tc-series-color:var(--tc-color-2);--tc-series-pattern:var(--tc-pattern-2);--tc-pattern-dash:6 3;--tc-swatch-pattern:radial-gradient(var(--tc-pattern-ink) .8px, #0000 1.2px) 0 0 / 4px 4px}.tc-series-3{--tc-series-color:var(--tc-color-3);--tc-series-pattern:var(--tc-pattern-3);--tc-pattern-dash:2 3;--tc-swatch-pattern:repeating-linear-gradient(-45deg, var(--tc-pattern-ink) 0 1.5px, #0000 0 4px)}.tc-series-4{--tc-series-color:var(--tc-color-4);--tc-series-pattern:var(--tc-pattern-4);--tc-pattern-dash:10 3 2 3;--tc-swatch-pattern:repeating-linear-gradient(var(--tc-pattern-ink) 0 1.5px, #0000 0 4px)}.tc-series-5{--tc-series-color:var(--tc-color-5);--tc-series-pattern:var(--tc-pattern-5);--tc-pattern-dash:4 4;--tc-swatch-pattern:repeating-linear-gradient(45deg, var(--tc-pattern-ink) 0 1px, #0000 0 4px), repeating-linear-gradient(-45deg, var(--tc-pattern-ink) 0 1px, #0000 0 4px)}.tc-series-6{--tc-series-color:var(--tc-color-6);--tc-series-pattern:var(--tc-pattern-6);--tc-pattern-dash:12 4;--tc-swatch-pattern:repeating-linear-gradient(90deg, var(--tc-pattern-ink) 0 1.5px, #0000 0 4px)}.tc-series-7{--tc-series-color:var(--tc-color-7);--tc-series-pattern:var(--tc-pattern-7);--tc-pattern-dash:2 2 6 2;--tc-swatch-pattern:repeating-linear-gradient(var(--tc-pattern-ink) 0 1px, #0000 0 4px), repeating-linear-gradient(90deg, var(--tc-pattern-ink) 0 1px, #0000 0 4px)}.tc-series-8{--tc-series-color:var(--tc-color-8);--tc-series-pattern:var(--tc-pattern-8);--tc-pattern-dash:8 2 2 2;--tc-swatch-pattern:linear-gradient(90deg, #0000 50%, var(--tc-series-color) 0) 0 0 / 4px 4px, repeating-linear-gradient(var(--tc-pattern-ink) 0 1.5px, #0000 0 4px)}.tc-tick-label{fill:var(--tc-text-muted);font-variant-numeric:tabular-nums}.tc-grid-line,.tc-grid-line-zero,.tc-axis-line,.tc-tick-line,.tc-crosshair,.tc-sparkline-zero,.tc-radar-ring,.tc-radar-spoke{stroke:var(--tc-baseline-color);stroke-width:var(--tc-grid-width);shape-rendering:crispedges;vector-effect:non-scaling-stroke}.tc-grid-line,.tc-sparkline-zero,.tc-radar-ring,.tc-radar-spoke{stroke:var(--tc-grid-color)}.tc-grid-line-zero{stroke:var(--tc-baseline-color)}.tc-line{fill:none;stroke:var(--tc-series-color);stroke-width:var(--tc-series-width,var(--tc-stroke-width));stroke-dasharray:var(--tc-series-dash,none);stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke}.tc-area{fill:var(--tc-series-color);fill-opacity:var(--tc-area-opacity);stroke:none}.tc-pie-slices{--tc-pie-gap:0px}.tc-slice{fill:var(--tc-series-color);stroke:var(--tc-surface);stroke-width:var(--tc-pie-gap);stroke-linejoin:round}.tc-pie-track,.tc-gauge-track{fill:var(--tc-grid-color)}.tc-gauge-arc{fill:var(--tc-series-color)}.tc-pie-value,.tc-gauge-value,.tc-parliament-value{font-size:var(--tc-pie-value-size);fill:var(--tc-text-color);font-variant-numeric:tabular-nums;font-weight:600}.tc-pie-label,.tc-gauge-label,.tc-parliament-label{fill:var(--tc-text-muted)}.tc-seat{fill:var(--tc-series-color);transition:transform var(--tc-duration) var(--tc-easing), r var(--tc-duration) var(--tc-easing)}.tc-seat-vacant{fill:var(--tc-grid-color)}.tc-chart-parliament .tc-hover-mark{opacity:.25}.tc-sankey-node{fill:var(--tc-series-color)}.tc-sankey-link{fill:var(--tc-series-color);fill-opacity:var(--tc-area-opacity);stroke:none}.tc-chart-sankey{--tc-area-opacity:.35}.tc-sankey-value{font-size:.92em}.tc-chart-sankey .tc-hover-mark{opacity:.5}.tc-radar-ring,.tc-radar-spoke,.tc-chart-radar .tc-crosshair{fill:none;shape-rendering:auto}.tc-area-gradient{fill-opacity:1}.tc-fade-start{stop-color:#fff;stop-opacity:var(--tc-area-gradient-start)}.tc-fade-end{stop-color:#fff;stop-opacity:var(--tc-area-gradient-end)}.tc-chart-sparkline{--tc-stroke-width:1.5px;--tc-area-gradient-start:.3}.tc-bubble{fill-opacity:var(--tc-bubble-opacity)}.tc-point{fill:var(--tc-series-color);stroke:var(--tc-surface);stroke-width:var(--tc-point-ring);paint-order:stroke;transition:cx var(--tc-duration) var(--tc-easing), cy var(--tc-duration) var(--tc-easing)}.tc-point-min,.tc-point-max{fill:var(--tc-text-muted)}.tc-annotation{--tc-annotation-color:var(--tc-text-muted)}.tc-annotation-line{stroke:var(--tc-annotation-color);stroke-width:1px;stroke-dasharray:4 3;shape-rendering:crispedges;vector-effect:non-scaling-stroke}.tc-annotation-band{fill:var(--tc-annotation-color);fill-opacity:.1}.tc-annotation-label{fill:var(--tc-annotation-color);font-weight:500}.tc-annotation-label,.tc-radar-value{paint-order:stroke;stroke:var(--tc-surface);stroke-width:3px;stroke-linejoin:round;font-size:.92em}.tc-annotations{pointer-events:none}.tc-value-label{fill:var(--tc-text-color);font-variant-numeric:tabular-nums;paint-order:stroke;stroke:var(--tc-surface);stroke-width:3px;stroke-linejoin:round;transition:transform var(--tc-duration) var(--tc-easing);animation:tc-fade-in var(--tc-duration) var(--tc-easing);font-weight:500}.tc-marker{transition:d var(--tc-duration) var(--tc-easing)}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) :is(.tc-legend-swatch,.tc-tooltip-swatch){background:var(--tc-series-color);width:10px;height:10px}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-2 :is(.tc-legend-swatch,.tc-tooltip-swatch){border-radius:1px;scale:.8}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-3 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(50% 3.6%,92.9% 82.1%,7.1% 82.1%);border-radius:0}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-4 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(50% 3.6%,96.4% 50%,50% 96.4%,3.6% 50%);border-radius:0}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-5 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(7.1% 17.9%,92.9% 17.9%,50% 96.4%);border-radius:0}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-6 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(35.7% 7.1%,64.3% 7.1%,64.3% 35.7%,92.9% 35.7%,92.9% 64.3%,64.3% 64.3%,64.3% 92.9%,35.7% 92.9%,35.7% 64.3%,7.1% 64.3%,7.1% 35.7%,35.7% 35.7%);border-radius:0}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-7 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(25% 7.1%,50% 32.1%,75% 7.1%,92.9% 25%,67.9% 50%,92.9% 75%,75% 92.9%,50% 67.9%,25% 92.9%,7.1% 75%,32.1% 50%,7.1% 25%);border-radius:0}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) .tc-series-8 :is(.tc-legend-swatch,.tc-tooltip-swatch){clip-path:polygon(50% 0%,61.4% 34.3%,97.5% 34.6%,68.6% 56.1%,79.3% 90.4%,50% 69.6%,20.7% 90.4%,31.4% 56.1%,2.5% 34.6%,38.6% 34.3%);border-radius:0}.tc-pattern-bg{fill:var(--tc-series-color)}.tc-pattern-ink{fill:none;stroke:var(--tc-pattern-ink);stroke-width:1.5px;stroke-linecap:round}.tc-patterned :is(.tc-bar,.tc-area,.tc-slice,.tc-gauge-arc,.tc-bubble){fill:var(--tc-series-pattern,var(--tc-series-color))}.tc-patterned .tc-area{fill-opacity:max(var(--tc-area-opacity), .4)}.tc-patterned .tc-line{stroke-dasharray:var(--tc-series-dash,var(--tc-pattern-dash))}:has(>.tc-patterned)>:is(.tc-legend,.tc-tooltip) :is(.tc-legend-swatch,.tc-tooltip-swatch){background:var(--tc-swatch-pattern), var(--tc-series-color)}@keyframes tc-reveal{0%{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0)}}@keyframes tc-grow{0%{transform:scaleY(0)}}@keyframes tc-grow-x{0%{transform:scaleX(0)}}@keyframes tc-fade-in{0%{opacity:0}}.tc-line,.tc-area,.tc-bar,.tc-radar-ring,.tc-dots{transition:d var(--tc-duration) var(--tc-easing)}.tc-slice,.tc-gauge-arc,.tc-gauge-track{transition:none var(--tc-duration)}.tc-chart-line .tc-series-list,.tc-chart-area .tc-series-list{animation:tc-reveal calc(var(--tc-duration) * 2) var(--tc-easing)}.tc-series-list .tc-series,.tc-areas .tc-series,.tc-sankey-links .tc-sankey-link,.tc-sankey-nodes .tc-series,.tc-parliament-seats .tc-series,.tc-parliament-seats .tc-seat,.tc-series-list .tc-point,.tc-heatmap-cells,.tc-candles,.tc-tick,.tc-grid-line{animation:tc-fade-in var(--tc-duration) var(--tc-easing)}.tc-bar{fill:var(--tc-series-color);transform-box:fill-box;transform-origin:50% 100%;animation:tc-grow var(--tc-duration) var(--tc-easing)}.tc-bar-negative{transform-origin:50% 0}.tc-cell{fill:var(--tc-cell-fill,var(--tc-heat-color,var(--tc-color-1)));transition:fill var(--tc-duration) var(--tc-easing)}@supports (color:color-mix(in oklab, red 50%, blue)){.tc-cell{fill:var(--tc-cell-fill,color-mix(in oklab, var(--tc-heat-color,var(--tc-color-1)) var(--tc-heat,100%), var(--tc-heat-empty,var(--tc-grid-color))))}}.tc-heatmap-row.tc-series{--tc-heat-color:var(--tc-series-color)}.tc-cell-empty{fill:var(--tc-heat-empty,var(--tc-grid-color));opacity:.5}.tc-candle{--tc-candle-color:var(--tc-up-color,var(--tc-color-6))}.tc-candle-down{--tc-candle-color:var(--tc-negative-color,var(--tc-color-8))}.tc-candle-body{fill:var(--tc-candle-color);transition:d var(--tc-duration) var(--tc-easing), fill var(--tc-duration) var(--tc-easing)}.tc-candle-wick{fill:none;stroke:var(--tc-candle-color);stroke-width:1px;vector-effect:non-scaling-stroke;transition:d var(--tc-duration) var(--tc-easing), stroke var(--tc-duration) var(--tc-easing)}.tc-tristate-loss{fill:var(--tc-negative-color,var(--tc-color-8))}.tc-tristate-draw{fill:var(--tc-baseline-color)}.tc-bar-horizontal{transform-origin:0;animation-name:tc-grow-x}.tc-bar-horizontal.tc-bar-negative{transform-origin:100%}.tc-tick,.tc-grid-line{transition:transform var(--tc-duration) var(--tc-easing)}@keyframes tc-pie-in{0%{opacity:0;transform:scale(.85)}}.tc-pie-slices,.tc-gauge-rings,.tc-parliament-seats,.tc-radar-series{animation:tc-pie-in calc(var(--tc-duration) * 1.5) var(--tc-easing)}.tc-hover .tc-point{transition:none;animation:none}.tc-static,.tc-chart[data-resizing]{--tc-duration:0s}:where(.tc-container){position:relative}.tc-hover{pointer-events:none}.tc-hover-band{fill:var(--tc-hover-color)}.tc-hover-mark{fill:var(--tc-series-color);opacity:.35}.tc-chart-heatmap .tc-hover-mark{fill:none;stroke:var(--tc-text-color);stroke-width:2px;opacity:.6}.tc-tooltip{z-index:10;pointer-events:none;opacity:0;min-width:120px;max-width:min(280px,100%);font-family:var(--tc-font-family);font-size:var(--tc-font-size);overflow-wrap:anywhere;color:var(--tc-tooltip-color);background:var(--tc-tooltip-bg);border:1px solid var(--tc-tooltip-border);border-radius:var(--tc-tooltip-radius);box-shadow:var(--tc-tooltip-shadow);transition:opacity var(--tc-duration-fast) var(--tc-easing);padding:8px 10px;line-height:1.4;position:absolute;top:0;left:0}.tc-tooltip-light{--tc-tooltip-bg:var(--tc-tooltip-light-bg);--tc-tooltip-color:var(--tc-tooltip-light-color);--tc-tooltip-muted:var(--tc-tooltip-light-muted);--tc-tooltip-border:var(--tc-tooltip-light-border)}.tc-tooltip .tc-series{--tc-pattern-ink:var(--tc-pattern-color,var(--tc-tooltip-bg))}.tc-tooltip[data-visible]{opacity:1;transition:opacity var(--tc-duration-fast) var(--tc-easing), transform var(--tc-duration-fast) var(--tc-easing)}.tc-tooltip-title{margin-bottom:4px;font-weight:600}.tc-tooltip-item{align-items:center;gap:8px;display:flex}.tc-tooltip-swatch,.tc-legend-swatch{background:var(--tc-series-color);border-radius:50%;flex:none;width:8px;height:8px}.tc-tooltip-name{color:var(--tc-tooltip-muted);flex:1}.tc-tooltip-value{white-space:nowrap;font-variant-numeric:tabular-nums;font-weight:500}.tc-tooltip-footer{border-top:1px solid var(--tc-tooltip-border);margin-top:4px;padding-top:4px}.tc-tooltip-item-active .tc-tooltip-name{color:var(--tc-tooltip-color)}.tc-legend{font-family:var(--tc-font-family);font-size:var(--tc-font-size);margin-bottom:8px;line-height:1.4}.tc-legend[data-position=bottom]{margin:8px 0 0}.tc-legend-items{flex-wrap:wrap;gap:4px 12px;display:flex}.tc-legend-item{appearance:none;font:inherit;text-align:start;color:var(--tc-text-color);cursor:pointer;transition:color var(--tc-duration-fast) var(--tc-easing);background:0 0;border:0;border-radius:4px;align-items:center;gap:6px;margin:0;padding:2px 4px;display:inline-flex}.tc-legend-item:hover{background:var(--tc-hover-color)}.tc-legend-item:focus-visible{outline:2px solid var(--tc-focus-color);outline-offset:1px}.tc-legend-item-hidden{color:var(--tc-text-muted)}.tc-legend-item-hidden .tc-legend-swatch{box-shadow:inset 0 0 0 1.5px var(--tc-series-color);background:0 0}.tc-download{z-index:11;font-family:var(--tc-font-family);font-size:var(--tc-font-size);line-height:1.4;position:absolute;top:0;right:0}.tc-download-toggle,.tc-download-item{appearance:none;font:inherit;color:var(--tc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:4px;align-items:center;margin:0;display:flex}.tc-download-toggle{justify-content:center;width:24px;height:24px;padding:0}.tc-download-toggle:hover,.tc-download-toggle[aria-expanded=true],.tc-download-item:hover{color:var(--tc-text-color);background:var(--tc-hover-color)}.tc-download-toggle:focus-visible,.tc-download-item:focus-visible{outline:2px solid var(--tc-focus-color);outline-offset:1px}.tc-download-menu{min-width:80px;color:var(--tc-text-color);background:var(--tc-surface);border:1px solid var(--tc-grid-color);border-radius:var(--tc-tooltip-radius);box-shadow:var(--tc-tooltip-shadow);margin-top:2px;padding:4px;position:absolute;top:100%;right:0}.tc-download-item{text-align:start;white-space:nowrap;width:100%;padding:4px 8px}.tc-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.tc-chart:focus{outline:none}.tc-chart:focus-visible{outline:2px solid var(--tc-focus-color);outline-offset:2px;border-radius:2px}.tc-table-wrap:not(.tc-sr-only){margin-top:12px;overflow-x:auto}.tc-table{border-collapse:collapse;width:100%;font-family:var(--tc-font-family);font-size:var(--tc-font-size);font-variant-numeric:tabular-nums;color:var(--tc-text-color)}.tc-table caption{text-align:start;margin-bottom:4px;font-weight:600}.tc-table th,.tc-table td{text-align:end;border-bottom:1px solid var(--tc-grid-color);padding:4px 8px}.tc-table th[scope=row],.tc-table thead th:first-child{text-align:start}.tc-table thead th{color:var(--tc-text-muted);border-bottom-color:var(--tc-baseline-color);font-weight:600}@media (prefers-reduced-motion:reduce){.tc-chart,.tc-tooltip{--tc-duration:0s;--tc-duration-fast:0s}}@media (forced-colors:active){.tc-value-label{fill:canvastext;stroke:canvas}.tc-tick-label{fill:canvastext}.tc-grid-line,.tc-radar-ring,.tc-radar-spoke{stroke:graytext}.tc-grid-line-zero,.tc-axis-line,.tc-tick-line,.tc-line{stroke:canvastext}.tc-area{fill:graytext}.tc-bar,.tc-point{fill:canvastext;stroke:canvas}.tc-crosshair{stroke:highlight}.tc-tooltip{border-color:canvastext}.tc-legend-swatch{background:canvastext}.tc-legend-item-hidden .tc-legend-swatch{background:0 0;box-shadow:inset 0 0 0 1.5px canvastext}.tc-pattern-bg{fill:canvas}.tc-pattern-ink{stroke:canvastext}:is(.tc-patterned,.tc-patterns-auto) :is(.tc-bar,.tc-area,.tc-slice,.tc-gauge-arc,.tc-bubble){fill:var(--tc-series-pattern,CanvasText);fill-opacity:1;stroke:canvastext;stroke-width:1px}.tc-patterns-auto .tc-line{stroke-dasharray:var(--tc-series-dash,var(--tc-pattern-dash))}:has(>:is(.tc-patterned,.tc-patterns-auto))>:is(.tc-legend,.tc-tooltip) .tc-series{--tc-pattern-color:CanvasText;--tc-series-color:Canvas}:has(>:is(.tc-patterned,.tc-patterns-auto))>:is(.tc-legend,.tc-tooltip) :is(.tc-legend-swatch,.tc-tooltip-swatch){forced-color-adjust:none;background:var(--tc-swatch-pattern), Canvas;box-shadow:inset 0 0 0 1px canvastext}:has(>svg .tc-marker)>:is(.tc-legend,.tc-tooltip) :is(.tc-legend-swatch,.tc-tooltip-swatch){box-shadow:none;background:canvastext}}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { t as h } from "./vnode-tCWItoUH.js";
|
|
2
|
+
import { n as tween, t as stop } from "./tween-BCYd0RTY.js";
|
|
3
|
+
import { r as arcPathStable } from "./arc-a1tRTEw7.js";
|
|
4
|
+
//#region src/render/sweep.ts
|
|
5
|
+
/**
|
|
6
|
+
* Arcs that turn to their new angles: a transition of `d` moves each point
|
|
7
|
+
* of a path along a straight line, which bends a slice out of its ring on
|
|
8
|
+
* the way. A path that knows which arc it draws (the `arc` of its node, see
|
|
9
|
+
* `arcNode`) is redrawn frame by frame instead, with the angles and radii
|
|
10
|
+
* in between, so slices grow and shrink around the center. Timed by the
|
|
11
|
+
* path's `transition-duration` (`--tc-duration`), with an ease-out curve.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A path drawing this arc, which keeps the arc with it (radii, angles, pad
|
|
15
|
+
* angle, corner radius): out of the markup, for the next render to sweep from.
|
|
16
|
+
*/
|
|
17
|
+
function arcNode(name, arc) {
|
|
18
|
+
const node = h("path", {
|
|
19
|
+
class: name,
|
|
20
|
+
d: arcPathStable(arc)
|
|
21
|
+
});
|
|
22
|
+
node.arc = [
|
|
23
|
+
arc.innerRadius,
|
|
24
|
+
arc.outerRadius,
|
|
25
|
+
arc.startAngle,
|
|
26
|
+
arc.endAngle,
|
|
27
|
+
arc.padAngle ?? 0,
|
|
28
|
+
arc.cornerRadius ?? 0
|
|
29
|
+
];
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Take `el` from the arc of its last render, `prev`, to the arc of `next`.
|
|
34
|
+
* Returns the attributes left for the caller to patch (all but `d`, set
|
|
35
|
+
* here frame by frame), or nothing when there is no sweep: not an arc, the
|
|
36
|
+
* same path, no arc to come from, or a chart without transitions.
|
|
37
|
+
*/
|
|
38
|
+
function sweep(el, prev, next) {
|
|
39
|
+
const { arc, attrs } = next;
|
|
40
|
+
if (!arc || prev.attrs.d === attrs.d) return;
|
|
41
|
+
const origin = stop(el) ?? prev.arc;
|
|
42
|
+
const duration = Number.parseFloat(getComputedStyle(el).transitionDuration) * 1e3;
|
|
43
|
+
if (!origin || !(duration > 0)) return;
|
|
44
|
+
tween(el, origin, arc, duration, ([innerRadius, outerRadius, startAngle, endAngle, padAngle, cornerRadius]) => arcPathStable({
|
|
45
|
+
innerRadius,
|
|
46
|
+
outerRadius,
|
|
47
|
+
startAngle,
|
|
48
|
+
endAngle,
|
|
49
|
+
padAngle,
|
|
50
|
+
cornerRadius
|
|
51
|
+
}), String(attrs.d));
|
|
52
|
+
return {
|
|
53
|
+
...attrs,
|
|
54
|
+
d: prev.attrs.d
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { sweep as n, arcNode as t };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=sweep-CbfR7--d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep-CbfR7--d.js","names":[],"sources":["../src/render/sweep.ts"],"sourcesContent":["/**\n * Arcs that turn to their new angles: a transition of `d` moves each point\n * of a path along a straight line, which bends a slice out of its ring on\n * the way. A path that knows which arc it draws (the `arc` of its node, see\n * `arcNode`) is redrawn frame by frame instead, with the angles and radii\n * in between, so slices grow and shrink around the center. Timed by the\n * path's `transition-duration` (`--tc-duration`), with an ease-out curve.\n */\n\nimport { type ArcOptions, arcPathStable } from '../shapes/arc.ts'\nimport { type Attrs, h, type VNode } from '../vnode.ts'\nimport { stop, tween } from './tween.ts'\n\n/**\n * A path drawing this arc, which keeps the arc with it (radii, angles, pad\n * angle, corner radius): out of the markup, for the next render to sweep from.\n */\nexport function arcNode(name: string, arc: ArcOptions): VNode {\n const node = h('path', { class: name, d: arcPathStable(arc) })\n node.arc = [\n arc.innerRadius,\n arc.outerRadius,\n arc.startAngle,\n arc.endAngle,\n arc.padAngle ?? 0,\n arc.cornerRadius ?? 0,\n ]\n return node\n}\n\n/**\n * Take `el` from the arc of its last render, `prev`, to the arc of `next`.\n * Returns the attributes left for the caller to patch (all but `d`, set\n * here frame by frame), or nothing when there is no sweep: not an arc, the\n * same path, no arc to come from, or a chart without transitions.\n */\nexport function sweep(el: Element, prev: VNode, next: VNode): Attrs | undefined {\n const { arc, attrs } = next\n if (!arc || prev.attrs.d === attrs.d) return\n // An interrupted sweep continues from where the arc is now.\n const origin = stop(el) ?? prev.arc\n // Zero in a chart without transitions (static, resizing, reduced motion).\n const duration = Number.parseFloat(getComputedStyle(el).transitionDuration) * 1000\n if (!origin || !(duration > 0)) return\n tween(\n el,\n origin,\n arc,\n duration,\n ([innerRadius, outerRadius, startAngle, endAngle, padAngle, cornerRadius]) =>\n arcPathStable({\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n padAngle,\n cornerRadius,\n } as ArcOptions),\n String(attrs.d),\n )\n return { ...attrs, d: prev.attrs.d as string }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAAc,KAAwB;CAC5D,MAAM,OAAO,EAAE,QAAQ;EAAE,OAAO;EAAM,GAAG,cAAc,GAAG;CAAE,CAAC;CAC7D,KAAK,MAAM;EACT,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI,YAAY;EAChB,IAAI,gBAAgB;CACtB;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,IAAa,MAAa,MAAgC;CAC9E,MAAM,EAAE,KAAK,UAAU;CACvB,IAAI,CAAC,OAAO,KAAK,MAAM,MAAM,MAAM,GAAG;CAEtC,MAAM,SAAS,KAAK,EAAE,KAAK,KAAK;CAEhC,MAAM,WAAW,OAAO,WAAW,iBAAiB,EAAE,CAAC,CAAC,kBAAkB,IAAI;CAC9E,IAAI,CAAC,UAAU,EAAE,WAAW,IAAI;CAChC,MACE,IACA,QACA,KACA,WACC,CAAC,aAAa,aAAa,YAAY,UAAU,UAAU,kBAC1D,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;CACF,CAAe,GACjB,OAAO,MAAM,CAAC,CAChB;CACA,OAAO;EAAE,GAAG;EAAO,GAAG,KAAK,MAAM;CAAY;AAC/C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const require_vnode = require("./vnode-CkQ27Cxe.cjs");
|
|
2
|
+
const require_tween = require("./tween-CIGBlryn.cjs");
|
|
3
|
+
const require_arc = require("./arc-BXpLrt9b.cjs");
|
|
4
|
+
//#region src/render/sweep.ts
|
|
5
|
+
/**
|
|
6
|
+
* Arcs that turn to their new angles: a transition of `d` moves each point
|
|
7
|
+
* of a path along a straight line, which bends a slice out of its ring on
|
|
8
|
+
* the way. A path that knows which arc it draws (the `arc` of its node, see
|
|
9
|
+
* `arcNode`) is redrawn frame by frame instead, with the angles and radii
|
|
10
|
+
* in between, so slices grow and shrink around the center. Timed by the
|
|
11
|
+
* path's `transition-duration` (`--tc-duration`), with an ease-out curve.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A path drawing this arc, which keeps the arc with it (radii, angles, pad
|
|
15
|
+
* angle, corner radius): out of the markup, for the next render to sweep from.
|
|
16
|
+
*/
|
|
17
|
+
function arcNode(name, arc) {
|
|
18
|
+
const node = require_vnode.h("path", {
|
|
19
|
+
class: name,
|
|
20
|
+
d: require_arc.arcPathStable(arc)
|
|
21
|
+
});
|
|
22
|
+
node.arc = [
|
|
23
|
+
arc.innerRadius,
|
|
24
|
+
arc.outerRadius,
|
|
25
|
+
arc.startAngle,
|
|
26
|
+
arc.endAngle,
|
|
27
|
+
arc.padAngle ?? 0,
|
|
28
|
+
arc.cornerRadius ?? 0
|
|
29
|
+
];
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Take `el` from the arc of its last render, `prev`, to the arc of `next`.
|
|
34
|
+
* Returns the attributes left for the caller to patch (all but `d`, set
|
|
35
|
+
* here frame by frame), or nothing when there is no sweep: not an arc, the
|
|
36
|
+
* same path, no arc to come from, or a chart without transitions.
|
|
37
|
+
*/
|
|
38
|
+
function sweep(el, prev, next) {
|
|
39
|
+
const { arc, attrs } = next;
|
|
40
|
+
if (!arc || prev.attrs.d === attrs.d) return;
|
|
41
|
+
const origin = require_tween.stop(el) ?? prev.arc;
|
|
42
|
+
const duration = Number.parseFloat(getComputedStyle(el).transitionDuration) * 1e3;
|
|
43
|
+
if (!origin || !(duration > 0)) return;
|
|
44
|
+
require_tween.tween(el, origin, arc, duration, ([innerRadius, outerRadius, startAngle, endAngle, padAngle, cornerRadius]) => require_arc.arcPathStable({
|
|
45
|
+
innerRadius,
|
|
46
|
+
outerRadius,
|
|
47
|
+
startAngle,
|
|
48
|
+
endAngle,
|
|
49
|
+
padAngle,
|
|
50
|
+
cornerRadius
|
|
51
|
+
}), String(attrs.d));
|
|
52
|
+
return {
|
|
53
|
+
...attrs,
|
|
54
|
+
d: prev.attrs.d
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
Object.defineProperty(exports, "arcNode", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function() {
|
|
61
|
+
return arcNode;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "sweep", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function() {
|
|
67
|
+
return sweep;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=sweep-DaTEDDuC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep-DaTEDDuC.cjs","names":["h","arcPathStable","stop"],"sources":["../src/render/sweep.ts"],"sourcesContent":["/**\n * Arcs that turn to their new angles: a transition of `d` moves each point\n * of a path along a straight line, which bends a slice out of its ring on\n * the way. A path that knows which arc it draws (the `arc` of its node, see\n * `arcNode`) is redrawn frame by frame instead, with the angles and radii\n * in between, so slices grow and shrink around the center. Timed by the\n * path's `transition-duration` (`--tc-duration`), with an ease-out curve.\n */\n\nimport { type ArcOptions, arcPathStable } from '../shapes/arc.ts'\nimport { type Attrs, h, type VNode } from '../vnode.ts'\nimport { stop, tween } from './tween.ts'\n\n/**\n * A path drawing this arc, which keeps the arc with it (radii, angles, pad\n * angle, corner radius): out of the markup, for the next render to sweep from.\n */\nexport function arcNode(name: string, arc: ArcOptions): VNode {\n const node = h('path', { class: name, d: arcPathStable(arc) })\n node.arc = [\n arc.innerRadius,\n arc.outerRadius,\n arc.startAngle,\n arc.endAngle,\n arc.padAngle ?? 0,\n arc.cornerRadius ?? 0,\n ]\n return node\n}\n\n/**\n * Take `el` from the arc of its last render, `prev`, to the arc of `next`.\n * Returns the attributes left for the caller to patch (all but `d`, set\n * here frame by frame), or nothing when there is no sweep: not an arc, the\n * same path, no arc to come from, or a chart without transitions.\n */\nexport function sweep(el: Element, prev: VNode, next: VNode): Attrs | undefined {\n const { arc, attrs } = next\n if (!arc || prev.attrs.d === attrs.d) return\n // An interrupted sweep continues from where the arc is now.\n const origin = stop(el) ?? prev.arc\n // Zero in a chart without transitions (static, resizing, reduced motion).\n const duration = Number.parseFloat(getComputedStyle(el).transitionDuration) * 1000\n if (!origin || !(duration > 0)) return\n tween(\n el,\n origin,\n arc,\n duration,\n ([innerRadius, outerRadius, startAngle, endAngle, padAngle, cornerRadius]) =>\n arcPathStable({\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n padAngle,\n cornerRadius,\n } as ArcOptions),\n String(attrs.d),\n )\n return { ...attrs, d: prev.attrs.d as string }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAAc,KAAwB;CAC5D,MAAM,OAAOA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAM,GAAGC,YAAAA,cAAc,GAAG;CAAE,CAAC;CAC7D,KAAK,MAAM;EACT,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI,YAAY;EAChB,IAAI,gBAAgB;CACtB;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,IAAa,MAAa,MAAgC;CAC9E,MAAM,EAAE,KAAK,UAAU;CACvB,IAAI,CAAC,OAAO,KAAK,MAAM,MAAM,MAAM,GAAG;CAEtC,MAAM,SAASC,cAAAA,KAAK,EAAE,KAAK,KAAK;CAEhC,MAAM,WAAW,OAAO,WAAW,iBAAiB,EAAE,CAAC,CAAC,kBAAkB,IAAI;CAC9E,IAAI,CAAC,UAAU,EAAE,WAAW,IAAI;CAChC,cAAA,MACE,IACA,QACA,KACA,WACC,CAAC,aAAa,aAAa,YAAY,UAAU,UAAU,kBAC1DD,YAAAA,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;CACF,CAAe,GACjB,OAAO,MAAM,CAAC,CAChB;CACA,OAAO;EAAE,GAAG;EAAO,GAAG,KAAK,MAAM;CAAY;AAC/C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { n as BandScale, t as BandKey } from "./band-DTcNDAFO.js";
|
|
2
|
+
//#region src/format.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Number and date formatting built on `Intl` — locale aware, zero bytes of
|
|
5
|
+
* locale data shipped.
|
|
6
|
+
*
|
|
7
|
+
* Formats are plain data (`Intl` options) or functions, so chart configs stay
|
|
8
|
+
* serializable (JSON attributes, SSR). Pass an explicit `locale` when
|
|
9
|
+
* rendering on the server, otherwise server and browser may disagree.
|
|
10
|
+
*/
|
|
11
|
+
/** Locale(s) passed to `Intl`; `undefined` uses the runtime default. */
|
|
12
|
+
type Locale = string | readonly string[] | undefined;
|
|
13
|
+
/** `Intl.NumberFormat` options, plus suffixes of our own for compact notation. */
|
|
14
|
+
interface NumberFormatOptions extends Intl.NumberFormatOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Compact notation with these suffixes for thousands, millions, billions…
|
|
17
|
+
* instead of the locale's words: `['k', 'M', 'G']` writes 1500 as "1.5k",
|
|
18
|
+
* or "1,5k" in Polish, where the locale itself writes "1,5 tys.". `true`
|
|
19
|
+
* stands for `['K', 'M', 'B', 'T']`. Larger numbers keep the last suffix.
|
|
20
|
+
*/
|
|
21
|
+
compactSymbols?: boolean | readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** Number format options or a custom formatter. */
|
|
24
|
+
type NumberFormat = NumberFormatOptions | ((value: number) => string);
|
|
25
|
+
/** `Intl.DateTimeFormat` options or a custom formatter. */
|
|
26
|
+
type DateFormat = Intl.DateTimeFormatOptions | ((value: Date) => string);
|
|
27
|
+
/** Shared, cached `Intl.NumberFormat` instance. */
|
|
28
|
+
declare function getNumberFormat(locale?: Locale, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
29
|
+
/** Shared, cached `Intl.DateTimeFormat` instance. */
|
|
30
|
+
declare function getDateFormat(locale?: Locale, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
31
|
+
/**
|
|
32
|
+
* Create a number formatter.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* formatNumber({ style: 'currency', currency: 'PLN' }, 'pl-PL')(1234.5) // "1234,50 zł"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function formatNumber(format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
39
|
+
/**
|
|
40
|
+
* A formatter for values read one at a time (tooltips, data tables) in an
|
|
41
|
+
* axis format. Compact notation suits ticks ("$25K") but hides the
|
|
42
|
+
* difference between values: unless the format sets its own precision, it
|
|
43
|
+
* keeps three significant digits ("$24.8K").
|
|
44
|
+
*/
|
|
45
|
+
declare function formatDetail(format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Number of fraction digits needed to tell apart ticks `step` apart,
|
|
48
|
+
* e.g. `1 → 0`, `0.2 → 1`, `0.05 → 2`.
|
|
49
|
+
*/
|
|
50
|
+
declare function stepPrecision(step: number): number;
|
|
51
|
+
/**
|
|
52
|
+
* Create a formatter for axis ticks `step` apart. Unless `format` sets its
|
|
53
|
+
* own precision, every tick gets the same number of fraction digits, derived
|
|
54
|
+
* from the step (`0, 0.5, 1` → `0.0, 0.5, 1.0`).
|
|
55
|
+
*/
|
|
56
|
+
declare function formatTicks(step: number, format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Create a date formatter accepting `Date` objects or timestamps.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* formatDate({ month: 'short', day: 'numeric' }, 'en-US')(new Date(2026, 0, 5)) // "Jan 5"
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function formatDate(format?: DateFormat, locale?: Locale): (value: Date | number) => string;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/scales/time.d.ts
|
|
67
|
+
/** A point in time: a `Date` or a timestamp in milliseconds. */
|
|
68
|
+
type TimeValue = Date | number;
|
|
69
|
+
interface TimeScaleOptions {
|
|
70
|
+
/** Align ticks to UTC instead of local time (use it for SSR). Defaults to `false`. */
|
|
71
|
+
utc?: boolean;
|
|
72
|
+
/** Clamp output to the range. */
|
|
73
|
+
clamp?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** Continuous scale mapping time to a pixel range, with calendar-aware ticks. */
|
|
76
|
+
interface TimeScale {
|
|
77
|
+
(value: TimeValue): number;
|
|
78
|
+
readonly domain: readonly [number, number];
|
|
79
|
+
readonly range: readonly [number, number];
|
|
80
|
+
readonly utc: boolean;
|
|
81
|
+
/** Map a pixel back to a time. */
|
|
82
|
+
invert(pixel: number): Date;
|
|
83
|
+
/** Tick dates at calendar boundaries, roughly `count` of them. */
|
|
84
|
+
ticks(count?: number): Date[];
|
|
85
|
+
/** A formatter suited to the tick interval chosen for `count`. */
|
|
86
|
+
tickFormat(count?: number, locale?: Locale): (date: Date) => string;
|
|
87
|
+
/** A copy with the domain extended to tick boundaries. */
|
|
88
|
+
nice(count?: number): TimeScale;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a time scale over `[start, end]`.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* const x = time([new Date(2026, 0, 1), new Date(2026, 2, 31)], [0, 600])
|
|
95
|
+
* x.ticks() // first of each month, or every week, depending on the range
|
|
96
|
+
* x.tickFormat() // e.g. "Jan", "Feb"
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function time(domain: readonly [TimeValue, TimeValue], range: readonly [number, number], options?: TimeScaleOptions): TimeScale;
|
|
100
|
+
/**
|
|
101
|
+
* A point scale over time for category charts: each category sits at its
|
|
102
|
+
* real distance in time. Conforms to `BandScale` (zero bandwidth), so line
|
|
103
|
+
* and area charts and their hit testing work unchanged. `stamps` must be
|
|
104
|
+
* ascending; `keys` are the categories' keys.
|
|
105
|
+
*/
|
|
106
|
+
declare function timePointScale(stamps: readonly number[], keys: readonly BandKey[], range: readonly [number, number], utc: boolean): {
|
|
107
|
+
scale: BandScale;
|
|
108
|
+
time: TimeScale;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { timePointScale as a, NumberFormat as c, formatDetail as d, formatNumber as f, stepPrecision as g, getNumberFormat as h, time as i, NumberFormatOptions as l, getDateFormat as m, TimeScaleOptions as n, DateFormat as o, formatTicks as p, TimeValue as r, Locale as s, TimeScale as t, formatDate as u };
|
|
112
|
+
//# sourceMappingURL=time-CHjiY9Q4.d.ts.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { n as BandScale, t as BandKey } from "./band-DTcNDAFO.cjs";
|
|
2
|
+
//#region src/format.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Number and date formatting built on `Intl` — locale aware, zero bytes of
|
|
5
|
+
* locale data shipped.
|
|
6
|
+
*
|
|
7
|
+
* Formats are plain data (`Intl` options) or functions, so chart configs stay
|
|
8
|
+
* serializable (JSON attributes, SSR). Pass an explicit `locale` when
|
|
9
|
+
* rendering on the server, otherwise server and browser may disagree.
|
|
10
|
+
*/
|
|
11
|
+
/** Locale(s) passed to `Intl`; `undefined` uses the runtime default. */
|
|
12
|
+
type Locale = string | readonly string[] | undefined;
|
|
13
|
+
/** `Intl.NumberFormat` options, plus suffixes of our own for compact notation. */
|
|
14
|
+
interface NumberFormatOptions extends Intl.NumberFormatOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Compact notation with these suffixes for thousands, millions, billions…
|
|
17
|
+
* instead of the locale's words: `['k', 'M', 'G']` writes 1500 as "1.5k",
|
|
18
|
+
* or "1,5k" in Polish, where the locale itself writes "1,5 tys.". `true`
|
|
19
|
+
* stands for `['K', 'M', 'B', 'T']`. Larger numbers keep the last suffix.
|
|
20
|
+
*/
|
|
21
|
+
compactSymbols?: boolean | readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** Number format options or a custom formatter. */
|
|
24
|
+
type NumberFormat = NumberFormatOptions | ((value: number) => string);
|
|
25
|
+
/** `Intl.DateTimeFormat` options or a custom formatter. */
|
|
26
|
+
type DateFormat = Intl.DateTimeFormatOptions | ((value: Date) => string);
|
|
27
|
+
/** Shared, cached `Intl.NumberFormat` instance. */
|
|
28
|
+
declare function getNumberFormat(locale?: Locale, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
29
|
+
/** Shared, cached `Intl.DateTimeFormat` instance. */
|
|
30
|
+
declare function getDateFormat(locale?: Locale, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
31
|
+
/**
|
|
32
|
+
* Create a number formatter.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* formatNumber({ style: 'currency', currency: 'PLN' }, 'pl-PL')(1234.5) // "1234,50 zł"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function formatNumber(format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
39
|
+
/**
|
|
40
|
+
* A formatter for values read one at a time (tooltips, data tables) in an
|
|
41
|
+
* axis format. Compact notation suits ticks ("$25K") but hides the
|
|
42
|
+
* difference between values: unless the format sets its own precision, it
|
|
43
|
+
* keeps three significant digits ("$24.8K").
|
|
44
|
+
*/
|
|
45
|
+
declare function formatDetail(format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Number of fraction digits needed to tell apart ticks `step` apart,
|
|
48
|
+
* e.g. `1 → 0`, `0.2 → 1`, `0.05 → 2`.
|
|
49
|
+
*/
|
|
50
|
+
declare function stepPrecision(step: number): number;
|
|
51
|
+
/**
|
|
52
|
+
* Create a formatter for axis ticks `step` apart. Unless `format` sets its
|
|
53
|
+
* own precision, every tick gets the same number of fraction digits, derived
|
|
54
|
+
* from the step (`0, 0.5, 1` → `0.0, 0.5, 1.0`).
|
|
55
|
+
*/
|
|
56
|
+
declare function formatTicks(step: number, format?: NumberFormat, locale?: Locale): (value: number) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Create a date formatter accepting `Date` objects or timestamps.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* formatDate({ month: 'short', day: 'numeric' }, 'en-US')(new Date(2026, 0, 5)) // "Jan 5"
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function formatDate(format?: DateFormat, locale?: Locale): (value: Date | number) => string;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/scales/time.d.ts
|
|
67
|
+
/** A point in time: a `Date` or a timestamp in milliseconds. */
|
|
68
|
+
type TimeValue = Date | number;
|
|
69
|
+
interface TimeScaleOptions {
|
|
70
|
+
/** Align ticks to UTC instead of local time (use it for SSR). Defaults to `false`. */
|
|
71
|
+
utc?: boolean;
|
|
72
|
+
/** Clamp output to the range. */
|
|
73
|
+
clamp?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** Continuous scale mapping time to a pixel range, with calendar-aware ticks. */
|
|
76
|
+
interface TimeScale {
|
|
77
|
+
(value: TimeValue): number;
|
|
78
|
+
readonly domain: readonly [number, number];
|
|
79
|
+
readonly range: readonly [number, number];
|
|
80
|
+
readonly utc: boolean;
|
|
81
|
+
/** Map a pixel back to a time. */
|
|
82
|
+
invert(pixel: number): Date;
|
|
83
|
+
/** Tick dates at calendar boundaries, roughly `count` of them. */
|
|
84
|
+
ticks(count?: number): Date[];
|
|
85
|
+
/** A formatter suited to the tick interval chosen for `count`. */
|
|
86
|
+
tickFormat(count?: number, locale?: Locale): (date: Date) => string;
|
|
87
|
+
/** A copy with the domain extended to tick boundaries. */
|
|
88
|
+
nice(count?: number): TimeScale;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a time scale over `[start, end]`.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* const x = time([new Date(2026, 0, 1), new Date(2026, 2, 31)], [0, 600])
|
|
95
|
+
* x.ticks() // first of each month, or every week, depending on the range
|
|
96
|
+
* x.tickFormat() // e.g. "Jan", "Feb"
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function time(domain: readonly [TimeValue, TimeValue], range: readonly [number, number], options?: TimeScaleOptions): TimeScale;
|
|
100
|
+
/**
|
|
101
|
+
* A point scale over time for category charts: each category sits at its
|
|
102
|
+
* real distance in time. Conforms to `BandScale` (zero bandwidth), so line
|
|
103
|
+
* and area charts and their hit testing work unchanged. `stamps` must be
|
|
104
|
+
* ascending; `keys` are the categories' keys.
|
|
105
|
+
*/
|
|
106
|
+
declare function timePointScale(stamps: readonly number[], keys: readonly BandKey[], range: readonly [number, number], utc: boolean): {
|
|
107
|
+
scale: BandScale;
|
|
108
|
+
time: TimeScale;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { timePointScale as a, NumberFormat as c, formatDetail as d, formatNumber as f, stepPrecision as g, getNumberFormat as h, time as i, NumberFormatOptions as l, getDateFormat as m, TimeScaleOptions as n, DateFormat as o, formatTicks as p, TimeValue as r, Locale as s, TimeScale as t, formatDate as u };
|
|
112
|
+
//# sourceMappingURL=time-CNVnt-B2.d.cts.map
|