@tabler/charts 0.0.0-stage → 0.0.1-alpha.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 +248 -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/area-BFvkc-ZM.d.cts +20 -0
- package/dist/area-DQsLERhx.js +26 -0
- package/dist/area-DQsLERhx.js.map +1 -0
- package/dist/area-DaO4MQl4.d.ts +20 -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-C-7zR2qp.cjs +243 -0
- package/dist/bar-C-7zR2qp.cjs.map +1 -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-DdsDxk3W.d.ts +43 -0
- package/dist/bar-a0h9KC8A.d.cts +43 -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-BKdPyorY.d.cts +44 -0
- package/dist/candlestick-BnUG1SGi.d.ts +44 -0
- package/dist/candlestick-DuXwAFID.js +145 -0
- package/dist/candlestick-DuXwAFID.js.map +1 -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-Qa417fJo.d.cts +927 -0
- package/dist/chart-iJGxMz9z.d.ts +927 -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-C7fPm6t7.cjs +976 -0
- package/dist/core-C7fPm6t7.cjs.map +1 -0
- package/dist/core-CjgbhS_v.d.ts +219 -0
- package/dist/core-CnGFKojH.d.cts +219 -0
- package/dist/core-plobgBC7.js +875 -0
- package/dist/core-plobgBC7.js.map +1 -0
- package/dist/core.cjs +113 -0
- package/dist/core.d.cts +20 -0
- package/dist/core.d.ts +20 -0
- package/dist/core.js +24 -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-CEfkWXSu.cjs +235 -0
- package/dist/gauge-CEfkWXSu.cjs.map +1 -0
- package/dist/gauge-Cu9jttC0.d.ts +65 -0
- package/dist/gauge-Cu_OFxBd.d.cts +65 -0
- package/dist/gauge-_ljQHrMN.js +230 -0
- package/dist/gauge-_ljQHrMN.js.map +1 -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-BwS-y0c6.d.cts +81 -0
- package/dist/heatmap-DSZ2bVIa.js +242 -0
- package/dist/heatmap-DSZ2bVIa.js.map +1 -0
- package/dist/heatmap-PhLPXIg1.d.ts +81 -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 +211 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +113 -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-CMDGH6q5.d.cts +47 -0
- package/dist/line-D5kb8e6w.d.ts +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/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-B8UlOZiq.d.ts +58 -0
- package/dist/pie-C1Pa6W_l.cjs +211 -0
- package/dist/pie-C1Pa6W_l.cjs.map +1 -0
- package/dist/pie-DnQQmxkk.d.cts +58 -0
- package/dist/pie-RnMTQWMS.js +200 -0
- package/dist/pie-RnMTQWMS.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-BB13CGmq.d.cts +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-pFI6fvOq.d.ts +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-B9JYnx7e.d.cts +67 -0
- package/dist/sankey-Bacx4fVe.cjs +425 -0
- package/dist/sankey-Bacx4fVe.cjs.map +1 -0
- package/dist/sankey-Bm518bqL.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-Bl7nasE6.d.ts +61 -0
- package/dist/scatter-DgMN9zRy.cjs +250 -0
- package/dist/scatter-DgMN9zRy.cjs.map +1 -0
- package/dist/scatter-DrJ8xYz4.d.cts +61 -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-BG13V4Pz.d.cts +43 -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-iWuXbKpd.d.ts +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-Duowaput.cjs +369 -0
- package/dist/sweep-Duowaput.cjs.map +1 -0
- package/dist/sweep-WSgn2etB.js +334 -0
- package/dist/sweep-WSgn2etB.js.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 +310 -3
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
const require_layout = require("./layout-CtMBhNd9.cjs");
|
|
2
|
+
const require_vnode = require("./vnode-CkQ27Cxe.cjs");
|
|
3
|
+
const require_cartesian = require("./cartesian-BoDfgBCV.cjs");
|
|
4
|
+
const require_clean = require("./clean-Byl6kzf0.cjs");
|
|
5
|
+
//#region src/charts/annotations.ts
|
|
6
|
+
/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */
|
|
7
|
+
function categorySpan(scales, label) {
|
|
8
|
+
if (scales.time) {
|
|
9
|
+
const p = scales.time(new Date(require_cartesian.toMs(label)));
|
|
10
|
+
return Number.isFinite(p) ? [p, p] : void 0;
|
|
11
|
+
}
|
|
12
|
+
const i = scales.keys.indexOf(require_cartesian.labelKey(label));
|
|
13
|
+
return i < 0 ? void 0 : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth];
|
|
14
|
+
}
|
|
15
|
+
/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */
|
|
16
|
+
const span = (v, f) => {
|
|
17
|
+
if (!Array.isArray(v)) return f(v);
|
|
18
|
+
const pair = v.map(f);
|
|
19
|
+
return pair.length === 2 && !pair.includes(null) ? pair : null;
|
|
20
|
+
};
|
|
21
|
+
/** Annotations from outside: lines or bands at finite values or labels, with text labels. */
|
|
22
|
+
const cleanAnnotations = (v) => v === void 0 ? v : require_clean.records(v, (a) => ({
|
|
23
|
+
...a,
|
|
24
|
+
y: a.y === void 0 ? a.y : span(a.y, require_clean.finite),
|
|
25
|
+
x: a.x === void 0 ? a.x : span(a.x, require_clean.label),
|
|
26
|
+
label: a.label == null ? void 0 : require_clean.text(a.label),
|
|
27
|
+
color: typeof a.color === "string" ? a.color : void 0
|
|
28
|
+
})).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== void 0);
|
|
29
|
+
const isPair = (v) => Array.isArray(v);
|
|
30
|
+
/** Values the value axis should include so every annotation shows. */
|
|
31
|
+
function annotationValues(annotations) {
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const a of cleanAnnotations(annotations) ?? []) {
|
|
34
|
+
if (a.y === void 0) continue;
|
|
35
|
+
for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Annotation layers: bands go below the series, lines and labels above
|
|
41
|
+
* them. Annotations outside the plot area are skipped.
|
|
42
|
+
*/
|
|
43
|
+
function annotationLayers(annotations, scales) {
|
|
44
|
+
annotations = cleanAnnotations(annotations);
|
|
45
|
+
if (!annotations?.length) return {
|
|
46
|
+
under: null,
|
|
47
|
+
over: null
|
|
48
|
+
};
|
|
49
|
+
const { area, horizontal, fontSize } = scales;
|
|
50
|
+
const bands = [];
|
|
51
|
+
const lines = [];
|
|
52
|
+
const x0 = area.x;
|
|
53
|
+
const x1 = area.x + area.width;
|
|
54
|
+
const y0 = area.y;
|
|
55
|
+
const y1 = area.y + area.height;
|
|
56
|
+
const inside = (p, lo, hi) => p >= lo - .5 && p <= hi + .5;
|
|
57
|
+
const pad = 4;
|
|
58
|
+
/**
|
|
59
|
+
* Where an annotation lands: the pixel span it covers within the plot, and
|
|
60
|
+
* whether it runs across x (a vertical line); `undefined` when it is off
|
|
61
|
+
* the plot or names nothing on the axes.
|
|
62
|
+
*/
|
|
63
|
+
const geometry = (a) => {
|
|
64
|
+
let span;
|
|
65
|
+
let vertical;
|
|
66
|
+
if (a.y !== void 0) {
|
|
67
|
+
const [from, to] = isPair(a.y) ? a.y : [a.y, a.y];
|
|
68
|
+
if (!Number.isFinite(from) || !Number.isFinite(to)) return void 0;
|
|
69
|
+
span = [scales.value(from), scales.value(to)];
|
|
70
|
+
vertical = horizontal;
|
|
71
|
+
} else if (a.x !== void 0) {
|
|
72
|
+
const [from, to] = isPair(a.x) ? a.x : [a.x, a.x];
|
|
73
|
+
const start = categorySpan(scales, from);
|
|
74
|
+
const stop = categorySpan(scales, to);
|
|
75
|
+
if (!start || !stop) return void 0;
|
|
76
|
+
span = isPair(a.x) ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])] : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2];
|
|
77
|
+
vertical = !horizontal;
|
|
78
|
+
} else return;
|
|
79
|
+
const lo = Math.min(span[0], span[1]);
|
|
80
|
+
const hi = Math.max(span[0], span[1]);
|
|
81
|
+
const [min, max] = vertical ? [x0, x1] : [y0, y1];
|
|
82
|
+
if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return void 0;
|
|
83
|
+
return {
|
|
84
|
+
a0: Math.max(lo, min),
|
|
85
|
+
a1: Math.min(hi, max),
|
|
86
|
+
vertical
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const shapes = annotations.map(geometry);
|
|
90
|
+
/** Boxes labels keep clear of: the labels placed so far, and every line. */
|
|
91
|
+
const placed = [];
|
|
92
|
+
const obstacles = [];
|
|
93
|
+
shapes.forEach((g, i) => {
|
|
94
|
+
if (!g || g.a1 - g.a0 > .5) return;
|
|
95
|
+
const at = g.a0;
|
|
96
|
+
obstacles.push([i, g.vertical ? [
|
|
97
|
+
at - 1.5,
|
|
98
|
+
y0,
|
|
99
|
+
at + 1.5,
|
|
100
|
+
y1
|
|
101
|
+
] : [
|
|
102
|
+
x0,
|
|
103
|
+
at - 1.5,
|
|
104
|
+
x1,
|
|
105
|
+
at + 1.5
|
|
106
|
+
]]);
|
|
107
|
+
});
|
|
108
|
+
const apart = (box, [l, t, r, b]) => box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b;
|
|
109
|
+
const clearOfLabels = (box) => placed.every((p) => apart(box, p));
|
|
110
|
+
const clear = (box, own) => clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l));
|
|
111
|
+
annotations.forEach((a, index) => {
|
|
112
|
+
const key = a.id ?? index;
|
|
113
|
+
const attrs = (part) => ({
|
|
114
|
+
key: part ? `${key}-${part}` : key,
|
|
115
|
+
class: [
|
|
116
|
+
"tc-annotation",
|
|
117
|
+
a.y !== void 0 ? "tc-annotation-y" : "tc-annotation-x",
|
|
118
|
+
a.class
|
|
119
|
+
],
|
|
120
|
+
style: { "--tc-annotation-color": a.color }
|
|
121
|
+
});
|
|
122
|
+
const end = a.position !== "start";
|
|
123
|
+
const shape = shapes[index];
|
|
124
|
+
if (!shape) return;
|
|
125
|
+
const { a0, a1, vertical } = shape;
|
|
126
|
+
let label;
|
|
127
|
+
if (a.label) {
|
|
128
|
+
const w = require_layout.estimateTextWidth(a.label, fontSize * .92);
|
|
129
|
+
const line = a1 - a0 <= .5;
|
|
130
|
+
const spots = [];
|
|
131
|
+
if (vertical) {
|
|
132
|
+
const after = a0 + pad;
|
|
133
|
+
const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w);
|
|
134
|
+
const sides = after + w <= x1 ? [after, before] : [before, after];
|
|
135
|
+
const top = end ? y0 + fontSize : y1 - pad;
|
|
136
|
+
const step = (end ? 1 : -1) * fontSize * 1.2;
|
|
137
|
+
for (const x of sides) {
|
|
138
|
+
if (x < x0 || x + w > x1) continue;
|
|
139
|
+
for (let k = 0; k < 3; k++) spots.push([x, top + k * step]);
|
|
140
|
+
}
|
|
141
|
+
if (!spots.length) spots.push([Math.max(x0 + pad, sides[0]), top]);
|
|
142
|
+
} else {
|
|
143
|
+
const near = end ? x1 - pad - w : x0 + pad;
|
|
144
|
+
const far = end ? x0 + pad : x1 - pad - w;
|
|
145
|
+
for (const x of [near, far]) if (line) spots.push([x, a0 - pad], [x, a0 + fontSize]);
|
|
146
|
+
else spots.push([x, a0 + fontSize], [x, a1 - pad]);
|
|
147
|
+
}
|
|
148
|
+
const box = ([x, y]) => [
|
|
149
|
+
x,
|
|
150
|
+
y - fontSize,
|
|
151
|
+
x + w,
|
|
152
|
+
y + fontSize * .25
|
|
153
|
+
];
|
|
154
|
+
const spot = spots.find((s) => clear(box(s), index)) ?? spots.find((s) => clearOfLabels(box(s))) ?? spots[0];
|
|
155
|
+
placed.push(box(spot));
|
|
156
|
+
label = require_vnode.h("text", {
|
|
157
|
+
class: "tc-annotation-label",
|
|
158
|
+
x: require_layout.round(spot[0]),
|
|
159
|
+
y: require_layout.round(spot[1])
|
|
160
|
+
}, a.label);
|
|
161
|
+
}
|
|
162
|
+
if (a1 - a0 > .5) {
|
|
163
|
+
const d = vertical ? `M${require_layout.round(a0)},${require_layout.round(y0)}H${require_layout.round(a1)}V${require_layout.round(y1)}H${require_layout.round(a0)}Z` : `M${require_layout.round(x0)},${require_layout.round(a0)}H${require_layout.round(x1)}V${require_layout.round(a1)}H${require_layout.round(x0)}Z`;
|
|
164
|
+
bands.push(require_vnode.h("g", attrs(), require_vnode.h("path", {
|
|
165
|
+
class: "tc-annotation-band",
|
|
166
|
+
d
|
|
167
|
+
})));
|
|
168
|
+
if (label) lines.push(require_vnode.h("g", attrs("label"), label));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const at = require_layout.round(a0);
|
|
172
|
+
lines.push(require_vnode.h("g", attrs(), require_vnode.h("line", vertical ? {
|
|
173
|
+
class: "tc-annotation-line",
|
|
174
|
+
x1: at,
|
|
175
|
+
x2: at,
|
|
176
|
+
y1: require_layout.round(y0),
|
|
177
|
+
y2: require_layout.round(y1)
|
|
178
|
+
} : {
|
|
179
|
+
class: "tc-annotation-line",
|
|
180
|
+
x1: require_layout.round(x0),
|
|
181
|
+
x2: require_layout.round(x1),
|
|
182
|
+
y1: at,
|
|
183
|
+
y2: at
|
|
184
|
+
}), label));
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
under: bands.length ? require_vnode.h("g", {
|
|
188
|
+
key: "annotations-under",
|
|
189
|
+
class: "tc-annotations",
|
|
190
|
+
"aria-hidden": "true"
|
|
191
|
+
}, bands) : null,
|
|
192
|
+
over: lines.length ? require_vnode.h("g", {
|
|
193
|
+
key: "annotations-over",
|
|
194
|
+
class: "tc-annotations",
|
|
195
|
+
"aria-hidden": "true"
|
|
196
|
+
}, lines) : null
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
Object.defineProperty(exports, "annotationLayers", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function() {
|
|
203
|
+
return annotationLayers;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, "annotationValues", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function() {
|
|
209
|
+
return annotationValues;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
//# sourceMappingURL=annotations-DpETO8dE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations-DpETO8dE.cjs","names":["toMs","labelKey","records","finite","label","text","estimateTextWidth","h","round"],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n const shapes = annotations.map(geometry)\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: ['tc-annotation', a.y !== undefined ? 'tc-annotation-y' : 'tc-annotation-x', a.class],\n style: { '--tc-annotation-color': a.color },\n })\n const end = a.position !== 'start'\n\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode | false | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAKA,kBAAAA,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAA;CACvC;CACA,MAAM,IAAI,OAAO,KAAK,QAAQC,kBAAAA,SAAS,KAAK,CAAC;CAC7C,OAAO,IAAI,IAAI,KAAA,IAAY,CAAC,OAAO,KAAK,GAAG,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,IAAI,OAAO,KAAK,SAAS;AAC1F;;AAGA,MAAM,QAAW,GAAY,MAAyD;CACpF,IAAI,CAAC,MAAM,QAAQ,CAAC,GAAG,OAAO,EAAE,CAAC;CACjC,MAAM,OAAO,EAAE,IAAI,C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J,MAAM,MAAM,SACRA,cAAAA,EAAE,KAAK;GAAE,KAAK;GAAoB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { n as BandScale, t as BandKey } from "./band-DTcNDAFO.cjs";
|
|
2
|
+
import { a as ClassValue, l as VNode } from "./vnode-BUflsBsa.cjs";
|
|
3
|
+
//#region src/layout.d.ts
|
|
4
|
+
/** Axis-aligned rectangle in pixels. */
|
|
5
|
+
interface Rect {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
/** Space around a box, in pixels. */
|
|
12
|
+
interface Insets {
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
left: number;
|
|
17
|
+
}
|
|
18
|
+
/** Insets given as one number for all sides or per side. */
|
|
19
|
+
type InsetsInput = number | Partial<Insets>;
|
|
20
|
+
/** Normalize an {@link InsetsInput}; missing sides fall back to `fallback`. */
|
|
21
|
+
declare function insets(value: InsetsInput | undefined, fallback?: number): Insets;
|
|
22
|
+
/** Rectangle left inside `width × height` after `margins`; never negative. */
|
|
23
|
+
declare function innerRect(width: number, height: number, margins: Insets): Rect;
|
|
24
|
+
/**
|
|
25
|
+
* Estimate the rendered width of `text` without a DOM, for layout on the
|
|
26
|
+
* server and in workers. Tuned for common UI sans-serif fonts; deterministic,
|
|
27
|
+
* so SSR and client layouts agree.
|
|
28
|
+
*/
|
|
29
|
+
declare function estimateTextWidth(text: string, fontSize: number): number;
|
|
30
|
+
/** Line height used for single-line labels, relative to the font size. */
|
|
31
|
+
declare const LINE_HEIGHT = 1.25;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/charts/annotations.d.ts
|
|
34
|
+
/** A category label, a number, or a date (on a time axis). */
|
|
35
|
+
type AnnotationLabel = string | number | Date;
|
|
36
|
+
/**
|
|
37
|
+
* A reference line or band drawn with the series: a target on the value
|
|
38
|
+
* axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category
|
|
39
|
+
* axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).
|
|
40
|
+
*/
|
|
41
|
+
interface Annotation {
|
|
42
|
+
/** A line at a value, or a band between two values, on the value axis. */
|
|
43
|
+
y?: number | readonly [number, number];
|
|
44
|
+
/** A line at a category (or a date on a time axis), or a band between two, on the category axis. */
|
|
45
|
+
x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel];
|
|
46
|
+
/** Short text next to the line or inside the band. */
|
|
47
|
+
label?: string;
|
|
48
|
+
/** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */
|
|
49
|
+
position?: "start" | "end";
|
|
50
|
+
/**
|
|
51
|
+
* Any CSS color; sets `--tc-annotation-color`.
|
|
52
|
+
* Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.
|
|
53
|
+
*/
|
|
54
|
+
color?: string;
|
|
55
|
+
/** Extra classes on the annotation group. */
|
|
56
|
+
class?: ClassValue;
|
|
57
|
+
/** Stable identity for keyed updates. Defaults to the position in the list. */
|
|
58
|
+
id?: string;
|
|
59
|
+
}
|
|
60
|
+
/** How the layout maps data to pixels for annotations. */
|
|
61
|
+
interface AnnotationScales {
|
|
62
|
+
area: Rect;
|
|
63
|
+
/** Whether categories run along y (horizontal bars). */
|
|
64
|
+
horizontal: boolean;
|
|
65
|
+
fontSize: number;
|
|
66
|
+
/** Pixel position of a value along the value axis. */
|
|
67
|
+
value: (v: number) => number;
|
|
68
|
+
/** The category scale, and the keys of its categories in order. */
|
|
69
|
+
band: BandScale;
|
|
70
|
+
keys: readonly BandKey[];
|
|
71
|
+
/** Pixel position of a date, when the category axis is a time axis. */
|
|
72
|
+
time?: ((date: Date) => number) | undefined;
|
|
73
|
+
}
|
|
74
|
+
/** Values the value axis should include so every annotation shows. */
|
|
75
|
+
declare function annotationValues(annotations: readonly Annotation[] | undefined): number[];
|
|
76
|
+
/**
|
|
77
|
+
* Annotation layers: bands go below the series, lines and labels above
|
|
78
|
+
* them. Annotations outside the plot area are skipped.
|
|
79
|
+
*/
|
|
80
|
+
declare function annotationLayers(annotations: readonly Annotation[] | undefined, scales: AnnotationScales): {
|
|
81
|
+
under: VNode | null;
|
|
82
|
+
over: VNode | null;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { InsetsInput as a, estimateTextWidth as c, Insets as i, innerRect as l, annotationLayers as n, LINE_HEIGHT as o, annotationValues as r, Rect as s, Annotation as t, insets as u };
|
|
86
|
+
//# sourceMappingURL=annotations-lyt0I3HU.d.cts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_features = require("./features-BclHgg2W.cjs");
|
|
3
|
+
const require_annotations = require("./annotations-DpETO8dE.cjs");
|
|
4
|
+
//#region src/annotations.ts
|
|
5
|
+
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
6
|
+
require_features.register({ annotations: {
|
|
7
|
+
layers: require_annotations.annotationLayers,
|
|
8
|
+
values: require_annotations.annotationValues
|
|
9
|
+
} });
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.annotationLayers = require_annotations.annotationLayers;
|
|
12
|
+
exports.annotationValues = require_annotations.annotationValues;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=annotations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.cjs","names":["register","annotationLayers","annotationValues"],"sources":["../src/annotations.ts"],"sourcesContent":["/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */\nimport { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport { register } from './features.ts'\n\nregister({ annotations: { layers: annotationLayers, values: annotationValues } })\n\nexport type { Annotation } from './charts/annotations.ts'\nexport { annotationLayers, annotationValues }\n"],"mappings":";;;;;AAIAA,iBAAAA,SAAS,EAAE,aAAa;CAAE,QAAQC,oBAAAA;CAAkB,QAAQC,oBAAAA;AAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { i as register } from "./features-wASyHGic.js";
|
|
2
|
+
import { n as annotationValues, t as annotationLayers } from "./annotations-BszTTjf9.js";
|
|
3
|
+
//#region src/annotations.ts
|
|
4
|
+
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
5
|
+
register({ annotations: {
|
|
6
|
+
layers: annotationLayers,
|
|
7
|
+
values: annotationValues
|
|
8
|
+
} });
|
|
9
|
+
//#endregion
|
|
10
|
+
export { annotationLayers, annotationValues };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","names":[],"sources":["../src/annotations.ts"],"sourcesContent":["/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */\nimport { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport { register } from './features.ts'\n\nregister({ annotations: { layers: annotationLayers, values: annotationValues } })\n\nexport type { Annotation } from './charts/annotations.ts'\nexport { annotationLayers, annotationValues }\n"],"mappings":";;;;AAIA,SAAS,EAAE,aAAa;CAAE,QAAQ;CAAkB,QAAQ;AAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { a as ChartType } from "./chart-Qa417fJo.cjs";
|
|
2
|
+
import { t as LineOptions } from "./line-CMDGH6q5.cjs";
|
|
3
|
+
//#region src/charts/area.d.ts
|
|
4
|
+
/** Options of the area chart: line options with the fill always on. */
|
|
5
|
+
type AreaOptions = Omit<LineOptions, "area">;
|
|
6
|
+
/**
|
|
7
|
+
* Area chart: filled lines over category labels, with zero in the y domain
|
|
8
|
+
* by default and a vertical fade (`fill: 'gradient'`).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* new Chart('#el', {
|
|
12
|
+
* type: area,
|
|
13
|
+
* data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const area: ChartType<AreaOptions>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { area as n, AreaOptions as t };
|
|
20
|
+
//# sourceMappingURL=area-BFvkc-ZM.d.cts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { m as seriesTable, p as seriesLegend } from "./cartesian-Cr0AF0nG.js";
|
|
2
|
+
import { r as cleanSeries, t as cleanData } from "./clean-o1vDEhFV.js";
|
|
3
|
+
import { n as renderLines } from "./line-B3Ed6u7j.js";
|
|
4
|
+
//#region src/charts/area.ts
|
|
5
|
+
/**
|
|
6
|
+
* Area chart: filled lines over category labels, with zero in the y domain
|
|
7
|
+
* by default and a vertical fade (`fill: 'gradient'`).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* new Chart('#el', {
|
|
11
|
+
* type: area,
|
|
12
|
+
* data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
const area = {
|
|
17
|
+
name: "area",
|
|
18
|
+
clean: cleanData(cleanSeries),
|
|
19
|
+
render: (options, ctx) => renderLines(options, ctx, true),
|
|
20
|
+
legend: (options) => seriesLegend(options.data),
|
|
21
|
+
table: (options, ctx, limit) => seriesTable(options, ctx, limit)
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { area as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=area-DQsLERhx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area-DQsLERhx.js","names":[],"sources":["../src/charts/area.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport { seriesLegend, seriesTable } from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\nimport { type LineOptions, renderLines } from './line.ts'\n\n/** Options of the area chart: line options with the fill always on. */\nexport type AreaOptions = Omit<LineOptions, 'area'>\n\n/**\n * Area chart: filled lines over category labels, with zero in the y domain\n * by default and a vertical fade (`fill: 'gradient'`).\n *\n * ```ts\n * new Chart('#el', {\n * type: area,\n * data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },\n * })\n * ```\n */\nexport const area: ChartType<AreaOptions> = {\n name: 'area',\n clean: cleanData(cleanSeries),\n render: (options, ctx) => renderLines(options, ctx, true),\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) => seriesTable(options, ctx, limit),\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,OAA+B;CAC1C,MAAM;CACN,OAAO,UAAU,WAAW;CAC5B,SAAS,SAAS,QAAQ,YAAY,SAAS,KAAK,IAAI;CACxD,SAAS,YAAY,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UAAU,YAAY,SAAS,KAAK,KAAK;AACjE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { a as ChartType } from "./chart-iJGxMz9z.js";
|
|
2
|
+
import { t as LineOptions } from "./line-D5kb8e6w.js";
|
|
3
|
+
//#region src/charts/area.d.ts
|
|
4
|
+
/** Options of the area chart: line options with the fill always on. */
|
|
5
|
+
type AreaOptions = Omit<LineOptions, "area">;
|
|
6
|
+
/**
|
|
7
|
+
* Area chart: filled lines over category labels, with zero in the y domain
|
|
8
|
+
* by default and a vertical fade (`fill: 'gradient'`).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* new Chart('#el', {
|
|
12
|
+
* type: area,
|
|
13
|
+
* data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const area: ChartType<AreaOptions>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { area as n, AreaOptions as t };
|
|
20
|
+
//# sourceMappingURL=area-DaO4MQl4.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_cartesian = require("./cartesian-BoDfgBCV.cjs");
|
|
2
|
+
const require_clean = require("./clean-Byl6kzf0.cjs");
|
|
3
|
+
const require_line = require("./line-fQbtP_jL.cjs");
|
|
4
|
+
//#region src/charts/area.ts
|
|
5
|
+
/**
|
|
6
|
+
* Area chart: filled lines over category labels, with zero in the y domain
|
|
7
|
+
* by default and a vertical fade (`fill: 'gradient'`).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* new Chart('#el', {
|
|
11
|
+
* type: area,
|
|
12
|
+
* data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
const area = {
|
|
17
|
+
name: "area",
|
|
18
|
+
clean: require_clean.cleanData(require_clean.cleanSeries),
|
|
19
|
+
render: (options, ctx) => require_line.renderLines(options, ctx, true),
|
|
20
|
+
legend: (options) => require_cartesian.seriesLegend(options.data),
|
|
21
|
+
table: (options, ctx, limit) => require_cartesian.seriesTable(options, ctx, limit)
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
Object.defineProperty(exports, "area", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return area;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=area-sHCE3pg5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area-sHCE3pg5.cjs","names":["cleanData","cleanSeries","renderLines","seriesLegend","seriesTable"],"sources":["../src/charts/area.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport { seriesLegend, seriesTable } from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\nimport { type LineOptions, renderLines } from './line.ts'\n\n/** Options of the area chart: line options with the fill always on. */\nexport type AreaOptions = Omit<LineOptions, 'area'>\n\n/**\n * Area chart: filled lines over category labels, with zero in the y domain\n * by default and a vertical fade (`fill: 'gradient'`).\n *\n * ```ts\n * new Chart('#el', {\n * type: area,\n * data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },\n * })\n * ```\n */\nexport const area: ChartType<AreaOptions> = {\n name: 'area',\n clean: cleanData(cleanSeries),\n render: (options, ctx) => renderLines(options, ctx, true),\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) => seriesTable(options, ctx, limit),\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,OAA+B;CAC1C,MAAM;CACN,OAAOA,cAAAA,UAAUC,cAAAA,WAAW;CAC5B,SAAS,SAAS,QAAQC,aAAAA,YAAY,SAAS,KAAK,IAAI;CACxD,SAAS,YAAYC,kBAAAA,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UAAUC,kBAAAA,YAAY,SAAS,KAAK,KAAK;AACjE"}
|
package/dist/area.cjs
ADDED
package/dist/area.d.cts
ADDED
package/dist/area.d.ts
ADDED
package/dist/area.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/scales/band.d.ts
|
|
2
|
+
/** Category identifier used by band and point scales. */
|
|
3
|
+
type BandKey = string | number;
|
|
4
|
+
interface BandScaleOptions {
|
|
5
|
+
/** Share of each step left empty between bands, `0…1`. Defaults to `0`. */
|
|
6
|
+
paddingInner?: number;
|
|
7
|
+
/** Space before the first and after the last band, in steps. Defaults to `0`. */
|
|
8
|
+
paddingOuter?: number;
|
|
9
|
+
/** Where leftover space goes: `0` start, `0.5` center, `1` end. Defaults to `0.5`. */
|
|
10
|
+
align?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Discrete scale splitting a range into equal bands, one per category. */
|
|
13
|
+
interface BandScale {
|
|
14
|
+
/** Start of the band for `key`, or `undefined` for unknown keys. */
|
|
15
|
+
(key: BandKey): number | undefined;
|
|
16
|
+
readonly domain: readonly BandKey[];
|
|
17
|
+
readonly range: readonly [number, number];
|
|
18
|
+
/** Width of a single band. */
|
|
19
|
+
readonly bandwidth: number;
|
|
20
|
+
/** Distance between the starts of adjacent bands. */
|
|
21
|
+
readonly step: number;
|
|
22
|
+
/** Start of the band at `index`. */
|
|
23
|
+
at(index: number): number;
|
|
24
|
+
/** Center of the band for `key`. */
|
|
25
|
+
center(key: BandKey): number | undefined;
|
|
26
|
+
/** Index of the band nearest to `pixel` (for hit testing), or `-1` when empty. */
|
|
27
|
+
indexAt(pixel: number): number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a band scale, e.g. for bar charts.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const x = band(['Jan', 'Feb', 'Mar'], [0, 300], { paddingInner: 0.2 })
|
|
34
|
+
* x('Feb') // start of the "Feb" band
|
|
35
|
+
* x.bandwidth // bar width
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function band(domain: readonly BandKey[], range: readonly [number, number], options?: BandScaleOptions): BandScale;
|
|
39
|
+
/**
|
|
40
|
+
* Create a point scale: a band scale with zero-width bands, placing each
|
|
41
|
+
* category on a single point (e.g. line charts over labels).
|
|
42
|
+
* `padding` is the space before the first and after the last point, in steps.
|
|
43
|
+
*/
|
|
44
|
+
declare function point(domain: readonly BandKey[], range: readonly [number, number], options?: {
|
|
45
|
+
padding?: number;
|
|
46
|
+
align?: number;
|
|
47
|
+
}): BandScale;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { point as a, band as i, BandScale as n, BandScaleOptions as r, BandKey as t };
|
|
50
|
+
//# sourceMappingURL=band-DTcNDAFO.d.cts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/scales/band.d.ts
|
|
2
|
+
/** Category identifier used by band and point scales. */
|
|
3
|
+
type BandKey = string | number;
|
|
4
|
+
interface BandScaleOptions {
|
|
5
|
+
/** Share of each step left empty between bands, `0…1`. Defaults to `0`. */
|
|
6
|
+
paddingInner?: number;
|
|
7
|
+
/** Space before the first and after the last band, in steps. Defaults to `0`. */
|
|
8
|
+
paddingOuter?: number;
|
|
9
|
+
/** Where leftover space goes: `0` start, `0.5` center, `1` end. Defaults to `0.5`. */
|
|
10
|
+
align?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Discrete scale splitting a range into equal bands, one per category. */
|
|
13
|
+
interface BandScale {
|
|
14
|
+
/** Start of the band for `key`, or `undefined` for unknown keys. */
|
|
15
|
+
(key: BandKey): number | undefined;
|
|
16
|
+
readonly domain: readonly BandKey[];
|
|
17
|
+
readonly range: readonly [number, number];
|
|
18
|
+
/** Width of a single band. */
|
|
19
|
+
readonly bandwidth: number;
|
|
20
|
+
/** Distance between the starts of adjacent bands. */
|
|
21
|
+
readonly step: number;
|
|
22
|
+
/** Start of the band at `index`. */
|
|
23
|
+
at(index: number): number;
|
|
24
|
+
/** Center of the band for `key`. */
|
|
25
|
+
center(key: BandKey): number | undefined;
|
|
26
|
+
/** Index of the band nearest to `pixel` (for hit testing), or `-1` when empty. */
|
|
27
|
+
indexAt(pixel: number): number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a band scale, e.g. for bar charts.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const x = band(['Jan', 'Feb', 'Mar'], [0, 300], { paddingInner: 0.2 })
|
|
34
|
+
* x('Feb') // start of the "Feb" band
|
|
35
|
+
* x.bandwidth // bar width
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function band(domain: readonly BandKey[], range: readonly [number, number], options?: BandScaleOptions): BandScale;
|
|
39
|
+
/**
|
|
40
|
+
* Create a point scale: a band scale with zero-width bands, placing each
|
|
41
|
+
* category on a single point (e.g. line charts over labels).
|
|
42
|
+
* `padding` is the space before the first and after the last point, in steps.
|
|
43
|
+
*/
|
|
44
|
+
declare function point(domain: readonly BandKey[], range: readonly [number, number], options?: {
|
|
45
|
+
padding?: number;
|
|
46
|
+
align?: number;
|
|
47
|
+
}): BandScale;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { point as a, band as i, BandScale as n, BandScaleOptions as r, BandKey as t };
|
|
50
|
+
//# sourceMappingURL=band-DTcNDAFO.d.ts.map
|