@tabler/charts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +258 -2
- package/dist/annotations-Bp7HwtF5.d.ts +86 -0
- package/dist/annotations-BszTTjf9.js +202 -0
- package/dist/annotations-BszTTjf9.js.map +1 -0
- package/dist/annotations-DpETO8dE.cjs +213 -0
- package/dist/annotations-DpETO8dE.cjs.map +1 -0
- package/dist/annotations-lyt0I3HU.d.cts +86 -0
- package/dist/annotations.cjs +14 -0
- package/dist/annotations.cjs.map +1 -0
- package/dist/annotations.d.cts +2 -0
- package/dist/annotations.d.ts +2 -0
- package/dist/annotations.js +12 -0
- package/dist/annotations.js.map +1 -0
- package/dist/arc-BXpLrt9b.cjs +301 -0
- package/dist/arc-BXpLrt9b.cjs.map +1 -0
- package/dist/arc-a1tRTEw7.js +278 -0
- package/dist/arc-a1tRTEw7.js.map +1 -0
- package/dist/area-CF__HOwL.d.ts +20 -0
- package/dist/area-DIxaAbYZ.d.cts +20 -0
- package/dist/area-DQsLERhx.js +26 -0
- package/dist/area-DQsLERhx.js.map +1 -0
- package/dist/area-sHCE3pg5.cjs +31 -0
- package/dist/area-sHCE3pg5.cjs.map +1 -0
- package/dist/area.cjs +3 -0
- package/dist/area.d.cts +2 -0
- package/dist/area.d.ts +2 -0
- package/dist/area.js +2 -0
- package/dist/band-DTcNDAFO.d.cts +50 -0
- package/dist/band-DTcNDAFO.d.ts +50 -0
- package/dist/bar-BBM8RhoL.d.ts +43 -0
- package/dist/bar-C-7zR2qp.cjs +243 -0
- package/dist/bar-C-7zR2qp.cjs.map +1 -0
- package/dist/bar-CRKLDg98.d.cts +43 -0
- package/dist/bar-DGuUN3nc.cjs +67 -0
- package/dist/bar-DGuUN3nc.cjs.map +1 -0
- package/dist/bar-DM16NUvV.js +56 -0
- package/dist/bar-DM16NUvV.js.map +1 -0
- package/dist/bar-jZEoao74.js +238 -0
- package/dist/bar-jZEoao74.js.map +1 -0
- package/dist/bar.cjs +3 -0
- package/dist/bar.d.cts +2 -0
- package/dist/bar.d.ts +2 -0
- package/dist/bar.js +2 -0
- package/dist/candlestick-B5r1w3kc.cjs +150 -0
- package/dist/candlestick-B5r1w3kc.cjs.map +1 -0
- package/dist/candlestick-D_vV0_XZ.d.ts +44 -0
- package/dist/candlestick-DuXwAFID.js +145 -0
- package/dist/candlestick-DuXwAFID.js.map +1 -0
- package/dist/candlestick-__pXl_pV.d.cts +44 -0
- package/dist/candlestick.cjs +11 -0
- package/dist/candlestick.cjs.map +1 -0
- package/dist/candlestick.d.cts +2 -0
- package/dist/candlestick.d.ts +2 -0
- package/dist/candlestick.js +10 -0
- package/dist/candlestick.js.map +1 -0
- package/dist/cartesian-BoDfgBCV.cjs +900 -0
- package/dist/cartesian-BoDfgBCV.cjs.map +1 -0
- package/dist/cartesian-Cr0AF0nG.js +709 -0
- package/dist/cartesian-Cr0AF0nG.js.map +1 -0
- package/dist/chart-BF2CK9I_.js +790 -0
- package/dist/chart-BF2CK9I_.js.map +1 -0
- package/dist/chart-CowF_lWY.cjs +903 -0
- package/dist/chart-CowF_lWY.cjs.map +1 -0
- package/dist/chart-D7ooEFnk.d.cts +933 -0
- package/dist/chart-DyN7bcx8.d.ts +933 -0
- package/dist/circle-BQMuAfls.cjs +12 -0
- package/dist/circle-BQMuAfls.cjs.map +1 -0
- package/dist/circle-Z7YfCoCM.js +7 -0
- package/dist/circle-Z7YfCoCM.js.map +1 -0
- package/dist/clean-Byl6kzf0.cjs +115 -0
- package/dist/clean-Byl6kzf0.cjs.map +1 -0
- package/dist/clean-o1vDEhFV.js +56 -0
- package/dist/clean-o1vDEhFV.js.map +1 -0
- package/dist/core-CegR_j55.js +884 -0
- package/dist/core-CegR_j55.js.map +1 -0
- package/dist/core-D1vO1LrC.d.cts +220 -0
- package/dist/core-DcbemzGf.d.ts +220 -0
- package/dist/core-RzS9IQO5.cjs +985 -0
- package/dist/core-RzS9IQO5.cjs.map +1 -0
- package/dist/core.cjs +115 -0
- package/dist/core.d.cts +21 -0
- package/dist/core.d.ts +21 -0
- package/dist/core.js +25 -0
- package/dist/dates-Btm7Zm6W.cjs +32 -0
- package/dist/dates-Btm7Zm6W.cjs.map +1 -0
- package/dist/dates-CG-FvioW.js +27 -0
- package/dist/dates-CG-FvioW.js.map +1 -0
- package/dist/decimate-BGg9XgF0.d.ts +17 -0
- package/dist/decimate-C87cl_Sp.js +84 -0
- package/dist/decimate-C87cl_Sp.js.map +1 -0
- package/dist/decimate-CNSpgGa5.d.cts +17 -0
- package/dist/decimate-tLhDk1ys.cjs +95 -0
- package/dist/decimate-tLhDk1ys.cjs.map +1 -0
- package/dist/decimate.cjs +14 -0
- package/dist/decimate.cjs.map +1 -0
- package/dist/decimate.d.cts +2 -0
- package/dist/decimate.d.ts +2 -0
- package/dist/decimate.js +12 -0
- package/dist/decimate.js.map +1 -0
- package/dist/dom-CLF868Qs.cjs +222 -0
- package/dist/dom-CLF868Qs.cjs.map +1 -0
- package/dist/dom-vP3IcMak.js +175 -0
- package/dist/dom-vP3IcMak.js.map +1 -0
- package/dist/export-chart-9w8t3rjZ.js +232 -0
- package/dist/export-chart-9w8t3rjZ.js.map +1 -0
- package/dist/export-chart-BhhYgksr.cjs +249 -0
- package/dist/export-chart-BhhYgksr.cjs.map +1 -0
- package/dist/export.cjs +18 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +2 -0
- package/dist/export.d.ts +2 -0
- package/dist/export.js +15 -0
- package/dist/export.js.map +1 -0
- package/dist/extent-BAMZo0Nq.js +19 -0
- package/dist/extent-BAMZo0Nq.js.map +1 -0
- package/dist/extent-DsFWvAHJ.cjs +24 -0
- package/dist/extent-DsFWvAHJ.cjs.map +1 -0
- package/dist/fade-Cs74puQS.cjs +217 -0
- package/dist/fade-Cs74puQS.cjs.map +1 -0
- package/dist/fade-D3NxH5Qg.js +200 -0
- package/dist/fade-D3NxH5Qg.js.map +1 -0
- package/dist/features-BclHgg2W.cjs +48 -0
- package/dist/features-BclHgg2W.cjs.map +1 -0
- package/dist/features-wASyHGic.js +25 -0
- package/dist/features-wASyHGic.js.map +1 -0
- package/dist/format-B0yKXBTH.cjs +183 -0
- package/dist/format-B0yKXBTH.cjs.map +1 -0
- package/dist/format-lStwuc1L.js +142 -0
- package/dist/format-lStwuc1L.js.map +1 -0
- package/dist/gauge-D-FYhuds.cjs +236 -0
- package/dist/gauge-D-FYhuds.cjs.map +1 -0
- package/dist/gauge-DP_EB2z3.d.cts +65 -0
- package/dist/gauge-Dh423FHh.js +231 -0
- package/dist/gauge-Dh423FHh.js.map +1 -0
- package/dist/gauge-zpia05t2.d.ts +65 -0
- package/dist/gauge.cjs +3 -0
- package/dist/gauge.d.cts +2 -0
- package/dist/gauge.d.ts +2 -0
- package/dist/gauge.js +2 -0
- package/dist/heatmap-BK18EBgJ.cjs +247 -0
- package/dist/heatmap-BK18EBgJ.cjs.map +1 -0
- package/dist/heatmap-BectCEeE.d.ts +81 -0
- package/dist/heatmap-CCso6m61.d.cts +81 -0
- package/dist/heatmap-DSZ2bVIa.js +242 -0
- package/dist/heatmap-DSZ2bVIa.js.map +1 -0
- package/dist/heatmap.cjs +3 -0
- package/dist/heatmap.d.cts +2 -0
- package/dist/heatmap.d.ts +2 -0
- package/dist/heatmap.js +2 -0
- package/dist/hydrate-CTTmQy0x.d.cts +10 -0
- package/dist/hydrate-CxwTXDqO.cjs +60 -0
- package/dist/hydrate-CxwTXDqO.cjs.map +1 -0
- package/dist/hydrate-CzfxLfTv.d.ts +10 -0
- package/dist/hydrate-DDNIHYv_.js +55 -0
- package/dist/hydrate-DDNIHYv_.js.map +1 -0
- package/dist/hydrate.cjs +13 -0
- package/dist/hydrate.cjs.map +1 -0
- package/dist/hydrate.d.cts +2 -0
- package/dist/hydrate.d.ts +2 -0
- package/dist/hydrate.js +12 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index.cjs +214 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -0
- package/dist/layout-B3hiqVEw.js +69 -0
- package/dist/layout-B3hiqVEw.js.map +1 -0
- package/dist/layout-CtMBhNd9.cjs +98 -0
- package/dist/layout-CtMBhNd9.cjs.map +1 -0
- package/dist/line-B3Ed6u7j.js +120 -0
- package/dist/line-B3Ed6u7j.js.map +1 -0
- package/dist/line-CN4uZ9ZX.d.ts +47 -0
- package/dist/line-W7VD_qs1.d.cts +47 -0
- package/dist/line-fQbtP_jL.cjs +131 -0
- package/dist/line-fQbtP_jL.cjs.map +1 -0
- package/dist/line.cjs +14 -0
- package/dist/line.cjs.map +1 -0
- package/dist/line.d.cts +2 -0
- package/dist/line.d.ts +2 -0
- package/dist/line.js +13 -0
- package/dist/line.js.map +1 -0
- package/dist/log-CaofN3-n.d.cts +48 -0
- package/dist/log-CaofN3-n.d.ts +48 -0
- package/dist/log-axis-83rSpvL5.cjs +130 -0
- package/dist/log-axis-83rSpvL5.cjs.map +1 -0
- package/dist/log-axis-B_uvvOFc.js +113 -0
- package/dist/log-axis-B_uvvOFc.js.map +1 -0
- package/dist/log.cjs +17 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.d.cts +2 -0
- package/dist/log.d.ts +2 -0
- package/dist/log.js +16 -0
- package/dist/log.js.map +1 -0
- package/dist/morph-BMxz3X2b.d.cts +10 -0
- package/dist/morph-BMxz3X2b.d.ts +10 -0
- package/dist/morph-Bgg-24l8.js +36 -0
- package/dist/morph-Bgg-24l8.js.map +1 -0
- package/dist/morph-CqYDu1bY.cjs +41 -0
- package/dist/morph-CqYDu1bY.cjs.map +1 -0
- package/dist/morph.cjs +14 -0
- package/dist/morph.cjs.map +1 -0
- package/dist/morph.d.cts +2 -0
- package/dist/morph.d.ts +2 -0
- package/dist/morph.js +13 -0
- package/dist/morph.js.map +1 -0
- package/dist/named-BWWb5LQJ.cjs +50 -0
- package/dist/named-BWWb5LQJ.cjs.map +1 -0
- package/dist/named-DE15TOgh.js +33 -0
- package/dist/named-DE15TOgh.js.map +1 -0
- package/dist/parliament-1Zv2Xh0D.d.ts +69 -0
- package/dist/parliament-CpWnoEvG.cjs +308 -0
- package/dist/parliament-CpWnoEvG.cjs.map +1 -0
- package/dist/parliament-DdrLVZwt.d.cts +69 -0
- package/dist/parliament-Dw0sOERi.js +303 -0
- package/dist/parliament-Dw0sOERi.js.map +1 -0
- package/dist/parliament.cjs +3 -0
- package/dist/parliament.d.cts +2 -0
- package/dist/parliament.d.ts +2 -0
- package/dist/parliament.js +2 -0
- package/dist/path-CwB28da0.d.cts +29 -0
- package/dist/path-CwB28da0.d.ts +29 -0
- package/dist/patterns-DtgcnA8o.js +85 -0
- package/dist/patterns-DtgcnA8o.js.map +1 -0
- package/dist/patterns-LfcQAWCy.cjs +102 -0
- package/dist/patterns-LfcQAWCy.cjs.map +1 -0
- package/dist/patterns.cjs +15 -0
- package/dist/patterns.cjs.map +1 -0
- package/dist/patterns.d.cts +2 -0
- package/dist/patterns.d.ts +2 -0
- package/dist/patterns.js +12 -0
- package/dist/patterns.js.map +1 -0
- package/dist/pie-5z1fDdKO.d.ts +58 -0
- package/dist/pie-BF9yI5mE.d.cts +58 -0
- package/dist/pie-BxTZt6Go.cjs +212 -0
- package/dist/pie-BxTZt6Go.cjs.map +1 -0
- package/dist/pie-DzUXDTcn.js +201 -0
- package/dist/pie-DzUXDTcn.js.map +1 -0
- package/dist/pie.cjs +4 -0
- package/dist/pie.d.cts +2 -0
- package/dist/pie.d.ts +2 -0
- package/dist/pie.js +2 -0
- package/dist/point-shapes-CGl4dugc.cjs +166 -0
- package/dist/point-shapes-CGl4dugc.cjs.map +1 -0
- package/dist/point-shapes-DI84NNpI.js +155 -0
- package/dist/point-shapes-DI84NNpI.js.map +1 -0
- package/dist/point-shapes.cjs +15 -0
- package/dist/point-shapes.cjs.map +1 -0
- package/dist/point-shapes.d.cts +2 -0
- package/dist/point-shapes.d.ts +2 -0
- package/dist/point-shapes.js +13 -0
- package/dist/point-shapes.js.map +1 -0
- package/dist/radar-1-EryihA.d.ts +60 -0
- package/dist/radar-CYPab_I4.js +285 -0
- package/dist/radar-CYPab_I4.js.map +1 -0
- package/dist/radar-CoGUNNSb.cjs +290 -0
- package/dist/radar-CoGUNNSb.cjs.map +1 -0
- package/dist/radar-DBW4O0Vt.d.cts +60 -0
- package/dist/radar.cjs +3 -0
- package/dist/radar.d.cts +2 -0
- package/dist/radar.d.ts +2 -0
- package/dist/radar.js +2 -0
- package/dist/sankey-B4PNKusJ.js +420 -0
- package/dist/sankey-B4PNKusJ.js.map +1 -0
- package/dist/sankey-Bacx4fVe.cjs +425 -0
- package/dist/sankey-Bacx4fVe.cjs.map +1 -0
- package/dist/sankey-DuGI3Qc5.d.cts +67 -0
- package/dist/sankey-OV_WoPrl.d.ts +67 -0
- package/dist/sankey.cjs +3 -0
- package/dist/sankey.d.cts +2 -0
- package/dist/sankey.d.ts +2 -0
- package/dist/sankey.js +2 -0
- package/dist/scatter-BqzgJqdX.d.ts +61 -0
- package/dist/scatter-DbxLyZX0.d.cts +61 -0
- package/dist/scatter-DgMN9zRy.cjs +250 -0
- package/dist/scatter-DgMN9zRy.cjs.map +1 -0
- package/dist/scatter-kgtgR318.js +245 -0
- package/dist/scatter-kgtgR318.js.map +1 -0
- package/dist/scatter.cjs +3 -0
- package/dist/scatter.d.cts +2 -0
- package/dist/scatter.d.ts +2 -0
- package/dist/scatter.js +2 -0
- package/dist/sparkline-BQzt27Fr.js +171 -0
- package/dist/sparkline-BQzt27Fr.js.map +1 -0
- package/dist/sparkline-BS9-hltA.cjs +176 -0
- package/dist/sparkline-BS9-hltA.cjs.map +1 -0
- package/dist/sparkline-BfyO_oNM.d.ts +43 -0
- package/dist/sparkline-CWlJDKyh.d.cts +43 -0
- package/dist/sparkline.cjs +3 -0
- package/dist/sparkline.d.cts +2 -0
- package/dist/sparkline.d.ts +2 -0
- package/dist/sparkline.js +2 -0
- package/dist/stack-CpR6RGKd.d.cts +6 -0
- package/dist/stack-CpR6RGKd.d.ts +6 -0
- package/dist/stack-DRbwTeF3.js +66 -0
- package/dist/stack-DRbwTeF3.js.map +1 -0
- package/dist/stack-DVhJWaki.cjs +77 -0
- package/dist/stack-DVhJWaki.cjs.map +1 -0
- package/dist/style.css +2 -0
- package/dist/sweep-CbfR7--d.js +60 -0
- package/dist/sweep-CbfR7--d.js.map +1 -0
- package/dist/sweep-DaTEDDuC.cjs +71 -0
- package/dist/sweep-DaTEDDuC.cjs.map +1 -0
- package/dist/time-CHjiY9Q4.d.ts +112 -0
- package/dist/time-CNVnt-B2.d.cts +112 -0
- package/dist/time-axis-Bc9eHX1r.js +365 -0
- package/dist/time-axis-Bc9eHX1r.js.map +1 -0
- package/dist/time-axis-VSX34_Tb.cjs +382 -0
- package/dist/time-axis-VSX34_Tb.cjs.map +1 -0
- package/dist/time.cjs +22 -0
- package/dist/time.cjs.map +1 -0
- package/dist/time.d.cts +2 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +20 -0
- package/dist/time.js.map +1 -0
- package/dist/tween-BCYd0RTY.js +40 -0
- package/dist/tween-BCYd0RTY.js.map +1 -0
- package/dist/tween-CIGBlryn.cjs +51 -0
- package/dist/tween-CIGBlryn.cjs.map +1 -0
- package/dist/value-labels-B0WJoJ7x.cjs +134 -0
- package/dist/value-labels-B0WJoJ7x.cjs.map +1 -0
- package/dist/value-labels-IZIQPhfk.js +123 -0
- package/dist/value-labels-IZIQPhfk.js.map +1 -0
- package/dist/value-labels.cjs +14 -0
- package/dist/value-labels.cjs.map +1 -0
- package/dist/value-labels.d.cts +2 -0
- package/dist/value-labels.d.ts +2 -0
- package/dist/value-labels.js +12 -0
- package/dist/value-labels.js.map +1 -0
- package/dist/vnode-BUflsBsa.d.cts +66 -0
- package/dist/vnode-BUflsBsa.d.ts +66 -0
- package/dist/vnode-CkQ27Cxe.cjs +110 -0
- package/dist/vnode-CkQ27Cxe.cjs.map +1 -0
- package/dist/vnode-tCWItoUH.js +93 -0
- package/dist/vnode-tCWItoUH.js.map +1 -0
- package/package.json +320 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatter-kgtgR318.js","names":[],"sources":["../src/charts/scatter.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { axis, axisSize, type Tick, thinTicks } from '../components/axis.ts'\nimport { grid } from '../components/grid.ts'\nimport { formatDetail, formatNumber } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n innerRect,\n insets,\n LINE_HEIGHT,\n round,\n} from '../layout.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport {\n domainOf,\n markerShape,\n plotClip,\n plottable,\n tickCount,\n type ValueAxisOptions,\n valueScale,\n valueTicks,\n} from './cartesian.ts'\nimport { cleanData, finite, isRecord, named, records, text } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** A point of a scatter or bubble chart. */\nexport interface ScatterPoint {\n x: number\n y: number\n /** Bubble size; the circle area is proportional to it. */\n size?: number\n /** Name shown in the tooltip and table (e.g. a country). */\n label?: string\n}\n\nexport interface ScatterSeries {\n name: string\n points: readonly ScatterPoint[]\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 series group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface ScatterOptions {\n data: { series: readonly ScatterSeries[] }\n /** Horizontal value axis. */\n x?: ValueAxisOptions\n /** Vertical value axis. */\n y?: ValueAxisOptions\n /** Radius of points without a size, in pixels. Defaults to `4`. */\n radius?: number\n /** Radius range for bubbles (points with `size`). Defaults to `{ min: 4, max: 24 }`. */\n size?: { min?: number; max?: number }\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\n/** Pointer distance (in pixels, beyond the radius) that still hits a point. */\nconst HIT_RADIUS = 24\nconst EDGE = 8\n\ninterface Placed {\n seriesIndex: number\n pointIndex: number\n point: ScatterPoint\n cx: number\n cy: number\n r: number\n}\n\n/** A point's bubble size, or `undefined` when it has none (or an invalid one). */\nconst sizeOf = (p: ScatterPoint): number | undefined =>\n p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : undefined\n\nfunction renderScatter(options: ScatterOptions, ctx: RenderContext) {\n const { width, height, fontSize, locale } = ctx\n const xOptions = options.x ?? {}\n const yOptions = options.y ?? {}\n const radius = options.radius ?? 4\n const visible = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const points = visible.flatMap((s) => s.points)\n const sizes = points.map(sizeOf).filter((v): v is number => v !== undefined)\n const maxSize = extent(sizes)?.[1] ?? 0\n const rMin = options.size?.min ?? 4\n const rMax = options.size?.max ?? 24\n // Area-proportional bubbles: the radius grows with the square root of the size.\n const bubble = (size: number | undefined) =>\n size != null && size > 0 && maxSize > 0\n ? rMin + (rMax - rMin) * Math.sqrt(size / maxSize)\n : radius\n const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2\n\n const countY = tickCount(yOptions, Math.max(2, Math.round(height / 60)))\n const countX = tickCount(xOptions, Math.max(2, Math.round(width / 80)))\n // Only points that can be plotted on both axes take part.\n const usable = (p: ScatterPoint) => plottable(p.x, xOptions) && plottable(p.y, yOptions)\n const shown = points.filter(usable)\n const xDomain = domainOf(\n shown.map((p) => p.x),\n xOptions,\n false,\n countX,\n )\n const yDomain = domainOf(\n shown.map((p) => p.y),\n yOptions,\n false,\n countY,\n )\n\n const showX = xOptions.show !== false\n const showY = yOptions.show !== false\n // Linear or logarithmic, as each axis asks (see valueScale).\n const ticksOf = (scale: LinearScale, axis: ValueAxisOptions, count: number) =>\n valueTicks(scale, axis, count, axis.format, locale)\n const probeY = ticksOf(valueScale(yDomain, [1, 0], yOptions), yOptions, countY)\n const probeX = ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX)\n const half = (tick: Tick | undefined) =>\n showX && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0\n const pad = insets(options.padding)\n const margins = {\n top:\n pad.top + Math.max(showY ? Math.ceil((fontSize * LINE_HEIGHT) / 2) : 0, overhang, EDGE / 2),\n right: pad.right + Math.max(half(probeX[probeX.length - 1]), overhang, EDGE),\n bottom:\n pad.bottom + Math.max(showX ? axisSize('bottom', probeX, fontSize) : 0, overhang, EDGE / 2),\n left:\n pad.left +\n Math.max(showY ? axisSize('left', probeY, fontSize) : 0, half(probeX[0]), overhang),\n }\n const area = innerRect(width, height, margins)\n const x = valueScale(xDomain, [area.x, area.x + area.width], xOptions)\n const y = valueScale(yDomain, [area.y + area.height, area.y], yOptions)\n // Thinned like the ticks of the other charts: on a log axis they crowd at the end of each decade.\n const xTicks = thinTicks(ticksOf(x, xOptions, countX), 'bottom', fontSize)\n const yTicks = thinTicks(ticksOf(y, yOptions, countY), 'left', fontSize, 4)\n\n // Every visible point in pixels, sorted by x for fast nearest-point lookups.\n const placed: Placed[] = []\n options.data.series.forEach((series, seriesIndex) => {\n if (ctx.hidden.has(keyOf(series))) return\n series.points.forEach((point, pointIndex) => {\n if (!usable(point)) return\n placed.push({\n seriesIndex,\n pointIndex,\n point,\n cx: x(point.x),\n cy: y(point.y),\n r: bubble(sizeOf(point)),\n })\n })\n })\n placed.sort((a, b) => a.cx - b.cx)\n\n const fx = formatDetail(xOptions.format, locale)\n const fy = formatDetail(yOptions.format, locale)\n const fs = formatNumber(undefined, locale)\n const hitFor = (p: Placed, index: number): Hit => {\n const series = options.data.series[p.seriesIndex] as ScatterSeries\n const sz = sizeOf(p.point)\n const size = sz === undefined ? '' : ` · ${fs(sz)}`\n const item: HitItem = {\n name: series.name,\n seriesIndex: p.seriesIndex,\n value: p.point.y,\n text: `${fx(p.point.x)}, ${fy(p.point.y)}${size}`,\n x: p.cx,\n y: p.cy,\n }\n if (series.color) item.color = series.color\n return {\n index,\n label: p.point.label ?? series.name,\n title: p.point.label ?? '',\n x: p.cx,\n area,\n items: [item],\n seriesIndex: p.seriesIndex,\n mark: { d: circlePath(round(p.r + 4)), x: p.cx, y: p.cy },\n }\n }\n\n const interaction: Interaction = {\n count: placed.length,\n hitIndex: (index) => {\n const p = placed[index]\n return p ? hitFor(p, index) : null\n },\n hitTest(px, py) {\n // Binary search the first point within reach on x, then scan the window.\n let lo = 0\n let hi = placed.length\n const reach = HIT_RADIUS + rMax\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n if ((placed[mid] as Placed).cx < px - reach) lo = mid + 1\n else hi = mid\n }\n let best = -1\n let bestDistance = Number.POSITIVE_INFINITY\n for (let i = lo; i < placed.length; i++) {\n const p = placed[i] as Placed\n if (p.cx > px + reach) break\n const distance = Math.hypot(p.cx - px, p.cy - py) - p.r\n if (distance < bestDistance && distance <= HIT_RADIUS) {\n best = i\n bestDistance = distance\n }\n }\n return best === -1 ? null : hitFor(placed[best] as Placed, best)\n },\n }\n ctx.onHitTest(interaction)\n\n /** One path drawing a dot of `radius` at every point (two arcs each, or the series' shape). */\n const shape = markerShape(options)\n const dotsPath = (dots: readonly ScatterPoint[], slot: number) => {\n if (!dots.length) return null\n const r = round(radius)\n let d = ''\n for (const p of dots) {\n d += shape\n ? shape(slot, x(p.x), y(p.y), r)\n : `M${round(x(p.x) - radius)},${round(y(p.y))}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0`\n }\n return h('path', { key: 'dots', class: ['tc-point tc-dots', shape && 'tc-marker'], d })\n }\n\n const background = []\n if (yOptions.grid !== false) background.push(grid({ direction: 'y', ticks: yTicks, area }))\n if (xOptions.grid) background.push(grid({ direction: 'x', ticks: xTicks, area }))\n\n // Dots may reach a little past the plot edges; bubbles are cut at them (like\n // Chart.js), as a big one there would cover the axis labels.\n const clip = plotClip(ctx, area, sizes.length ? 0 : overhang)\n const groups = options.data.series.map(\n (series, seriesIndex) =>\n !ctx.hidden.has(keyOf(series)) &&\n h(\n 'g',\n groupAttrs(series, seriesIndex),\n // Plain points share one path per series: thousands of circles would\n // each cost the browser style and layout work. The path keeps its\n // commands while the point count does, so new data morphs. Bubbles\n // stay circles: each is see-through over the others.\n dotsPath(\n series.points.filter((p) => usable(p) && sizeOf(p) === undefined),\n seriesIndex,\n ),\n series.points.map(\n (point, i) =>\n usable(point) &&\n sizeOf(point) !== undefined &&\n h('circle', {\n key: i,\n class: 'tc-point tc-bubble',\n cx: round(x(point.x)),\n cy: round(y(point.y)),\n r: round(bubble(sizeOf(point))),\n }),\n ),\n ),\n )\n\n return [\n h('defs', null, clip.def),\n background,\n h('g', { key: 'series', class: 'tc-series-list', 'clip-path': clip.url }, groups),\n showY && axis({ position: 'left', ticks: yTicks, area }),\n showX && axis({ position: 'bottom', ticks: xTicks, area }),\n ]\n}\n\nfunction scatterTable(\n options: ScatterOptions,\n ctx: RenderContext,\n limit: number = Number.POSITIVE_INFINITY,\n): DataTable {\n const fx = formatDetail(options.x?.format, ctx.locale)\n const fy = formatDetail(options.y?.format, ctx.locale)\n const fs = formatNumber(undefined, ctx.locale)\n const series = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const withSize = series.some((s) => s.points.some((p) => p.size != null))\n const withLabel = series.some((s) => s.points.some((p) => p.label != null))\n const total = series.reduce((sum, s) => sum + s.points.length, 0)\n let left = limit\n return {\n columns: ['', ...(withLabel ? ['Label'] : []), 'x', 'y', ...(withSize ? ['Size'] : [])],\n total,\n rows: series.flatMap((s) => {\n const take = s.points.slice(0, Math.max(0, left))\n left -= take.length\n return take.map((p) => [\n s.name,\n ...(withLabel ? [p.label ?? ''] : []),\n fx(p.x),\n fy(p.y),\n ...(withSize ? [sizeOf(p) === undefined ? '–' : fs(sizeOf(p) as number)] : []),\n ])\n }),\n }\n}\n\n/**\n * Scatter chart: points on two value axes; give points a `size` for a\n * bubble chart (area-proportional radii).\n *\n * ```ts\n * new Chart('#el', {\n * type: scatter,\n * data: { series: [{ name: 'Cities', points: [{ x: 12, y: 3.4 }, { x: 18, y: 5.1 }] }] },\n * })\n * ```\n */\nexport const scatter: ChartType<ScatterOptions> = {\n name: 'scatter',\n clean: cleanData((data) => ({\n ...(isRecord(data) ? data : {}),\n series: records(isRecord(data) && data.series, (s) => ({\n ...named(s),\n points: records(s.points, (p) => ({\n ...p,\n x: finite(p.x),\n y: finite(p.y),\n size: finite(p.size) ?? undefined,\n label: p.label == null ? undefined : text(p.label),\n })).filter((p) => p.x !== null && p.y !== null),\n })),\n })),\n render: renderScatter,\n legend: (options) => legendItems(options.data.series),\n table: scatterTable,\n valueLabels: { format: (options) => options.y?.format },\n}\n"],"mappings":";;;;;;;;;;AAwEA,MAAM,aAAa;AACnB,MAAM,OAAO;;AAYb,MAAM,UAAU,MACd,EAAE,QAAQ,QAAQ,OAAO,SAAS,EAAE,IAAI,KAAK,EAAE,OAAO,IAAI,EAAE,OAAO,KAAA;AAErE,SAAS,cAAc,SAAyB,KAAoB;CAClE,MAAM,EAAE,OAAO,QAAQ,UAAU,WAAW;CAC5C,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,SAAS,QAAQ,UAAU;CAEjC,MAAM,SADU,QAAQ,KAAK,OAAO,QAAQ,MAAM,CAAC,IAAI,OAAO,IAAI,MAAM,CAAC,CAAC,CACrD,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM;CAC9C,MAAM,QAAQ,OAAO,IAAI,MAAM,CAAC,CAAC,QAAQ,MAAmB,MAAM,KAAA,CAAS;CAC3E,MAAM,UAAU,OAAO,KAAK,CAAC,GAAG,MAAM;CACtC,MAAM,OAAO,QAAQ,MAAM,OAAO;CACl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MAAM,OAAO,SAAS,MAAM;GAC1B,MAAM,OAAO,EAAE,OAAO,MAAM,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;GAChD,QAAQ,KAAK;GACb,OAAO,KAAK,KAAK,MAAM;IACrB,EAAE;IACF,GAAI,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC;IACnC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAI,WAAW,CAAC,OAAO,CAAC,MAAM,KAAA,IAAY,MAAM,GAAG,OAAO,CAAC,CAAW,CAAC,IAAI,CAAC;GAC9E,CAAC;EACH,CAAC;CACH;AACF;;;;;;;;;;;;AAaA,MAAa,UAAqC;CAChD,MAAM;CACN,OAAO,WAAW,UAAU;EAC1B,GAAI,SAAS,IAAI,IAAI,OAAO,CAAC;EAC7B,QAAQ,QAAQ,SAAS,IAAI,KAAK,KAAK,SAAS,OAAO;GACrD,GAAG,MAAM,CAAC;GACV,QAAQ,QAAQ,EAAE,SAAS,OAAO;IAChC,GAAG;IACH,GAAG,OAAO,EAAE,CAAC;IACb,GAAG,OAAO,EAAE,CAAC;IACb,MAAM,OAAO,EAAE,IAAI,KAAK,KAAA;IACxB,OAAO,EAAE,SAAS,OAAO,KAAA,IAAY,KAAK,EAAE,KAAK;GACnD,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE,MAAM,QAAQ,EAAE,MAAM,IAAI;EAChD,EAAE;CACJ,EAAE;CACF,QAAQ;CACR,SAAS,YAAY,YAAY,QAAQ,KAAK,MAAM;CACpD,OAAO;CACP,aAAa,EAAE,SAAS,YAAY,QAAQ,GAAG,OAAO;AACxD"}
|
package/dist/scatter.cjs
ADDED
package/dist/scatter.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { a as round, i as insets, r as innerRect } from "./layout-B3hiqVEw.js";
|
|
2
|
+
import { t as h } from "./vnode-tCWItoUH.js";
|
|
3
|
+
import { r as formatNumber } from "./format-lStwuc1L.js";
|
|
4
|
+
import { b as linear, o as labelKey, r as domainOf } from "./cartesian-Cr0AF0nG.js";
|
|
5
|
+
import { c as numbers, o as label, t as cleanData } from "./clean-o1vDEhFV.js";
|
|
6
|
+
import { n as areaPath, r as linePath, t as fadeMask } from "./fade-D3NxH5Qg.js";
|
|
7
|
+
import { t as barPath } from "./bar-DM16NUvV.js";
|
|
8
|
+
import { t as circlePath } from "./circle-Z7YfCoCM.js";
|
|
9
|
+
//#region src/charts/sparkline.ts
|
|
10
|
+
function renderSparkline(options, ctx) {
|
|
11
|
+
const { variant = "line", curve = "monotone", point = "last", markers = "none", pointRadius = 3, name = "Value" } = options;
|
|
12
|
+
const values = options.data.map((v) => v == null || !Number.isFinite(v) ? null : v);
|
|
13
|
+
const count = values.length;
|
|
14
|
+
const overhang = point === "last" || markers === "minmax" ? pointRadius + 2 : 2;
|
|
15
|
+
const pad = insets(options.padding, 0);
|
|
16
|
+
const area = innerRect(ctx.width, ctx.height, {
|
|
17
|
+
top: pad.top + overhang,
|
|
18
|
+
right: pad.right + overhang,
|
|
19
|
+
bottom: pad.bottom + overhang,
|
|
20
|
+
left: pad.left + overhang
|
|
21
|
+
});
|
|
22
|
+
const tristate = variant === "tristate";
|
|
23
|
+
const zero = options.zero ?? variant !== "line";
|
|
24
|
+
const domain = tristate ? [-1, 1] : domainOf(values, { nice: false }, zero, 2);
|
|
25
|
+
const bars = variant === "bar" || tristate;
|
|
26
|
+
const gap = 1;
|
|
27
|
+
const slot = count > 0 ? area.width / count : 0;
|
|
28
|
+
const xAt = (i) => bars ? area.x + slot * i + slot / 2 : area.x + (count > 1 ? area.width * i / (count - 1) : area.width / 2);
|
|
29
|
+
const y = linear(domain, [area.y + area.height, area.y]);
|
|
30
|
+
const baseline = y(Math.min(Math.max(0, domain[0]), domain[1]));
|
|
31
|
+
const points = values.map((v, i) => v === null ? null : [xAt(i), y(v)]);
|
|
32
|
+
const format = formatNumber(options.format, ctx.locale);
|
|
33
|
+
const labelOf = (i) => {
|
|
34
|
+
const label = options.labels?.[i];
|
|
35
|
+
return label === void 0 ? "" : String(label);
|
|
36
|
+
};
|
|
37
|
+
const yOf = (v) => y(tristate ? Math.sign(v) : v);
|
|
38
|
+
const hitFor = (i) => {
|
|
39
|
+
const value = values[i];
|
|
40
|
+
if (value === void 0) return null;
|
|
41
|
+
const px = xAt(i);
|
|
42
|
+
const item = {
|
|
43
|
+
name,
|
|
44
|
+
seriesIndex: 0,
|
|
45
|
+
value,
|
|
46
|
+
text: value === null ? "–" : format(value),
|
|
47
|
+
x: px,
|
|
48
|
+
y: value === null ? null : yOf(value)
|
|
49
|
+
};
|
|
50
|
+
const hit = {
|
|
51
|
+
index: i,
|
|
52
|
+
label: labelKey(options.labels?.[i] ?? i + 1),
|
|
53
|
+
title: labelOf(i),
|
|
54
|
+
x: px,
|
|
55
|
+
area,
|
|
56
|
+
items: [item]
|
|
57
|
+
};
|
|
58
|
+
if (value !== null) hit.mark = {
|
|
59
|
+
d: circlePath(pointRadius + 3),
|
|
60
|
+
x: px,
|
|
61
|
+
y: yOf(value)
|
|
62
|
+
};
|
|
63
|
+
return hit;
|
|
64
|
+
};
|
|
65
|
+
const interaction = {
|
|
66
|
+
count,
|
|
67
|
+
hitIndex: (i) => hitFor(i),
|
|
68
|
+
hitTest(px, py) {
|
|
69
|
+
if (count === 0 || py < area.y - overhang || py > area.y + area.height + overhang) return null;
|
|
70
|
+
const i = bars ? Math.floor((px - area.x) / slot) : Math.round((px - area.x) / Math.max(1, area.width) * (count - 1));
|
|
71
|
+
return hitFor(Math.max(0, Math.min(count - 1, i)));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
ctx.onHitTest(interaction);
|
|
75
|
+
const marks = [];
|
|
76
|
+
if (tristate) {
|
|
77
|
+
const width = Math.max(1, slot - gap);
|
|
78
|
+
marks.push(h("line", {
|
|
79
|
+
class: "tc-sparkline-zero",
|
|
80
|
+
x1: area.x,
|
|
81
|
+
x2: area.x + area.width,
|
|
82
|
+
y1: round(baseline),
|
|
83
|
+
y2: round(baseline)
|
|
84
|
+
}));
|
|
85
|
+
values.forEach((v, i) => {
|
|
86
|
+
if (v === null) return;
|
|
87
|
+
const sign = Math.sign(v);
|
|
88
|
+
const tick = Math.min(2, area.height / 2);
|
|
89
|
+
const [from, to] = sign === 0 ? [baseline + tick / 2, baseline - tick / 2] : [baseline, y(sign)];
|
|
90
|
+
marks.push(h("path", {
|
|
91
|
+
key: i,
|
|
92
|
+
class: [
|
|
93
|
+
"tc-bar",
|
|
94
|
+
sign < 0 && "tc-bar-negative",
|
|
95
|
+
sign < 0 ? "tc-tristate-loss" : sign > 0 ? "tc-tristate-win" : "tc-tristate-draw"
|
|
96
|
+
],
|
|
97
|
+
d: barPath(xAt(i) - width / 2, width, from, to, sign === 0 ? 0 : Math.min(2, width / 2))
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
} else if (bars) {
|
|
101
|
+
const width = Math.max(1, slot - gap);
|
|
102
|
+
values.forEach((v, i) => {
|
|
103
|
+
if (v === null) return;
|
|
104
|
+
marks.push(h("path", {
|
|
105
|
+
key: i,
|
|
106
|
+
class: ["tc-bar", v < 0 && "tc-bar-negative"],
|
|
107
|
+
d: barPath(xAt(i) - width / 2, width, baseline, y(v), Math.min(2, width / 2))
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
if (variant === "area") marks.push(h("path", {
|
|
112
|
+
class: "tc-area tc-area-gradient",
|
|
113
|
+
d: areaPath(points, baseline, { curve }),
|
|
114
|
+
mask: `url(#${ctx.id}-fade)`
|
|
115
|
+
}));
|
|
116
|
+
marks.push(h("path", {
|
|
117
|
+
class: "tc-line",
|
|
118
|
+
d: linePath(points, { curve })
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
const dotAt = (i, cls) => {
|
|
122
|
+
const v = values[i];
|
|
123
|
+
return v == null ? null : h("circle", {
|
|
124
|
+
key: `${cls}-${i}`,
|
|
125
|
+
class: ["tc-point", cls],
|
|
126
|
+
cx: round(xAt(i)),
|
|
127
|
+
cy: round(y(v)),
|
|
128
|
+
r: pointRadius
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const extremes = [];
|
|
132
|
+
if (markers === "minmax") {
|
|
133
|
+
let min = -1;
|
|
134
|
+
let max = -1;
|
|
135
|
+
values.forEach((v, i) => {
|
|
136
|
+
if (v === null) return;
|
|
137
|
+
if (min === -1 || v < values[min]) min = i;
|
|
138
|
+
if (max === -1 || v > values[max]) max = i;
|
|
139
|
+
});
|
|
140
|
+
if (min !== -1) extremes.push(dotAt(min, "tc-point-min"));
|
|
141
|
+
if (max !== -1 && max !== min) extremes.push(dotAt(max, "tc-point-max"));
|
|
142
|
+
}
|
|
143
|
+
let last = -1;
|
|
144
|
+
if (point === "last") {
|
|
145
|
+
for (let i = count - 1; i >= 0; i--) if (values[i] !== null) {
|
|
146
|
+
last = i;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return [variant === "area" && h("defs", null, fadeMask(`${ctx.id}-fade`)), h("g", { class: "tc-series tc-series-1 tc-sparkline" }, marks, extremes, last !== -1 && !bars && dotAt(last, "tc-point-last"))];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sparkline: a tiny line, area or bar chart without axes, for stat tiles.
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
const sparkline = {
|
|
160
|
+
name: "sparkline",
|
|
161
|
+
clean: (options) => ({
|
|
162
|
+
...cleanData(numbers)(options),
|
|
163
|
+
labels: Array.isArray(options.labels) ? options.labels.map(label) : void 0
|
|
164
|
+
}),
|
|
165
|
+
render: renderSparkline,
|
|
166
|
+
keyboard: false
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
export { sparkline as t };
|
|
170
|
+
|
|
171
|
+
//# sourceMappingURL=sparkline-BQzt27Fr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sparkline-BQzt27Fr.js","names":[],"sources":["../src/charts/sparkline.ts"],"sourcesContent":["import type { ChartType, RenderContext } from '../chart.ts'\nimport { fadeMask } from '../components/fade.ts'\nimport { formatNumber, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets, round } from '../layout.ts'\nimport { linear } from '../scales/linear.ts'\nimport { barPath } from '../shapes/bar.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { areaPath, type Curve, linePath, type Point } from '../shapes/path.ts'\nimport { h } from '../vnode.ts'\nimport { domainOf, type Label, labelKey } from './cartesian.ts'\nimport { cleanData, label, numbers } from './clean.ts'\n\nexport interface SparklineOptions {\n /** The values; `null` leaves a gap. */\n data: readonly (number | null | undefined)[]\n /** Labels for the tooltip, one per value (e.g. dates). */\n labels?: readonly Label[]\n /** Name shown in the tooltip. Defaults to `'Value'`. */\n name?: string\n /**\n * `'line'` (default), `'area'`, `'bar'`, or `'tristate'`: only the sign\n * counts, as a full bar up (win), down (loss) or a tick on the middle (draw).\n */\n variant?: 'line' | 'area' | 'bar' | 'tristate'\n /** Interpolation for lines and areas. Defaults to `'monotone'`. */\n curve?: Curve\n /** Dot on the last value. Defaults to `'last'`. */\n point?: 'last' | 'none'\n /** Mark the minimum and maximum values. */\n markers?: 'minmax' | 'none'\n /** Dot radius in pixels. Defaults to `3`. */\n pointRadius?: number\n /** Include zero in the value range. Defaults to `true` for areas and bars, `false` for lines. */\n zero?: boolean\n /** Format of values in the tooltip. */\n format?: NumberFormat\n /** Extra space around the plot, in pixels. */\n padding?: InsetsInput\n}\n\nfunction renderSparkline(options: SparklineOptions, ctx: RenderContext) {\n const {\n variant = 'line',\n curve = 'monotone',\n point = 'last',\n markers = 'none',\n pointRadius = 3,\n name = 'Value',\n } = options\n const values = options.data.map((v) => (v == null || !Number.isFinite(v) ? null : v))\n // (No log option on sparklines, so finite is all that matters here.)\n const count = values.length\n const dots = point === 'last' || markers === 'minmax'\n // Room for the stroke and dots so nothing is clipped at the edges.\n const overhang = dots ? pointRadius + 2 : 2\n const pad = insets(options.padding, 0)\n const area = innerRect(ctx.width, ctx.height, {\n top: pad.top + overhang,\n right: pad.right + overhang,\n bottom: pad.bottom + overhang,\n left: pad.left + overhang,\n })\n const tristate = variant === 'tristate'\n const zero = options.zero ?? variant !== 'line'\n // Tristate bars span half the height each way, whatever the magnitude.\n const domain: [number, number] = tristate ? [-1, 1] : domainOf(values, { nice: false }, zero, 2)\n\n const bars = variant === 'bar' || tristate\n const gap = 1\n const slot = count > 0 ? area.width / count : 0\n const xAt = (i: number) =>\n bars\n ? area.x + slot * i + slot / 2\n : area.x + (count > 1 ? (area.width * i) / (count - 1) : area.width / 2)\n const y = linear(domain, [area.y + area.height, area.y])\n const baseline = y(Math.min(Math.max(0, domain[0]), domain[1]))\n const points: Point[] = values.map((v, i) => (v === null ? null : [xAt(i), y(v)]))\n\n const format = formatNumber(options.format, ctx.locale)\n const labelOf = (i: number) => {\n const label = options.labels?.[i]\n return label === undefined ? '' : String(label)\n }\n // Where a value is drawn: a tristate bar ends at its sign, not its magnitude.\n const yOf = (v: number) => y(tristate ? Math.sign(v) : v)\n const hitFor = (i: number): Hit | null => {\n const value = values[i]\n if (value === undefined) return null\n const px = xAt(i)\n const item: HitItem = {\n name,\n seriesIndex: 0,\n value,\n text: value === null ? '–' : format(value),\n x: px,\n y: value === null ? null : yOf(value),\n }\n const hit: Hit = {\n index: i,\n label: labelKey(options.labels?.[i] ?? i + 1),\n title: labelOf(i),\n x: px,\n area,\n items: [item],\n }\n if (value !== null) hit.mark = { d: circlePath(pointRadius + 3), x: px, y: yOf(value) }\n return hit\n }\n const interaction: Interaction = {\n count,\n hitIndex: (i) => hitFor(i),\n hitTest(px, py) {\n if (count === 0 || py < area.y - overhang || py > area.y + area.height + overhang) return null\n const i = bars\n ? Math.floor((px - area.x) / slot)\n : Math.round(((px - area.x) / Math.max(1, area.width)) * (count - 1))\n return hitFor(Math.max(0, Math.min(count - 1, i)))\n },\n }\n ctx.onHitTest(interaction)\n\n const marks = []\n if (tristate) {\n const width = Math.max(1, slot - gap)\n marks.push(\n h('line', {\n class: 'tc-sparkline-zero',\n x1: area.x,\n x2: area.x + area.width,\n y1: round(baseline),\n y2: round(baseline),\n }),\n )\n values.forEach((v, i) => {\n if (v === null) return\n const sign = Math.sign(v)\n // A draw is a short tick centered on the middle line.\n const tick = Math.min(2, area.height / 2)\n const [from, to] =\n sign === 0 ? [baseline + tick / 2, baseline - tick / 2] : [baseline, y(sign)]\n marks.push(\n h('path', {\n key: i,\n class: [\n 'tc-bar',\n sign < 0 && 'tc-bar-negative',\n sign < 0 ? 'tc-tristate-loss' : sign > 0 ? 'tc-tristate-win' : 'tc-tristate-draw',\n ],\n d: barPath(xAt(i) - width / 2, width, from, to, sign === 0 ? 0 : Math.min(2, width / 2)),\n }),\n )\n })\n } else if (bars) {\n const width = Math.max(1, slot - gap)\n values.forEach((v, i) => {\n if (v === null) return\n marks.push(\n h('path', {\n key: i,\n class: ['tc-bar', v < 0 && 'tc-bar-negative'],\n d: barPath(xAt(i) - width / 2, width, baseline, y(v), Math.min(2, width / 2)),\n }),\n )\n })\n } else {\n if (variant === 'area') {\n marks.push(\n h('path', {\n class: 'tc-area tc-area-gradient',\n d: areaPath(points, baseline, { curve }),\n mask: `url(#${ctx.id}-fade)`,\n }),\n )\n }\n marks.push(h('path', { class: 'tc-line', d: linePath(points, { curve }) }))\n }\n\n const dotAt = (i: number, cls: string) => {\n const v = values[i]\n return v == null\n ? null\n : h('circle', {\n key: `${cls}-${i}`,\n class: ['tc-point', cls],\n cx: round(xAt(i)),\n cy: round(y(v)),\n r: pointRadius,\n })\n }\n const extremes = []\n if (markers === 'minmax') {\n let min = -1\n let max = -1\n values.forEach((v, i) => {\n if (v === null) return\n if (min === -1 || v < (values[min] as number)) min = i\n if (max === -1 || v > (values[max] as number)) max = i\n })\n if (min !== -1) extremes.push(dotAt(min, 'tc-point-min'))\n if (max !== -1 && max !== min) extremes.push(dotAt(max, 'tc-point-max'))\n }\n let last = -1\n if (point === 'last') {\n for (let i = count - 1; i >= 0; i--) {\n if (values[i] !== null) {\n last = i\n break\n }\n }\n }\n\n return [\n variant === 'area' && h('defs', null, fadeMask(`${ctx.id}-fade`)),\n h(\n 'g',\n { class: 'tc-series tc-series-1 tc-sparkline' },\n marks,\n extremes,\n last !== -1 && !bars && dotAt(last, 'tc-point-last'),\n ),\n ]\n}\n\n/**\n * Sparkline: a tiny line, area or bar chart without axes, for stat tiles.\n *\n * ```ts\n * new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })\n * ```\n */\nexport const sparkline: ChartType<SparklineOptions> = {\n name: 'sparkline',\n // The labels too: they come from outside like the values.\n clean: (options) => ({\n ...cleanData(numbers)(options),\n labels: Array.isArray(options.labels) ? options.labels.map(label) : undefined,\n }),\n render: renderSparkline,\n // Decorative by default: opt in with `keyboard: true`.\n keyboard: false,\n}\n"],"mappings":";;;;;;;;;AAyCA,SAAS,gBAAgB,SAA2B,KAAoB;CACtE,MAAM,EACJ,UAAU,QACV,QAAQ,YACR,QAAQ,QACR,UAAU,QACV,cAAc,GACd,OAAO,YACL;CACJ,MAAM,SAAS,QAAQ,KAAK,KAAK,MAAO,KAAK,QAAQ,CAAC,OAAO,SAAS,CAAC,IAAI,OAAO,CAAE;CAEpF,MAAM,QAAQ,OAAO;CAGrB,MAAM,WAFO,UAAU,UAAU,YAAY,WAErB,cAAc,IAAI;CAC1C,MAAM,MAAM,OAAO,QAAQ,SAAS,CAAC;CACrC,MAAM,OAAO,UAAU,IAAI,OAAO,IAAI,QAAQ;EAC5C,KAAK,IAAI,MAAM;EACf,OAAO,IAAI,QAAQ;EACnB,QAAQ,IAAI,SAAS;EACrB,MAAM,IAAI,OAAO;CACnB,CAAC;CACD,MAAM,WAAW,YAAY;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,MAAiB,MAAM;GACrD,IAAI,QAAQ,MAAM,IAAK,OAAO,MAAiB,MAAM;EACvD,CAAC;EACD,IAAI,QAAQ,IAAI,SAAS,KAAK,MAAM,KAAK,cAAc,CAAC;EACxD,IAAI,QAAQ,MAAM,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,cAAc,CAAC;CACzE;CACA,IAAI,OAAO;CACX,IAAI,UAAU,QACP;OAAA,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,IAAI,OAAO,OAAO,MAAM;GACtB,OAAO;GACP;EACF;;CAIJ,OAAO,CACL,YAAY,UAAU,EAAE,QAAQ,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,GAChE,EACE,KACA,EAAE,OAAO,qCAAqC,GAC9C,OACA,UACA,SAAS,MAAM,CAAC,QAAQ,MAAM,MAAM,eAAe,CACrD,CACF;AACF;;;;;;;;AASA,MAAa,YAAyC;CACpD,MAAM;CAEN,QAAQ,aAAa;EACnB,GAAG,UAAU,OAAO,CAAC,CAAC,OAAO;EAC7B,QAAQ,MAAM,QAAQ,QAAQ,MAAM,IAAI,QAAQ,OAAO,IAAI,KAAK,IAAI,KAAA;CACtE;CACA,QAAQ;CAER,UAAU;AACZ"}
|
|
@@ -0,0 +1,176 @@
|
|
|
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_cartesian = require("./cartesian-BoDfgBCV.cjs");
|
|
5
|
+
const require_clean = require("./clean-Byl6kzf0.cjs");
|
|
6
|
+
const require_fade = require("./fade-Cs74puQS.cjs");
|
|
7
|
+
const require_bar = require("./bar-DGuUN3nc.cjs");
|
|
8
|
+
const require_circle = require("./circle-BQMuAfls.cjs");
|
|
9
|
+
//#region src/charts/sparkline.ts
|
|
10
|
+
function renderSparkline(options, ctx) {
|
|
11
|
+
const { variant = "line", curve = "monotone", point = "last", markers = "none", pointRadius = 3, name = "Value" } = options;
|
|
12
|
+
const values = options.data.map((v) => v == null || !Number.isFinite(v) ? null : v);
|
|
13
|
+
const count = values.length;
|
|
14
|
+
const overhang = point === "last" || markers === "minmax" ? pointRadius + 2 : 2;
|
|
15
|
+
const pad = require_layout.insets(options.padding, 0);
|
|
16
|
+
const area = require_layout.innerRect(ctx.width, ctx.height, {
|
|
17
|
+
top: pad.top + overhang,
|
|
18
|
+
right: pad.right + overhang,
|
|
19
|
+
bottom: pad.bottom + overhang,
|
|
20
|
+
left: pad.left + overhang
|
|
21
|
+
});
|
|
22
|
+
const tristate = variant === "tristate";
|
|
23
|
+
const zero = options.zero ?? variant !== "line";
|
|
24
|
+
const domain = tristate ? [-1, 1] : require_cartesian.domainOf(values, { nice: false }, zero, 2);
|
|
25
|
+
const bars = variant === "bar" || tristate;
|
|
26
|
+
const gap = 1;
|
|
27
|
+
const slot = count > 0 ? area.width / count : 0;
|
|
28
|
+
const xAt = (i) => bars ? area.x + slot * i + slot / 2 : area.x + (count > 1 ? area.width * i / (count - 1) : area.width / 2);
|
|
29
|
+
const y = require_cartesian.linear(domain, [area.y + area.height, area.y]);
|
|
30
|
+
const baseline = y(Math.min(Math.max(0, domain[0]), domain[1]));
|
|
31
|
+
const points = values.map((v, i) => v === null ? null : [xAt(i), y(v)]);
|
|
32
|
+
const format = require_format.formatNumber(options.format, ctx.locale);
|
|
33
|
+
const labelOf = (i) => {
|
|
34
|
+
const label = options.labels?.[i];
|
|
35
|
+
return label === void 0 ? "" : String(label);
|
|
36
|
+
};
|
|
37
|
+
const yOf = (v) => y(tristate ? Math.sign(v) : v);
|
|
38
|
+
const hitFor = (i) => {
|
|
39
|
+
const value = values[i];
|
|
40
|
+
if (value === void 0) return null;
|
|
41
|
+
const px = xAt(i);
|
|
42
|
+
const item = {
|
|
43
|
+
name,
|
|
44
|
+
seriesIndex: 0,
|
|
45
|
+
value,
|
|
46
|
+
text: value === null ? "–" : format(value),
|
|
47
|
+
x: px,
|
|
48
|
+
y: value === null ? null : yOf(value)
|
|
49
|
+
};
|
|
50
|
+
const hit = {
|
|
51
|
+
index: i,
|
|
52
|
+
label: require_cartesian.labelKey(options.labels?.[i] ?? i + 1),
|
|
53
|
+
title: labelOf(i),
|
|
54
|
+
x: px,
|
|
55
|
+
area,
|
|
56
|
+
items: [item]
|
|
57
|
+
};
|
|
58
|
+
if (value !== null) hit.mark = {
|
|
59
|
+
d: require_circle.circlePath(pointRadius + 3),
|
|
60
|
+
x: px,
|
|
61
|
+
y: yOf(value)
|
|
62
|
+
};
|
|
63
|
+
return hit;
|
|
64
|
+
};
|
|
65
|
+
const interaction = {
|
|
66
|
+
count,
|
|
67
|
+
hitIndex: (i) => hitFor(i),
|
|
68
|
+
hitTest(px, py) {
|
|
69
|
+
if (count === 0 || py < area.y - overhang || py > area.y + area.height + overhang) return null;
|
|
70
|
+
const i = bars ? Math.floor((px - area.x) / slot) : Math.round((px - area.x) / Math.max(1, area.width) * (count - 1));
|
|
71
|
+
return hitFor(Math.max(0, Math.min(count - 1, i)));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
ctx.onHitTest(interaction);
|
|
75
|
+
const marks = [];
|
|
76
|
+
if (tristate) {
|
|
77
|
+
const width = Math.max(1, slot - gap);
|
|
78
|
+
marks.push(require_vnode.h("line", {
|
|
79
|
+
class: "tc-sparkline-zero",
|
|
80
|
+
x1: area.x,
|
|
81
|
+
x2: area.x + area.width,
|
|
82
|
+
y1: require_layout.round(baseline),
|
|
83
|
+
y2: require_layout.round(baseline)
|
|
84
|
+
}));
|
|
85
|
+
values.forEach((v, i) => {
|
|
86
|
+
if (v === null) return;
|
|
87
|
+
const sign = Math.sign(v);
|
|
88
|
+
const tick = Math.min(2, area.height / 2);
|
|
89
|
+
const [from, to] = sign === 0 ? [baseline + tick / 2, baseline - tick / 2] : [baseline, y(sign)];
|
|
90
|
+
marks.push(require_vnode.h("path", {
|
|
91
|
+
key: i,
|
|
92
|
+
class: [
|
|
93
|
+
"tc-bar",
|
|
94
|
+
sign < 0 && "tc-bar-negative",
|
|
95
|
+
sign < 0 ? "tc-tristate-loss" : sign > 0 ? "tc-tristate-win" : "tc-tristate-draw"
|
|
96
|
+
],
|
|
97
|
+
d: require_bar.barPath(xAt(i) - width / 2, width, from, to, sign === 0 ? 0 : Math.min(2, width / 2))
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
} else if (bars) {
|
|
101
|
+
const width = Math.max(1, slot - gap);
|
|
102
|
+
values.forEach((v, i) => {
|
|
103
|
+
if (v === null) return;
|
|
104
|
+
marks.push(require_vnode.h("path", {
|
|
105
|
+
key: i,
|
|
106
|
+
class: ["tc-bar", v < 0 && "tc-bar-negative"],
|
|
107
|
+
d: require_bar.barPath(xAt(i) - width / 2, width, baseline, y(v), Math.min(2, width / 2))
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
if (variant === "area") marks.push(require_vnode.h("path", {
|
|
112
|
+
class: "tc-area tc-area-gradient",
|
|
113
|
+
d: require_fade.areaPath(points, baseline, { curve }),
|
|
114
|
+
mask: `url(#${ctx.id}-fade)`
|
|
115
|
+
}));
|
|
116
|
+
marks.push(require_vnode.h("path", {
|
|
117
|
+
class: "tc-line",
|
|
118
|
+
d: require_fade.linePath(points, { curve })
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
const dotAt = (i, cls) => {
|
|
122
|
+
const v = values[i];
|
|
123
|
+
return v == null ? null : require_vnode.h("circle", {
|
|
124
|
+
key: `${cls}-${i}`,
|
|
125
|
+
class: ["tc-point", cls],
|
|
126
|
+
cx: require_layout.round(xAt(i)),
|
|
127
|
+
cy: require_layout.round(y(v)),
|
|
128
|
+
r: pointRadius
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const extremes = [];
|
|
132
|
+
if (markers === "minmax") {
|
|
133
|
+
let min = -1;
|
|
134
|
+
let max = -1;
|
|
135
|
+
values.forEach((v, i) => {
|
|
136
|
+
if (v === null) return;
|
|
137
|
+
if (min === -1 || v < values[min]) min = i;
|
|
138
|
+
if (max === -1 || v > values[max]) max = i;
|
|
139
|
+
});
|
|
140
|
+
if (min !== -1) extremes.push(dotAt(min, "tc-point-min"));
|
|
141
|
+
if (max !== -1 && max !== min) extremes.push(dotAt(max, "tc-point-max"));
|
|
142
|
+
}
|
|
143
|
+
let last = -1;
|
|
144
|
+
if (point === "last") {
|
|
145
|
+
for (let i = count - 1; i >= 0; i--) if (values[i] !== null) {
|
|
146
|
+
last = i;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return [variant === "area" && require_vnode.h("defs", null, require_fade.fadeMask(`${ctx.id}-fade`)), require_vnode.h("g", { class: "tc-series tc-series-1 tc-sparkline" }, marks, extremes, last !== -1 && !bars && dotAt(last, "tc-point-last"))];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sparkline: a tiny line, area or bar chart without axes, for stat tiles.
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
const sparkline = {
|
|
160
|
+
name: "sparkline",
|
|
161
|
+
clean: (options) => ({
|
|
162
|
+
...require_clean.cleanData(require_clean.numbers)(options),
|
|
163
|
+
labels: Array.isArray(options.labels) ? options.labels.map(require_clean.label) : void 0
|
|
164
|
+
}),
|
|
165
|
+
render: renderSparkline,
|
|
166
|
+
keyboard: false
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
Object.defineProperty(exports, "sparkline", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function() {
|
|
172
|
+
return sparkline;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=sparkline-BS9-hltA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sparkline-BS9-hltA.cjs","names":["insets","innerRect","domainOf","linear","formatNumber","labelKey","circlePath","h","round","barPath","areaPath","linePath","fadeMask","cleanData","numbers","label"],"sources":["../src/charts/sparkline.ts"],"sourcesContent":["import type { ChartType, RenderContext } from '../chart.ts'\nimport { fadeMask } from '../components/fade.ts'\nimport { formatNumber, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets, round } from '../layout.ts'\nimport { linear } from '../scales/linear.ts'\nimport { barPath } from '../shapes/bar.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { areaPath, type Curve, linePath, type Point } from '../shapes/path.ts'\nimport { h } from '../vnode.ts'\nimport { domainOf, type Label, labelKey } from './cartesian.ts'\nimport { cleanData, label, numbers } from './clean.ts'\n\nexport interface SparklineOptions {\n /** The values; `null` leaves a gap. */\n data: readonly (number | null | undefined)[]\n /** Labels for the tooltip, one per value (e.g. dates). */\n labels?: readonly Label[]\n /** Name shown in the tooltip. Defaults to `'Value'`. */\n name?: string\n /**\n * `'line'` (default), `'area'`, `'bar'`, or `'tristate'`: only the sign\n * counts, as a full bar up (win), down (loss) or a tick on the middle (draw).\n */\n variant?: 'line' | 'area' | 'bar' | 'tristate'\n /** Interpolation for lines and areas. Defaults to `'monotone'`. */\n curve?: Curve\n /** Dot on the last value. Defaults to `'last'`. */\n point?: 'last' | 'none'\n /** Mark the minimum and maximum values. */\n markers?: 'minmax' | 'none'\n /** Dot radius in pixels. Defaults to `3`. */\n pointRadius?: number\n /** Include zero in the value range. Defaults to `true` for areas and bars, `false` for lines. */\n zero?: boolean\n /** Format of values in the tooltip. */\n format?: NumberFormat\n /** Extra space around the plot, in pixels. */\n padding?: InsetsInput\n}\n\nfunction renderSparkline(options: SparklineOptions, ctx: RenderContext) {\n const {\n variant = 'line',\n curve = 'monotone',\n point = 'last',\n markers = 'none',\n pointRadius = 3,\n name = 'Value',\n } = options\n const values = options.data.map((v) => (v == null || !Number.isFinite(v) ? null : v))\n // (No log option on sparklines, so finite is all that matters here.)\n const count = values.length\n const dots = point === 'last' || markers === 'minmax'\n // Room for the stroke and dots so nothing is clipped at the edges.\n const overhang = dots ? pointRadius + 2 : 2\n const pad = insets(options.padding, 0)\n const area = innerRect(ctx.width, ctx.height, {\n top: pad.top + overhang,\n right: pad.right + overhang,\n bottom: pad.bottom + overhang,\n left: pad.left + overhang,\n })\n const tristate = variant === 'tristate'\n const zero = options.zero ?? variant !== 'line'\n // Tristate bars span half the height each way, whatever the magnitude.\n const domain: [number, number] = tristate ? [-1, 1] : domainOf(values, { nice: false }, zero, 2)\n\n const bars = variant === 'bar' || tristate\n const gap = 1\n const slot = count > 0 ? area.width / count : 0\n const xAt = (i: number) =>\n bars\n ? area.x + slot * i + slot / 2\n : area.x + (count > 1 ? (area.width * i) / (count - 1) : area.width / 2)\n const y = linear(domain, [area.y + area.height, area.y])\n const baseline = y(Math.min(Math.max(0, domain[0]), domain[1]))\n const points: Point[] = values.map((v, i) => (v === null ? null : [xAt(i), y(v)]))\n\n const format = formatNumber(options.format, ctx.locale)\n const labelOf = (i: number) => {\n const label = options.labels?.[i]\n return label === undefined ? '' : String(label)\n }\n // Where a value is drawn: a tristate bar ends at its sign, not its magnitude.\n const yOf = (v: number) => y(tristate ? Math.sign(v) : v)\n const hitFor = (i: number): Hit | null => {\n const value = values[i]\n if (value === undefined) return null\n const px = xAt(i)\n const item: HitItem = {\n name,\n seriesIndex: 0,\n value,\n text: value === null ? '–' : format(value),\n x: px,\n y: value === null ? null : yOf(value),\n }\n const hit: Hit = {\n index: i,\n label: labelKey(options.labels?.[i] ?? i + 1),\n title: labelOf(i),\n x: px,\n area,\n items: [item],\n }\n if (value !== null) hit.mark = { d: circlePath(pointRadius + 3), x: px, y: yOf(value) }\n return hit\n }\n const interaction: Interaction = {\n count,\n hitIndex: (i) => hitFor(i),\n hitTest(px, py) {\n if (count === 0 || py < area.y - overhang || py > area.y + area.height + overhang) return null\n const i = bars\n ? Math.floor((px - area.x) / slot)\n : Math.round(((px - area.x) / Math.max(1, area.width)) * (count - 1))\n return hitFor(Math.max(0, Math.min(count - 1, i)))\n },\n }\n ctx.onHitTest(interaction)\n\n const marks = []\n if (tristate) {\n const width = Math.max(1, slot - gap)\n marks.push(\n h('line', {\n class: 'tc-sparkline-zero',\n x1: area.x,\n x2: area.x + area.width,\n y1: round(baseline),\n y2: round(baseline),\n }),\n )\n values.forEach((v, i) => {\n if (v === null) return\n const sign = Math.sign(v)\n // A draw is a short tick centered on the middle line.\n const tick = Math.min(2, area.height / 2)\n const [from, to] =\n sign === 0 ? [baseline + tick / 2, baseline - tick / 2] : [baseline, y(sign)]\n marks.push(\n h('path', {\n key: i,\n class: [\n 'tc-bar',\n sign < 0 && 'tc-bar-negative',\n sign < 0 ? 'tc-tristate-loss' : sign > 0 ? 'tc-tristate-win' : 'tc-tristate-draw',\n ],\n d: barPath(xAt(i) - width / 2, width, from, to, sign === 0 ? 0 : Math.min(2, width / 2)),\n }),\n )\n })\n } else if (bars) {\n const width = Math.max(1, slot - gap)\n values.forEach((v, i) => {\n if (v === null) return\n marks.push(\n h('path', {\n key: i,\n class: ['tc-bar', v < 0 && 'tc-bar-negative'],\n d: barPath(xAt(i) - width / 2, width, baseline, y(v), Math.min(2, width / 2)),\n }),\n )\n })\n } else {\n if (variant === 'area') {\n marks.push(\n h('path', {\n class: 'tc-area tc-area-gradient',\n d: areaPath(points, baseline, { curve }),\n mask: `url(#${ctx.id}-fade)`,\n }),\n )\n }\n marks.push(h('path', { class: 'tc-line', d: linePath(points, { curve }) }))\n }\n\n const dotAt = (i: number, cls: string) => {\n const v = values[i]\n return v == null\n ? null\n : h('circle', {\n key: `${cls}-${i}`,\n class: ['tc-point', cls],\n cx: round(xAt(i)),\n cy: round(y(v)),\n r: pointRadius,\n })\n }\n const extremes = []\n if (markers === 'minmax') {\n let min = -1\n let max = -1\n values.forEach((v, i) => {\n if (v === null) return\n if (min === -1 || v < (values[min] as number)) min = i\n if (max === -1 || v > (values[max] as number)) max = i\n })\n if (min !== -1) extremes.push(dotAt(min, 'tc-point-min'))\n if (max !== -1 && max !== min) extremes.push(dotAt(max, 'tc-point-max'))\n }\n let last = -1\n if (point === 'last') {\n for (let i = count - 1; i >= 0; i--) {\n if (values[i] !== null) {\n last = i\n break\n }\n }\n }\n\n return [\n variant === 'area' && h('defs', null, fadeMask(`${ctx.id}-fade`)),\n h(\n 'g',\n { class: 'tc-series tc-series-1 tc-sparkline' },\n marks,\n extremes,\n last !== -1 && !bars && dotAt(last, 'tc-point-last'),\n ),\n ]\n}\n\n/**\n * Sparkline: a tiny line, area or bar chart without axes, for stat tiles.\n *\n * ```ts\n * new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })\n * ```\n */\nexport const sparkline: ChartType<SparklineOptions> = {\n name: 'sparkline',\n // The labels too: they come from outside like the values.\n clean: (options) => ({\n ...cleanData(numbers)(options),\n labels: Array.isArray(options.labels) ? options.labels.map(label) : undefined,\n }),\n render: renderSparkline,\n // Decorative by default: opt in with `keyboard: true`.\n keyboard: false,\n}\n"],"mappings":";;;;;;;;;AAyCA,SAAS,gBAAgB,SAA2B,KAAoB;CACtE,MAAM,EACJ,UAAU,QACV,QAAQ,YACR,QAAQ,QACR,UAAU,QACV,cAAc,GACd,OAAO,YACL;CACJ,MAAM,SAAS,QAAQ,KAAK,KAAK,MAAO,KAAK,QAAQ,CAAC,OAAO,SAAS,CAAC,IAAI,OAAO,CAAE;CAEpF,MAAM,QAAQ,OAAO;CAGrB,MAAM,WAFO,UAAU,UAAU,YAAY,WAErB,cAAc,IAAI;CAC1C,MAAM,MAAMA,eAAAA,OAAO,QAAQ,SAAS,CAAC;CACrC,MAAM,OAAOC,eAAAA,UAAU,IAAI,OAAO,IAAI,QAAQ;EAC5C,KAAK,IAAI,MAAM;EACf,OAAO,IAAI,QAAQ;EACnB,QAAQ,IAAI,SAAS;EACrB,MAAM,IAAI,OAA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ACd,GAAG;EACL,CAAC;CACP;CACA,MAAM,WAAW,CAAC;CAClB,IAAI,YAAY,UAAU;EACxB,IAAI,MAAM;EACV,IAAI,MAAM;EACV,OAAO,SAAS,GAAG,MAAM;GACvB,IAAI,MAAM,MAAM;GAChB,IAAI,QAAQ,MAAM,IAAK,OAAO,MAAiB,MAAM;GACrD,IAAI,QAAQ,MAAM,IAAK,OAAO,MAAiB,MAAM;EACvD,CAAC;EACD,IAAI,QAAQ,IAAI,SAAS,KAAK,MAAM,KAAK,cAAc,CAAC;EACxD,IAAI,QAAQ,MAAM,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,cAAc,CAAC;CACzE;CACA,IAAI,OAAO;CACX,IAAI,UAAU,QACP;OAAA,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,IAAI,OAAO,OAAO,MAAM;GACtB,OAAO;GACP;EACF;;CAIJ,OAAO,CACL,YAAY,UAAUD,cAAAA,EAAE,QAAQ,MAAMK,aAAAA,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,GAChEL,cAAAA,EACE,KACA,EAAE,OAAO,qCAAqC,GAC9C,OACA,UACA,SAAS,MAAM,CAAC,QAAQ,MAAM,MAAM,eAAe,CACrD,CACF;AACF;;;;;;;;AASA,MAAa,YAAyC;CACpD,MAAM;CAEN,QAAQ,aAAa;EACnB,GAAGM,cAAAA,UAAUC,cAAAA,OAAO,CAAC,CAAC,OAAO;EAC7B,QAAQ,MAAM,QAAQ,QAAQ,MAAM,IAAI,QAAQ,OAAO,IAAIC,cAAAA,KAAK,IAAI,KAAA;CACtE;CACA,QAAQ;CAER,UAAU;AACZ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { a as InsetsInput } from "./annotations-Bp7HwtF5.js";
|
|
2
|
+
import { a as ChartType, tt as Label } from "./chart-DyN7bcx8.js";
|
|
3
|
+
import { c as NumberFormat } from "./time-CHjiY9Q4.js";
|
|
4
|
+
import { t as Curve } from "./path-CwB28da0.js";
|
|
5
|
+
//#region src/charts/sparkline.d.ts
|
|
6
|
+
interface SparklineOptions {
|
|
7
|
+
/** The values; `null` leaves a gap. */
|
|
8
|
+
data: readonly (number | null | undefined)[];
|
|
9
|
+
/** Labels for the tooltip, one per value (e.g. dates). */
|
|
10
|
+
labels?: readonly Label[];
|
|
11
|
+
/** Name shown in the tooltip. Defaults to `'Value'`. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/**
|
|
14
|
+
* `'line'` (default), `'area'`, `'bar'`, or `'tristate'`: only the sign
|
|
15
|
+
* counts, as a full bar up (win), down (loss) or a tick on the middle (draw).
|
|
16
|
+
*/
|
|
17
|
+
variant?: "line" | "area" | "bar" | "tristate";
|
|
18
|
+
/** Interpolation for lines and areas. Defaults to `'monotone'`. */
|
|
19
|
+
curve?: Curve;
|
|
20
|
+
/** Dot on the last value. Defaults to `'last'`. */
|
|
21
|
+
point?: "last" | "none";
|
|
22
|
+
/** Mark the minimum and maximum values. */
|
|
23
|
+
markers?: "minmax" | "none";
|
|
24
|
+
/** Dot radius in pixels. Defaults to `3`. */
|
|
25
|
+
pointRadius?: number;
|
|
26
|
+
/** Include zero in the value range. Defaults to `true` for areas and bars, `false` for lines. */
|
|
27
|
+
zero?: boolean;
|
|
28
|
+
/** Format of values in the tooltip. */
|
|
29
|
+
format?: NumberFormat;
|
|
30
|
+
/** Extra space around the plot, in pixels. */
|
|
31
|
+
padding?: InsetsInput;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sparkline: a tiny line, area or bar chart without axes, for stat tiles.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const sparkline: ChartType<SparklineOptions>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { sparkline as n, SparklineOptions as t };
|
|
43
|
+
//# sourceMappingURL=sparkline-BfyO_oNM.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { a as InsetsInput } from "./annotations-lyt0I3HU.cjs";
|
|
2
|
+
import { a as ChartType, tt as Label } from "./chart-D7ooEFnk.cjs";
|
|
3
|
+
import { c as NumberFormat } from "./time-CNVnt-B2.cjs";
|
|
4
|
+
import { t as Curve } from "./path-CwB28da0.cjs";
|
|
5
|
+
//#region src/charts/sparkline.d.ts
|
|
6
|
+
interface SparklineOptions {
|
|
7
|
+
/** The values; `null` leaves a gap. */
|
|
8
|
+
data: readonly (number | null | undefined)[];
|
|
9
|
+
/** Labels for the tooltip, one per value (e.g. dates). */
|
|
10
|
+
labels?: readonly Label[];
|
|
11
|
+
/** Name shown in the tooltip. Defaults to `'Value'`. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/**
|
|
14
|
+
* `'line'` (default), `'area'`, `'bar'`, or `'tristate'`: only the sign
|
|
15
|
+
* counts, as a full bar up (win), down (loss) or a tick on the middle (draw).
|
|
16
|
+
*/
|
|
17
|
+
variant?: "line" | "area" | "bar" | "tristate";
|
|
18
|
+
/** Interpolation for lines and areas. Defaults to `'monotone'`. */
|
|
19
|
+
curve?: Curve;
|
|
20
|
+
/** Dot on the last value. Defaults to `'last'`. */
|
|
21
|
+
point?: "last" | "none";
|
|
22
|
+
/** Mark the minimum and maximum values. */
|
|
23
|
+
markers?: "minmax" | "none";
|
|
24
|
+
/** Dot radius in pixels. Defaults to `3`. */
|
|
25
|
+
pointRadius?: number;
|
|
26
|
+
/** Include zero in the value range. Defaults to `true` for areas and bars, `false` for lines. */
|
|
27
|
+
zero?: boolean;
|
|
28
|
+
/** Format of values in the tooltip. */
|
|
29
|
+
format?: NumberFormat;
|
|
30
|
+
/** Extra space around the plot, in pixels. */
|
|
31
|
+
padding?: InsetsInput;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sparkline: a tiny line, area or bar chart without axes, for stat tiles.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* new Chart('#el', { type: sparkline, data: [3, 5, 4, 7, 6], height: 40 })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const sparkline: ChartType<SparklineOptions>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { sparkline as n, SparklineOptions as t };
|
|
43
|
+
//# sourceMappingURL=sparkline-CWlJDKyh.d.cts.map
|