@rokkit/chart 1.3.7 → 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 +19 -10
- 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 +95 -178
- package/dist/Plot.svelte.d.ts +4 -0
- package/dist/PlotState.svelte.d.ts +16 -0
- package/dist/PlotState.svelte.js +118 -16
- package/dist/PlotSurface.svelte +162 -0
- package/dist/PlotSurface.svelte.d.ts +25 -0
- package/dist/charts/AreaChart.svelte +4 -1
- package/dist/charts/AreaChart.svelte.d.ts +1 -0
- 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 +1 -1
- 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 +2 -2
- package/dist/geoms/Bar.svelte +17 -6
- 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/Jitter.svelte +82 -0
- package/dist/geoms/Jitter.svelte.d.ts +15 -0
- package/dist/geoms/Line.svelte +1 -1
- package/dist/geoms/Point.svelte +7 -1
- package/dist/geoms/Rule.svelte +113 -0
- package/dist/geoms/Rule.svelte.d.ts +16 -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 +24 -4
- package/dist/index.js +25 -5
- package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +1 -1
- 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 +4 -1
- package/dist/lib/brewing/marks/lines.js +18 -15
- 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/plot/scales.js +12 -7
- package/dist/lib/plot/types.d.ts +9 -1
- package/dist/lib/plot/types.js +3 -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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext, untrack } from 'svelte'
|
|
3
|
+
import type { Snippet } from 'svelte'
|
|
4
|
+
import { PlotState } from './PlotState.svelte.js'
|
|
5
|
+
import DefinePatterns from './patterns/DefinePatterns.svelte'
|
|
6
|
+
|
|
7
|
+
type Row = Record<string, unknown>
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
/** Full PlotState config. `config.width` is the initial/fallback width — PlotSurface
|
|
11
|
+
* owns the responsive width via a ResizeObserver and overrides it. */
|
|
12
|
+
config?: Record<string, unknown>
|
|
13
|
+
/** Animate marks on data/flip changes (data-plot-animate). Enabled one frame after the
|
|
14
|
+
* width settles so the initial layout paints un-animated. */
|
|
15
|
+
animate?: boolean
|
|
16
|
+
/** Enable d3-zoom pan/zoom on the svg. */
|
|
17
|
+
zoom?: boolean
|
|
18
|
+
ariaLabel?: string
|
|
19
|
+
/** SVG <desc> for screen readers. */
|
|
20
|
+
summary?: string
|
|
21
|
+
/** Two-way selection (row references), synced with the PlotState selection. */
|
|
22
|
+
selected?: Row[]
|
|
23
|
+
/** Canvas content (geoms/grid/axes) — rendered inside the svg. */
|
|
24
|
+
children?: Snippet
|
|
25
|
+
/** HTML overlays (legend/tooltip/a11y table) — rendered outside the svg but INSIDE the
|
|
26
|
+
* plot-state context, so they can read plotState. */
|
|
27
|
+
overlay?: Snippet
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
config = {},
|
|
32
|
+
animate = true,
|
|
33
|
+
zoom = false,
|
|
34
|
+
ariaLabel = 'Chart visualization',
|
|
35
|
+
summary = '',
|
|
36
|
+
selected = $bindable([]),
|
|
37
|
+
children,
|
|
38
|
+
overlay
|
|
39
|
+
}: Props = $props()
|
|
40
|
+
|
|
41
|
+
// ── Responsive width: observe the container, use its pixel width so the chart fills the stage.
|
|
42
|
+
let containerEl = $state<HTMLDivElement | null>(null)
|
|
43
|
+
let svgEl = $state<SVGSVGElement | null>(null)
|
|
44
|
+
let observedWidth = $state(0)
|
|
45
|
+
$effect(() => {
|
|
46
|
+
if (!containerEl) return
|
|
47
|
+
const ro = new ResizeObserver((entries) => {
|
|
48
|
+
const w = Math.floor(entries[0].contentRect.width)
|
|
49
|
+
if (w > 0) observedWidth = w
|
|
50
|
+
})
|
|
51
|
+
ro.observe(containerEl)
|
|
52
|
+
return () => ro.disconnect()
|
|
53
|
+
})
|
|
54
|
+
const fallbackWidth = $derived(Number(config.width) || 600)
|
|
55
|
+
const effectiveWidth = $derived(observedWidth > 0 ? observedWidth : fallbackWidth)
|
|
56
|
+
const svgHeight = $derived(Number(config.height) || 400)
|
|
57
|
+
const mode = $derived(config.mode as 'light' | 'dark' | undefined)
|
|
58
|
+
|
|
59
|
+
// ── The single PlotState + context. config.width is overridden with the observed width.
|
|
60
|
+
const fullConfig = () => ({ ...config, width: effectiveWidth })
|
|
61
|
+
const plotState = untrack(() => new PlotState(fullConfig()))
|
|
62
|
+
setContext('plot-state', plotState)
|
|
63
|
+
$effect(() => {
|
|
64
|
+
plotState.update(fullConfig())
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// ── Selection sync (external prop ↔ PlotState). Guarded to avoid an update loop.
|
|
68
|
+
$effect(() => {
|
|
69
|
+
plotState.setSelected(selected)
|
|
70
|
+
})
|
|
71
|
+
$effect(() => {
|
|
72
|
+
const rows = plotState.selectedRows
|
|
73
|
+
const same = rows.length === selected.length && rows.every((r, i) => r === selected[i])
|
|
74
|
+
if (!same) selected = rows
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// ── Enable data-change / flip animation one frame after the width first settles, so the
|
|
78
|
+
// initial (possibly reflowed) layout paints without animating.
|
|
79
|
+
let animateReady = $state(false)
|
|
80
|
+
$effect(() => {
|
|
81
|
+
if (!animate || animateReady || observedWidth <= 0) return
|
|
82
|
+
const raf = requestAnimationFrame(() => {
|
|
83
|
+
animateReady = true
|
|
84
|
+
})
|
|
85
|
+
return () => cancelAnimationFrame(raf)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// ── Pan/zoom (d3-zoom/d3-selection are client-only → dynamic import).
|
|
89
|
+
$effect(() => {
|
|
90
|
+
if (!zoom || !svgEl) return
|
|
91
|
+
let cancelled = false
|
|
92
|
+
let detach: (() => void) | undefined
|
|
93
|
+
Promise.all([import('d3-zoom'), import('d3-selection')]).then(
|
|
94
|
+
([{ zoom: d3Zoom }, { select }]) => {
|
|
95
|
+
if (cancelled || !svgEl) return
|
|
96
|
+
const zoomBehavior = d3Zoom<SVGSVGElement, unknown>()
|
|
97
|
+
.scaleExtent([1, 8])
|
|
98
|
+
.on('zoom', (event) => plotState.applyZoom(event.transform))
|
|
99
|
+
const sel = select(svgEl)
|
|
100
|
+
sel.call(zoomBehavior)
|
|
101
|
+
detach = () => sel.on('.zoom', null)
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
return () => {
|
|
105
|
+
cancelled = true
|
|
106
|
+
detach?.()
|
|
107
|
+
plotState.resetZoom()
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<div class="plot-surface" bind:this={containerEl}>
|
|
113
|
+
<svg
|
|
114
|
+
bind:this={svgEl}
|
|
115
|
+
width={effectiveWidth}
|
|
116
|
+
height={svgHeight}
|
|
117
|
+
viewBox="0 0 {effectiveWidth} {svgHeight}"
|
|
118
|
+
role="img"
|
|
119
|
+
aria-label={ariaLabel}
|
|
120
|
+
data-plot-root
|
|
121
|
+
data-mode={mode}
|
|
122
|
+
data-plot-animate={animate && animateReady ? '' : undefined}
|
|
123
|
+
style:cursor={zoom ? 'grab' : undefined}
|
|
124
|
+
>
|
|
125
|
+
{#if summary}
|
|
126
|
+
<desc>{summary}</desc>
|
|
127
|
+
{/if}
|
|
128
|
+
<!-- SVG <pattern> defs for texture fills (Bar/Area/Arc/Box/Violin `pattern` channel) -->
|
|
129
|
+
<DefinePatterns />
|
|
130
|
+
<g
|
|
131
|
+
class="plot-canvas"
|
|
132
|
+
transform="translate({plotState.margin.left}, {plotState.margin.top})"
|
|
133
|
+
data-plot-canvas
|
|
134
|
+
>
|
|
135
|
+
{@render children?.()}
|
|
136
|
+
</g>
|
|
137
|
+
</svg>
|
|
138
|
+
<!-- HTML overlays (legend/tooltip/a11y table) — inside the context, outside the svg. -->
|
|
139
|
+
{@render overlay?.()}
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<style>
|
|
143
|
+
.plot-surface {
|
|
144
|
+
width: 100%;
|
|
145
|
+
}
|
|
146
|
+
.plot-surface svg {
|
|
147
|
+
display: block;
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: auto;
|
|
150
|
+
overflow: visible;
|
|
151
|
+
}
|
|
152
|
+
.plot-canvas {
|
|
153
|
+
pointer-events: all;
|
|
154
|
+
}
|
|
155
|
+
/* Mode token-lock colour (only when data-mode is set explicitly). */
|
|
156
|
+
[data-plot-root][data-mode='light'] {
|
|
157
|
+
color: rgba(var(--color-surface-700, 59, 65, 77), 1);
|
|
158
|
+
}
|
|
159
|
+
[data-plot-root][data-mode='dark'] {
|
|
160
|
+
color: rgba(var(--color-surface-200, 224, 224, 224), 1);
|
|
161
|
+
}
|
|
162
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Row = Record<string, unknown>;
|
|
3
|
+
type Props = {
|
|
4
|
+
/** Full PlotState config. `config.width` is the initial/fallback width — PlotSurface
|
|
5
|
+
* owns the responsive width via a ResizeObserver and overrides it. */
|
|
6
|
+
config?: Record<string, unknown>;
|
|
7
|
+
/** Animate marks on data/flip changes (data-plot-animate). Enabled one frame after the
|
|
8
|
+
* width settles so the initial layout paints un-animated. */
|
|
9
|
+
animate?: boolean;
|
|
10
|
+
/** Enable d3-zoom pan/zoom on the svg. */
|
|
11
|
+
zoom?: boolean;
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
/** SVG <desc> for screen readers. */
|
|
14
|
+
summary?: string;
|
|
15
|
+
/** Two-way selection (row references), synced with the PlotState selection. */
|
|
16
|
+
selected?: Row[];
|
|
17
|
+
/** Canvas content (geoms/grid/axes) — rendered inside the svg. */
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
/** HTML overlays (legend/tooltip/a11y table) — rendered outside the svg but INSIDE the
|
|
20
|
+
* plot-state context, so they can read plotState. */
|
|
21
|
+
overlay?: Snippet;
|
|
22
|
+
};
|
|
23
|
+
declare const PlotSurface: import("svelte").Component<Props, {}, "selected">;
|
|
24
|
+
type PlotSurface = ReturnType<typeof PlotSurface>;
|
|
25
|
+
export default PlotSurface;
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
mode?: 'light' | 'dark'
|
|
21
21
|
grid?: boolean | 'x' | 'y' | 'both'
|
|
22
22
|
legend?: boolean
|
|
23
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
23
24
|
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean)
|
|
24
25
|
trend?: Method | Method[]
|
|
25
26
|
xFormat?: Format
|
|
@@ -43,9 +44,10 @@
|
|
|
43
44
|
stack = false,
|
|
44
45
|
width = 600,
|
|
45
46
|
height = 400,
|
|
46
|
-
mode =
|
|
47
|
+
mode = undefined,
|
|
47
48
|
grid = true,
|
|
48
49
|
legend = false,
|
|
50
|
+
tooltip = false,
|
|
49
51
|
highlight = undefined,
|
|
50
52
|
trend = undefined,
|
|
51
53
|
xFormat = undefined,
|
|
@@ -68,6 +70,7 @@
|
|
|
68
70
|
{mode}
|
|
69
71
|
{grid}
|
|
70
72
|
{legend}
|
|
73
|
+
{tooltip}
|
|
71
74
|
{highlight}
|
|
72
75
|
{trend}
|
|
73
76
|
{xFormat}
|
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
mode?: 'light' | 'dark';
|
|
19
19
|
grid?: boolean | 'x' | 'y' | 'both';
|
|
20
20
|
legend?: boolean;
|
|
21
|
+
tooltip?: boolean | ((data: Row) => string);
|
|
21
22
|
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean);
|
|
22
23
|
trend?: Method | Method[];
|
|
23
24
|
xFormat?: Format;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
type Row = Record<string, unknown>
|
|
6
6
|
type Format = (v: unknown) => string
|
|
7
|
+
type Method = string | number | { type: string; [k: string]: unknown }
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
data?: Row[]
|
|
@@ -20,11 +21,16 @@
|
|
|
20
21
|
stack?: boolean
|
|
21
22
|
label?: boolean | string | ((data: Row) => unknown)
|
|
22
23
|
tooltip?: boolean | ((data: Row) => string)
|
|
24
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean)
|
|
25
|
+
trend?: Method | Method[]
|
|
23
26
|
xFormat?: Format
|
|
24
27
|
yFormat?: Format
|
|
25
28
|
xTicks?: number
|
|
26
29
|
yTicks?: number
|
|
27
30
|
minorTicks?: boolean
|
|
31
|
+
onselect?: (detail: unknown) => void
|
|
32
|
+
selectable?: boolean
|
|
33
|
+
selected?: Row[]
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
let {
|
|
@@ -35,21 +41,44 @@
|
|
|
35
41
|
pattern = undefined,
|
|
36
42
|
width = 600,
|
|
37
43
|
height = 400,
|
|
38
|
-
mode =
|
|
44
|
+
mode = undefined,
|
|
39
45
|
grid = true,
|
|
40
46
|
legend = false,
|
|
41
47
|
stat = 'identity',
|
|
42
48
|
stack = false,
|
|
43
49
|
label = false,
|
|
44
50
|
tooltip = false,
|
|
51
|
+
highlight = undefined,
|
|
52
|
+
trend = undefined,
|
|
45
53
|
xFormat = undefined,
|
|
46
54
|
yFormat = undefined,
|
|
47
55
|
xTicks = undefined,
|
|
48
56
|
yTicks = undefined,
|
|
49
|
-
minorTicks = false
|
|
57
|
+
minorTicks = false,
|
|
58
|
+
onselect = undefined,
|
|
59
|
+
selectable = false,
|
|
60
|
+
selected = $bindable([])
|
|
50
61
|
}: Props = $props()
|
|
51
62
|
</script>
|
|
52
63
|
|
|
53
|
-
<Plot
|
|
64
|
+
<Plot
|
|
65
|
+
{data}
|
|
66
|
+
{width}
|
|
67
|
+
{height}
|
|
68
|
+
{mode}
|
|
69
|
+
{grid}
|
|
70
|
+
{legend}
|
|
71
|
+
{tooltip}
|
|
72
|
+
{highlight}
|
|
73
|
+
{trend}
|
|
74
|
+
{xFormat}
|
|
75
|
+
{yFormat}
|
|
76
|
+
{xTicks}
|
|
77
|
+
{yTicks}
|
|
78
|
+
{minorTicks}
|
|
79
|
+
{onselect}
|
|
80
|
+
{selectable}
|
|
81
|
+
bind:selected
|
|
82
|
+
>
|
|
54
83
|
<Bar {x} {y} color={fill} {pattern} {label} {stat} options={{ stack }} />
|
|
55
84
|
</Plot>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
type Row = Record<string, unknown>;
|
|
2
2
|
type Format = (v: unknown) => string;
|
|
3
|
+
type Method = string | number | {
|
|
4
|
+
type: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
3
7
|
type Props = {
|
|
4
8
|
data?: Row[];
|
|
5
9
|
x?: string;
|
|
@@ -15,12 +19,17 @@ type Props = {
|
|
|
15
19
|
stack?: boolean;
|
|
16
20
|
label?: boolean | string | ((data: Row) => unknown);
|
|
17
21
|
tooltip?: boolean | ((data: Row) => string);
|
|
22
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean);
|
|
23
|
+
trend?: Method | Method[];
|
|
18
24
|
xFormat?: Format;
|
|
19
25
|
yFormat?: Format;
|
|
20
26
|
xTicks?: number;
|
|
21
27
|
yTicks?: number;
|
|
22
28
|
minorTicks?: boolean;
|
|
29
|
+
onselect?: (detail: unknown) => void;
|
|
30
|
+
selectable?: boolean;
|
|
31
|
+
selected?: Row[];
|
|
23
32
|
};
|
|
24
|
-
declare const BarChart: import("svelte").Component<Props, {}, "">;
|
|
33
|
+
declare const BarChart: import("svelte").Component<Props, {}, "selected">;
|
|
25
34
|
type BarChart = ReturnType<typeof BarChart>;
|
|
26
35
|
export default BarChart;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
mode?: 'light' | 'dark'
|
|
15
15
|
grid?: boolean
|
|
16
16
|
legend?: boolean
|
|
17
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
17
18
|
yFormat?: (v: unknown) => string
|
|
18
19
|
yTicks?: number
|
|
19
20
|
minorTicks?: boolean
|
|
@@ -26,15 +27,16 @@
|
|
|
26
27
|
fill = undefined,
|
|
27
28
|
width = 600,
|
|
28
29
|
height = 400,
|
|
29
|
-
mode =
|
|
30
|
+
mode = undefined,
|
|
30
31
|
grid = true,
|
|
31
32
|
legend = false,
|
|
33
|
+
tooltip = false,
|
|
32
34
|
yFormat = undefined,
|
|
33
35
|
yTicks = undefined,
|
|
34
36
|
minorTicks = false
|
|
35
37
|
}: Props = $props()
|
|
36
38
|
</script>
|
|
37
39
|
|
|
38
|
-
<Plot {data} {width} {height} {mode} {grid} {legend} {yFormat} {yTicks} {minorTicks}>
|
|
40
|
+
<Plot {data} {width} {height} {mode} {grid} {legend} {tooltip} {yFormat} {yTicks} {minorTicks}>
|
|
39
41
|
<Box {x} {y} {fill} />
|
|
40
42
|
</Plot>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
type Row = Record<string, unknown>
|
|
6
6
|
type Format = (v: unknown) => string
|
|
7
|
+
type Method = string | number | { type: string; [k: string]: unknown }
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
data?: Row[]
|
|
@@ -17,11 +18,17 @@
|
|
|
17
18
|
mode?: 'light' | 'dark'
|
|
18
19
|
grid?: boolean
|
|
19
20
|
legend?: boolean
|
|
21
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
22
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean)
|
|
23
|
+
trend?: Method | Method[]
|
|
20
24
|
xFormat?: Format
|
|
21
25
|
yFormat?: Format
|
|
22
26
|
xTicks?: number
|
|
23
27
|
yTicks?: number
|
|
24
28
|
minorTicks?: boolean
|
|
29
|
+
onselect?: (detail: unknown) => void
|
|
30
|
+
selectable?: boolean
|
|
31
|
+
selected?: Row[]
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
let {
|
|
@@ -33,17 +40,41 @@
|
|
|
33
40
|
size, // required: field name for bubble radius
|
|
34
41
|
width = 600,
|
|
35
42
|
height = 400,
|
|
36
|
-
mode =
|
|
43
|
+
mode = undefined,
|
|
37
44
|
grid = true,
|
|
38
45
|
legend = false,
|
|
46
|
+
tooltip = false,
|
|
47
|
+
highlight = undefined,
|
|
48
|
+
trend = undefined,
|
|
39
49
|
xFormat = undefined,
|
|
40
50
|
yFormat = undefined,
|
|
41
51
|
xTicks = undefined,
|
|
42
52
|
yTicks = undefined,
|
|
43
|
-
minorTicks = false
|
|
53
|
+
minorTicks = false,
|
|
54
|
+
onselect = undefined,
|
|
55
|
+
selectable = false,
|
|
56
|
+
selected = $bindable([])
|
|
44
57
|
}: Props = $props()
|
|
45
58
|
</script>
|
|
46
59
|
|
|
47
|
-
<Plot
|
|
60
|
+
<Plot
|
|
61
|
+
{data}
|
|
62
|
+
{width}
|
|
63
|
+
{height}
|
|
64
|
+
{mode}
|
|
65
|
+
{grid}
|
|
66
|
+
{legend}
|
|
67
|
+
{tooltip}
|
|
68
|
+
{highlight}
|
|
69
|
+
{trend}
|
|
70
|
+
{xFormat}
|
|
71
|
+
{yFormat}
|
|
72
|
+
{xTicks}
|
|
73
|
+
{yTicks}
|
|
74
|
+
{minorTicks}
|
|
75
|
+
{onselect}
|
|
76
|
+
{selectable}
|
|
77
|
+
bind:selected
|
|
78
|
+
>
|
|
48
79
|
<Point {x} {y} {color} {size} />
|
|
49
80
|
</Plot>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
type Row = Record<string, unknown>;
|
|
2
2
|
type Format = (v: unknown) => string;
|
|
3
|
+
type Method = string | number | {
|
|
4
|
+
type: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
3
7
|
type Props = {
|
|
4
8
|
data?: Row[];
|
|
5
9
|
x?: string;
|
|
@@ -12,12 +16,18 @@ type Props = {
|
|
|
12
16
|
mode?: 'light' | 'dark';
|
|
13
17
|
grid?: boolean;
|
|
14
18
|
legend?: boolean;
|
|
19
|
+
tooltip?: boolean | ((data: Row) => string);
|
|
20
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean);
|
|
21
|
+
trend?: Method | Method[];
|
|
15
22
|
xFormat?: Format;
|
|
16
23
|
yFormat?: Format;
|
|
17
24
|
xTicks?: number;
|
|
18
25
|
yTicks?: number;
|
|
19
26
|
minorTicks?: boolean;
|
|
27
|
+
onselect?: (detail: unknown) => void;
|
|
28
|
+
selectable?: boolean;
|
|
29
|
+
selected?: Row[];
|
|
20
30
|
};
|
|
21
|
-
declare const BubbleChart: import("svelte").Component<Props, {}, "">;
|
|
31
|
+
declare const BubbleChart: import("svelte").Component<Props, {}, "selected">;
|
|
22
32
|
type BubbleChart = ReturnType<typeof BubbleChart>;
|
|
23
33
|
export default BubbleChart;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
type Row = Record<string, unknown>
|
|
6
6
|
type Format = (v: unknown) => string
|
|
7
|
+
type Method = string | number | { type: string; [k: string]: unknown }
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
data?: Row[]
|
|
@@ -20,11 +21,16 @@
|
|
|
20
21
|
grid?: boolean
|
|
21
22
|
legend?: boolean
|
|
22
23
|
jitter?: { width?: number; height?: number } | null
|
|
24
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean)
|
|
25
|
+
trend?: Method | Method[]
|
|
23
26
|
xFormat?: Format
|
|
24
27
|
yFormat?: Format
|
|
25
28
|
xTicks?: number
|
|
26
29
|
yTicks?: number
|
|
27
30
|
minorTicks?: boolean
|
|
31
|
+
onselect?: (detail: unknown) => void
|
|
32
|
+
selectable?: boolean
|
|
33
|
+
selected?: Row[]
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
let {
|
|
@@ -38,18 +44,41 @@
|
|
|
38
44
|
tooltip = false,
|
|
39
45
|
width = 600,
|
|
40
46
|
height = 400,
|
|
41
|
-
mode =
|
|
47
|
+
mode = undefined,
|
|
42
48
|
grid = true,
|
|
43
49
|
legend = false,
|
|
44
50
|
jitter = undefined,
|
|
51
|
+
highlight = undefined,
|
|
52
|
+
trend = undefined,
|
|
45
53
|
xFormat = undefined,
|
|
46
54
|
yFormat = undefined,
|
|
47
55
|
xTicks = undefined,
|
|
48
56
|
yTicks = undefined,
|
|
49
|
-
minorTicks = false
|
|
57
|
+
minorTicks = false,
|
|
58
|
+
onselect = undefined,
|
|
59
|
+
selectable = false,
|
|
60
|
+
selected = $bindable([])
|
|
50
61
|
}: Props = $props()
|
|
51
62
|
</script>
|
|
52
63
|
|
|
53
|
-
<Plot
|
|
64
|
+
<Plot
|
|
65
|
+
{data}
|
|
66
|
+
{width}
|
|
67
|
+
{height}
|
|
68
|
+
{mode}
|
|
69
|
+
{grid}
|
|
70
|
+
{legend}
|
|
71
|
+
{tooltip}
|
|
72
|
+
{highlight}
|
|
73
|
+
{trend}
|
|
74
|
+
{xFormat}
|
|
75
|
+
{yFormat}
|
|
76
|
+
{xTicks}
|
|
77
|
+
{yTicks}
|
|
78
|
+
{minorTicks}
|
|
79
|
+
{onselect}
|
|
80
|
+
{selectable}
|
|
81
|
+
bind:selected
|
|
82
|
+
>
|
|
54
83
|
<Point {x} {y} {color} {size} {symbol} {label} options={{ jitter }} />
|
|
55
84
|
</Plot>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
type Row = Record<string, unknown>;
|
|
2
2
|
type Format = (v: unknown) => string;
|
|
3
|
+
type Method = string | number | {
|
|
4
|
+
type: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
3
7
|
type Props = {
|
|
4
8
|
data?: Row[];
|
|
5
9
|
x?: string;
|
|
@@ -18,12 +22,17 @@ type Props = {
|
|
|
18
22
|
width?: number;
|
|
19
23
|
height?: number;
|
|
20
24
|
} | null;
|
|
25
|
+
highlight?: 'first' | 'last' | 'min' | 'max' | number | ((row: Row, i: number) => boolean);
|
|
26
|
+
trend?: Method | Method[];
|
|
21
27
|
xFormat?: Format;
|
|
22
28
|
yFormat?: Format;
|
|
23
29
|
xTicks?: number;
|
|
24
30
|
yTicks?: number;
|
|
25
31
|
minorTicks?: boolean;
|
|
32
|
+
onselect?: (detail: unknown) => void;
|
|
33
|
+
selectable?: boolean;
|
|
34
|
+
selected?: Row[];
|
|
26
35
|
};
|
|
27
|
-
declare const ScatterPlot: import("svelte").Component<Props, {}, "">;
|
|
36
|
+
declare const ScatterPlot: import("svelte").Component<Props, {}, "selected">;
|
|
28
37
|
type ScatterPlot = ReturnType<typeof ScatterPlot>;
|
|
29
38
|
export default ScatterPlot;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
mode?: 'light' | 'dark'
|
|
15
15
|
grid?: boolean
|
|
16
16
|
legend?: boolean
|
|
17
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
17
18
|
yFormat?: (v: unknown) => string
|
|
18
19
|
yTicks?: number
|
|
19
20
|
minorTicks?: boolean
|
|
@@ -26,15 +27,16 @@
|
|
|
26
27
|
fill = undefined,
|
|
27
28
|
width = 600,
|
|
28
29
|
height = 400,
|
|
29
|
-
mode =
|
|
30
|
+
mode = undefined,
|
|
30
31
|
grid = true,
|
|
31
32
|
legend = false,
|
|
33
|
+
tooltip = false,
|
|
32
34
|
yFormat = undefined,
|
|
33
35
|
yTicks = undefined,
|
|
34
36
|
minorTicks = false
|
|
35
37
|
}: Props = $props()
|
|
36
38
|
</script>
|
|
37
39
|
|
|
38
|
-
<Plot {data} {width} {height} {mode} {grid} {legend} {yFormat} {yTicks} {minorTicks}>
|
|
40
|
+
<Plot {data} {width} {height} {mode} {grid} {legend} {tooltip} {yFormat} {yTicks} {minorTicks}>
|
|
39
41
|
<Violin {x} {y} {fill} />
|
|
40
42
|
</Plot>
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<Plot.Grid />
|
|
37
37
|
<Plot.Axis type="x" label="Product Category" />
|
|
38
38
|
<Plot.Axis type="y" label="Number of Products" />
|
|
39
|
-
<Plot.Bar
|
|
39
|
+
<Plot.Bar x="category" y="count" fill="category" />
|
|
40
40
|
<Plot.Legend labels={{ category: 'Categories' }} />
|
|
41
41
|
</Plot.Root>
|
|
42
42
|
</div>
|
package/dist/geoms/Arc.svelte
CHANGED
|
@@ -65,14 +65,15 @@
|
|
|
65
65
|
// this derived runs first with stale data whose rows don't have the new
|
|
66
66
|
// field — causing all keys to be undefined (duplicate key error).
|
|
67
67
|
if (fillField && !(fillField in data[0])) return []
|
|
68
|
-
|
|
68
|
+
// innerRadius passed through raw — buildArcs interprets it (a fraction of the
|
|
69
|
+
// radius when <= 1, absolute pixels when > 1) and clamps it below the outer radius.
|
|
69
70
|
return buildArcs(
|
|
70
71
|
data,
|
|
71
72
|
{ color: fillField, y: theta, pattern },
|
|
72
73
|
colors,
|
|
73
74
|
w,
|
|
74
75
|
h,
|
|
75
|
-
{ innerRadius },
|
|
76
|
+
{ innerRadius: options.innerRadius ?? 0 },
|
|
76
77
|
patterns
|
|
77
78
|
)
|
|
78
79
|
})
|
package/dist/geoms/Area.svelte
CHANGED
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
if (!data?.length || !xScale || !yScale || !x || !y) return []
|
|
65
65
|
const channels = { x, y, color, pattern }
|
|
66
66
|
if (options.stack) {
|
|
67
|
-
return buildStackedAreas(data, channels, xScale, yScale, colors, options.curve, patterns)
|
|
67
|
+
return buildStackedAreas(data, channels, xScale, yScale, colors, options.curve, patterns, plotState.place.bind(plotState))
|
|
68
68
|
}
|
|
69
|
-
return buildAreas(data, channels, xScale, yScale, colors, options.curve, patterns)
|
|
69
|
+
return buildAreas(data, channels, xScale, yScale, colors, options.curve, patterns, plotState.place.bind(plotState))
|
|
70
70
|
})
|
|
71
71
|
</script>
|
|
72
72
|
|