@svgrid/grid 3.0.2 → 3.0.4
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/README.md +2 -1
- package/dist/GridMenus.svelte +44 -2
- package/dist/SvChartMenu.svelte +69 -0
- package/dist/SvChartMenu.svelte.d.ts +11 -0
- package/dist/SvChartPanes.svelte +113 -0
- package/dist/SvChartPanes.svelte.d.ts +20 -0
- package/dist/SvGrid.controller.svelte.d.ts +110 -39
- package/dist/SvGrid.controller.svelte.js +655 -200
- package/dist/SvGrid.css +105 -2
- package/dist/SvGrid.svelte +386 -514
- package/dist/SvGrid.types.d.ts +210 -9
- package/dist/SvGridCellEditor.svelte +17 -0
- package/dist/SvGridChart.svelte +2257 -329
- package/dist/SvGridChart.svelte.d.ts +6 -106
- package/dist/SvGridChart.types.d.ts +338 -0
- package/dist/SvGridChart.types.js +1 -0
- package/dist/SvGridChartBuilder.svelte +323 -0
- package/dist/SvGridChartBuilder.svelte.d.ts +34 -0
- package/dist/SvGridChartPanel.svelte +221 -275
- package/dist/SvGridChartPickers.svelte +417 -0
- package/dist/SvGridChartPickers.svelte.d.ts +70 -0
- package/dist/SvGridChartView.svelte +13 -14
- package/dist/SvModal.svelte +7 -1
- package/dist/SvModal.svelte.d.ts +5 -0
- package/dist/ai.d.ts +40 -8
- package/dist/ai.js +135 -24
- package/dist/aria.d.ts +11 -0
- package/dist/build-api.js +108 -22
- package/dist/cdn/GridMenus-7kbpnnBW.js +635 -0
- package/dist/cdn/GridMenus-BL7ZgQvU.js +636 -0
- package/dist/cdn/SvChartMenu-Bl6PBbkT.js +58 -0
- package/dist/cdn/SvChartMenu-FBSMINA6.js +59 -0
- package/dist/cdn/{SvDateRangeInput-DMLKmGEc.js → SvDateRangeInput-BeU_TkbQ.js} +15 -14
- package/dist/cdn/{SvDateRangeInput-CaOuMs8O.js → SvDateRangeInput-yX8vzleW.js} +38 -37
- package/dist/cdn/{SvDateTimePicker-sonaH0oh.js → SvDateTimePicker-DQwt4UAs.js} +139 -180
- package/dist/cdn/SvDateTimePicker-vNU6bZ-q.js +775 -0
- package/dist/cdn/{SvGridCellEditor-CjEJMJKc.js → SvGridCellEditor-B1p-vCK5.js} +188 -178
- package/dist/cdn/{SvGridCellEditor-BWnTi2N7.js → SvGridCellEditor-D_0q4xAu.js} +98 -88
- package/dist/cdn/SvGridChart-C3EWAZaM.js +3574 -0
- package/dist/cdn/SvGridChart-DzLkSwCH.js +3572 -0
- package/dist/cdn/SvGridChartBuilder-BE2T1ykB.js +783 -0
- package/dist/cdn/SvGridChartBuilder-CfII62sZ.js +784 -0
- package/dist/cdn/SvGridChartPanel-CCX5_Wgd.js +675 -0
- package/dist/cdn/SvGridChartPanel-xf4sWVTo.js +699 -0
- package/dist/cdn/SvGridChartView-CfuXmY5I.js +48 -0
- package/dist/cdn/SvGridChartView-DYwabQWj.js +47 -0
- package/dist/cdn/SvMenuList-CLN8OuIK.js +452 -0
- package/dist/cdn/SvMenuList-DkGhNKjf.js +451 -0
- package/dist/cdn/SvModal-BAE-pjZX.js +396 -0
- package/dist/cdn/SvModal-CIZWCcad.js +397 -0
- package/dist/cdn/chart-Dz7SqMXH.js +4341 -0
- package/dist/cdn/chart-export-BXqueeWJ.js +135 -0
- package/dist/cdn/chart-export-pdf-DONFUnNY.js +110 -0
- package/dist/cdn/chart-panel-messages-CUbf2R4i.js +1052 -0
- package/dist/cdn/chart-panel-messages-CmNrMdsr.js +1053 -0
- package/dist/cdn/chart-summary-BJW_tg_X.js +138 -0
- package/dist/cdn/chart-trend-CaN9mDEV.js +50 -0
- package/dist/cdn/chart-validate-HcOVFAfJ.js +188 -0
- package/dist/cdn/{column-resize-DsfNXMom.js → column-resize-DpmOLfRp.js} +3 -3
- package/dist/cdn/{date-format-BnnHlqGw.js → date-format-CtquV-p3.js} +583 -603
- package/dist/cdn/{date-format-BNii4zeD.js → date-format-D6KFzU_W.js} +347 -367
- package/dist/cdn/dismissable-DAHetSNk.js +44 -0
- package/dist/cdn/editor-contract-LXgQJAgd.js +22 -0
- package/dist/cdn/focus-trap-BBOQYBma.js +65 -0
- package/dist/cdn/{row-resize-BRcimkUT.js → row-resize-niQCp040.js} +44 -36
- package/dist/cdn/{src-DNbz94Ct.js → src-BKhZ6eXd.js} +10227 -9787
- package/dist/cdn/{src-BJ2opd0j.js → src-V1uu8iE9.js} +6568 -6128
- package/dist/cdn/svgrid.js +26 -15
- package/dist/cdn/svgrid.svelte-external.js +26 -15
- package/dist/chart-axes.d.ts +53 -0
- package/dist/chart-axes.js +351 -0
- package/dist/chart-cartesian.d.ts +88 -0
- package/dist/chart-cartesian.js +1862 -0
- package/dist/chart-decimate.d.ts +51 -0
- package/dist/chart-decimate.js +199 -0
- package/dist/chart-export-pdf.d.ts +47 -0
- package/dist/chart-export-pdf.js +187 -0
- package/dist/chart-export.d.ts +2 -1
- package/dist/chart-export.js +18 -3
- package/dist/chart-financial.d.ts +91 -0
- package/dist/chart-financial.js +175 -0
- package/dist/chart-flow.d.ts +10 -0
- package/dist/chart-flow.js +298 -0
- package/dist/chart-format.d.ts +18 -0
- package/dist/chart-format.js +65 -0
- package/dist/chart-grid.d.ts +8 -0
- package/dist/chart-grid.js +190 -0
- package/dist/chart-hierarchy.d.ts +17 -0
- package/dist/chart-hierarchy.js +146 -0
- package/dist/chart-indicators.d.ts +115 -0
- package/dist/chart-indicators.js +389 -0
- package/dist/chart-messages.d.ts +95 -0
- package/dist/chart-messages.js +92 -0
- package/dist/chart-motion.d.ts +16 -0
- package/dist/chart-motion.js +141 -0
- package/dist/chart-panel-messages.d.ts +265 -0
- package/dist/chart-panel-messages.js +285 -0
- package/dist/chart-pivot.d.ts +87 -0
- package/dist/chart-pivot.js +156 -0
- package/dist/chart-polar.d.ts +25 -0
- package/dist/chart-polar.js +700 -0
- package/dist/chart-samples.d.ts +16 -0
- package/dist/chart-samples.js +153 -0
- package/dist/chart-scale.d.ts +113 -0
- package/dist/chart-scale.js +405 -0
- package/dist/chart-stats.d.ts +111 -0
- package/dist/chart-stats.js +419 -0
- package/dist/chart-stream.d.ts +45 -0
- package/dist/chart-stream.js +91 -0
- package/dist/chart-summary.d.ts +27 -0
- package/dist/chart-summary.js +205 -0
- package/dist/chart-sync.svelte.d.ts +32 -0
- package/dist/chart-sync.svelte.js +23 -0
- package/dist/chart-table.d.ts +35 -0
- package/dist/chart-table.js +165 -0
- package/dist/chart-trend.d.ts +19 -0
- package/dist/chart-trend.js +61 -0
- package/dist/chart-types.d.ts +1456 -0
- package/dist/chart-types.js +6 -0
- package/dist/chart-validate.d.ts +43 -0
- package/dist/chart-validate.js +272 -0
- package/dist/chart-zoom.d.ts +40 -0
- package/dist/chart-zoom.js +145 -0
- package/dist/chart.d.ts +186 -865
- package/dist/chart.js +460 -2204
- package/dist/clipboard.d.ts +1 -0
- package/dist/clipboard.js +137 -18
- package/dist/column-resize.d.ts +3 -0
- package/dist/column-resize.js +4 -1
- package/dist/columns.js +3 -0
- package/dist/command-context.d.ts +19 -0
- package/dist/command-context.js +116 -0
- package/dist/core.d.ts +7 -0
- package/dist/createPopoverSelect.svelte.d.ts +2 -2
- package/dist/editing.d.ts +2 -8
- package/dist/editing.js +262 -33
- package/dist/fill-patterns.d.ts +0 -5
- package/dist/fill-patterns.js +56 -2
- package/dist/grid-messages.d.ts +10 -3
- package/dist/grid-messages.js +5 -0
- package/dist/history.d.ts +83 -0
- package/dist/history.js +133 -0
- package/dist/index.d.ts +24 -6
- package/dist/index.js +20 -2
- package/dist/keyboard-handlers.js +88 -31
- package/dist/keyboard.d.ts +55 -0
- package/dist/keyboard.js +132 -0
- package/dist/menus.d.ts +3 -1
- package/dist/menus.js +7 -2
- package/dist/merges.d.ts +97 -0
- package/dist/merges.js +147 -0
- package/dist/row-resize.d.ts +3 -0
- package/dist/row-resize.js +14 -0
- package/dist/scroll-sync.d.ts +1 -0
- package/dist/scroll-sync.js +24 -0
- package/dist/selection.d.ts +16 -0
- package/dist/selection.js +108 -16
- package/dist/shortcut-registry.d.ts +145 -0
- package/dist/shortcut-registry.js +44 -0
- package/dist/svgrid-wrapper.types.d.ts +213 -22
- package/dist/virtualization/virtualizer.js +38 -17
- package/package.json +6 -1
- package/src/GridMenus.svelte +44 -2
- package/src/SvChartMenu.svelte +69 -0
- package/src/SvChartPanes.svelte +113 -0
- package/src/SvChartPanes.test.ts +66 -0
- package/src/SvGrid.controller.svelte.ts +629 -172
- package/src/SvGrid.css +105 -2
- package/src/SvGrid.svelte +386 -514
- package/src/SvGrid.types.ts +188 -8
- package/src/SvGridCellEditor.svelte +17 -0
- package/src/SvGridChart.svelte +2257 -329
- package/src/SvGridChart.test.ts +1419 -1
- package/src/SvGridChart.types.ts +336 -0
- package/src/SvGridChartBuilder.svelte +323 -0
- package/src/SvGridChartPanel.svelte +221 -275
- package/src/SvGridChartPickers.svelte +417 -0
- package/src/SvGridChartView.svelte +13 -14
- package/src/SvModal.svelte +7 -1
- package/src/SvModal.test.ts +9 -0
- package/src/ai.test.ts +57 -2
- package/src/ai.ts +166 -22
- package/src/aria.d.ts +11 -0
- package/src/build-api.coverage.test.ts +184 -0
- package/src/build-api.ts +107 -18
- package/src/chart-axes.test.ts +573 -0
- package/src/chart-axes.ts +342 -0
- package/src/chart-cartesian.ts +1863 -0
- package/src/chart-decimate.test.ts +249 -0
- package/src/chart-decimate.ts +186 -0
- package/src/chart-export-pdf.test.ts +91 -0
- package/src/chart-export-pdf.ts +207 -0
- package/src/chart-export.test.ts +14 -0
- package/src/chart-export.ts +13 -3
- package/src/chart-financial.ts +208 -0
- package/src/chart-flow.ts +286 -0
- package/src/chart-format.ts +67 -0
- package/src/chart-grid.ts +179 -0
- package/src/chart-hierarchy.ts +135 -0
- package/src/chart-indicators.test.ts +443 -0
- package/src/chart-indicators.ts +384 -0
- package/src/chart-messages.test.ts +21 -0
- package/src/chart-messages.ts +184 -0
- package/src/chart-motion.test.ts +71 -0
- package/src/chart-motion.ts +148 -0
- package/src/chart-panel-messages.test.ts +29 -0
- package/src/chart-panel-messages.ts +550 -0
- package/src/chart-pivot.test.ts +54 -0
- package/src/chart-pivot.ts +225 -0
- package/src/chart-polar.ts +674 -0
- package/src/chart-samples.ts +106 -0
- package/src/chart-scale.ts +394 -0
- package/src/chart-series-types.test.ts +714 -0
- package/src/chart-stats.ts +409 -0
- package/src/chart-stream.test.ts +75 -0
- package/src/chart-stream.ts +114 -0
- package/src/chart-summary.test.ts +90 -0
- package/src/chart-summary.ts +197 -0
- package/src/chart-sync.svelte.ts +41 -0
- package/src/chart-table.test.ts +76 -0
- package/src/chart-table.ts +178 -0
- package/src/chart-trend.ts +47 -0
- package/src/chart-types.ts +1309 -0
- package/src/chart-validate.test.ts +100 -0
- package/src/chart-validate.ts +247 -0
- package/src/chart-zoom.test.ts +137 -0
- package/src/chart-zoom.ts +124 -0
- package/src/chart.coverage.test.ts +81 -0
- package/src/chart.test.ts +56 -3
- package/src/chart.ts +557 -2784
- package/src/clipboard.test.ts +151 -0
- package/src/clipboard.ts +145 -16
- package/src/column-resize.ts +7 -1
- package/src/columns.ts +2 -0
- package/src/command-context.test.ts +200 -0
- package/src/command-context.ts +137 -0
- package/src/core.ts +7 -0
- package/src/editing.test.ts +281 -3
- package/src/editing.ts +256 -38
- package/src/fill-patterns.test.ts +35 -0
- package/src/fill-patterns.ts +56 -2
- package/src/grid-messages.ts +16 -3
- package/src/history.test.ts +196 -0
- package/src/history.ts +162 -0
- package/src/icon-seam.test.ts +3 -2
- package/src/index.ts +150 -2
- package/src/keyboard-handlers.coverage.test.ts +126 -6
- package/src/keyboard-handlers.ts +91 -30
- package/src/keyboard-shortcuts.seam.test.ts +200 -0
- package/src/keyboard.test.ts +124 -1
- package/src/keyboard.ts +142 -0
- package/src/menus.test.ts +26 -0
- package/src/menus.ts +10 -3
- package/src/merges.test.ts +112 -0
- package/src/merges.ts +168 -0
- package/src/pivot.grid.test.ts +40 -5
- package/src/row-resize.test.ts +44 -0
- package/src/row-resize.ts +17 -0
- package/src/scroll-sync.test.ts +42 -1
- package/src/scroll-sync.ts +25 -0
- package/src/selection.multi-range.test.ts +34 -0
- package/src/selection.test.ts +30 -2
- package/src/selection.ts +111 -19
- package/src/shortcut-registry.test.ts +97 -0
- package/src/shortcut-registry.ts +181 -0
- package/src/svgrid-wrapper.types.ts +184 -13
- package/src/svgrid.behavior.test.ts +135 -0
- package/src/svgrid.charting.test.ts +513 -3
- package/src/svgrid.context-menu.test.ts +31 -0
- package/src/svgrid.new-features.wrapper.test.ts +10 -3
- package/src/virtualization/virtualizer.ts +39 -17
- package/dist/cdn/GridMenus-DyFA-QxA.js +0 -602
- package/dist/cdn/GridMenus-M2XP9t0_.js +0 -603
- package/dist/cdn/SvDateTimePicker-CCbDZNZB.js +0 -816
- package/dist/cdn/SvGridChart-DAb9RbRs.js +0 -1480
- package/dist/cdn/SvGridChart-Yl-IXZFO.js +0 -1481
- package/dist/cdn/SvGridChartPanel-DayQpDsR.js +0 -834
- package/dist/cdn/SvGridChartPanel-aqf8n-vJ.js +0 -810
- package/dist/cdn/SvGridChartView-CxfakxR0.js +0 -56
- package/dist/cdn/SvGridChartView-Dm_YEx9L.js +0 -55
- package/dist/cdn/chart-CKJRCPOk.js +0 -1652
|
@@ -1,108 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* labels, and an `onSelect` drill hook. No external charting dependency.
|
|
8
|
-
*/
|
|
9
|
-
import type { Snippet } from 'svelte';
|
|
10
|
-
import { type ChartSpec, type ChartSelection, type ChartGeometry, type ChartScales } from './chart.js';
|
|
11
|
-
/** What a custom mark is handed. `scales` is null on non-cartesian types. */
|
|
12
|
-
type ChartRenderContext = {
|
|
13
|
-
geo: ChartGeometry;
|
|
14
|
-
/** Pixel x at the centre of category `i`. Null when there is no x axis. */
|
|
15
|
-
xOf: ChartScales['xOf'] | null;
|
|
16
|
-
/** Pixel y for a value. Null when there is no value axis. */
|
|
17
|
-
yOf: ChartScales['yOf'] | null;
|
|
18
|
-
scales: ChartScales | null;
|
|
19
|
-
};
|
|
20
|
-
type Props = {
|
|
21
|
-
spec: ChartSpec;
|
|
22
|
-
/** Show the (clickable) legend. Default true. */
|
|
23
|
-
legend?: boolean;
|
|
24
|
-
/** Enable tooltips + crosshair + legend toggling. Default true. */
|
|
25
|
-
interactive?: boolean;
|
|
26
|
-
/** Draw the value on each bar / point / slice. Default false. */
|
|
27
|
-
dataLabels?: boolean;
|
|
28
|
-
/** Format a value for tooltips, data labels, AND Y-axis ticks. */
|
|
29
|
-
formatValue?: (value: number) => string;
|
|
30
|
-
/** Fired when a category / slice is clicked (drill into the grid). */
|
|
31
|
-
onSelect?: (selection: ChartSelection) => void;
|
|
32
|
-
/** Like `onSelect`, but only fires when the spec carries `rowIds` and
|
|
33
|
-
* includes them in the payload. Use this to filter / highlight the
|
|
34
|
-
* source grid when the user clicks a chart element. */
|
|
35
|
-
onDrill?: (selection: ChartSelection) => void;
|
|
36
|
-
/** Allow drag-to-zoom on the plot area. Double-click resets.
|
|
37
|
-
* Only meaningful for cartesian charts (not pie). Default false. */
|
|
38
|
-
zoomable?: boolean;
|
|
39
|
-
/** Show a compact brush / mini-map under the main chart. A draggable
|
|
40
|
-
* window selects what the main chart shows. Pairs naturally with
|
|
41
|
-
* `zoomable`. Default false. */
|
|
42
|
-
brush?: boolean;
|
|
43
|
-
/** Height of the brush strip in pixels. Default 88. */
|
|
44
|
-
brushHeight?: number;
|
|
45
|
-
/** Show a small toolbar above the chart: reset-zoom (when zoomed) and
|
|
46
|
-
* export (PNG / SVG / copy). Default true when zoomable or onDrill is
|
|
47
|
-
* set, otherwise false. Set to `false` to hide explicitly. */
|
|
48
|
-
toolbar?: boolean;
|
|
49
|
-
/** Explicit chart pixel size (viewBox). When set, the chart lays out to
|
|
50
|
-
* fit exactly - used by the docked panel to size the chart to its body. */
|
|
51
|
-
width?: number;
|
|
52
|
-
height?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Draw your own marks in the chart's own coordinates - the custom-series
|
|
55
|
-
* seam. `underlay` paints beneath the built-in marks (bands, shaded
|
|
56
|
-
* regions, a background you want the bars to sit on); `overlay` paints
|
|
57
|
-
* above them but below the crosshair and the hit layer, so tooltips and
|
|
58
|
-
* clicks keep working over whatever you draw.
|
|
59
|
-
*
|
|
60
|
-
* Both receive the laid-out geometry and its scales, so a custom mark lands
|
|
61
|
-
* on exactly the axis the built-in ones did:
|
|
62
|
-
*
|
|
63
|
-
* ```svelte
|
|
64
|
-
* <SvChart {spec}>
|
|
65
|
-
* {#snippet overlay({ geo, xOf, yOf })}
|
|
66
|
-
* <circle cx={xOf(3)} cy={yOf(120)} r="5" fill="tomato" />
|
|
67
|
-
* {/snippet}
|
|
68
|
-
* </SvChart>
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* `xOf` / `yOf` are null for the types with no cartesian axes (pie, gauge,
|
|
72
|
-
* treemap, sankey, calendar, radar, funnel); `geo` is always there.
|
|
73
|
-
*/
|
|
74
|
-
underlay?: Snippet<[ChartRenderContext]>;
|
|
75
|
-
overlay?: Snippet<[ChartRenderContext]>;
|
|
76
|
-
/**
|
|
77
|
-
* Let a reader pin annotations on the plot. Adds an "Annotate" toggle to
|
|
78
|
-
* the toolbar; while it is on, clicking the plot fires `onAnnotate` with
|
|
79
|
-
* the point that was clicked, and clicking an existing marker fires
|
|
80
|
-
* `onAnnotationRemove` with its index.
|
|
81
|
-
*
|
|
82
|
-
* The chart does NOT store them. It owns the gesture - which you cannot
|
|
83
|
-
* build from outside, because drag is already zoom and click is already
|
|
84
|
-
* drill - and hands back the data point; where the annotations live, and
|
|
85
|
-
* whether they survive a reload, is the host's business. Put what comes
|
|
86
|
-
* back into `spec.annotations` and they render like any other.
|
|
87
|
-
*/
|
|
88
|
-
annotatable?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* A point the reader picked while annotating. It is a DATA point, not a
|
|
91
|
-
* pixel: annotate mode takes over the category gesture, so a note anchors
|
|
92
|
-
* to the category it was pinned on and stays there when the chart is
|
|
93
|
-
* re-laid-out, re-sorted or zoomed. That also means it works from the
|
|
94
|
-
* keyboard, since the category hit zones already navigate with arrows.
|
|
95
|
-
*/
|
|
96
|
-
onAnnotate?: (at: {
|
|
97
|
-
/** The category picked, and its index. */
|
|
98
|
-
category: string;
|
|
99
|
-
index: number;
|
|
100
|
-
/** The value at that category on the first series. */
|
|
101
|
-
value: number;
|
|
102
|
-
}) => void;
|
|
103
|
-
/** An existing `spec.annotations` entry was clicked, by index. */
|
|
104
|
-
onAnnotationRemove?: (index: number) => void;
|
|
105
|
-
};
|
|
106
|
-
declare const SvGridChart: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChartZoomWindow } from './chart-types.js';
|
|
2
|
+
import type { SvChartProps } from './SvGridChart.types.js';
|
|
3
|
+
declare const SvGridChart: import("svelte").Component<SvChartProps, {
|
|
4
|
+
zoomTo: (window: ChartZoomWindow | null) => void;
|
|
5
|
+
resetZoom: () => void;
|
|
6
|
+
}, "selected" | "drillPath" | "zoom">;
|
|
107
7
|
type SvGridChart = ReturnType<typeof SvGridChart>;
|
|
108
8
|
export default SvGridChart;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props of `SvChart` / `SvGridChart`, in a plain `.ts` file so tooling
|
|
3
|
+
* that cannot parse a `.svelte` component (the web-component surface
|
|
4
|
+
* generator, the API reference) can read them.
|
|
5
|
+
*/
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { ChartDataLabelConfig, ChartDrawing, ChartDrawingKind, ChartGeometry, ChartPointRef, ChartScales, ChartSelection, ChartSpec, ChartZoomWindow } from './chart-types.js';
|
|
8
|
+
import type { ChartRangePreset } from './chart-zoom.js';
|
|
9
|
+
import type { ChartMessages } from './chart-messages.js';
|
|
10
|
+
import type { MenuItem } from './menu-item.js';
|
|
11
|
+
/** The point `onHover` reports: the category, its index in the drawn
|
|
12
|
+
* window, the series nearest the pointer (or null) and that series' value. */
|
|
13
|
+
export type ChartHoverPoint = {
|
|
14
|
+
category: string;
|
|
15
|
+
index: number;
|
|
16
|
+
series: string | null;
|
|
17
|
+
value: number | null;
|
|
18
|
+
};
|
|
19
|
+
/** What a custom mark is handed. `scales` is null on non-cartesian types. */
|
|
20
|
+
export type ChartRenderContext = {
|
|
21
|
+
geo: ChartGeometry;
|
|
22
|
+
/** Pixel x at the centre of category `i`. Null when there is no x axis. */
|
|
23
|
+
xOf: ChartScales['xOf'] | null;
|
|
24
|
+
/** Pixel y for a value. Null when there is no value axis. */
|
|
25
|
+
yOf: ChartScales['yOf'] | null;
|
|
26
|
+
scales: ChartScales | null;
|
|
27
|
+
};
|
|
28
|
+
/** One row of the default tooltip. */
|
|
29
|
+
export type ChartTooltipRow = {
|
|
30
|
+
label?: string;
|
|
31
|
+
color?: string;
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* What a custom `tooltip` snippet or `tooltipFormat` receives: the hovered
|
|
36
|
+
* category, its index, and the rows the default tooltip would have shown
|
|
37
|
+
* (already formatted), plus the single series when `tooltipMode` is
|
|
38
|
+
* `'single'` or the hover was on one mark.
|
|
39
|
+
*/
|
|
40
|
+
export type ChartTooltipContext = {
|
|
41
|
+
/** The category (x label) under the pointer, or the mark's own label. */
|
|
42
|
+
category: string;
|
|
43
|
+
/** Its index in the visible categories, or -1 for a non-category mark. */
|
|
44
|
+
index: number;
|
|
45
|
+
/** The default rows, one per visible series (or per number of a candle). */
|
|
46
|
+
rows: ChartTooltipRow[];
|
|
47
|
+
/** The series under the pointer when the tooltip is for one series. */
|
|
48
|
+
series?: string;
|
|
49
|
+
/** That series' value at the category, when known. */
|
|
50
|
+
value?: number;
|
|
51
|
+
};
|
|
52
|
+
/** What a custom `legendItem` snippet receives. */
|
|
53
|
+
export type ChartLegendItemContext = {
|
|
54
|
+
label: string;
|
|
55
|
+
color: string;
|
|
56
|
+
/** The series (or slice) is toggled off. */
|
|
57
|
+
off: boolean;
|
|
58
|
+
index: number;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Which zoom gestures the plot answers to. `zoomable: true` is drag only,
|
|
62
|
+
* the behaviour the chart always had.
|
|
63
|
+
*/
|
|
64
|
+
export type ChartZoomConfig = {
|
|
65
|
+
/** Rubber-band a rectangle to zoom into it. Default true. */
|
|
66
|
+
drag?: boolean;
|
|
67
|
+
/** Mouse wheel zooms around the pointer. `'modifier'` needs Ctrl / Cmd held,
|
|
68
|
+
* so the page still scrolls over the chart. Default false. */
|
|
69
|
+
wheel?: boolean | 'modifier';
|
|
70
|
+
/** Two-finger pinch on touch screens. Default true when `wheel` is set. */
|
|
71
|
+
pinch?: boolean;
|
|
72
|
+
/** Drag to pan a zoomed chart: `'shift'` with Shift held, `'mode'` through a
|
|
73
|
+
* toolbar toggle, `true` both. Default false. */
|
|
74
|
+
pan?: boolean | 'shift' | 'mode';
|
|
75
|
+
/** Which axes the rubber band zooms. Default `'x'`. */
|
|
76
|
+
axis?: 'x' | 'y' | 'xy';
|
|
77
|
+
};
|
|
78
|
+
/** How the chart animates. `animate: true` turns on the data-update tween. */
|
|
79
|
+
export type ChartAnimateConfig = {
|
|
80
|
+
/** Tween length in ms. Default 400. */
|
|
81
|
+
duration?: number;
|
|
82
|
+
/** How marks first appear: fade (default), grow from the baseline, or wipe
|
|
83
|
+
* left to right. `'none'` draws them in place. */
|
|
84
|
+
enter?: 'fade' | 'grow' | 'wipe' | 'none';
|
|
85
|
+
/** Slide marks to their new positions when the data changes. Default true
|
|
86
|
+
* when `animate` is set at all. */
|
|
87
|
+
update?: boolean;
|
|
88
|
+
};
|
|
89
|
+
/** What the context menu's custom items are built against. */
|
|
90
|
+
export type ChartContextTarget = {
|
|
91
|
+
category?: string;
|
|
92
|
+
index?: number;
|
|
93
|
+
series?: string;
|
|
94
|
+
value?: number;
|
|
95
|
+
};
|
|
96
|
+
/** Where the legend sits. `true` is `'bottom'`. */
|
|
97
|
+
export type ChartLegendPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
98
|
+
/**
|
|
99
|
+
* The props of `SvChart` (alias `SvGridChart`). Everything is optional but
|
|
100
|
+
* `spec`; the defaults are noted per field.
|
|
101
|
+
*/
|
|
102
|
+
export type SvChartProps = {
|
|
103
|
+
spec: ChartSpec;
|
|
104
|
+
/** Show the (clickable) legend, and where. `true` = below the chart.
|
|
105
|
+
* Default true. */
|
|
106
|
+
legend?: boolean | ChartLegendPosition;
|
|
107
|
+
/** Render each legend entry yourself. Receives the label, colour, whether
|
|
108
|
+
* it is toggled off, and its index. The click / double-click / hover
|
|
109
|
+
* behaviour stays on the button around it. */
|
|
110
|
+
legendItem?: Snippet<[ChartLegendItemContext]>;
|
|
111
|
+
/** Enable tooltips + crosshair + legend toggling. Default true. */
|
|
112
|
+
interactive?: boolean;
|
|
113
|
+
/** Draw the value on each bar / point / slice. `true` uses the defaults;
|
|
114
|
+
* an object picks placement, a formatter and overlap hiding. On a pie,
|
|
115
|
+
* `{ placement: 'outside' }` draws callout labels with leader lines.
|
|
116
|
+
* Unset, the spec's own `dataLabels` applies; default off. */
|
|
117
|
+
dataLabels?: boolean | ChartDataLabelConfig;
|
|
118
|
+
/** Format a value for tooltips, data labels, AND Y-axis ticks. */
|
|
119
|
+
formatValue?: (value: number) => string;
|
|
120
|
+
/**
|
|
121
|
+
* Render the tooltip body yourself. Receives the hovered category, the
|
|
122
|
+
* default rows (already formatted) and, for a single-series hover, that
|
|
123
|
+
* series. The positioning, flipping and theming stay with the chart.
|
|
124
|
+
*/
|
|
125
|
+
tooltip?: Snippet<[ChartTooltipContext]>;
|
|
126
|
+
/** Rewrite the default tooltip's title and rows without taking over the
|
|
127
|
+
* markup. Return only what you want to change. */
|
|
128
|
+
tooltipFormat?: (ctx: ChartTooltipContext) => {
|
|
129
|
+
title?: string;
|
|
130
|
+
rows?: ChartTooltipRow[];
|
|
131
|
+
};
|
|
132
|
+
/** `'shared'` (default) lists every series at the hovered category;
|
|
133
|
+
* `'single'` shows only the series nearest the pointer. */
|
|
134
|
+
tooltipMode?: 'shared' | 'single';
|
|
135
|
+
/**
|
|
136
|
+
* Where the tooltip sits: `'follow'` (default) beside the pointer, or
|
|
137
|
+
* pinned in a corner of the plot so it never covers the mark under the
|
|
138
|
+
* pointer on a dense chart and never flips.
|
|
139
|
+
*/
|
|
140
|
+
tooltipPosition?: 'follow' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
141
|
+
/**
|
|
142
|
+
* A click pins the tooltip: it stays while the pointer leaves, its text
|
|
143
|
+
* can be selected and copied, and a second click on the same category,
|
|
144
|
+
* Escape or a click outside the chart releases it. A tap on a touch screen
|
|
145
|
+
* shows and pins in one. Default false.
|
|
146
|
+
*/
|
|
147
|
+
tooltipSticky?: boolean;
|
|
148
|
+
/** Fired when a category / slice is clicked (drill into the grid). */
|
|
149
|
+
onSelect?: (selection: ChartSelection) => void;
|
|
150
|
+
/** Like `onSelect`, but only fires when the spec carries `rowIds` and
|
|
151
|
+
* includes them in the payload. Use this to filter / highlight the
|
|
152
|
+
* source grid when the user clicks a chart element. */
|
|
153
|
+
onDrill?: (selection: ChartSelection) => void;
|
|
154
|
+
/** Allow zooming the plot: `true` for drag-to-zoom (double-click resets),
|
|
155
|
+
* or an object choosing wheel, pinch, pan and the axes. Cartesian charts
|
|
156
|
+
* only. Default false. */
|
|
157
|
+
zoomable?: boolean | ChartZoomConfig;
|
|
158
|
+
/**
|
|
159
|
+
* The visible window, bindable: read it to persist a zoom, set it to zoom
|
|
160
|
+
* from outside (`null` is the whole chart). The component also exposes
|
|
161
|
+
* `zoomTo(window)` and `resetZoom()` through `bind:this`.
|
|
162
|
+
*/
|
|
163
|
+
zoom?: ChartZoomWindow | null;
|
|
164
|
+
/** Fired whenever the window changes, by gesture, preset, API or sync. */
|
|
165
|
+
onZoom?: (window: ChartZoomWindow | null) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Range buttons in the toolbar for a time axis: `true` for 1W / 1M / 3M /
|
|
168
|
+
* 6M / YTD / 1Y / All, or your own list (`'1M'`, or
|
|
169
|
+
* `{ label, days | from, to }`). Also in the context menu.
|
|
170
|
+
*/
|
|
171
|
+
rangePresets?: boolean | ChartRangePreset[];
|
|
172
|
+
/**
|
|
173
|
+
* Charts sharing a group name share their crosshair and their zoom window.
|
|
174
|
+
* Categories are matched by label, then by date when both parse, so a daily
|
|
175
|
+
* and a weekly chart still line up.
|
|
176
|
+
*/
|
|
177
|
+
syncGroup?: string;
|
|
178
|
+
/**
|
|
179
|
+
* A right-click menu: `true` for the built-in items (export, copy, reset
|
|
180
|
+
* zoom, series toggles, presets), an array of your own `MenuItem`s appended
|
|
181
|
+
* after them, or a function of the clicked point returning that array.
|
|
182
|
+
*/
|
|
183
|
+
contextMenu?: boolean | MenuItem[] | ((target: ChartContextTarget) => MenuItem[]);
|
|
184
|
+
/**
|
|
185
|
+
* Motion: `true` for a 400ms data-update tween with the default fade-in, or
|
|
186
|
+
* an object choosing the enter effect and duration. Respects
|
|
187
|
+
* `prefers-reduced-motion`. Dense charts (thousands of points) never tween.
|
|
188
|
+
* A feed faster than the tween wants `live` instead.
|
|
189
|
+
*/
|
|
190
|
+
animate?: boolean | ChartAnimateConfig;
|
|
191
|
+
/**
|
|
192
|
+
* The spec is a live feed (see `appendPoints`): skip the data-update tween
|
|
193
|
+
* and the enter effect, because a tween restarted every few hundred
|
|
194
|
+
* milliseconds never settles and an enter effect replays on every tick.
|
|
195
|
+
* Default false.
|
|
196
|
+
*/
|
|
197
|
+
live?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Drill into a tree map, sunburst or pie (built from `tree`) by clicking a
|
|
200
|
+
* node with children; the toolbar grows a breadcrumb back up. Default false.
|
|
201
|
+
*/
|
|
202
|
+
drillable?: boolean;
|
|
203
|
+
/** The current drill path (node names from the root), bindable. */
|
|
204
|
+
drillPath?: string[];
|
|
205
|
+
/**
|
|
206
|
+
* Let readers select points: `'single'` (or `true`) keeps one, Ctrl / Shift
|
|
207
|
+
* adds; `'multi'` toggles on every click. Unselected marks dim while there
|
|
208
|
+
* is a selection. Default false.
|
|
209
|
+
*/
|
|
210
|
+
selectable?: boolean | 'single' | 'multi';
|
|
211
|
+
/** The selected points, bindable. */
|
|
212
|
+
selected?: ChartPointRef[];
|
|
213
|
+
onSelectionChange?: (selected: ChartPointRef[]) => void;
|
|
214
|
+
/**
|
|
215
|
+
* The point under the pointer or the keyboard focus, or `null` when it
|
|
216
|
+
* leaves. Fires once per change, not per pixel: mirror it into a KPI, a
|
|
217
|
+
* linked table row or another chart. `series` is null when the whole
|
|
218
|
+
* category is hovered and no series is near.
|
|
219
|
+
*/
|
|
220
|
+
onHover?: (point: ChartHoverPoint | null) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Hovering a mark dims the other series so the one under the pointer
|
|
223
|
+
* stands out, the way the legend does on hover. On a category chart the
|
|
224
|
+
* series within 18px of the pointer is the one; farther away, nothing
|
|
225
|
+
* dims. Default true; `false` keeps every series at full opacity.
|
|
226
|
+
*/
|
|
227
|
+
hoverHighlight?: boolean;
|
|
228
|
+
/** Announce the focused point to screen readers through a live region.
|
|
229
|
+
* Default true. */
|
|
230
|
+
announce?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Describe the chart in plain words (`chartSummary`: trend and extremes
|
|
233
|
+
* per series, the biggest slices, a scatter's correlation, the last close)
|
|
234
|
+
* as the SVG's `aria-description` and in the data table's caption, and
|
|
235
|
+
* offer "Describe chart" in the context menu, which copies the sentence.
|
|
236
|
+
* Default true.
|
|
237
|
+
*/
|
|
238
|
+
describe?: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Translations for the chart's own strings: toolbar buttons and titles,
|
|
241
|
+
* the context menu, the legend's hints, the empty state and what it says
|
|
242
|
+
* to assistive technology. A partial map; unset keys stay English. See
|
|
243
|
+
* {@link ChartMessages} for every key.
|
|
244
|
+
*/
|
|
245
|
+
localeText?: Partial<ChartMessages>;
|
|
246
|
+
/**
|
|
247
|
+
* Read the crosshair off the axes: the hovered category in a pill on the x
|
|
248
|
+
* axis and the value under the pointer in a pill on the value axis, the way
|
|
249
|
+
* a trading chart reads. Default true on cartesian charts; `false` keeps
|
|
250
|
+
* the crosshair line alone.
|
|
251
|
+
*/
|
|
252
|
+
crosshairLabels?: boolean;
|
|
253
|
+
/** Show a compact brush / mini-map under the main chart. A draggable
|
|
254
|
+
* window selects what the main chart shows. Pairs naturally with
|
|
255
|
+
* `zoomable`. Default false. */
|
|
256
|
+
brush?: boolean;
|
|
257
|
+
/** Height of the brush strip in pixels. Default 88. */
|
|
258
|
+
brushHeight?: number;
|
|
259
|
+
/** Show a small toolbar above the chart: reset-zoom (when zoomed) and
|
|
260
|
+
* export (PNG / SVG / copy). Default true when zoomable or onDrill is
|
|
261
|
+
* set, otherwise false. Set to `false` to hide explicitly. */
|
|
262
|
+
toolbar?: boolean;
|
|
263
|
+
/** Explicit chart pixel size (viewBox). When set, the chart lays out to
|
|
264
|
+
* fit exactly - used by the docked panel to size the chart to its body. */
|
|
265
|
+
width?: number;
|
|
266
|
+
height?: number;
|
|
267
|
+
/**
|
|
268
|
+
* Size the chart to its container. The SVG is laid out at the container's
|
|
269
|
+
* pixel size (minus the toolbar, legend and brush) and re-laid-out when it
|
|
270
|
+
* resizes, so axis labels never squash and the plot uses every pixel. Give
|
|
271
|
+
* the chart its height through a flex or grid parent that stretches it; in a
|
|
272
|
+
* plain block it follows the width and keeps its own `height` (default 300).
|
|
273
|
+
* Explicit `width` / `height` win. Default false.
|
|
274
|
+
*/
|
|
275
|
+
autosize?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Draw your own marks in the chart's own coordinates - the custom-series
|
|
278
|
+
* seam. `underlay` paints beneath the built-in marks (bands, shaded
|
|
279
|
+
* regions, a background you want the bars to sit on); `overlay` paints
|
|
280
|
+
* above them but below the crosshair and the hit layer, so tooltips and
|
|
281
|
+
* clicks keep working over whatever you draw.
|
|
282
|
+
*
|
|
283
|
+
* Both receive the laid-out geometry and its scales, so a custom mark lands
|
|
284
|
+
* on exactly the axis the built-in ones did:
|
|
285
|
+
*
|
|
286
|
+
* ```svelte
|
|
287
|
+
* <SvChart {spec}>
|
|
288
|
+
* {#snippet overlay({ geo, xOf, yOf })}
|
|
289
|
+
* <circle cx={xOf(3)} cy={yOf(120)} r="5" fill="tomato" />
|
|
290
|
+
* {/snippet}
|
|
291
|
+
* </SvChart>
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* `xOf` / `yOf` are null for the types with no cartesian axes (pie, gauge,
|
|
295
|
+
* treemap, sankey, calendar, radar, funnel); `geo` is always there.
|
|
296
|
+
*/
|
|
297
|
+
underlay?: Snippet<[ChartRenderContext]>;
|
|
298
|
+
overlay?: Snippet<[ChartRenderContext]>;
|
|
299
|
+
/**
|
|
300
|
+
* Let a reader pin annotations on the plot. Adds an "Annotate" toggle to
|
|
301
|
+
* the toolbar; while it is on, clicking the plot fires `onAnnotate` with
|
|
302
|
+
* the point that was clicked, and clicking an existing marker fires
|
|
303
|
+
* `onAnnotationRemove` with its index.
|
|
304
|
+
*
|
|
305
|
+
* The chart does NOT store them. It owns the gesture - which you cannot
|
|
306
|
+
* build from outside, because drag is already zoom and click is already
|
|
307
|
+
* drill - and hands back the data point; where the annotations live, and
|
|
308
|
+
* whether they survive a reload, is the host's business. Put what comes
|
|
309
|
+
* back into `spec.annotations` and they render like any other.
|
|
310
|
+
*/
|
|
311
|
+
annotatable?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* A point the reader picked while annotating. It is a DATA point, not a
|
|
314
|
+
* pixel: annotate mode takes over the category gesture, so a note anchors
|
|
315
|
+
* to the category it was pinned on and stays there when the chart is
|
|
316
|
+
* re-laid-out, re-sorted or zoomed. That also means it works from the
|
|
317
|
+
* keyboard, since the category hit zones already navigate with arrows.
|
|
318
|
+
*/
|
|
319
|
+
onAnnotate?: (at: {
|
|
320
|
+
/** The category picked, and its index. */
|
|
321
|
+
category: string;
|
|
322
|
+
index: number;
|
|
323
|
+
/** The value at that category on the first series. */
|
|
324
|
+
value: number;
|
|
325
|
+
}) => void;
|
|
326
|
+
/** An existing `spec.annotations` entry was clicked, by index. */
|
|
327
|
+
onAnnotationRemove?: (index: number) => void;
|
|
328
|
+
/**
|
|
329
|
+
* Drawing tools in the toolbar: `true` for all of them (trend line,
|
|
330
|
+
* horizontal ray, Fibonacci retracement, rectangle, arrow, text) or a list
|
|
331
|
+
* of kinds. A tool takes the plot click over; the drawings are DATA points
|
|
332
|
+
* the host stores in `spec.drawings`. Cartesian charts only.
|
|
333
|
+
*/
|
|
334
|
+
drawable?: boolean | ChartDrawingKind[];
|
|
335
|
+
/** The drawings after a reader added, moved or removed one. Store them in
|
|
336
|
+
* `spec.drawings` and they render like any other. */
|
|
337
|
+
onDrawingsChange?: (drawings: ChartDrawing[]) => void;
|
|
338
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|