@rokkit/chart 1.1.17 → 1.1.19
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.d.ts +35 -0
- package/dist/Chart.svelte.d.ts +21 -0
- package/dist/ChartExporter.svelte.d.ts +22 -0
- package/dist/ChartLegend.svelte.d.ts +30 -0
- package/dist/ChartProvider.svelte.d.ts +10 -0
- package/dist/FacetPlot/Panel.svelte.d.ts +22 -0
- package/dist/FacetPlot.svelte.d.ts +32 -0
- package/dist/Plot/Arc.svelte.d.ts +18 -0
- package/dist/Plot/Area.svelte.d.ts +14 -0
- package/dist/Plot/Axis.svelte.d.ts +13 -0
- package/dist/Plot/Bar.svelte.d.ts +11 -0
- package/dist/Plot/Grid.svelte.d.ts +3 -0
- package/dist/Plot/Legend.svelte.d.ts +6 -0
- package/dist/Plot/Line.svelte.d.ts +13 -0
- package/dist/Plot/Point.svelte.d.ts +13 -0
- package/dist/Plot/Root.svelte.d.ts +21 -0
- package/dist/Plot/Timeline.svelte.d.ts +13 -0
- package/dist/Plot/Tooltip.svelte.d.ts +7 -0
- package/dist/Plot.svelte.d.ts +34 -0
- package/dist/PlotState.svelte.d.ts +0 -3
- package/dist/Sparkline.svelte.d.ts +16 -0
- package/dist/Symbol.svelte.d.ts +12 -0
- package/dist/Texture.svelte.d.ts +12 -0
- package/dist/charts/AreaChart.svelte.d.ts +25 -0
- package/dist/charts/BarChart.svelte.d.ts +26 -0
- package/dist/charts/BoxPlot.svelte.d.ts +18 -0
- package/dist/charts/BubbleChart.svelte.d.ts +23 -0
- package/dist/charts/LineChart.svelte.d.ts +26 -0
- package/dist/charts/PieChart.svelte.d.ts +19 -0
- package/dist/charts/ScatterPlot.svelte.d.ts +29 -0
- package/dist/charts/ViolinPlot.svelte.d.ts +18 -0
- package/dist/crossfilter/CrossFilter.svelte.d.ts +12 -0
- package/dist/crossfilter/FilterBar.svelte.d.ts +12 -0
- package/dist/crossfilter/FilterHistogram.svelte.d.ts +19 -0
- package/dist/crossfilter/FilterSlider.svelte.d.ts +15 -0
- package/dist/elements/Bar.svelte.d.ts +17 -0
- package/dist/elements/ColorRamp.svelte.d.ts +17 -0
- package/dist/elements/ContinuousLegend.svelte.d.ts +18 -0
- package/dist/elements/DefinePatterns.svelte.d.ts +21 -0
- package/dist/elements/DiscreteLegend.svelte.d.ts +17 -0
- package/dist/elements/Label.svelte.d.ts +11 -0
- package/dist/elements/SymbolGrid.svelte.d.ts +8 -0
- package/dist/examples/BarChartExample.svelte.d.ts +18 -0
- package/dist/geoms/Arc.svelte.d.ts +20 -0
- package/dist/geoms/Area.svelte.d.ts +16 -0
- package/dist/geoms/Bar.svelte.d.ts +23 -0
- package/dist/geoms/Box.svelte.d.ts +12 -0
- package/dist/geoms/Candlestick.svelte.d.ts +20 -0
- package/dist/geoms/Heatmap.svelte.d.ts +13 -0
- package/dist/geoms/Hexbin.svelte.d.ts +13 -0
- package/dist/geoms/LabelPill.svelte.d.ts +9 -0
- package/dist/geoms/Line.svelte.d.ts +24 -0
- package/dist/geoms/Point.svelte.d.ts +30 -0
- package/dist/geoms/Ribbon.svelte.d.ts +16 -0
- package/dist/geoms/Violin.svelte.d.ts +12 -0
- package/dist/geoms/Waterfall.svelte.d.ts +18 -0
- package/dist/geoms/lib/areas.d.ts +5 -3
- package/dist/lib/brewing/brewer.svelte.d.ts +24 -15
- package/dist/lib/brewing/marks/arcs.d.ts +16 -6
- package/dist/lib/brewing/marks/areas.d.ts +2 -2
- package/dist/lib/brewing/marks/boxes.d.ts +3 -3
- package/dist/lib/brewing/marks/lines.d.ts +6 -6
- package/dist/lib/brewing/marks/points.d.ts +13 -12
- package/dist/lib/brewing/marks/violins.d.ts +3 -3
- package/dist/lib/brewing/scales.d.ts +3 -3
- package/dist/lib/chart.d.ts +2 -2
- package/dist/lib/keyboard-nav.d.ts +1 -1
- package/dist/lib/plot/facet.d.ts +2 -2
- package/dist/lib/plot/frames.d.ts +9 -9
- package/dist/lib/plot/scales.d.ts +3 -3
- package/dist/lib/plot/types.d.ts +7 -4
- package/dist/lib/scales.svelte.d.ts +2 -2
- package/dist/lib/utils.d.ts +7 -1
- package/dist/lib/xscale.d.ts +1 -1
- package/dist/patterns/DefinePatterns.svelte.d.ts +7 -0
- package/dist/patterns/PatternDef.svelte.d.ts +11 -0
- package/dist/spec/chart-spec.d.ts +22 -0
- package/dist/symbols/RoundedSquare.svelte.d.ts +11 -0
- package/dist/symbols/Shape.svelte.d.ts +18 -0
- package/dist/symbols/constants/index.d.ts +1 -1
- package/dist/symbols/index.d.ts +2 -2
- package/dist/symbols/outline.svelte.d.ts +18 -0
- package/dist/symbols/solid.svelte.d.ts +18 -0
- package/package.json +22 -3
- package/src/AnimatedPlot.svelte +49 -43
- package/src/Chart.svelte +34 -22
- package/src/ChartExporter.svelte +19 -16
- package/src/ChartLegend.svelte +24 -20
- package/src/ChartProvider.svelte +10 -2
- package/src/FacetPlot/Panel.svelte +23 -3
- package/src/FacetPlot.svelte +29 -26
- package/src/Plot/Arc.svelte +3 -2
- package/src/Plot/Area.svelte +30 -8
- package/src/Plot/Axis.svelte +26 -45
- package/src/Plot/Bar.svelte +20 -5
- package/src/Plot/Grid.svelte +5 -4
- package/src/Plot/Legend.svelte +8 -4
- package/src/Plot/Line.svelte +24 -7
- package/src/Plot/Point.svelte +24 -6
- package/src/Plot/Root.svelte +17 -2
- package/src/Plot/Timeline.svelte +13 -14
- package/src/Plot/Tooltip.svelte +12 -6
- package/src/Plot.svelte +58 -40
- package/src/PlotState.svelte.js +6 -2
- package/src/Sparkline.svelte +22 -8
- package/src/Symbol.svelte +15 -5
- package/src/Texture.svelte +12 -2
- package/src/charts/AreaChart.svelte +26 -3
- package/src/charts/BarChart.svelte +27 -3
- package/src/charts/BoxPlot.svelte +19 -3
- package/src/charts/BubbleChart.svelte +24 -3
- package/src/charts/LineChart.svelte +27 -3
- package/src/charts/PieChart.svelte +20 -3
- package/src/charts/ScatterPlot.svelte +27 -3
- package/src/charts/ViolinPlot.svelte +19 -3
- package/src/crossfilter/CrossFilter.svelte +13 -10
- package/src/crossfilter/FilterBar.svelte +14 -3
- package/src/crossfilter/FilterHistogram.svelte +49 -24
- package/src/crossfilter/FilterSlider.svelte +16 -5
- package/src/elements/Bar.svelte +16 -2
- package/src/elements/ColorRamp.svelte +28 -4
- package/src/elements/ContinuousLegend.svelte +20 -3
- package/src/elements/DefinePatterns.svelte +23 -7
- package/src/elements/DiscreteLegend.svelte +18 -2
- package/src/elements/Label.svelte +11 -2
- package/src/elements/SymbolGrid.svelte +13 -4
- package/src/examples/BarChartExample.svelte +12 -15
- package/src/geoms/Arc.svelte +18 -5
- package/src/geoms/Area.svelte +38 -20
- package/src/geoms/Bar.svelte +40 -23
- package/src/geoms/Box.svelte +13 -4
- package/src/geoms/Candlestick.svelte +27 -7
- package/src/geoms/Heatmap.svelte +20 -9
- package/src/geoms/Hexbin.svelte +35 -13
- package/src/geoms/LabelPill.svelte +9 -3
- package/src/geoms/Line.svelte +27 -10
- package/src/geoms/Point.svelte +33 -13
- package/src/geoms/Ribbon.svelte +26 -8
- package/src/geoms/Violin.svelte +13 -4
- package/src/geoms/Waterfall.svelte +32 -12
- package/src/geoms/lib/areas.js +2 -2
- package/src/lib/brewing/marks/arcs.js +3 -2
- package/src/lib/brewing/marks/boxes.js +1 -1
- package/src/lib/brewing/marks/lines.js +2 -2
- package/src/lib/brewing/marks/points.js +3 -2
- package/src/lib/brewing/marks/violins.js +1 -1
- package/src/lib/plot/facet.js +1 -1
- package/src/lib/plot/frames.js +4 -4
- package/src/lib/plot/types.js +6 -3
- package/src/lib/utils.js +7 -1
- package/src/patterns/DefinePatterns.svelte +9 -4
- package/src/patterns/PatternDef.svelte +11 -3
- package/src/symbols/RoundedSquare.svelte +15 -4
- package/src/symbols/Shape.svelte +21 -3
- package/src/symbols/outline.svelte +2 -0
- package/src/symbols/solid.svelte +2 -0
package/src/Plot/Timeline.svelte
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type Props = {
|
|
3
|
+
frameKeys?: unknown[]
|
|
4
|
+
currentIndex?: number
|
|
5
|
+
playing?: boolean
|
|
6
|
+
speed?: number
|
|
7
|
+
onplay?: () => void
|
|
8
|
+
onpause?: () => void
|
|
9
|
+
onscrub?: (index: number) => void
|
|
10
|
+
onspeed?: (speed: number) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
14
13
|
let {
|
|
15
14
|
frameKeys = [],
|
|
16
15
|
currentIndex = 0,
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
onpause,
|
|
21
20
|
onscrub,
|
|
22
21
|
onspeed
|
|
23
|
-
} = $props()
|
|
22
|
+
}: Props = $props()
|
|
24
23
|
|
|
25
24
|
const safeIndex = $derived(
|
|
26
25
|
frameKeys.length === 0 ? 0 : Math.min(currentIndex, frameKeys.length - 1)
|
package/src/Plot/Tooltip.svelte
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte'
|
|
3
|
+
import type { PlotState } from '../PlotState.svelte.js'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
let { tooltip = true } = $props()
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
type Props = {
|
|
8
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { tooltip = true }: Props = $props()
|
|
12
|
+
|
|
13
|
+
const plotState = getContext<PlotState>('plot-state')
|
|
8
14
|
|
|
9
15
|
let mouseX = $state(0)
|
|
10
16
|
let mouseY = $state(0)
|
|
11
17
|
|
|
12
18
|
$effect(() => {
|
|
13
|
-
function onMove(e) {
|
|
19
|
+
function onMove(e: MouseEvent) {
|
|
14
20
|
mouseX = e.clientX
|
|
15
21
|
mouseY = e.clientY
|
|
16
22
|
}
|
|
@@ -21,7 +27,7 @@
|
|
|
21
27
|
const hovered = $derived(plotState.hovered)
|
|
22
28
|
const mode = $derived(plotState.mode)
|
|
23
29
|
|
|
24
|
-
function formatDefault(data) {
|
|
30
|
+
function formatDefault(data: Row) {
|
|
25
31
|
return Object.entries(data)
|
|
26
32
|
.filter(([, v]) => v !== undefined && v !== null)
|
|
27
33
|
.map(
|
package/src/Plot.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { setContext, getContext, untrack } from 'svelte'
|
|
3
|
-
import {
|
|
4
|
-
import { select } from 'd3-selection'
|
|
3
|
+
import type { Snippet } from 'svelte'
|
|
5
4
|
import { PlotState } from './PlotState.svelte.js'
|
|
6
5
|
import { defaultPreset } from './lib/preset.js'
|
|
6
|
+
import type { PlotSpec, PlotHelpers } from './lib/plot/types.js'
|
|
7
7
|
import Axis from './Plot/Axis.svelte'
|
|
8
8
|
import Grid from './Plot/Grid.svelte'
|
|
9
9
|
import Legend from './Plot/Legend.svelte'
|
|
@@ -22,25 +22,33 @@
|
|
|
22
22
|
import Hexbin from './geoms/Hexbin.svelte'
|
|
23
23
|
import Ribbon from './geoms/Ribbon.svelte'
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
type Row = Record<string, unknown>
|
|
26
|
+
type Margin = { top: number; right: number; bottom: number; left: number }
|
|
27
|
+
type ChartPresetCtx = { current: typeof defaultPreset }
|
|
28
|
+
|
|
29
|
+
type Props = {
|
|
30
|
+
data?: Row[]
|
|
31
|
+
spec?: PlotSpec
|
|
32
|
+
helpers?: PlotHelpers
|
|
33
|
+
width?: number
|
|
34
|
+
height?: number
|
|
35
|
+
mode?: 'light' | 'dark'
|
|
36
|
+
grid?: boolean
|
|
37
|
+
axes?: boolean
|
|
38
|
+
margin?: Margin
|
|
39
|
+
legend?: boolean
|
|
40
|
+
title?: string
|
|
41
|
+
summary?: string
|
|
42
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
43
|
+
zoom?: boolean
|
|
44
|
+
xFormat?: (v: unknown) => string
|
|
45
|
+
yFormat?: (v: unknown) => string
|
|
46
|
+
xTicks?: number
|
|
47
|
+
yTicks?: number
|
|
48
|
+
minorTicks?: boolean
|
|
49
|
+
children?: Snippet
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
let {
|
|
45
53
|
data = [],
|
|
46
54
|
spec = undefined,
|
|
@@ -62,14 +70,14 @@
|
|
|
62
70
|
yTicks = undefined,
|
|
63
71
|
minorTicks = false,
|
|
64
72
|
children
|
|
65
|
-
} = $props()
|
|
73
|
+
}: Props = $props()
|
|
66
74
|
|
|
67
|
-
const chartPresetCtx = getContext('chart-preset')
|
|
75
|
+
const chartPresetCtx = getContext<ChartPresetCtx | undefined>('chart-preset')
|
|
68
76
|
const chartPreset = $derived(chartPresetCtx?.current ?? defaultPreset)
|
|
69
77
|
|
|
70
78
|
// Responsive width: observe container and use actual pixel width for scale calculations
|
|
71
|
-
let svgEl = $state(null)
|
|
72
|
-
let containerEl = $state(null)
|
|
79
|
+
let svgEl = $state<SVGSVGElement | null>(null)
|
|
80
|
+
let containerEl = $state<HTMLDivElement | null>(null)
|
|
73
81
|
let observedWidth = $state(0)
|
|
74
82
|
|
|
75
83
|
$effect(() => {
|
|
@@ -92,7 +100,9 @@
|
|
|
92
100
|
// Accessible data table — screen reader fallback
|
|
93
101
|
const tableData = $derived(spec?.data ?? data)
|
|
94
102
|
const tableColumns = $derived.by(() => {
|
|
95
|
-
const cols = [spec?.x, spec?.y, spec?.color ?? spec?.fill].filter(
|
|
103
|
+
const cols = [spec?.x, spec?.y, spec?.color ?? spec?.fill].filter(
|
|
104
|
+
(c): c is string => Boolean(c)
|
|
105
|
+
)
|
|
96
106
|
if (cols.length > 0) return cols
|
|
97
107
|
const first = tableData[0]
|
|
98
108
|
return first ? Object.keys(first) : []
|
|
@@ -132,15 +142,26 @@
|
|
|
132
142
|
|
|
133
143
|
$effect(() => {
|
|
134
144
|
if (!zoom || !svgEl) return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
)
|
|
142
162
|
return () => {
|
|
143
|
-
|
|
163
|
+
cancelled = true
|
|
164
|
+
detach?.()
|
|
144
165
|
plotState.resetZoom()
|
|
145
166
|
}
|
|
146
167
|
})
|
|
@@ -164,11 +185,8 @@
|
|
|
164
185
|
ribbon: Ribbon
|
|
165
186
|
}
|
|
166
187
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*/
|
|
170
|
-
function resolveGeomComponent(type) {
|
|
171
|
-
return helpers?.geoms?.[type] ?? GEOM_COMPONENTS[type]
|
|
188
|
+
function resolveGeomComponent(type: string) {
|
|
189
|
+
return helpers?.geoms?.[type] ?? GEOM_COMPONENTS[type as keyof typeof GEOM_COMPONENTS]
|
|
172
190
|
}
|
|
173
191
|
</script>
|
|
174
192
|
|
package/src/PlotState.svelte.js
CHANGED
|
@@ -191,8 +191,12 @@ export class PlotState {
|
|
|
191
191
|
// use it instead of deriving distinct values from the local panel data.
|
|
192
192
|
colors = $derived.by(() => {
|
|
193
193
|
const field = this.#effectiveChannels.color
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
if (isLiteralColor(field)) {
|
|
195
|
+
/** @type {Map<unknown, { fill: string, stroke: string }>} */
|
|
196
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
197
|
+
const literal = new Map([[null, { fill: field, stroke: field }]])
|
|
198
|
+
return literal
|
|
199
|
+
}
|
|
196
200
|
const values = this.#colorDomain ?? distinct(this.#data, field)
|
|
197
201
|
// No color channel but data exists → use first preset color for single-series rendering.
|
|
198
202
|
// This prevents geoms from falling back to gray (#888) on charts with no fill channel.
|
package/src/Sparkline.svelte
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { scaleLinear } from 'd3-scale'
|
|
3
3
|
import { line as d3line, area as d3area, curveCatmullRom } from 'd3-shape'
|
|
4
4
|
import PatternDef from './patterns/PatternDef.svelte'
|
|
5
5
|
import { PATTERNS } from './patterns/patterns.js'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type Props = {
|
|
8
|
+
data?: number[] | Record<string, unknown>[]
|
|
9
|
+
field?: string
|
|
10
|
+
type?: 'line' | 'area' | 'bar'
|
|
11
|
+
curve?: 'linear' | 'smooth'
|
|
12
|
+
color?: string
|
|
13
|
+
pattern?: keyof typeof PATTERNS
|
|
14
|
+
width?: number
|
|
15
|
+
height?: number
|
|
16
|
+
min?: number
|
|
17
|
+
max?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
let {
|
|
11
21
|
data = [],
|
|
12
22
|
field = undefined,
|
|
@@ -18,9 +28,13 @@
|
|
|
18
28
|
height = 24,
|
|
19
29
|
min = undefined,
|
|
20
30
|
max = undefined
|
|
21
|
-
} = $props()
|
|
31
|
+
}: Props = $props()
|
|
22
32
|
|
|
23
|
-
const values = $derived(
|
|
33
|
+
const values = $derived(
|
|
34
|
+
data.map((d) =>
|
|
35
|
+
field && typeof d === 'object' && d !== null ? Number(d[field]) : Number(d)
|
|
36
|
+
)
|
|
37
|
+
)
|
|
24
38
|
|
|
25
39
|
const yMin = $derived(min ?? Math.min(...values))
|
|
26
40
|
const yMax = $derived(max ?? Math.max(...values))
|
|
@@ -33,7 +47,7 @@
|
|
|
33
47
|
const yScale = $derived(scaleLinear().domain([yMin, yMax]).range([height, 0]))
|
|
34
48
|
|
|
35
49
|
const linePath = $derived.by(() => {
|
|
36
|
-
const gen = d3line()
|
|
50
|
+
const gen = d3line<number>()
|
|
37
51
|
.x((_, i) => xScale(i))
|
|
38
52
|
.y((v) => yScale(v))
|
|
39
53
|
if (curve === 'smooth') gen.curve(curveCatmullRom)
|
|
@@ -41,7 +55,7 @@
|
|
|
41
55
|
})
|
|
42
56
|
|
|
43
57
|
const areaPath = $derived.by(() => {
|
|
44
|
-
const gen = d3area()
|
|
58
|
+
const gen = d3area<number>()
|
|
45
59
|
.x((_, i) => xScale(i))
|
|
46
60
|
.y0(height)
|
|
47
61
|
.y1((v) => yScale(v))
|
package/src/Symbol.svelte
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
2
3
|
import { components } from './symbols'
|
|
3
4
|
|
|
5
|
+
type Props = {
|
|
6
|
+
x?: number
|
|
7
|
+
y?: number
|
|
8
|
+
size?: number
|
|
9
|
+
fill?: string
|
|
10
|
+
stroke?: string
|
|
11
|
+
name?: string
|
|
12
|
+
} & Omit<SVGAttributes<SVGElement>, 'x' | 'y' | 'fill' | 'stroke'>
|
|
13
|
+
|
|
4
14
|
let {
|
|
5
15
|
x = 0,
|
|
6
16
|
y = 0,
|
|
@@ -9,13 +19,13 @@
|
|
|
9
19
|
stroke = 'currentColor',
|
|
10
20
|
name = 'circle',
|
|
11
21
|
...restProps
|
|
12
|
-
} = $props()
|
|
22
|
+
}: Props = $props()
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
let
|
|
24
|
+
const shapes: Record<string, (typeof components)[keyof typeof components]> = components
|
|
25
|
+
let RenderShape = $derived(shapes[name] ?? components.default)
|
|
16
26
|
</script>
|
|
17
27
|
|
|
18
28
|
<!-- {#snippet defaultSymbol(props)}
|
|
19
29
|
<circle cx={x} cy={y} r={size / 2} {fill} {stroke} />
|
|
20
30
|
{/snippet} -->
|
|
21
|
-
<RenderShape {...
|
|
31
|
+
<RenderShape {...restProps} {x} {y} {size} {fill} {stroke} />
|
package/src/Texture.svelte
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type Props = {
|
|
3
|
+
id?: string
|
|
4
|
+
path?: string
|
|
5
|
+
fill?: string
|
|
6
|
+
stroke?: string
|
|
7
|
+
thickness?: number
|
|
8
|
+
patternUnits?: 'userSpaceOnUse' | 'objectBoundingBox'
|
|
9
|
+
size?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
let {
|
|
3
13
|
id,
|
|
4
14
|
path,
|
|
@@ -7,7 +17,7 @@
|
|
|
7
17
|
thickness = 0.5,
|
|
8
18
|
patternUnits = 'userSpaceOnUse',
|
|
9
19
|
size = 10
|
|
10
|
-
} = $props()
|
|
20
|
+
}: Props = $props()
|
|
11
21
|
</script>
|
|
12
22
|
|
|
13
23
|
<pattern {id} {patternUnits} width={size} height={size}>
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Area from '../geoms/Area.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
type Format = (v: unknown) => string
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
data?: Row[]
|
|
10
|
+
x?: string
|
|
11
|
+
y?: string
|
|
12
|
+
fill?: string
|
|
13
|
+
stat?: string
|
|
14
|
+
curve?: 'linear' | 'smooth' | 'step'
|
|
15
|
+
pattern?: string
|
|
16
|
+
stack?: boolean
|
|
17
|
+
width?: number
|
|
18
|
+
height?: number
|
|
19
|
+
mode?: 'light' | 'dark'
|
|
20
|
+
grid?: boolean
|
|
21
|
+
legend?: boolean
|
|
22
|
+
xFormat?: Format
|
|
23
|
+
yFormat?: Format
|
|
24
|
+
xTicks?: number
|
|
25
|
+
yTicks?: number
|
|
26
|
+
minorTicks?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
6
29
|
let {
|
|
7
30
|
data = [],
|
|
8
31
|
x = undefined,
|
|
@@ -22,7 +45,7 @@
|
|
|
22
45
|
xTicks = undefined,
|
|
23
46
|
yTicks = undefined,
|
|
24
47
|
minorTicks = false
|
|
25
|
-
} = $props()
|
|
48
|
+
}: Props = $props()
|
|
26
49
|
</script>
|
|
27
50
|
|
|
28
51
|
<Plot {data} {width} {height} {mode} {grid} {legend} {xFormat} {yFormat} {xTicks} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Bar from '../geoms/Bar.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
type Format = (v: unknown) => string
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
data?: Row[]
|
|
10
|
+
x?: string
|
|
11
|
+
y?: string
|
|
12
|
+
fill?: string
|
|
13
|
+
pattern?: string
|
|
14
|
+
width?: number
|
|
15
|
+
height?: number
|
|
16
|
+
mode?: 'light' | 'dark'
|
|
17
|
+
grid?: boolean
|
|
18
|
+
legend?: boolean
|
|
19
|
+
stat?: string
|
|
20
|
+
stack?: boolean
|
|
21
|
+
label?: boolean | string | ((data: Row) => unknown)
|
|
22
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
23
|
+
xFormat?: Format
|
|
24
|
+
yFormat?: Format
|
|
25
|
+
xTicks?: number
|
|
26
|
+
yTicks?: number
|
|
27
|
+
minorTicks?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
let {
|
|
7
31
|
data = [],
|
|
8
32
|
x = undefined,
|
|
@@ -23,7 +47,7 @@
|
|
|
23
47
|
xTicks = undefined,
|
|
24
48
|
yTicks = undefined,
|
|
25
49
|
minorTicks = false
|
|
26
|
-
} = $props()
|
|
50
|
+
}: Props = $props()
|
|
27
51
|
</script>
|
|
28
52
|
|
|
29
53
|
<Plot {data} {width} {height} {mode} {grid} {legend} {tooltip} {xFormat} {yFormat} {xTicks} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Box from '../geoms/Box.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
data?: Row[]
|
|
9
|
+
x?: string
|
|
10
|
+
y?: string
|
|
11
|
+
fill?: string
|
|
12
|
+
width?: number
|
|
13
|
+
height?: number
|
|
14
|
+
mode?: 'light' | 'dark'
|
|
15
|
+
grid?: boolean
|
|
16
|
+
legend?: boolean
|
|
17
|
+
yFormat?: (v: unknown) => string
|
|
18
|
+
yTicks?: number
|
|
19
|
+
minorTicks?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
let {
|
|
7
23
|
data = [],
|
|
8
24
|
x = undefined,
|
|
@@ -16,7 +32,7 @@
|
|
|
16
32
|
yFormat = undefined,
|
|
17
33
|
yTicks = undefined,
|
|
18
34
|
minorTicks = false
|
|
19
|
-
} = $props()
|
|
35
|
+
}: Props = $props()
|
|
20
36
|
</script>
|
|
21
37
|
|
|
22
38
|
<Plot {data} {width} {height} {mode} {grid} {legend} {yFormat} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Point from '../geoms/Point.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
type Format = (v: unknown) => string
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
data?: Row[]
|
|
10
|
+
x?: string
|
|
11
|
+
y?: string
|
|
12
|
+
color?: string
|
|
13
|
+
symbol?: string
|
|
14
|
+
size?: string
|
|
15
|
+
width?: number
|
|
16
|
+
height?: number
|
|
17
|
+
mode?: 'light' | 'dark'
|
|
18
|
+
grid?: boolean
|
|
19
|
+
legend?: boolean
|
|
20
|
+
xFormat?: Format
|
|
21
|
+
yFormat?: Format
|
|
22
|
+
xTicks?: number
|
|
23
|
+
yTicks?: number
|
|
24
|
+
minorTicks?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
6
27
|
let {
|
|
7
28
|
data = [],
|
|
8
29
|
x = undefined,
|
|
@@ -20,7 +41,7 @@
|
|
|
20
41
|
xTicks = undefined,
|
|
21
42
|
yTicks = undefined,
|
|
22
43
|
minorTicks = false
|
|
23
|
-
} = $props()
|
|
44
|
+
}: Props = $props()
|
|
24
45
|
</script>
|
|
25
46
|
|
|
26
47
|
<Plot {data} {width} {height} {mode} {grid} {legend} {xFormat} {yFormat} {xTicks} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Line from '../geoms/Line.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
type Format = (v: unknown) => string
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
data?: Row[]
|
|
10
|
+
x?: string
|
|
11
|
+
y?: string
|
|
12
|
+
color?: string
|
|
13
|
+
stat?: string
|
|
14
|
+
symbol?: string
|
|
15
|
+
curve?: 'linear' | 'smooth' | 'step'
|
|
16
|
+
label?: boolean | string | ((data: Row) => unknown)
|
|
17
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
18
|
+
width?: number
|
|
19
|
+
height?: number
|
|
20
|
+
mode?: 'light' | 'dark'
|
|
21
|
+
grid?: boolean
|
|
22
|
+
legend?: boolean
|
|
23
|
+
xFormat?: Format
|
|
24
|
+
yFormat?: Format
|
|
25
|
+
xTicks?: number
|
|
26
|
+
yTicks?: number
|
|
27
|
+
minorTicks?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
let {
|
|
7
31
|
data = [],
|
|
8
32
|
x = undefined,
|
|
@@ -23,7 +47,7 @@
|
|
|
23
47
|
xTicks = undefined,
|
|
24
48
|
yTicks = undefined,
|
|
25
49
|
minorTicks = false
|
|
26
|
-
} = $props()
|
|
50
|
+
}: Props = $props()
|
|
27
51
|
</script>
|
|
28
52
|
|
|
29
53
|
<Plot {data} {width} {height} {mode} {grid} {legend} {tooltip} {xFormat} {yFormat} {xTicks} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Arc from '../geoms/Arc.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
data?: Row[]
|
|
9
|
+
label?: string
|
|
10
|
+
y?: string
|
|
11
|
+
fill?: string
|
|
12
|
+
pattern?: string
|
|
13
|
+
innerRadius?: number
|
|
14
|
+
labelFn?: (data: Row) => string
|
|
15
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
16
|
+
width?: number
|
|
17
|
+
height?: number
|
|
18
|
+
mode?: 'light' | 'dark'
|
|
19
|
+
legend?: boolean
|
|
20
|
+
stat?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
let {
|
|
7
24
|
data = [],
|
|
8
25
|
label = undefined,
|
|
@@ -17,7 +34,7 @@
|
|
|
17
34
|
mode = 'light',
|
|
18
35
|
legend = false,
|
|
19
36
|
stat = 'sum'
|
|
20
|
-
} = $props()
|
|
37
|
+
}: Props = $props()
|
|
21
38
|
</script>
|
|
22
39
|
|
|
23
40
|
<Plot
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Point from '../geoms/Point.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
type Format = (v: unknown) => string
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
data?: Row[]
|
|
10
|
+
x?: string
|
|
11
|
+
y?: string
|
|
12
|
+
color?: string
|
|
13
|
+
symbol?: string
|
|
14
|
+
size?: string
|
|
15
|
+
label?: boolean | string | ((data: Row) => unknown)
|
|
16
|
+
tooltip?: boolean | ((data: Row) => string)
|
|
17
|
+
width?: number
|
|
18
|
+
height?: number
|
|
19
|
+
mode?: 'light' | 'dark'
|
|
20
|
+
grid?: boolean
|
|
21
|
+
legend?: boolean
|
|
22
|
+
jitter?: { width?: number; height?: number } | null
|
|
23
|
+
xFormat?: Format
|
|
24
|
+
yFormat?: Format
|
|
25
|
+
xTicks?: number
|
|
26
|
+
yTicks?: number
|
|
27
|
+
minorTicks?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
let {
|
|
7
31
|
data = [],
|
|
8
32
|
x = undefined,
|
|
@@ -23,7 +47,7 @@
|
|
|
23
47
|
xTicks = undefined,
|
|
24
48
|
yTicks = undefined,
|
|
25
49
|
minorTicks = false
|
|
26
|
-
} = $props()
|
|
50
|
+
}: Props = $props()
|
|
27
51
|
</script>
|
|
28
52
|
|
|
29
53
|
<Plot {data} {width} {height} {mode} {grid} {legend} {tooltip} {xFormat} {yFormat} {xTicks} {yTicks} {minorTicks}>
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Plot from '../Plot.svelte'
|
|
3
3
|
import Violin from '../geoms/Violin.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Row = Record<string, unknown>
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
data?: Row[]
|
|
9
|
+
x?: string
|
|
10
|
+
y?: string
|
|
11
|
+
fill?: string
|
|
12
|
+
width?: number
|
|
13
|
+
height?: number
|
|
14
|
+
mode?: 'light' | 'dark'
|
|
15
|
+
grid?: boolean
|
|
16
|
+
legend?: boolean
|
|
17
|
+
yFormat?: (v: unknown) => string
|
|
18
|
+
yTicks?: number
|
|
19
|
+
minorTicks?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
let {
|
|
7
23
|
data = [],
|
|
8
24
|
x = undefined,
|
|
@@ -16,7 +32,7 @@
|
|
|
16
32
|
yFormat = undefined,
|
|
17
33
|
yTicks = undefined,
|
|
18
34
|
minorTicks = false
|
|
19
|
-
} = $props()
|
|
35
|
+
}: Props = $props()
|
|
20
36
|
</script>
|
|
21
37
|
|
|
22
38
|
<Plot {data} {width} {height} {mode} {grid} {legend} {yFormat} {yTicks} {minorTicks}>
|