@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,58 @@
|
|
|
1
|
+
import { a as InsetsInput } from "./annotations-lyt0I3HU.cjs";
|
|
2
|
+
import { a as ClassValue } from "./vnode-BUflsBsa.cjs";
|
|
3
|
+
import { a as ChartType } from "./chart-Qa417fJo.cjs";
|
|
4
|
+
import { c as NumberFormat } from "./time-CNVnt-B2.cjs";
|
|
5
|
+
//#region src/charts/pie.d.ts
|
|
6
|
+
/** One slice of a pie or donut. */
|
|
7
|
+
interface PieSlice {
|
|
8
|
+
name: string;
|
|
9
|
+
/** Non-negative value; negative values count as zero. */
|
|
10
|
+
value: number;
|
|
11
|
+
/** Stable identity for keyed updates and legend toggles. Defaults to `name`. */
|
|
12
|
+
id?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Custom color; overrides the palette slot via `--tc-series-color`.
|
|
15
|
+
* Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.
|
|
16
|
+
*/
|
|
17
|
+
color?: string;
|
|
18
|
+
/** Extra classes on the slice group. */
|
|
19
|
+
class?: ClassValue;
|
|
20
|
+
/** Start hidden (toggle it back from the legend). */
|
|
21
|
+
hidden?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface PieOptions {
|
|
24
|
+
data: readonly PieSlice[];
|
|
25
|
+
/** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */
|
|
26
|
+
innerRadius?: number;
|
|
27
|
+
/** Gap between slices in pixels, drawn as surface. Defaults to `2`. */
|
|
28
|
+
gap?: number;
|
|
29
|
+
/** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */
|
|
30
|
+
cornerRadius?: number;
|
|
31
|
+
/** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */
|
|
32
|
+
startAngle?: number;
|
|
33
|
+
/** Format of the values (tooltip, table, donut total). */
|
|
34
|
+
format?: NumberFormat;
|
|
35
|
+
/**
|
|
36
|
+
* Text in the donut hole: the total by default; `false` hides it, or give
|
|
37
|
+
* your own `value` / `label`.
|
|
38
|
+
*/
|
|
39
|
+
center?: false | {
|
|
40
|
+
value?: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
};
|
|
43
|
+
/** Extra space around the pie, in pixels. */
|
|
44
|
+
padding?: InsetsInput;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pie chart: parts of a whole as slices, in data order, clockwise from the top.
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare const pie: ChartType<PieOptions>;
|
|
54
|
+
/** Donut chart: a pie with a hole showing the total (or your own `center`). */
|
|
55
|
+
declare const donut: ChartType<PieOptions>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { pie as i, PieSlice as n, donut as r, PieOptions as t };
|
|
58
|
+
//# sourceMappingURL=pie-DnQQmxkk.d.cts.map
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { i as insets, r as innerRect } from "./layout-B3hiqVEw.js";
|
|
2
|
+
import { t as h } from "./vnode-tCWItoUH.js";
|
|
3
|
+
import { o as getNumberFormat, r as formatNumber } from "./format-lStwuc1L.js";
|
|
4
|
+
import { r as features } from "./features-wASyHGic.js";
|
|
5
|
+
import { n as cleanItems, t as cleanData } from "./clean-o1vDEhFV.js";
|
|
6
|
+
import { n as keyOf, r as legendItems, t as groupAttrs } from "./named-DE15TOgh.js";
|
|
7
|
+
import { a as arcPathStable, i as arcCentroid, n as sweep, o as padAngleForGap, r as DEG, t as arcNode } from "./sweep-WSgn2etB.js";
|
|
8
|
+
//#region src/charts/pie.ts
|
|
9
|
+
/** Angles of the visible slices, clockwise from `startAngle`. */
|
|
10
|
+
function layoutSlices(options, hidden) {
|
|
11
|
+
const visible = options.data.map((data, index) => ({
|
|
12
|
+
data,
|
|
13
|
+
index,
|
|
14
|
+
value: Math.max(0, data.value || 0)
|
|
15
|
+
})).filter((slice) => !hidden.has(keyOf(slice.data)));
|
|
16
|
+
const total = visible.reduce((sum, slice) => sum + slice.value, 0);
|
|
17
|
+
let angle = (options.startAngle ?? 0) * DEG;
|
|
18
|
+
return {
|
|
19
|
+
slices: visible.map((slice) => {
|
|
20
|
+
const sweep = total > 0 ? slice.value / total * Math.PI * 2 : 0;
|
|
21
|
+
const out = {
|
|
22
|
+
...slice,
|
|
23
|
+
startAngle: angle,
|
|
24
|
+
endAngle: angle + sweep
|
|
25
|
+
};
|
|
26
|
+
angle += sweep;
|
|
27
|
+
return out;
|
|
28
|
+
}),
|
|
29
|
+
total
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function renderPie(options, ctx, defaults) {
|
|
33
|
+
const { width, height, locale } = ctx;
|
|
34
|
+
const gap = options.gap ?? 2;
|
|
35
|
+
const area = innerRect(width, height, insets(options.padding, 0));
|
|
36
|
+
const outer = Math.max(0, Math.min(area.width, area.height) / 2 - 8);
|
|
37
|
+
const inner = outer * Math.min(.95, Math.max(0, options.innerRadius ?? defaults.inner));
|
|
38
|
+
const cornerRadius = options.cornerRadius ?? defaults.corner;
|
|
39
|
+
const cx = area.x + area.width / 2;
|
|
40
|
+
const cy = area.y + area.height / 2;
|
|
41
|
+
const { slices, total } = layoutSlices(options, ctx.hidden);
|
|
42
|
+
const drawn = slices.filter((slice) => slice.value > 0);
|
|
43
|
+
const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0;
|
|
44
|
+
const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0;
|
|
45
|
+
const value = formatNumber(options.format, locale);
|
|
46
|
+
const share = getNumberFormat(locale, {
|
|
47
|
+
style: "percent",
|
|
48
|
+
maximumFractionDigits: 1
|
|
49
|
+
});
|
|
50
|
+
const geometry = (slice, r0 = inner, r1 = outer) => ({
|
|
51
|
+
innerRadius: r0,
|
|
52
|
+
outerRadius: r1,
|
|
53
|
+
startAngle: slice.startAngle,
|
|
54
|
+
endAngle: slice.endAngle,
|
|
55
|
+
padAngle,
|
|
56
|
+
cornerRadius
|
|
57
|
+
});
|
|
58
|
+
const hitFor = (slice, position) => {
|
|
59
|
+
const [x, y] = arcCentroid(geometry(slice));
|
|
60
|
+
const item = {
|
|
61
|
+
name: slice.data.name,
|
|
62
|
+
seriesIndex: slice.index,
|
|
63
|
+
value: slice.value,
|
|
64
|
+
text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,
|
|
65
|
+
x: cx + x,
|
|
66
|
+
y: cy + y
|
|
67
|
+
};
|
|
68
|
+
if (slice.data.color) item.color = slice.data.color;
|
|
69
|
+
return {
|
|
70
|
+
index: position,
|
|
71
|
+
label: slice.data.name,
|
|
72
|
+
title: "",
|
|
73
|
+
x: cx + x,
|
|
74
|
+
area: {
|
|
75
|
+
x: cx - outer,
|
|
76
|
+
y: cy - outer,
|
|
77
|
+
width: outer * 2,
|
|
78
|
+
height: outer * 2
|
|
79
|
+
},
|
|
80
|
+
items: [item],
|
|
81
|
+
seriesIndex: slice.index,
|
|
82
|
+
mark: {
|
|
83
|
+
d: arcPathStable({
|
|
84
|
+
...geometry(slice, outer + 2, outer + 6),
|
|
85
|
+
cornerRadius: 2
|
|
86
|
+
}),
|
|
87
|
+
x: cx,
|
|
88
|
+
y: cy
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const interaction = {
|
|
93
|
+
count: drawn.length,
|
|
94
|
+
hitIndex: (position) => {
|
|
95
|
+
const slice = drawn[position];
|
|
96
|
+
return slice ? hitFor(slice, position) : null;
|
|
97
|
+
},
|
|
98
|
+
hitTest(px, py) {
|
|
99
|
+
const dx = px - cx;
|
|
100
|
+
const dy = py - cy;
|
|
101
|
+
const r = Math.hypot(dx, dy);
|
|
102
|
+
if (r < inner - 2 || r > outer + 8) return null;
|
|
103
|
+
const start = (options.startAngle ?? 0) * DEG;
|
|
104
|
+
const turn = Math.PI * 2;
|
|
105
|
+
let angle = Math.atan2(dx, -dy);
|
|
106
|
+
angle = start + ((angle - start) % turn + turn) % turn;
|
|
107
|
+
const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle);
|
|
108
|
+
return position === -1 ? null : hitFor(drawn[position], position);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
ctx.onHitTest(interaction);
|
|
112
|
+
const groups = slices.map((slice) => h("g", groupAttrs(slice.data, slice.index), arcNode("tc-slice", geometry(slice))));
|
|
113
|
+
const center = options.center;
|
|
114
|
+
const showCenter = inner > 0 && center !== false;
|
|
115
|
+
const centerValue = showCenter ? center?.value ?? value(total) : "";
|
|
116
|
+
const centerLabel = showCenter ? center?.label : void 0;
|
|
117
|
+
return [h("g", {
|
|
118
|
+
class: "tc-pie",
|
|
119
|
+
style: `transform:translate(${cx}px,${cy}px)`
|
|
120
|
+
}, total === 0 && h("path", {
|
|
121
|
+
class: "tc-pie-track",
|
|
122
|
+
d: arcPathStable({
|
|
123
|
+
innerRadius: inner,
|
|
124
|
+
outerRadius: outer,
|
|
125
|
+
startAngle: 0,
|
|
126
|
+
endAngle: Math.PI * 2
|
|
127
|
+
})
|
|
128
|
+
}), h("g", {
|
|
129
|
+
class: "tc-pie-slices",
|
|
130
|
+
style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : void 0
|
|
131
|
+
}, groups)), showCenter && h("g", {
|
|
132
|
+
class: "tc-pie-center",
|
|
133
|
+
"aria-hidden": "true"
|
|
134
|
+
}, h("text", {
|
|
135
|
+
class: "tc-pie-value",
|
|
136
|
+
x: cx,
|
|
137
|
+
y: cy,
|
|
138
|
+
dy: centerLabel ? "0" : "0.35em",
|
|
139
|
+
"text-anchor": "middle"
|
|
140
|
+
}, centerValue), centerLabel && h("text", {
|
|
141
|
+
class: "tc-pie-label",
|
|
142
|
+
x: cx,
|
|
143
|
+
y: cy,
|
|
144
|
+
dy: "1.6em",
|
|
145
|
+
"text-anchor": "middle"
|
|
146
|
+
}, centerLabel))];
|
|
147
|
+
}
|
|
148
|
+
function pieTable(options, ctx) {
|
|
149
|
+
const { slices, total } = layoutSlices(options, ctx.hidden);
|
|
150
|
+
const value = formatNumber(options.format, ctx.locale);
|
|
151
|
+
const share = getNumberFormat(ctx.locale, {
|
|
152
|
+
style: "percent",
|
|
153
|
+
maximumFractionDigits: 1
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
columns: [
|
|
157
|
+
"",
|
|
158
|
+
"Value",
|
|
159
|
+
"Share"
|
|
160
|
+
],
|
|
161
|
+
rows: slices.map((slice) => [
|
|
162
|
+
slice.data.name,
|
|
163
|
+
value(slice.value),
|
|
164
|
+
share.format(total > 0 ? slice.value / total : 0)
|
|
165
|
+
])
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function pieType(name, defaults) {
|
|
169
|
+
return {
|
|
170
|
+
name,
|
|
171
|
+
clean: cleanData(cleanItems),
|
|
172
|
+
render: (options, ctx) => {
|
|
173
|
+
features.sweep = sweep;
|
|
174
|
+
return renderPie(options, ctx, defaults);
|
|
175
|
+
},
|
|
176
|
+
legend: (options) => legendItems(options.data),
|
|
177
|
+
table: pieTable,
|
|
178
|
+
valueLabels: { marks: "slice" }
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Pie chart: parts of a whole as slices, in data order, clockwise from the top.
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
const pie = pieType("pie", {
|
|
189
|
+
inner: 0,
|
|
190
|
+
corner: 0
|
|
191
|
+
});
|
|
192
|
+
/** Donut chart: a pie with a hole showing the total (or your own `center`). */
|
|
193
|
+
const donut = pieType("donut", {
|
|
194
|
+
inner: .62,
|
|
195
|
+
corner: 4
|
|
196
|
+
});
|
|
197
|
+
//#endregion
|
|
198
|
+
export { pie as n, donut as t };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=pie-RnMTQWMS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-RnMTQWMS.js","names":[],"sources":["../src/charts/pie.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { features } from '../features.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets } from '../layout.ts'\nimport { arcNode, sweep } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO, padAngleForGap } from '../shapes/arc.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** One slice of a pie or donut. */\nexport interface PieSlice {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-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 slice group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PieOptions {\n data: readonly PieSlice[]\n /** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */\n innerRadius?: number\n /** Gap between slices in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */\n cornerRadius?: number\n /** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Format of the values (tooltip, table, donut total). */\n format?: NumberFormat\n /**\n * Text in the donut hole: the total by default; `false` hides it, or give\n * your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the pie, in pixels. */\n padding?: InsetsInput\n}\n\ninterface Slice {\n data: PieSlice\n index: number\n value: number\n startAngle: number\n endAngle: number\n}\n\n/** Angles of the visible slices, clockwise from `startAngle`. */\nfunction layoutSlices(\n options: PieOptions,\n hidden: ReadonlySet<string>,\n): { slices: Slice[]; total: number } {\n const visible = options.data\n .map((data, index) => ({ data, index, value: Math.max(0, data.value || 0) }))\n .filter((slice) => !hidden.has(keyOf(slice.data)))\n const total = visible.reduce((sum, slice) => sum + slice.value, 0)\n let angle = (options.startAngle ?? 0) * DEG\n const slices = visible.map((slice) => {\n const sweep = total > 0 ? (slice.value / total) * Math.PI * 2 : 0\n const out: Slice = { ...slice, startAngle: angle, endAngle: angle + sweep }\n angle += sweep\n return out\n })\n return { slices, total }\n}\n\nfunction renderPie(\n options: PieOptions,\n ctx: RenderContext,\n defaults: { inner: number; corner: number },\n) {\n const { width, height, locale } = ctx\n const gap = options.gap ?? 2\n const area = innerRect(width, height, insets(options.padding, 0))\n const outer = Math.max(0, Math.min(area.width, area.height) / 2 - HALO)\n const ratio = Math.min(0.95, Math.max(0, options.innerRadius ?? defaults.inner))\n const inner = outer * ratio\n const cornerRadius = options.cornerRadius ?? defaults.corner\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const drawn = slices.filter((slice) => slice.value > 0)\n // A single slice is a full ring: no gap to cut.\n // Rings get a pad angle, which keeps a constant gap width along the whole\n // edge. In a full pie every slice meets at the center, so a pad angle would\n // widen into a wedge: the gap is a surface-colored stroke instead.\n const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0\n const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const geometry = (slice: Slice, r0 = inner, r1 = outer) => ({\n innerRadius: r0,\n outerRadius: r1,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n padAngle,\n cornerRadius,\n })\n\n const hitFor = (slice: Slice, position: number): Hit => {\n const [x, y] = arcCentroid(geometry(slice))\n const item: HitItem = {\n name: slice.data.name,\n seriesIndex: slice.index,\n value: slice.value,\n text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,\n x: cx + x,\n y: cy + y,\n }\n if (slice.data.color) item.color = slice.data.color\n return {\n index: position,\n label: slice.data.name,\n title: '',\n x: cx + x,\n area: { x: cx - outer, y: cy - outer, width: outer * 2, height: outer * 2 },\n items: [item],\n seriesIndex: slice.index,\n // A thin halo just outside the slice.\n mark: {\n d: arcPathStable({ ...geometry(slice, outer + 2, outer + 6), cornerRadius: 2 }),\n x: cx,\n y: cy,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => {\n const slice = drawn[position]\n return slice ? hitFor(slice, position) : null\n },\n hitTest(px, py) {\n const dx = px - cx\n const dy = py - cy\n const r = Math.hypot(dx, dy)\n if (r < inner - 2 || r > outer + HALO) return null\n const start = (options.startAngle ?? 0) * DEG\n const turn = Math.PI * 2\n // Clockwise angle from 12 o'clock, normalized into [start, start + turn).\n let angle = Math.atan2(dx, -dy)\n angle = start + ((((angle - start) % turn) + turn) % turn)\n const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle)\n return position === -1 ? null : hitFor(drawn[position] as Slice, position)\n },\n }\n ctx.onHitTest(interaction)\n\n const groups = slices.map((slice) =>\n h(\n 'g',\n groupAttrs(slice.data, slice.index),\n // The path keeps its arc, so new data sweeps slices around the center\n // (see `sweep`). An empty slice keeps its path, a line with no area in\n // the gap between its neighbors, to grow from there.\n arcNode('tc-slice', geometry(slice)),\n ),\n )\n\n const center = options.center\n const showCenter = inner > 0 && center !== false\n const centerValue = showCenter ? (center?.value ?? value(total)) : ''\n const centerLabel = showCenter ? center?.label : undefined\n\n return [\n h(\n 'g',\n { class: 'tc-pie', style: `transform:translate(${cx}px,${cy}px)` },\n total === 0 &&\n h('path', {\n class: 'tc-pie-track',\n d: arcPathStable({\n innerRadius: inner,\n outerRadius: outer,\n startAngle: 0,\n endAngle: Math.PI * 2,\n }),\n }),\n h(\n 'g',\n {\n class: 'tc-pie-slices',\n style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : undefined,\n },\n groups,\n ),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-pie-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-pie-value',\n x: cx,\n y: cy,\n dy: centerLabel ? '0' : '0.35em',\n 'text-anchor': 'middle',\n },\n centerValue,\n ),\n centerLabel &&\n h(\n 'text',\n { class: 'tc-pie-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n}\n\nfunction pieTable(options: PieOptions, ctx: RenderContext): DataTable {\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: slices.map((slice) => [\n slice.data.name,\n value(slice.value),\n share.format(total > 0 ? slice.value / total : 0),\n ]),\n }\n}\n\nfunction pieType(name: string, defaults: { inner: number; corner: number }): ChartType<PieOptions> {\n return {\n name,\n clean: cleanData(cleanItems),\n render: (options, ctx): ChildInput => {\n // Set here, not as the module loads: a module with side effects would\n // stay in every bundle that imports another chart type next to it.\n features.sweep = sweep\n return renderPie(options, ctx, defaults)\n },\n legend: (options) => legendItems(options.data),\n table: pieTable,\n valueLabels: { marks: 'slice' },\n }\n}\n\n/**\n * Pie chart: parts of a whole as slices, in data order, clockwise from the top.\n *\n * ```ts\n * new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })\n * ```\n */\nexport const pie: ChartType<PieOptions> = pieType('pie', { inner: 0, corner: 0 })\n\n/** Donut chart: a pie with a hole showing the total (or your own `center`). */\nexport const donut: ChartType<PieOptions> = pieType('donut', { inner: 0.62, corner: 4 })\n"],"mappings":";;;;;;;;;AA4DA,SAAS,aACP,SACA,QACoC;CACpC,MAAM,UAAU,QAAQ,KACrB,KAAK,MAAM,WAAW;EAAE;EAAM;EAAO,OAAO,KAAK,IAAI,GAAG,KAAK,SAAS,CAAC;CAAE,EAAE,CAAC,CAC5E,QAAQ,UAAU,CAAC,OAAO,IAAI,MAAM,MAAM,IAAI,CAAC,CAAC;CACnD,MAAM,QAAQ,QAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;CACjE,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;EACL,SAAS;GAAC;GAAI;GAAS;EAAO;EAC9B,MAAM,OAAO,KAAK,UAAU;GAC1B,MAAM,KAAK;GACX,MAAM,MAAM,KAAK;GACjB,MAAM,OAAO,QAAQ,IAAI,MAAM,QAAQ,QAAQ,CAAC;EAClD,CAAC;CACH;AACF;AAEA,SAAS,QAAQ,MAAc,UAAoE;CACjG,OAAO;EACL;EACA,OAAO,UAAU,UAAU;EAC3B,SAAS,SAAS,QAAoB;GAGpC,SAAS,QAAQ;GACjB,OAAO,UAAU,SAAS,KAAK,QAAQ;EACzC;EACA,SAAS,YAAY,YAAY,QAAQ,IAAI;EAC7C,OAAO;EACP,aAAa,EAAE,OAAO,QAAQ;CAChC;AACF;;;;;;;;AASA,MAAa,MAA6B,QAAQ,OAAO;CAAE,OAAO;CAAG,QAAQ;AAAE,CAAC;;AAGhF,MAAa,QAA+B,QAAQ,SAAS;CAAE,OAAO;CAAM,QAAQ;AAAE,CAAC"}
|
package/dist/pie.cjs
ADDED
package/dist/pie.d.cts
ADDED
package/dist/pie.d.ts
ADDED
package/dist/pie.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const require_layout = require("./layout-CtMBhNd9.cjs");
|
|
2
|
+
//#region src/charts/point-shapes.ts
|
|
3
|
+
/**
|
|
4
|
+
* Outlines by color slot (0-based), as x, y pairs in units of the radius,
|
|
5
|
+
* sized so the shapes weigh about the same as the circle of slot 0 (and of
|
|
6
|
+
* slots 9 and up).
|
|
7
|
+
*/
|
|
8
|
+
const SHAPES = [
|
|
9
|
+
[],
|
|
10
|
+
[
|
|
11
|
+
-.9,
|
|
12
|
+
-.9,
|
|
13
|
+
.9,
|
|
14
|
+
-.9,
|
|
15
|
+
.9,
|
|
16
|
+
.9,
|
|
17
|
+
-.9,
|
|
18
|
+
.9
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
0,
|
|
22
|
+
-1.3,
|
|
23
|
+
1.2,
|
|
24
|
+
.9,
|
|
25
|
+
-1.2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+
],
|
|
98
|
+
[
|
|
99
|
+
0,
|
|
100
|
+
-1.4,
|
|
101
|
+
.32,
|
|
102
|
+
-.44,
|
|
103
|
+
1.33,
|
|
104
|
+
-.43,
|
|
105
|
+
.52,
|
|
106
|
+
.17,
|
|
107
|
+
.82,
|
|
108
|
+
1.13,
|
|
109
|
+
0,
|
|
110
|
+
.55,
|
|
111
|
+
-.82,
|
|
112
|
+
1.13,
|
|
113
|
+
-.52,
|
|
114
|
+
.17,
|
|
115
|
+
-1.33,
|
|
116
|
+
-.43,
|
|
117
|
+
-.32,
|
|
118
|
+
-.44
|
|
119
|
+
]
|
|
120
|
+
];
|
|
121
|
+
/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */
|
|
122
|
+
function markerPath(slot, x, y, r) {
|
|
123
|
+
const shape = SHAPES[slot] ?? [];
|
|
124
|
+
if (!shape.length) return `M${require_layout.round(x - r)},${require_layout.round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`;
|
|
125
|
+
let d = "";
|
|
126
|
+
for (let i = 0; i < shape.length; i += 2) d += `${i ? "L" : "M"}${require_layout.round(x + shape[i] * r)},${require_layout.round(y + shape[i + 1] * r)}`;
|
|
127
|
+
return `${d}Z`;
|
|
128
|
+
}
|
|
129
|
+
/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */
|
|
130
|
+
function reshape(child, slot) {
|
|
131
|
+
if (Array.isArray(child)) return child.map((c) => reshape(c, slot));
|
|
132
|
+
if (!child || typeof child !== "object") return child;
|
|
133
|
+
const { attrs } = child;
|
|
134
|
+
const cls = String(attrs.class ?? "");
|
|
135
|
+
const group = /\btc-series-(\d+)\b/.exec(cls);
|
|
136
|
+
if (child.tag === "circle" && slot >= 0 && /\btc-point\b/.test(cls) && !/\btc-bubble\b/.test(cls)) return {
|
|
137
|
+
tag: "path",
|
|
138
|
+
attrs: {
|
|
139
|
+
class: `${cls} tc-marker`,
|
|
140
|
+
d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0))
|
|
141
|
+
},
|
|
142
|
+
children: [],
|
|
143
|
+
key: child.key
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
...child,
|
|
147
|
+
children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot))
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */
|
|
151
|
+
const shapesStep = (config, content) => config.shapes ?? config.patterns === true ? reshape(content, -1) : content;
|
|
152
|
+
//#endregion
|
|
153
|
+
Object.defineProperty(exports, "markerPath", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function() {
|
|
156
|
+
return markerPath;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
Object.defineProperty(exports, "shapesStep", {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function() {
|
|
162
|
+
return shapesStep;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=point-shapes-CGl4dugc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point-shapes-CGl4dugc.cjs","names":["round"],"sources":["../src/charts/point-shapes.ts"],"sourcesContent":["/**\n * Marker shapes, so the points of series do not depend on color alone\n * (color vision deficiency, grayscale print): one shape per color slot,\n * for line, radar and scatter points and the active points of the hover.\n * On with `shapes: true`, and with `patterns: true` unless `shapes` says\n * otherwise. Legend and tooltip swatches take the same shapes in CSS.\n */\nimport type { PostStep } from '../features.ts'\nimport { round } from '../layout.ts'\nimport type { Child, ChildInput, VNode } from '../vnode.ts'\n\n/**\n * Outlines by color slot (0-based), as x, y pairs in units of the radius,\n * sized so the shapes weigh about the same as the circle of slot 0 (and of\n * slots 9 and up).\n */\nconst SHAPES: readonly (readonly number[])[] = [\n [],\n // Square.\n [-0.9, -0.9, 0.9, -0.9, 0.9, 0.9, -0.9, 0.9],\n // Triangle.\n [0, -1.3, 1.2, 0.9, -1.2, 0.9],\n // Diamond.\n [0, -1.3, 1.3, 0, 0, 1.3, -1.3, 0],\n // Triangle, pointing down.\n [-1.2, -0.9, 1.2, -0.9, 0, 1.3],\n // Plus.\n [\n -0.4, -1.2, 0.4, -1.2, 0.4, -0.4, 1.2, -0.4, 1.2, 0.4, 0.4, 0.4, 0.4, 1.2, -0.4, 1.2, -0.4, 0.4,\n -1.2, 0.4, -1.2, -0.4, -0.4, -0.4,\n ],\n // Cross.\n [\n -0.7, -1.2, 0, -0.5, 0.7, -1.2, 1.2, -0.7, 0.5, 0, 1.2, 0.7, 0.7, 1.2, 0, 0.5, -0.7, 1.2, -1.2,\n 0.7, -0.5, 0, -1.2, -0.7,\n ],\n // Star.\n [\n 0, -1.4, 0.32, -0.44, 1.33, -0.43, 0.52, 0.17, 0.82, 1.13, 0, 0.55, -0.82, 1.13, -0.52, 0.17,\n -1.33, -0.43, -0.32, -0.44,\n ],\n]\n\n/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */\nexport function markerPath(slot: number, x: number, y: number, r: number): string {\n const shape = SHAPES[slot] ?? []\n if (!shape.length) {\n return `M${round(x - r)},${round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`\n }\n let d = ''\n for (let i = 0; i < shape.length; i += 2) {\n d += `${i ? 'L' : 'M'}${round(x + (shape[i] as number) * r)},${round(y + (shape[i + 1] as number) * r)}`\n }\n return `${d}Z`\n}\n\n/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */\nfunction reshape(child: ChildInput, slot: number): ChildInput {\n if (Array.isArray(child)) return child.map((c) => reshape(c, slot))\n if (!child || typeof child !== 'object') return child\n const { attrs } = child\n const cls = String(attrs.class ?? '')\n const group = /\\btc-series-(\\d+)\\b/.exec(cls)\n if (\n child.tag === 'circle' &&\n slot >= 0 &&\n /\\btc-point\\b/.test(cls) &&\n !/\\btc-bubble\\b/.test(cls)\n ) {\n const shaped: VNode = {\n tag: 'path',\n attrs: {\n class: `${cls} tc-marker`,\n d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0)),\n },\n children: [],\n key: child.key,\n }\n return shaped\n }\n return {\n ...child,\n children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot) as Child),\n }\n}\n\n/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */\nexport const shapesStep: PostStep = (config, content) =>\n (config.shapes ?? config.patterns === true) ? reshape(content, -1) : content\n"],"mappings":";;;;;;;AAgBA,MAAM,SAAyC;CAC7C,CAAC;CAED;EAAC;EAAM;EAAM;EAAK;EAAM;EAAK;EAAK;EAAM;CAAG;CAE3C;EAAC;EAAG;EAAM;EAAK;EAAK;EAAM;CAAG;CAE7B;EAAC;EAAG;EAAM;EAAK;EAAG;EAAG;EAAK;EAAM;CAAC;CAEjC;EAAC;EAAM;EAAM;EAAK;EAAM;EAAG;CAAG;CAE9B;EACE;EAAM;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAK;EAAK;EAAK;EAAK;EAAK;EAAM;EAAK;EAAM;EAC5F;EAAM;EAAK;EAAM;EAAM;EAAM;CAC/B;CAEA;EACE;EAAM;EAAM;EAAG;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAG;EAAK;EAAK;EAAK;EAAK;EAAG;EAAK;EAAM;EAAK;EAC1F;EAAK;EAAM;EAAG;EAAM;CACtB;CAEA;EACE;EAAG;EAAM;EAAM;EAAO;EAAM;EAAO;EAAM;EAAM;EAAM;EAAM;EAAG;EAAM;EAAO;EAAM;EAAO;EACxF;EAAO;EAAO;EAAO;CACvB;AACF;;AAGA,SAAgB,WAAW,MAAc,GAAW,GAAW,GAAmB;CAChF,MAAM,QAAQ,OAAO,SAAS,CAAC;CAC/B,IAAI,CAAC,MAAM,QACT,OAAO,IAAIA,eAAAA,MAAM,IAAI,CAAC,EAAE,GAAGA,eAAAA,MAAM,CA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
+
/**
|
|
4
|
+
* Outlines by color slot (0-based), as x, y pairs in units of the radius,
|
|
5
|
+
* sized so the shapes weigh about the same as the circle of slot 0 (and of
|
|
6
|
+
* slots 9 and up).
|
|
7
|
+
*/
|
|
8
|
+
const SHAPES = [
|
|
9
|
+
[],
|
|
10
|
+
[
|
|
11
|
+
-.9,
|
|
12
|
+
-.9,
|
|
13
|
+
.9,
|
|
14
|
+
-.9,
|
|
15
|
+
.9,
|
|
16
|
+
.9,
|
|
17
|
+
-.9,
|
|
18
|
+
.9
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
0,
|
|
22
|
+
-1.3,
|
|
23
|
+
1.2,
|
|
24
|
+
.9,
|
|
25
|
+
-1.2,
|
|
26
|
+
.9
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
0,
|
|
30
|
+
-1.3,
|
|
31
|
+
1.3,
|
|
32
|
+
0,
|
|
33
|
+
0,
|
|
34
|
+
1.3,
|
|
35
|
+
-1.3,
|
|
36
|
+
0
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
-1.2,
|
|
40
|
+
-.9,
|
|
41
|
+
1.2,
|
|
42
|
+
-.9,
|
|
43
|
+
0,
|
|
44
|
+
1.3
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
-.4,
|
|
48
|
+
-1.2,
|
|
49
|
+
.4,
|
|
50
|
+
-1.2,
|
|
51
|
+
.4,
|
|
52
|
+
-.4,
|
|
53
|
+
1.2,
|
|
54
|
+
-.4,
|
|
55
|
+
1.2,
|
|
56
|
+
.4,
|
|
57
|
+
.4,
|
|
58
|
+
.4,
|
|
59
|
+
.4,
|
|
60
|
+
1.2,
|
|
61
|
+
-.4,
|
|
62
|
+
1.2,
|
|
63
|
+
-.4,
|
|
64
|
+
.4,
|
|
65
|
+
-1.2,
|
|
66
|
+
.4,
|
|
67
|
+
-1.2,
|
|
68
|
+
-.4,
|
|
69
|
+
-.4,
|
|
70
|
+
-.4
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
-.7,
|
|
74
|
+
-1.2,
|
|
75
|
+
0,
|
|
76
|
+
-.5,
|
|
77
|
+
.7,
|
|
78
|
+
-1.2,
|
|
79
|
+
1.2,
|
|
80
|
+
-.7,
|
|
81
|
+
.5,
|
|
82
|
+
0,
|
|
83
|
+
1.2,
|
|
84
|
+
.7,
|
|
85
|
+
.7,
|
|
86
|
+
1.2,
|
|
87
|
+
0,
|
|
88
|
+
.5,
|
|
89
|
+
-.7,
|
|
90
|
+
1.2,
|
|
91
|
+
-1.2,
|
|
92
|
+
.7,
|
|
93
|
+
-.5,
|
|
94
|
+
0,
|
|
95
|
+
-1.2,
|
|
96
|
+
-.7
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
0,
|
|
100
|
+
-1.4,
|
|
101
|
+
.32,
|
|
102
|
+
-.44,
|
|
103
|
+
1.33,
|
|
104
|
+
-.43,
|
|
105
|
+
.52,
|
|
106
|
+
.17,
|
|
107
|
+
.82,
|
|
108
|
+
1.13,
|
|
109
|
+
0,
|
|
110
|
+
.55,
|
|
111
|
+
-.82,
|
|
112
|
+
1.13,
|
|
113
|
+
-.52,
|
|
114
|
+
.17,
|
|
115
|
+
-1.33,
|
|
116
|
+
-.43,
|
|
117
|
+
-.32,
|
|
118
|
+
-.44
|
|
119
|
+
]
|
|
120
|
+
];
|
|
121
|
+
/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */
|
|
122
|
+
function markerPath(slot, x, y, r) {
|
|
123
|
+
const shape = SHAPES[slot] ?? [];
|
|
124
|
+
if (!shape.length) return `M${round(x - r)},${round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`;
|
|
125
|
+
let d = "";
|
|
126
|
+
for (let i = 0; i < shape.length; i += 2) d += `${i ? "L" : "M"}${round(x + shape[i] * r)},${round(y + shape[i + 1] * r)}`;
|
|
127
|
+
return `${d}Z`;
|
|
128
|
+
}
|
|
129
|
+
/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */
|
|
130
|
+
function reshape(child, slot) {
|
|
131
|
+
if (Array.isArray(child)) return child.map((c) => reshape(c, slot));
|
|
132
|
+
if (!child || typeof child !== "object") return child;
|
|
133
|
+
const { attrs } = child;
|
|
134
|
+
const cls = String(attrs.class ?? "");
|
|
135
|
+
const group = /\btc-series-(\d+)\b/.exec(cls);
|
|
136
|
+
if (child.tag === "circle" && slot >= 0 && /\btc-point\b/.test(cls) && !/\btc-bubble\b/.test(cls)) return {
|
|
137
|
+
tag: "path",
|
|
138
|
+
attrs: {
|
|
139
|
+
class: `${cls} tc-marker`,
|
|
140
|
+
d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0))
|
|
141
|
+
},
|
|
142
|
+
children: [],
|
|
143
|
+
key: child.key
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
...child,
|
|
147
|
+
children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot))
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */
|
|
151
|
+
const shapesStep = (config, content) => config.shapes ?? config.patterns === true ? reshape(content, -1) : content;
|
|
152
|
+
//#endregion
|
|
153
|
+
export { shapesStep as n, markerPath as t };
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=point-shapes-DI84NNpI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point-shapes-DI84NNpI.js","names":[],"sources":["../src/charts/point-shapes.ts"],"sourcesContent":["/**\n * Marker shapes, so the points of series do not depend on color alone\n * (color vision deficiency, grayscale print): one shape per color slot,\n * for line, radar and scatter points and the active points of the hover.\n * On with `shapes: true`, and with `patterns: true` unless `shapes` says\n * otherwise. Legend and tooltip swatches take the same shapes in CSS.\n */\nimport type { PostStep } from '../features.ts'\nimport { round } from '../layout.ts'\nimport type { Child, ChildInput, VNode } from '../vnode.ts'\n\n/**\n * Outlines by color slot (0-based), as x, y pairs in units of the radius,\n * sized so the shapes weigh about the same as the circle of slot 0 (and of\n * slots 9 and up).\n */\nconst SHAPES: readonly (readonly number[])[] = [\n [],\n // Square.\n [-0.9, -0.9, 0.9, -0.9, 0.9, 0.9, -0.9, 0.9],\n // Triangle.\n [0, -1.3, 1.2, 0.9, -1.2, 0.9],\n // Diamond.\n [0, -1.3, 1.3, 0, 0, 1.3, -1.3, 0],\n // Triangle, pointing down.\n [-1.2, -0.9, 1.2, -0.9, 0, 1.3],\n // Plus.\n [\n -0.4, -1.2, 0.4, -1.2, 0.4, -0.4, 1.2, -0.4, 1.2, 0.4, 0.4, 0.4, 0.4, 1.2, -0.4, 1.2, -0.4, 0.4,\n -1.2, 0.4, -1.2, -0.4, -0.4, -0.4,\n ],\n // Cross.\n [\n -0.7, -1.2, 0, -0.5, 0.7, -1.2, 1.2, -0.7, 0.5, 0, 1.2, 0.7, 0.7, 1.2, 0, 0.5, -0.7, 1.2, -1.2,\n 0.7, -0.5, 0, -1.2, -0.7,\n ],\n // Star.\n [\n 0, -1.4, 0.32, -0.44, 1.33, -0.43, 0.52, 0.17, 0.82, 1.13, 0, 0.55, -0.82, 1.13, -0.52, 0.17,\n -1.33, -0.43, -0.32, -0.44,\n ],\n]\n\n/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */\nexport function markerPath(slot: number, x: number, y: number, r: number): string {\n const shape = SHAPES[slot] ?? []\n if (!shape.length) {\n return `M${round(x - r)},${round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`\n }\n let d = ''\n for (let i = 0; i < shape.length; i += 2) {\n d += `${i ? 'L' : 'M'}${round(x + (shape[i] as number) * r)},${round(y + (shape[i + 1] as number) * r)}`\n }\n return `${d}Z`\n}\n\n/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */\nfunction reshape(child: ChildInput, slot: number): ChildInput {\n if (Array.isArray(child)) return child.map((c) => reshape(c, slot))\n if (!child || typeof child !== 'object') return child\n const { attrs } = child\n const cls = String(attrs.class ?? '')\n const group = /\\btc-series-(\\d+)\\b/.exec(cls)\n if (\n child.tag === 'circle' &&\n slot >= 0 &&\n /\\btc-point\\b/.test(cls) &&\n !/\\btc-bubble\\b/.test(cls)\n ) {\n const shaped: VNode = {\n tag: 'path',\n attrs: {\n class: `${cls} tc-marker`,\n d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0)),\n },\n children: [],\n key: child.key,\n }\n return shaped\n }\n return {\n ...child,\n children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot) as Child),\n }\n}\n\n/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */\nexport const shapesStep: PostStep = (config, content) =>\n (config.shapes ?? config.patterns === true) ? reshape(content, -1) : content\n"],"mappings":";;;;;;;AAgBA,MAAM,SAAyC;CAC7C,CAAC;CAED;EAAC;EAAM;EAAM;EAAK;EAAM;EAAK;EAAK;EAAM;CAAG;CAE3C;EAAC;EAAG;EAAM;EAAK;EAAK;EAAM;CAAG;CAE7B;EAAC;EAAG;EAAM;EAAK;EAAG;EAAG;EAAK;EAAM;CAAC;CAEjC;EAAC;EAAM;EAAM;EAAK;EAAM;EAAG;CAAG;CAE9B;EACE;EAAM;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAK;EAAK;EAAK;EAAK;EAAK;EAAM;EAAK;EAAM;EAC5F;EAAM;EAAK;EAAM;EAAM;EAAM;CAC/B;CAEA;EACE;EAAM;EAAM;EAAG;EAAM;EAAK;EAAM;EAAK;EAAM;EAAK;EAAG;EAAK;EAAK;EAAK;EAAK;EAAG;EAAK;EAAM;EAAK;EAC1F;EAAK;EAAM;EAAG;EAAM;CACtB;CAEA;EACE;EAAG;EAAM;EAAM;EAAO;EAAM;EAAO;EAAM;EAAM;EAAM;EAAM;EAAG;EAAM;EAAO;EAAM;EAAO;EACxF;EAAO;EAAO;EAA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AAU,OAAO,aAAa,OAAQ,QAAQ,SAAS,EAAE,IAAI"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_features = require("./features-BclHgg2W.cjs");
|
|
3
|
+
const require_point_shapes = require("./point-shapes-CGl4dugc.cjs");
|
|
4
|
+
//#region src/point-shapes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Standalone entry: `import '@tabler/charts/point-shapes'` enables `shapes`
|
|
7
|
+
* (a point shape per series) on the core.
|
|
8
|
+
*/
|
|
9
|
+
require_features.register({ "point-shapes": require_point_shapes.markerPath });
|
|
10
|
+
require_features.addPost(require_point_shapes.shapesStep);
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.markerPath = require_point_shapes.markerPath;
|
|
13
|
+
exports.shapesStep = require_point_shapes.shapesStep;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=point-shapes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point-shapes.cjs","names":["register","markerPath","addPost","shapesStep"],"sources":["../src/point-shapes.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/point-shapes'` enables `shapes`\n * (a point shape per series) on the core.\n */\nimport { markerPath, shapesStep } from './charts/point-shapes.ts'\nimport { addPost, register } from './features.ts'\n\nregister({ 'point-shapes': markerPath })\naddPost(shapesStep)\n\nexport { markerPath, shapesStep }\n"],"mappings":";;;;;;;;AAOAA,iBAAAA,SAAS,EAAE,gBAAgBC,qBAAAA,WAAW,CAAC;AACvCC,iBAAAA,QAAQC,qBAAAA,UAAU"}
|