@rokkit/chart 1.3.6 → 1.3.8
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/dist/AnimatedPlot.svelte +26 -8
- package/dist/AnimatedPlot.svelte.d.ts +5 -0
- package/dist/Chart.svelte +1 -1
- package/dist/FacetPlot.svelte +1 -1
- package/dist/Plot/Axis.svelte +21 -10
- package/dist/Plot/Grid.svelte +32 -13
- package/dist/Plot/Grid.svelte.d.ts +6 -1
- package/dist/Plot/Root.svelte +64 -46
- package/dist/Plot/Root.svelte.d.ts +27 -2
- package/dist/Plot/Timeline.svelte +39 -13
- package/dist/Plot/index.d.ts +4 -4
- package/dist/Plot/index.js +4 -4
- package/dist/Plot.svelte +128 -164
- package/dist/Plot.svelte.d.ts +18 -2
- package/dist/PlotState.svelte.d.ts +23 -0
- package/dist/PlotState.svelte.js +155 -16
- package/dist/PlotSurface.svelte +162 -0
- package/dist/PlotSurface.svelte.d.ts +25 -0
- package/dist/charts/AreaChart.svelte +37 -4
- package/dist/charts/AreaChart.svelte.d.ts +12 -2
- package/dist/charts/BarChart.svelte +32 -3
- package/dist/charts/BarChart.svelte.d.ts +10 -1
- package/dist/charts/BoxPlot.svelte +4 -2
- package/dist/charts/BoxPlot.svelte.d.ts +1 -0
- package/dist/charts/BubbleChart.svelte +34 -3
- package/dist/charts/BubbleChart.svelte.d.ts +11 -1
- package/dist/charts/LineChart.svelte +35 -4
- package/dist/charts/LineChart.svelte.d.ts +11 -2
- package/dist/charts/PieChart.svelte +1 -1
- package/dist/charts/ScatterPlot.svelte +32 -3
- package/dist/charts/ScatterPlot.svelte.d.ts +10 -1
- package/dist/charts/ViolinPlot.svelte +4 -2
- package/dist/charts/ViolinPlot.svelte.d.ts +1 -0
- package/dist/examples/BarChartExample.svelte +1 -1
- package/dist/geoms/Arc.svelte +3 -2
- package/dist/geoms/Area.svelte +20 -3
- package/dist/geoms/Bar.svelte +57 -13
- package/dist/geoms/Box.svelte +131 -76
- package/dist/geoms/Box.svelte.d.ts +7 -0
- package/dist/geoms/Candlestick.svelte +17 -11
- package/dist/geoms/Highlight.svelte +105 -0
- package/dist/geoms/Highlight.svelte.d.ts +10 -0
- package/dist/geoms/Jitter.svelte +82 -0
- package/dist/geoms/Jitter.svelte.d.ts +15 -0
- package/dist/geoms/Line.svelte +26 -9
- package/dist/geoms/Point.svelte +37 -11
- package/dist/geoms/Rule.svelte +113 -0
- package/dist/geoms/Rule.svelte.d.ts +16 -0
- package/dist/geoms/Trend.svelte +66 -0
- package/dist/geoms/Trend.svelte.d.ts +12 -0
- package/dist/geoms/Violin.svelte +30 -6
- package/dist/geoms/Violin.svelte.d.ts +5 -0
- package/dist/geoms/Waterfall.svelte +16 -9
- package/dist/geoms/lib/areas.d.ts +6 -2
- package/dist/geoms/lib/areas.js +17 -11
- package/dist/geoms/lib/bars.d.ts +18 -3
- package/dist/geoms/lib/bars.js +70 -96
- package/dist/index.d.ts +30 -4
- package/dist/index.js +31 -5
- package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +1 -1
- package/dist/lib/brewing/brewer.svelte.d.ts +1 -0
- package/dist/lib/brewing/marks/arcs.js +7 -1
- package/dist/lib/brewing/marks/boxes.d.ts +11 -2
- package/dist/lib/brewing/marks/boxes.js +32 -11
- package/dist/lib/brewing/marks/lines.d.ts +6 -2
- package/dist/lib/brewing/marks/lines.js +19 -12
- package/dist/lib/brewing/marks/swarm.d.ts +32 -0
- package/dist/lib/brewing/marks/swarm.js +125 -0
- package/dist/lib/brewing/marks/violins.d.ts +4 -20
- package/dist/lib/brewing/marks/violins.js +41 -25
- package/dist/lib/brewing/stats.d.ts +3 -1
- package/dist/lib/brewing/stats.js +28 -11
- package/dist/lib/highlight.d.ts +10 -0
- package/dist/lib/highlight.js +43 -0
- package/dist/lib/plot/scales.js +12 -7
- package/dist/lib/plot/types.d.ts +9 -1
- package/dist/lib/plot/types.js +3 -1
- package/dist/lib/scale.d.ts +10 -0
- package/dist/lib/scale.js +14 -0
- package/dist/lib/select.d.ts +22 -0
- package/dist/lib/select.js +22 -0
- package/dist/lib/trend.d.ts +27 -0
- package/dist/lib/trend.js +113 -0
- package/dist/patterns/README.md +1 -1
- package/package.json +1 -1
- package/dist/Plot/Area.svelte +0 -54
- package/dist/Plot/Area.svelte.d.ts +0 -14
- package/dist/Plot/Bar.svelte +0 -69
- package/dist/Plot/Bar.svelte.d.ts +0 -11
- package/dist/Plot/Line.svelte +0 -54
- package/dist/Plot/Line.svelte.d.ts +0 -13
- package/dist/Plot/Point.svelte +0 -58
- package/dist/Plot/Point.svelte.d.ts +0 -13
package/dist/Plot.svelte
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
import type { Snippet } from 'svelte'
|
|
4
|
-
import { PlotState } from './PlotState.svelte.js'
|
|
5
4
|
import { defaultPreset } from './lib/preset.js'
|
|
6
5
|
import type { PlotSpec, PlotHelpers } from './lib/plot/types.js'
|
|
6
|
+
import PlotSurface from './PlotSurface.svelte'
|
|
7
7
|
import Axis from './Plot/Axis.svelte'
|
|
8
8
|
import Grid from './Plot/Grid.svelte'
|
|
9
9
|
import Legend from './Plot/Legend.svelte'
|
|
10
10
|
import Tooltip from './Plot/Tooltip.svelte'
|
|
11
|
-
import DefinePatterns from './patterns/DefinePatterns.svelte'
|
|
12
11
|
import Bar from './geoms/Bar.svelte'
|
|
13
12
|
import Line from './geoms/Line.svelte'
|
|
14
13
|
import Area from './geoms/Area.svelte'
|
|
@@ -21,8 +20,11 @@
|
|
|
21
20
|
import Waterfall from './geoms/Waterfall.svelte'
|
|
22
21
|
import Hexbin from './geoms/Hexbin.svelte'
|
|
23
22
|
import Ribbon from './geoms/Ribbon.svelte'
|
|
23
|
+
import Highlight from './geoms/Highlight.svelte'
|
|
24
|
+
import Trend from './geoms/Trend.svelte'
|
|
24
25
|
|
|
25
26
|
type Row = Record<string, unknown>
|
|
27
|
+
type Method = string | number | { type: string; [k: string]: unknown }
|
|
26
28
|
type Margin = { top: number; right: number; bottom: number; left: number }
|
|
27
29
|
type ChartPresetCtx = { current: typeof defaultPreset }
|
|
28
30
|
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
width?: number
|
|
34
36
|
height?: number
|
|
35
37
|
mode?: 'light' | 'dark'
|
|
36
|
-
grid?: boolean
|
|
38
|
+
grid?: boolean | 'x' | 'y' | 'both'
|
|
37
39
|
axes?: boolean
|
|
38
40
|
margin?: Margin
|
|
39
41
|
legend?: boolean
|
|
@@ -46,6 +48,18 @@
|
|
|
46
48
|
xTicks?: number
|
|
47
49
|
yTicks?: number
|
|
48
50
|
minorTicks?: boolean
|
|
51
|
+
x?: string
|
|
52
|
+
y?: string
|
|
53
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean)
|
|
54
|
+
label?: boolean | string | ((row: Row) => unknown)
|
|
55
|
+
trend?: Method | Method[]
|
|
56
|
+
onselect?: (detail: unknown) => void
|
|
57
|
+
selectable?: boolean
|
|
58
|
+
selected?: Row[]
|
|
59
|
+
/** Animate marks on data/flip changes (opt-out for e.g. AnimatedPlot, which
|
|
60
|
+
* tweens its own frames). Enabled one frame after the width settles so the
|
|
61
|
+
* initial layout paints un-animated. Default `true`. */
|
|
62
|
+
animate?: boolean
|
|
49
63
|
children?: Snippet
|
|
50
64
|
}
|
|
51
65
|
|
|
@@ -55,7 +69,7 @@
|
|
|
55
69
|
helpers = {},
|
|
56
70
|
width = 600,
|
|
57
71
|
height = 400,
|
|
58
|
-
mode =
|
|
72
|
+
mode = undefined,
|
|
59
73
|
grid = true,
|
|
60
74
|
axes = true,
|
|
61
75
|
margin = undefined,
|
|
@@ -69,30 +83,26 @@
|
|
|
69
83
|
xTicks = undefined,
|
|
70
84
|
yTicks = undefined,
|
|
71
85
|
minorTicks = false,
|
|
86
|
+
x = undefined,
|
|
87
|
+
y = undefined,
|
|
88
|
+
highlight = undefined,
|
|
89
|
+
label = false,
|
|
90
|
+
trend = undefined,
|
|
91
|
+
onselect = undefined,
|
|
92
|
+
selectable = false,
|
|
93
|
+
selected = $bindable([]),
|
|
94
|
+
animate = true,
|
|
72
95
|
children
|
|
73
96
|
}: Props = $props()
|
|
74
97
|
|
|
75
98
|
const chartPresetCtx = getContext<ChartPresetCtx | undefined>('chart-preset')
|
|
76
99
|
const chartPreset = $derived(chartPresetCtx?.current ?? defaultPreset)
|
|
77
100
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
$effect(() => {
|
|
84
|
-
if (!containerEl) return
|
|
85
|
-
const ro = new ResizeObserver((entries) => {
|
|
86
|
-
const w = Math.floor(entries[0].contentRect.width)
|
|
87
|
-
if (w > 0) observedWidth = w
|
|
88
|
-
})
|
|
89
|
-
ro.observe(containerEl)
|
|
90
|
-
return () => ro.disconnect()
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
const effectiveWidth = $derived(observedWidth > 0 ? observedWidth : (spec?.width ?? width))
|
|
94
|
-
const svgHeight = $derived(spec?.height ?? height)
|
|
95
|
-
const showGrid = $derived(spec?.grid ?? grid)
|
|
101
|
+
const gridValue = $derived(spec?.grid ?? grid)
|
|
102
|
+
const showGrid = $derived(gridValue !== false)
|
|
103
|
+
const gridLines = $derived(
|
|
104
|
+
gridValue === true || gridValue === false ? 'auto' : gridValue
|
|
105
|
+
)
|
|
96
106
|
const showLegend = $derived(spec?.legend ?? legend)
|
|
97
107
|
const chartTitle = $derived(spec?.title ?? title)
|
|
98
108
|
const chartSummary = $derived(spec?.summary ?? summary)
|
|
@@ -100,18 +110,22 @@
|
|
|
100
110
|
// Accessible data table — screen reader fallback
|
|
101
111
|
const tableData = $derived(spec?.data ?? data)
|
|
102
112
|
const tableColumns = $derived.by(() => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
// Dedupe: a channel may repeat (e.g. x === color), and the table's keyed each
|
|
114
|
+
// requires unique column names.
|
|
115
|
+
const cols = [...new Set(
|
|
116
|
+
[spec?.x, spec?.y, spec?.color ?? spec?.fill].filter((c): c is string => Boolean(c))
|
|
117
|
+
)]
|
|
106
118
|
if (cols.length > 0) return cols
|
|
107
119
|
const first = tableData[0]
|
|
108
120
|
return first ? Object.keys(first) : []
|
|
109
121
|
})
|
|
110
122
|
|
|
123
|
+
// Config for the shared PlotSurface (which owns PlotState, the responsive width, context,
|
|
124
|
+
// animation, patterns, and zoom). `width` is the fallback — PlotSurface observes the container.
|
|
111
125
|
function buildPlotConfig() {
|
|
112
126
|
return {
|
|
113
127
|
data: spec?.data ?? data,
|
|
114
|
-
width:
|
|
128
|
+
width: spec?.width ?? width,
|
|
115
129
|
height: spec?.height ?? height,
|
|
116
130
|
mode,
|
|
117
131
|
margin,
|
|
@@ -125,50 +139,20 @@
|
|
|
125
139
|
colorScheme: spec?.colorScheme,
|
|
126
140
|
colorMidpoint: spec?.colorMidpoint,
|
|
127
141
|
orientation: spec?.orientation,
|
|
128
|
-
|
|
142
|
+
sort: spec?.sort,
|
|
143
|
+
continuousCategory: spec?.continuousCategory,
|
|
144
|
+
chartPreset,
|
|
145
|
+
onselect,
|
|
146
|
+
selectable
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
149
|
|
|
132
|
-
// Create PlotState with initial values and provide as context.
|
|
133
|
-
// untrack() suppresses "captures initial value" warnings — intentional:
|
|
134
|
-
// the $effect below handles all subsequent reactive updates.
|
|
135
|
-
const plotState = untrack(() => new PlotState(buildPlotConfig()))
|
|
136
|
-
setContext('plot-state', plotState)
|
|
137
|
-
|
|
138
|
-
// Keep state in sync when reactive config changes
|
|
139
|
-
$effect(() => {
|
|
140
|
-
plotState.update(buildPlotConfig())
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
$effect(() => {
|
|
144
|
-
if (!zoom || !svgEl) return
|
|
145
|
-
// d3-zoom/d3-selection are client-only; load them dynamically so they are
|
|
146
|
-
// not bundled into (and tree-shaken-as-unused from) the SSR/main bundle.
|
|
147
|
-
let cancelled = false
|
|
148
|
-
let detach: (() => void) | undefined
|
|
149
|
-
Promise.all([import('d3-zoom'), import('d3-selection')]).then(
|
|
150
|
-
([{ zoom: d3Zoom }, { select }]) => {
|
|
151
|
-
if (cancelled || !svgEl) return
|
|
152
|
-
const zoomBehavior = d3Zoom<SVGSVGElement, unknown>()
|
|
153
|
-
.scaleExtent([1, 8])
|
|
154
|
-
.on('zoom', (event) => {
|
|
155
|
-
plotState.applyZoom(event.transform)
|
|
156
|
-
})
|
|
157
|
-
const sel = select(svgEl)
|
|
158
|
-
sel.call(zoomBehavior)
|
|
159
|
-
detach = () => sel.on('.zoom', null)
|
|
160
|
-
}
|
|
161
|
-
)
|
|
162
|
-
return () => {
|
|
163
|
-
cancelled = true
|
|
164
|
-
detach?.()
|
|
165
|
-
plotState.resetZoom()
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
|
|
169
150
|
// Geoms from spec (spec-driven API)
|
|
170
151
|
const specGeoms = $derived(spec?.geoms ?? [])
|
|
171
152
|
|
|
153
|
+
const overlayX = $derived(spec?.x ?? x)
|
|
154
|
+
const overlayY = $derived(spec?.y ?? y)
|
|
155
|
+
|
|
172
156
|
// Geom component resolver for spec-driven mode
|
|
173
157
|
const GEOM_COMPONENTS = {
|
|
174
158
|
bar: Bar,
|
|
@@ -190,103 +174,100 @@
|
|
|
190
174
|
}
|
|
191
175
|
</script>
|
|
192
176
|
|
|
193
|
-
<div class="plot-root"
|
|
177
|
+
<div class="plot-root">
|
|
194
178
|
{#if chartTitle}
|
|
195
179
|
<div class="plot-title" data-plot-title>{chartTitle}</div>
|
|
196
180
|
{/if}
|
|
197
181
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
182
|
+
<!-- The shared root shell (PlotState, responsive width, context, animation, patterns, zoom).
|
|
183
|
+
The batteries below (grid/axes/geoms/overlays) render inside its canvas via context. -->
|
|
184
|
+
<PlotSurface
|
|
185
|
+
config={buildPlotConfig()}
|
|
186
|
+
{animate}
|
|
187
|
+
{zoom}
|
|
188
|
+
ariaLabel={chartTitle || 'Chart visualization'}
|
|
189
|
+
summary={chartSummary}
|
|
190
|
+
bind:selected
|
|
206
191
|
>
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
<!-- Grid (behind everything) -->
|
|
193
|
+
{#if showGrid}
|
|
194
|
+
<Grid lines={gridLines} {xTicks} {yTicks} />
|
|
209
195
|
{/if}
|
|
210
|
-
<!-- SVG pattern defs -->
|
|
211
|
-
<DefinePatterns />
|
|
212
196
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
transform="translate({plotState.margin.left}, {plotState.margin.top})"
|
|
216
|
-
data-plot-canvas
|
|
217
|
-
>
|
|
218
|
-
<!-- Grid (behind everything) -->
|
|
219
|
-
{#if showGrid}
|
|
220
|
-
<Grid />
|
|
221
|
-
{/if}
|
|
197
|
+
<!-- Declarative children (geom components) -->
|
|
198
|
+
{@render children?.()}
|
|
222
199
|
|
|
223
|
-
|
|
224
|
-
|
|
200
|
+
<!-- Spec-driven geoms -->
|
|
201
|
+
{#each specGeoms as geomSpec (geomSpec.type)}
|
|
202
|
+
{@const GeomComponent = resolveGeomComponent(geomSpec.type)}
|
|
203
|
+
{#if GeomComponent}
|
|
204
|
+
<GeomComponent
|
|
205
|
+
x={geomSpec.x ?? spec?.x}
|
|
206
|
+
y={geomSpec.y ?? spec?.y}
|
|
207
|
+
color={geomSpec.color ?? spec?.color}
|
|
208
|
+
fill={geomSpec.fill ?? spec?.fill}
|
|
209
|
+
pattern={geomSpec.pattern}
|
|
210
|
+
symbol={geomSpec.symbol}
|
|
211
|
+
stat={geomSpec.stat}
|
|
212
|
+
label={geomSpec.label}
|
|
213
|
+
options={{
|
|
214
|
+
...(spec?.stack !== undefined ? { stack: spec.stack } : {}),
|
|
215
|
+
...(spec?.orientation !== undefined ? { orientation: spec.orientation } : {}),
|
|
216
|
+
...(geomSpec.options ?? {})
|
|
217
|
+
}}
|
|
218
|
+
/>
|
|
219
|
+
{/if}
|
|
220
|
+
{/each}
|
|
225
221
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
x={geomSpec.x ?? spec?.x}
|
|
232
|
-
y={geomSpec.y ?? spec?.y}
|
|
233
|
-
color={geomSpec.color ?? spec?.color}
|
|
234
|
-
fill={geomSpec.fill ?? spec?.fill}
|
|
235
|
-
pattern={geomSpec.pattern}
|
|
236
|
-
symbol={geomSpec.symbol}
|
|
237
|
-
stat={geomSpec.stat}
|
|
238
|
-
label={geomSpec.label}
|
|
239
|
-
options={{
|
|
240
|
-
...(spec?.stack !== undefined ? { stack: spec.stack } : {}),
|
|
241
|
-
...(spec?.orientation !== undefined ? { orientation: spec.orientation } : {}),
|
|
242
|
-
...(geomSpec.options ?? {})
|
|
243
|
-
}}
|
|
244
|
-
/>
|
|
245
|
-
{/if}
|
|
246
|
-
{/each}
|
|
222
|
+
<!-- Axes -->
|
|
223
|
+
{#if axes}
|
|
224
|
+
<Axis type="x" label={spec?.labels?.[spec?.x ?? ''] ?? ''} format={xFormat} ticks={xTicks} {minorTicks} />
|
|
225
|
+
<Axis type="y" label={spec?.labels?.[spec?.y ?? ''] ?? ''} format={yFormat} ticks={yTicks} {minorTicks} />
|
|
226
|
+
{/if}
|
|
247
227
|
|
|
248
|
-
|
|
249
|
-
{
|
|
250
|
-
|
|
251
|
-
<Axis type="y" label={spec?.labels?.[spec?.y ?? ''] ?? ''} format={yFormat} ticks={yTicks} {minorTicks} />
|
|
252
|
-
{/if}
|
|
253
|
-
</g>
|
|
254
|
-
</svg>
|
|
228
|
+
{#if trend !== null && trend !== undefined}
|
|
229
|
+
<Trend x={overlayX} y={overlayY} {trend} />
|
|
230
|
+
{/if}
|
|
255
231
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
{/if}
|
|
232
|
+
{#if (highlight !== null && highlight !== undefined) || selectable || selected.length}
|
|
233
|
+
<Highlight x={overlayX} y={overlayY} {highlight} {label} />
|
|
234
|
+
{/if}
|
|
260
235
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
236
|
+
<!-- HTML overlays — outside the svg but INSIDE the plot-state context. -->
|
|
237
|
+
{#snippet overlay()}
|
|
238
|
+
{#if showLegend}
|
|
239
|
+
<Legend labels={spec?.labels ?? {}} />
|
|
240
|
+
{/if}
|
|
265
241
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
<table class="plot-sr-table" aria-label={chartTitle || 'Chart data'}>
|
|
269
|
-
{#if chartTitle}
|
|
270
|
-
<caption>{chartTitle}</caption>
|
|
242
|
+
{#if tooltip}
|
|
243
|
+
<Tooltip {tooltip} />
|
|
271
244
|
{/if}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
245
|
+
|
|
246
|
+
{#if tableData.length > 0 && tableColumns.length > 0}
|
|
247
|
+
<table class="plot-sr-table" aria-label={chartTitle || 'Chart data'}>
|
|
248
|
+
{#if chartTitle}
|
|
249
|
+
<caption>{chartTitle}</caption>
|
|
250
|
+
{/if}
|
|
251
|
+
<thead>
|
|
252
|
+
<tr>
|
|
253
|
+
{#each tableColumns as col (col)}
|
|
254
|
+
<th scope="col">{col}</th>
|
|
255
|
+
{/each}
|
|
256
|
+
</tr>
|
|
257
|
+
</thead>
|
|
258
|
+
<tbody>
|
|
259
|
+
{#each tableData as row, i (i)}
|
|
260
|
+
<tr>
|
|
261
|
+
{#each tableColumns as col (col)}
|
|
262
|
+
<td>{row[col] ?? ''}</td>
|
|
263
|
+
{/each}
|
|
264
|
+
</tr>
|
|
284
265
|
{/each}
|
|
285
|
-
</
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
266
|
+
</tbody>
|
|
267
|
+
</table>
|
|
268
|
+
{/if}
|
|
269
|
+
{/snippet}
|
|
270
|
+
</PlotSurface>
|
|
290
271
|
</div>
|
|
291
272
|
|
|
292
273
|
<style>
|
|
@@ -296,23 +277,6 @@
|
|
|
296
277
|
height: auto;
|
|
297
278
|
}
|
|
298
279
|
|
|
299
|
-
[data-plot-root][data-mode='light'] {
|
|
300
|
-
color: rgba(var(--color-surface-700, 59, 65, 77), 1);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
[data-plot-root][data-mode='dark'] {
|
|
304
|
-
color: rgba(var(--color-surface-200, 224, 224, 224), 1);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
svg {
|
|
308
|
-
display: block;
|
|
309
|
-
overflow: visible;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.plot-canvas {
|
|
313
|
-
pointer-events: all;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
280
|
.plot-title {
|
|
317
281
|
font-size: 14px;
|
|
318
282
|
font-weight: 600;
|
package/dist/Plot.svelte.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { PlotSpec, PlotHelpers } from './lib/plot/types.js';
|
|
3
3
|
type Row = Record<string, unknown>;
|
|
4
|
+
type Method = string | number | {
|
|
5
|
+
type: string;
|
|
6
|
+
[k: string]: unknown;
|
|
7
|
+
};
|
|
4
8
|
type Margin = {
|
|
5
9
|
top: number;
|
|
6
10
|
right: number;
|
|
@@ -14,7 +18,7 @@ type Props = {
|
|
|
14
18
|
width?: number;
|
|
15
19
|
height?: number;
|
|
16
20
|
mode?: 'light' | 'dark';
|
|
17
|
-
grid?: boolean;
|
|
21
|
+
grid?: boolean | 'x' | 'y' | 'both';
|
|
18
22
|
axes?: boolean;
|
|
19
23
|
margin?: Margin;
|
|
20
24
|
legend?: boolean;
|
|
@@ -27,8 +31,20 @@ type Props = {
|
|
|
27
31
|
xTicks?: number;
|
|
28
32
|
yTicks?: number;
|
|
29
33
|
minorTicks?: boolean;
|
|
34
|
+
x?: string;
|
|
35
|
+
y?: string;
|
|
36
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean);
|
|
37
|
+
label?: boolean | string | ((row: Row) => unknown);
|
|
38
|
+
trend?: Method | Method[];
|
|
39
|
+
onselect?: (detail: unknown) => void;
|
|
40
|
+
selectable?: boolean;
|
|
41
|
+
selected?: Row[];
|
|
42
|
+
/** Animate marks on data/flip changes (opt-out for e.g. AnimatedPlot, which
|
|
43
|
+
* tweens its own frames). Enabled one frame after the width settles so the
|
|
44
|
+
* initial layout paints un-animated. Default `true`. */
|
|
45
|
+
animate?: boolean;
|
|
30
46
|
children?: Snippet;
|
|
31
47
|
};
|
|
32
|
-
declare const Plot: import("svelte").Component<Props, {}, "">;
|
|
48
|
+
declare const Plot: import("svelte").Component<Props, {}, "selected">;
|
|
33
49
|
type Plot = ReturnType<typeof Plot>;
|
|
34
50
|
export default Plot;
|
|
@@ -40,6 +40,23 @@ export class PlotState {
|
|
|
40
40
|
patterns: any;
|
|
41
41
|
symbols: any;
|
|
42
42
|
};
|
|
43
|
+
get data(): any[];
|
|
44
|
+
/** @returns {{ x?: string, y?: string, color?: string, pattern?: string, symbol?: string }} */
|
|
45
|
+
get channels(): {
|
|
46
|
+
x?: string;
|
|
47
|
+
y?: string;
|
|
48
|
+
color?: string;
|
|
49
|
+
pattern?: string;
|
|
50
|
+
symbol?: string;
|
|
51
|
+
};
|
|
52
|
+
get isFlipped(): boolean;
|
|
53
|
+
get continuousCategory(): boolean;
|
|
54
|
+
place(u: any, v: any): {
|
|
55
|
+
x: any;
|
|
56
|
+
y: any;
|
|
57
|
+
};
|
|
58
|
+
get bandScale(): any;
|
|
59
|
+
get valueScale(): any;
|
|
43
60
|
get margin(): {
|
|
44
61
|
top: number;
|
|
45
62
|
right: number;
|
|
@@ -71,8 +88,14 @@ export class PlotState {
|
|
|
71
88
|
symbols: string[];
|
|
72
89
|
};
|
|
73
90
|
get hovered(): null;
|
|
91
|
+
get interactive(): boolean;
|
|
92
|
+
get selectedRows(): any[];
|
|
74
93
|
setHovered(data: any): void;
|
|
75
94
|
clearHovered(): void;
|
|
95
|
+
isSelected(row: any): boolean;
|
|
96
|
+
setSelected(rows: any): void;
|
|
97
|
+
clearSelected(): void;
|
|
98
|
+
handleSelect(detail: any): void;
|
|
76
99
|
applyZoom(transform: any): void;
|
|
77
100
|
resetZoom(): void;
|
|
78
101
|
#private;
|