@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 @@
|
|
|
1
|
+
{"version":3,"file":"named-DE15TOgh.js","names":[],"sources":["../src/charts/named.ts"],"sourcesContent":["import type { LegendItem } from '../legend.ts'\nimport type { ClassValue, Props } from '../vnode.ts'\n\n/** What series, slices and rings have in common: a name, and how they look in a legend. */\nexport interface Named {\n name: string\n id?: string\n color?: string\n class?: ClassValue\n hidden?: boolean\n}\n\n/** Stable key of a series, slice or ring: its `id`, or its name. */\nexport const keyOf = (item: Named): string => item.id ?? item.name\n\n/** Legend entries for series, slices or rings, in their order (which is their color slot). */\nexport function legendItems(list: readonly Named[]): LegendItem[] {\n return list.map((entry, index) => {\n const item: LegendItem = { key: keyOf(entry), name: entry.name, index }\n if (entry.color) item.color = entry.color\n if (entry.hidden) item.hidden = true\n return item\n })\n}\n\n/** Attributes of the group of a series, slice or ring in color slot `index`. */\nexport function groupAttrs(item: Named, index: number): Props {\n return {\n key: keyOf(item),\n class: ['tc-series', `tc-series-${index + 1}`, item.class],\n 'data-series': item.name,\n // A map, so values from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': item.color },\n }\n}\n"],"mappings":";;AAaA,MAAa,SAAS,SAAwB,KAAK,MAAM,KAAK;;AAG9D,SAAgB,YAAY,MAAsC;CAChE,OAAO,KAAK,KAAK,OAAO,UAAU;EAChC,MAAM,OAAmB;GAAE,KAAK,MAAM,KAAK;GAAG,MAAM,MAAM;GAAM;EAAM;EACtE,IAAI,MAAM,OAAO,KAAK,QAAQ,MAAM;EACpC,IAAI,MAAM,QAAQ,KAAK,SAAS;EAChC,OAAO;CACT,CAAC;AACH;;AAGA,SAAgB,WAAW,MAAa,OAAsB;CAC5D,OAAO;EACL,KAAK,MAAM,IAAI;EACf,OAAO;GAAC;GAAa,aAAa,QAAQ;GAAK,KAAK;EAAK;EACzD,eAAe,KAAK;EAEpB,OAAO,EAAE,qBAAqB,KAAK,MAAM;CAC3C;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/shapes/path.d.ts
|
|
2
|
+
/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */
|
|
3
|
+
type Point = readonly [x: number, y: number] | null | undefined;
|
|
4
|
+
/** Curve used to connect consecutive points. */
|
|
5
|
+
type Curve = "linear" | "monotone" | "step" | "step-before" | "step-after";
|
|
6
|
+
interface PathOptions {
|
|
7
|
+
/** Interpolation between points. Defaults to `'linear'`. */
|
|
8
|
+
curve?: Curve;
|
|
9
|
+
/** Decimal places kept in the path data. Defaults to `2`. */
|
|
10
|
+
precision?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)
|
|
14
|
+
* start a new subpath; a lone point renders as `M x,y Z`.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function linePath(points: readonly Point[], options?: PathOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* Build the `d` attribute of an area between `points` and a `baseline`:
|
|
23
|
+
* a constant y (e.g. the zero line) or one y per point (stacked areas).
|
|
24
|
+
* Each run of valid points becomes a closed subpath.
|
|
25
|
+
*/
|
|
26
|
+
declare function areaPath(points: readonly Point[], baseline: number | readonly (number | null | undefined)[], options?: PathOptions): string;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { linePath as a, areaPath as i, PathOptions as n, Point as r, Curve as t };
|
|
29
|
+
//# sourceMappingURL=path-CwB28da0.d.cts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/shapes/path.d.ts
|
|
2
|
+
/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */
|
|
3
|
+
type Point = readonly [x: number, y: number] | null | undefined;
|
|
4
|
+
/** Curve used to connect consecutive points. */
|
|
5
|
+
type Curve = "linear" | "monotone" | "step" | "step-before" | "step-after";
|
|
6
|
+
interface PathOptions {
|
|
7
|
+
/** Interpolation between points. Defaults to `'linear'`. */
|
|
8
|
+
curve?: Curve;
|
|
9
|
+
/** Decimal places kept in the path data. Defaults to `2`. */
|
|
10
|
+
precision?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)
|
|
14
|
+
* start a new subpath; a lone point renders as `M x,y Z`.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function linePath(points: readonly Point[], options?: PathOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* Build the `d` attribute of an area between `points` and a `baseline`:
|
|
23
|
+
* a constant y (e.g. the zero line) or one y per point (stacked areas).
|
|
24
|
+
* Each run of valid points becomes a closed subpath.
|
|
25
|
+
*/
|
|
26
|
+
declare function areaPath(points: readonly Point[], baseline: number | readonly (number | null | undefined)[], options?: PathOptions): string;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { linePath as a, areaPath as i, PathOptions as n, Point as r, Curve as t };
|
|
29
|
+
//# sourceMappingURL=path-CwB28da0.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as h } from "./vnode-tCWItoUH.js";
|
|
2
|
+
import { s as resolveLegend } from "./chart-BF2CK9I_.js";
|
|
3
|
+
//#region src/charts/patterns.ts
|
|
4
|
+
/**
|
|
5
|
+
* Pattern fills, so series do not depend on color alone (color vision
|
|
6
|
+
* deficiency, grayscale print, forced colors). Every legend entry gets an
|
|
7
|
+
* 8×8 tile: its series color with lines or dots in `--tc-pattern-color` (the
|
|
8
|
+
* surface by default) over it, one shape per color slot. The chart root
|
|
9
|
+
* carries `--tc-pattern-{n}: url(#…)` and the slot classes map it to
|
|
10
|
+
* `--tc-series-pattern`, which the stylesheet uses as the fill of bars,
|
|
11
|
+
* areas, slices, rings and bubbles (lines get dashes instead) when
|
|
12
|
+
* `patterns` is `true`, or with `'auto'` (the default) in forced colors.
|
|
13
|
+
*/
|
|
14
|
+
/** Tile shapes by color slot: lines as strokes, dots as round-capped stubs. */
|
|
15
|
+
const TILES = [
|
|
16
|
+
"M-2,2L2,-2M0,8L8,0M6,10L10,6",
|
|
17
|
+
"M2,2h.01M6,6h.01",
|
|
18
|
+
"M-2,6L2,10M0,0L8,8M6,-2L10,2",
|
|
19
|
+
"M0,4H8",
|
|
20
|
+
"M0,8L8,0M0,0L8,8",
|
|
21
|
+
"M4,0V8",
|
|
22
|
+
"M0,4H8M4,0V8",
|
|
23
|
+
"M1,2H4M5,6H8"
|
|
24
|
+
];
|
|
25
|
+
/** Slots with a pattern of their own; series 9+ share the one of the "other" color. */
|
|
26
|
+
const SLOTS = TILES.length;
|
|
27
|
+
/** The pattern of a slot (0-based): its id suffix and slot class. */
|
|
28
|
+
const slot = (index) => index < SLOTS ? [`${index + 1}`, `tc-series-${index + 1}`] : ["other", ""];
|
|
29
|
+
/** `<pattern>` elements for the legend entries of a chart. */
|
|
30
|
+
function patternDefs(items, id) {
|
|
31
|
+
const out = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
const [n, cls] = slot(item.index);
|
|
34
|
+
if (out.has(n)) continue;
|
|
35
|
+
out.set(n, h("pattern", {
|
|
36
|
+
key: n,
|
|
37
|
+
id: `${id}-pattern-${n}`,
|
|
38
|
+
class: [
|
|
39
|
+
"tc-pattern",
|
|
40
|
+
"tc-series",
|
|
41
|
+
cls
|
|
42
|
+
],
|
|
43
|
+
width: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
patternUnits: "userSpaceOnUse",
|
|
46
|
+
style: { "--tc-series-color": item.color }
|
|
47
|
+
}, h("rect", {
|
|
48
|
+
class: "tc-pattern-bg",
|
|
49
|
+
width: 8,
|
|
50
|
+
height: 8
|
|
51
|
+
}), h("path", {
|
|
52
|
+
class: "tc-pattern-ink",
|
|
53
|
+
d: TILES[item.index % SLOTS]
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
return [...out.values()];
|
|
57
|
+
}
|
|
58
|
+
/** The `--tc-pattern-{n}` references for the chart root. */
|
|
59
|
+
function patternVars(items, id) {
|
|
60
|
+
const vars = {};
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
const [n] = slot(item.index);
|
|
63
|
+
vars[`--tc-pattern-${n}`] = `url(#${id}-pattern-${n})`;
|
|
64
|
+
}
|
|
65
|
+
return vars;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The pattern fills of a chart: its root class (`tc-patterned` with
|
|
69
|
+
* `patterns: true`, `tc-patterns-auto` for forced colors), the root's
|
|
70
|
+
* `--tc-pattern-{n}` references and the `<defs>` with the patterns;
|
|
71
|
+
* `undefined` for a chart without legend entries.
|
|
72
|
+
*/
|
|
73
|
+
function patternFills(config, id) {
|
|
74
|
+
const { items } = resolveLegend(config);
|
|
75
|
+
if (!items.length) return void 0;
|
|
76
|
+
return [
|
|
77
|
+
config.patterns === true ? "tc-patterned" : "tc-patterns-auto",
|
|
78
|
+
patternVars(items, id),
|
|
79
|
+
h("defs", { key: "patterns" }, patternDefs(items, id))
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { patternFills as n, patternVars as r, patternDefs as t };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=patterns-DtgcnA8o.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns-DtgcnA8o.js","names":[],"sources":["../src/charts/patterns.ts"],"sourcesContent":["/**\n * Pattern fills, so series do not depend on color alone (color vision\n * deficiency, grayscale print, forced colors). Every legend entry gets an\n * 8×8 tile: its series color with lines or dots in `--tc-pattern-color` (the\n * surface by default) over it, one shape per color slot. The chart root\n * carries `--tc-pattern-{n}: url(#…)` and the slot classes map it to\n * `--tc-series-pattern`, which the stylesheet uses as the fill of bars,\n * areas, slices, rings and bubbles (lines get dashes instead) when\n * `patterns` is `true`, or with `'auto'` (the default) in forced colors.\n */\nimport { type ChartConfig, resolveLegend } from '../chart.ts'\nimport type { LegendItem } from '../legend.ts'\nimport { h, type VNode } from '../vnode.ts'\n\n/** Tile shapes by color slot: lines as strokes, dots as round-capped stubs. */\nconst TILES = [\n // Diagonal /, with the corners filled in so tiles join up.\n 'M-2,2L2,-2M0,8L8,0M6,10L10,6',\n // Dots.\n 'M2,2h.01M6,6h.01',\n // Diagonal \.\n 'M-2,6L2,10M0,0L8,8M6,-2L10,2',\n // Horizontal.\n 'M0,4H8',\n // Cross-hatch.\n 'M0,8L8,0M0,0L8,8',\n // Vertical.\n 'M4,0V8',\n // Grid.\n 'M0,4H8M4,0V8',\n // Dashes.\n 'M1,2H4M5,6H8',\n]\n\n/** Slots with a pattern of their own; series 9+ share the one of the \"other\" color. */\nconst SLOTS = TILES.length\n\n/** The pattern of a slot (0-based): its id suffix and slot class. */\nconst slot = (index: number): [string, string] =>\n index < SLOTS ? [`${index + 1}`, `tc-series-${index + 1}`] : ['other', '']\n\n/** `<pattern>` elements for the legend entries of a chart. */\nexport function patternDefs(items: readonly LegendItem[], id: string): VNode[] {\n const out = new Map<string, VNode>()\n for (const item of items) {\n const [n, cls] = slot(item.index)\n if (out.has(n)) continue\n out.set(\n n,\n h(\n 'pattern',\n {\n key: n,\n id: `${id}-pattern-${n}`,\n class: ['tc-pattern', 'tc-series', cls],\n width: 8,\n height: 8,\n patternUnits: 'userSpaceOnUse',\n // A map, so a color from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': item.color },\n },\n h('rect', { class: 'tc-pattern-bg', width: 8, height: 8 }),\n h('path', { class: 'tc-pattern-ink', d: TILES[item.index % SLOTS] as string }),\n ),\n )\n }\n return [...out.values()]\n}\n\n/** The `--tc-pattern-{n}` references for the chart root. */\nexport function patternVars(items: readonly LegendItem[], id: string): Record<string, string> {\n const vars: Record<string, string> = {}\n for (const item of items) {\n const [n] = slot(item.index)\n vars[`--tc-pattern-${n}`] = `url(#${id}-pattern-${n})`\n }\n return vars\n}\n\n/**\n * The pattern fills of a chart: its root class (`tc-patterned` with\n * `patterns: true`, `tc-patterns-auto` for forced colors), the root's\n * `--tc-pattern-{n}` references and the `<defs>` with the patterns;\n * `undefined` for a chart without legend entries.\n */\nexport function patternFills(\n config: ChartConfig<object>,\n id: string,\n): [string, Record<string, string>, VNode] | undefined {\n const { items } = resolveLegend(config)\n if (!items.length) return undefined\n return [\n config.patterns === true ? 'tc-patterned' : 't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AAO,aAAa,OAAO,iBAAiB;EAC5C,YAAY,OAAO,EAAE;EACrB,EAAE,QAAQ,EAAE,KAAK,WAAW,GAAG,YAAY,OAAO,EAAE,CAAC;CACvD;AACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const require_vnode = require("./vnode-CkQ27Cxe.cjs");
|
|
2
|
+
const require_chart = require("./chart-CowF_lWY.cjs");
|
|
3
|
+
//#region src/charts/patterns.ts
|
|
4
|
+
/**
|
|
5
|
+
* Pattern fills, so series do not depend on color alone (color vision
|
|
6
|
+
* deficiency, grayscale print, forced colors). Every legend entry gets an
|
|
7
|
+
* 8×8 tile: its series color with lines or dots in `--tc-pattern-color` (the
|
|
8
|
+
* surface by default) over it, one shape per color slot. The chart root
|
|
9
|
+
* carries `--tc-pattern-{n}: url(#…)` and the slot classes map it to
|
|
10
|
+
* `--tc-series-pattern`, which the stylesheet uses as the fill of bars,
|
|
11
|
+
* areas, slices, rings and bubbles (lines get dashes instead) when
|
|
12
|
+
* `patterns` is `true`, or with `'auto'` (the default) in forced colors.
|
|
13
|
+
*/
|
|
14
|
+
/** Tile shapes by color slot: lines as strokes, dots as round-capped stubs. */
|
|
15
|
+
const TILES = [
|
|
16
|
+
"M-2,2L2,-2M0,8L8,0M6,10L10,6",
|
|
17
|
+
"M2,2h.01M6,6h.01",
|
|
18
|
+
"M-2,6L2,10M0,0L8,8M6,-2L10,2",
|
|
19
|
+
"M0,4H8",
|
|
20
|
+
"M0,8L8,0M0,0L8,8",
|
|
21
|
+
"M4,0V8",
|
|
22
|
+
"M0,4H8M4,0V8",
|
|
23
|
+
"M1,2H4M5,6H8"
|
|
24
|
+
];
|
|
25
|
+
/** Slots with a pattern of their own; series 9+ share the one of the "other" color. */
|
|
26
|
+
const SLOTS = TILES.length;
|
|
27
|
+
/** The pattern of a slot (0-based): its id suffix and slot class. */
|
|
28
|
+
const slot = (index) => index < SLOTS ? [`${index + 1}`, `tc-series-${index + 1}`] : ["other", ""];
|
|
29
|
+
/** `<pattern>` elements for the legend entries of a chart. */
|
|
30
|
+
function patternDefs(items, id) {
|
|
31
|
+
const out = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
const [n, cls] = slot(item.index);
|
|
34
|
+
if (out.has(n)) continue;
|
|
35
|
+
out.set(n, require_vnode.h("pattern", {
|
|
36
|
+
key: n,
|
|
37
|
+
id: `${id}-pattern-${n}`,
|
|
38
|
+
class: [
|
|
39
|
+
"tc-pattern",
|
|
40
|
+
"tc-series",
|
|
41
|
+
cls
|
|
42
|
+
],
|
|
43
|
+
width: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
patternUnits: "userSpaceOnUse",
|
|
46
|
+
style: { "--tc-series-color": item.color }
|
|
47
|
+
}, require_vnode.h("rect", {
|
|
48
|
+
class: "tc-pattern-bg",
|
|
49
|
+
width: 8,
|
|
50
|
+
height: 8
|
|
51
|
+
}), require_vnode.h("path", {
|
|
52
|
+
class: "tc-pattern-ink",
|
|
53
|
+
d: TILES[item.index % SLOTS]
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
return [...out.values()];
|
|
57
|
+
}
|
|
58
|
+
/** The `--tc-pattern-{n}` references for the chart root. */
|
|
59
|
+
function patternVars(items, id) {
|
|
60
|
+
const vars = {};
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
const [n] = slot(item.index);
|
|
63
|
+
vars[`--tc-pattern-${n}`] = `url(#${id}-pattern-${n})`;
|
|
64
|
+
}
|
|
65
|
+
return vars;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The pattern fills of a chart: its root class (`tc-patterned` with
|
|
69
|
+
* `patterns: true`, `tc-patterns-auto` for forced colors), the root's
|
|
70
|
+
* `--tc-pattern-{n}` references and the `<defs>` with the patterns;
|
|
71
|
+
* `undefined` for a chart without legend entries.
|
|
72
|
+
*/
|
|
73
|
+
function patternFills(config, id) {
|
|
74
|
+
const { items } = require_chart.resolveLegend(config);
|
|
75
|
+
if (!items.length) return void 0;
|
|
76
|
+
return [
|
|
77
|
+
config.patterns === true ? "tc-patterned" : "tc-patterns-auto",
|
|
78
|
+
patternVars(items, id),
|
|
79
|
+
require_vnode.h("defs", { key: "patterns" }, patternDefs(items, id))
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
Object.defineProperty(exports, "patternDefs", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function() {
|
|
86
|
+
return patternDefs;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "patternFills", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return patternFills;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "patternVars", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function() {
|
|
98
|
+
return patternVars;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=patterns-LfcQAWCy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns-LfcQAWCy.cjs","names":["h","resolveLegend"],"sources":["../src/charts/patterns.ts"],"sourcesContent":["/**\n * Pattern fills, so series do not depend on color alone (color vision\n * deficiency, grayscale print, forced colors). Every legend entry gets an\n * 8×8 tile: its series color with lines or dots in `--tc-pattern-color` (the\n * surface by default) over it, one shape per color slot. The chart root\n * carries `--tc-pattern-{n}: url(#…)` and the slot classes map it to\n * `--tc-series-pattern`, which the stylesheet uses as the fill of bars,\n * areas, slices, rings and bubbles (lines get dashes instead) when\n * `patterns` is `true`, or with `'auto'` (the default) in forced colors.\n */\nimport { type ChartConfig, resolveLegend } from '../chart.ts'\nimport type { LegendItem } from '../legend.ts'\nimport { h, type VNode } from '../vnode.ts'\n\n/** Tile shapes by color slot: lines as strokes, dots as round-capped stubs. */\nconst TILES = [\n // Diagonal /, with the corners filled in so tiles join up.\n 'M-2,2L2,-2M0,8L8,0M6,10L10,6',\n // Dots.\n 'M2,2h.01M6,6h.01',\n // Diagonal \.\n 'M-2,6L2,10M0,0L8,8M6,-2L10,2',\n // Horizontal.\n 'M0,4H8',\n // Cross-hatch.\n 'M0,8L8,0M0,0L8,8',\n // Vertical.\n 'M4,0V8',\n // Grid.\n 'M0,4H8M4,0V8',\n // Dashes.\n 'M1,2H4M5,6H8',\n]\n\n/** Slots with a pattern of their own; series 9+ share the one of the \"other\" color. */\nconst SLOTS = TILES.length\n\n/** The pattern of a slot (0-based): its id suffix and slot class. */\nconst slot = (index: number): [string, string] =>\n index < SLOTS ? [`${index + 1}`, `tc-series-${index + 1}`] : ['other', '']\n\n/** `<pattern>` elements for the legend entries of a chart. */\nexport function patternDefs(items: readonly LegendItem[], id: string): VNode[] {\n const out = new Map<string, VNode>()\n for (const item of items) {\n const [n, cls] = slot(item.index)\n if (out.has(n)) continue\n out.set(\n n,\n h(\n 'pattern',\n {\n key: n,\n id: `${id}-pattern-${n}`,\n class: ['tc-pattern', 'tc-series', cls],\n width: 8,\n height: 8,\n patternUnits: 'userSpaceOnUse',\n // A map, so a color from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': item.color },\n },\n h('rect', { class: 'tc-pattern-bg', width: 8, height: 8 }),\n h('path', { class: 'tc-pattern-ink', d: TILES[item.index % SLOTS] as string }),\n ),\n )\n }\n return [...out.values()]\n}\n\n/** The `--tc-pattern-{n}` references for the chart root. */\nexport function patternVars(items: readonly LegendItem[], id: string): Record<string, string> {\n const vars: Record<string, string> = {}\n for (const item of items) {\n const [n] = slot(item.index)\n vars[`--tc-pattern-${n}`] = `url(#${id}-pattern-${n})`\n }\n return vars\n}\n\n/**\n * The pattern fills of a chart: its root class (`tc-patterned` with\n * `patterns: true`, `tc-patterns-auto` for forced colors), the root's\n * `--tc-pattern-{n}` references and the `<defs>` with the patterns;\n * `undefined` for a chart without legend entries.\n */\nexport function patternFills(\n config: ChartConfig<object>,\n id: string,\n): [string, Record<string, string>, VNode] | undefined {\n const { items } = resolveLegend(config)\n if (!items.length) return undefined\n return [\n config.patterns === true ? 'tc-patterned' : 'tc-patterns-auto',\n patternVars(items, id),\n h('defs', { key: 'patterns' }, patternDefs(items, id)),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,QAAQ;CAEZ;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;AACF;;AAGA,MAAM,QAAQ,MAAM;;AAGpB,MAAM,QAAQ,UACZ,QAAQ,QAAQ,CAAC,GAAG,QAAQ,KAAK,aAAa,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE;;AAG3E,SAAgB,YAAY,OAA8B,IAAqB;CAC7E,MAAM,sBAAM,IAAI,IAAmB;CACnC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,KAAK;EAChC,IAAI,IAAI,IAAI,CAAC,GAAG;EAChB,IAAI,IACF,GACAA,cAAAA,EACE,WACA;GACE,KAAK;GACL,IAAI,GAAG,GAAG,WAAW;GACrB,OAAO;IAAC;IAAc;IAAa;GAAG;GACtC,OAAO;GACP,QAAQ;GACR,cAAc;GAEd,OAAO,EAAE,qBAAqB,KAAK,MAAM;EAC3C,GACAA,cAAAA,EAAE,QAAQ;GAAE,OAAO;GAAiB,OAAO;GAAG,QAAQ;EAAE,CAAC,GACzDA,cAAAA,EAAE,QAAQ;GAAE,OAAO;GAAkB,GAAG,MAAM,KAAK,QAAQ;EAAiB,CAAC,CAC/E,CACF;CACF;CACA,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;;AAGA,SAAgB,YAAY,OAA8B,IAAoC;CAC5F,MAAM,OAA+B,CAAC;CACtC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,CAAC,KAAK,KAAK,KAAK,KAAK;EAC3B,KAAK,gBAAgB,OAAO,QAAQ,GAAG,WAAW,EAAE;CACtD;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,aACd,QACA,IACqD;CACrD,MAAM,EAAE,UAAUC,cAAAA,cAAc,MAAM;CACtC,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAA;CAC1B,OAAO;EACL,OAAO,aAAa,OAAO,iBAAiB;EAC5C,YAAY,OAAO,EAAE;EACrBD,cAAAA,EAAE,QAAQ,EAAE,KAAK,WAAW,GAAG,YAAY,OAAO,EAAE,CAAC;CACvD;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_features = require("./features-BclHgg2W.cjs");
|
|
3
|
+
const require_patterns = require("./patterns-LfcQAWCy.cjs");
|
|
4
|
+
//#region src/patterns.ts
|
|
5
|
+
/**
|
|
6
|
+
* Standalone entry: `import '@tabler/charts/patterns'` enables pattern fills
|
|
7
|
+
* (`patterns: true`, and in forced colors by default) on the core.
|
|
8
|
+
*/
|
|
9
|
+
require_features.register({ patterns: require_patterns.patternFills });
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.patternDefs = require_patterns.patternDefs;
|
|
12
|
+
exports.patternFills = require_patterns.patternFills;
|
|
13
|
+
exports.patternVars = require_patterns.patternVars;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=patterns.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.cjs","names":["register","patternFills"],"sources":["../src/patterns.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/patterns'` enables pattern fills\n * (`patterns: true`, and in forced colors by default) on the core.\n */\nimport { patternDefs, patternFills, patternVars } from './charts/patterns.ts'\nimport { register } from './features.ts'\n\nregister({ patterns: patternFills })\n\nexport { patternDefs, patternFills, patternVars }\n"],"mappings":";;;;;;;;AAOAA,iBAAAA,SAAS,EAAE,UAAUC,iBAAAA,aAAa,CAAC"}
|
package/dist/patterns.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { i as register } from "./features-wASyHGic.js";
|
|
2
|
+
import { n as patternFills, r as patternVars, t as patternDefs } from "./patterns-DtgcnA8o.js";
|
|
3
|
+
//#region src/patterns.ts
|
|
4
|
+
/**
|
|
5
|
+
* Standalone entry: `import '@tabler/charts/patterns'` enables pattern fills
|
|
6
|
+
* (`patterns: true`, and in forced colors by default) on the core.
|
|
7
|
+
*/
|
|
8
|
+
register({ patterns: patternFills });
|
|
9
|
+
//#endregion
|
|
10
|
+
export { patternDefs, patternFills, patternVars };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.js","names":[],"sources":["../src/patterns.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/patterns'` enables pattern fills\n * (`patterns: true`, and in forced colors by default) on the core.\n */\nimport { patternDefs, patternFills, patternVars } from './charts/patterns.ts'\nimport { register } from './features.ts'\n\nregister({ patterns: patternFills })\n\nexport { patternDefs, patternFills, patternVars }\n"],"mappings":";;;;;;;AAOA,SAAS,EAAE,UAAU,aAAa,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as InsetsInput } from "./annotations-Bp7HwtF5.js";
|
|
2
|
+
import { a as ClassValue } from "./vnode-BUflsBsa.js";
|
|
3
|
+
import { a as ChartType } from "./chart-iJGxMz9z.js";
|
|
4
|
+
import { c as NumberFormat } from "./time-CHjiY9Q4.js";
|
|
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-B8UlOZiq.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
const require_layout = require("./layout-CtMBhNd9.cjs");
|
|
2
|
+
const require_vnode = require("./vnode-CkQ27Cxe.cjs");
|
|
3
|
+
const require_format = require("./format-B0yKXBTH.cjs");
|
|
4
|
+
const require_features = require("./features-BclHgg2W.cjs");
|
|
5
|
+
const require_clean = require("./clean-Byl6kzf0.cjs");
|
|
6
|
+
const require_named = require("./named-BWWb5LQJ.cjs");
|
|
7
|
+
const require_sweep = require("./sweep-Duowaput.cjs");
|
|
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(require_named.keyOf(slice.data)));
|
|
16
|
+
const total = visible.reduce((sum, slice) => sum + slice.value, 0);
|
|
17
|
+
let angle = (options.startAngle ?? 0) * require_sweep.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 = require_layout.innerRect(width, height, require_layout.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 ? require_sweep.padAngleForGap(gap, inner, outer) : 0;
|
|
45
|
+
const value = require_format.formatNumber(options.format, locale);
|
|
46
|
+
const share = require_format.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] = require_sweep.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: require_sweep.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) * require_sweep.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) => require_vnode.h("g", require_named.groupAttrs(slice.data, slice.index), require_sweep.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 [require_vnode.h("g", {
|
|
118
|
+
class: "tc-pie",
|
|
119
|
+
style: `transform:translate(${cx}px,${cy}px)`
|
|
120
|
+
}, total === 0 && require_vnode.h("path", {
|
|
121
|
+
class: "tc-pie-track",
|
|
122
|
+
d: require_sweep.arcPathStable({
|
|
123
|
+
innerRadius: inner,
|
|
124
|
+
outerRadius: outer,
|
|
125
|
+
startAngle: 0,
|
|
126
|
+
endAngle: Math.PI * 2
|
|
127
|
+
})
|
|
128
|
+
}), require_vnode.h("g", {
|
|
129
|
+
class: "tc-pie-slices",
|
|
130
|
+
style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : void 0
|
|
131
|
+
}, groups)), showCenter && require_vnode.h("g", {
|
|
132
|
+
class: "tc-pie-center",
|
|
133
|
+
"aria-hidden": "true"
|
|
134
|
+
}, require_vnode.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 && require_vnode.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 = require_format.formatNumber(options.format, ctx.locale);
|
|
151
|
+
const share = require_format.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: require_clean.cleanData(require_clean.cleanItems),
|
|
172
|
+
render: (options, ctx) => {
|
|
173
|
+
require_features.features.sweep = require_sweep.sweep;
|
|
174
|
+
return renderPie(options, ctx, defaults);
|
|
175
|
+
},
|
|
176
|
+
legend: (options) => require_named.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
|
+
Object.defineProperty(exports, "donut", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function() {
|
|
201
|
+
return donut;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(exports, "pie", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function() {
|
|
207
|
+
return pie;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=pie-C1Pa6W_l.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-C1Pa6W_l.cjs","names":["keyOf","DEG","innerRect","insets","padAngleForGap","formatNumber","getNumberFormat","arcCentroid","arcPathStable","h","groupAttrs","arcNode","cleanData","cleanItems","sweep","legendItems"],"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,CAA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