@rokkit/chart 1.7.0 → 1.8.1
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 +13 -0
- package/dist/Plot/DataTable.svelte +54 -0
- package/dist/Plot/DataTable.svelte.d.ts +12 -0
- package/dist/Plot/SpecGeoms.svelte +78 -0
- package/dist/Plot/SpecGeoms.svelte.d.ts +11 -0
- package/dist/Plot.svelte +47 -151
- package/dist/Plot.svelte.d.ts +5 -0
- package/dist/PlotState.svelte.d.ts +115 -71
- package/dist/PlotState.svelte.js +174 -547
- package/dist/SparkState.svelte.d.ts +3 -1
- package/dist/SparkState.svelte.js +11 -41
- package/dist/geoms/Arc.svelte +1 -1
- package/dist/geoms/Bar.svelte +23 -32
- package/dist/geoms/Contour.svelte +88 -0
- package/dist/geoms/Contour.svelte.d.ts +19 -0
- package/dist/geoms/Hull.svelte +89 -0
- package/dist/geoms/Hull.svelte.d.ts +17 -0
- package/dist/geoms/Region.svelte +107 -0
- package/dist/geoms/Region.svelte.d.ts +27 -0
- package/dist/geoms/Rule.svelte +88 -26
- package/dist/geoms/Rule.svelte.d.ts +8 -0
- package/dist/geoms/lib/PlotAreaClip.svelte +18 -0
- package/dist/geoms/lib/PlotAreaClip.svelte.d.ts +6 -0
- package/dist/geoms/lib/bars.js +13 -20
- package/dist/geoms/lib/grouping.d.ts +35 -0
- package/dist/geoms/lib/grouping.js +59 -0
- package/dist/geoms/lib/marks/arc.d.ts +1 -0
- package/dist/geoms/lib/marks/contour.d.ts +26 -0
- package/dist/geoms/lib/marks/contour.js +67 -0
- package/dist/geoms/lib/marks/hull.d.ts +26 -0
- package/dist/geoms/lib/marks/hull.js +36 -0
- package/dist/geoms/lib/marks/waterfall.js +15 -20
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/lib/abline.d.ts +41 -0
- package/dist/lib/abline.js +51 -0
- package/dist/lib/brewing/marks/arcs.d.ts +6 -1
- package/dist/lib/brewing/marks/arcs.js +9 -1
- package/dist/lib/brewing/polar.js +8 -3
- package/dist/lib/hull.d.ts +18 -0
- package/dist/lib/hull.js +64 -0
- package/dist/lib/plot/domains.d.ts +61 -0
- package/dist/lib/plot/domains.js +130 -0
- package/dist/lib/plot/running.d.ts +23 -0
- package/dist/lib/plot/running.js +32 -0
- package/dist/lib/plot/spec.d.ts +59 -0
- package/dist/lib/plot/spec.js +131 -0
- package/dist/lib/plot/stacking.d.ts +32 -0
- package/dist/lib/plot/stacking.js +34 -0
- package/dist/lib/plot/types.d.ts +8 -1
- package/dist/lib/plot/types.js +5 -1
- package/dist/lib/preset.d.ts +2 -0
- package/dist/lib/preset.js +76 -41
- package/dist/lib/region.d.ts +63 -0
- package/dist/lib/region.js +127 -0
- package/dist/state/AestheticState.svelte.d.ts +43 -0
- package/dist/state/AestheticState.svelte.js +84 -0
- package/dist/state/AxisState.svelte.d.ts +26 -0
- package/dist/state/AxisState.svelte.js +56 -0
- package/dist/state/ChannelState.svelte.d.ts +34 -0
- package/dist/state/ChannelState.svelte.js +67 -0
- package/dist/state/GeomRegistry.svelte.d.ts +44 -0
- package/dist/state/GeomRegistry.svelte.js +86 -0
- package/dist/state/InteractionState.svelte.d.ts +30 -0
- package/dist/state/InteractionState.svelte.js +69 -0
- package/dist/state/OrientationState.svelte.d.ts +34 -0
- package/dist/state/OrientationState.svelte.js +64 -0
- package/dist/state/PlotConfig.svelte.d.ts +179 -0
- package/dist/state/PlotConfig.svelte.js +195 -0
- package/dist/state/PlotFrame.svelte.d.ts +17 -0
- package/dist/state/PlotFrame.svelte.js +18 -0
- package/dist/state/ScaleState.svelte.d.ts +36 -0
- package/dist/state/ScaleState.svelte.js +121 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -100,6 +100,19 @@ const dimensions = brewer.getDimensions()
|
|
|
100
100
|
| `Plot.Grid` | Background grid lines derived from axis scales. |
|
|
101
101
|
| `Plot.Legend` | Color legend; clicking items filters the visible series. |
|
|
102
102
|
|
|
103
|
+
Every geom is on the namespace too — `Line`, `Area`, `Point`, `Arc`, `Box`, `Violin`, `Jitter`,
|
|
104
|
+
`Heatmap`, `Hexbin`, `Candlestick`, `Waterfall`, `Ribbon`, `Radar`, `Highlight`, `Trend` — plus four
|
|
105
|
+
that annotate the metric plane rather than draw rows:
|
|
106
|
+
|
|
107
|
+
| Component | Description |
|
|
108
|
+
| -------------- | --------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `Plot.Rule` | Reference lines at `x` / `y` values, or `slope` + `intercept`, clipped to the plot. |
|
|
110
|
+
| `Plot.Region` | Shaded band (`[lo, hi]`, `null` = open end) or polygon (`points`) in data coordinates. |
|
|
111
|
+
| `Plot.Hull` | Padded convex hull around each group of the `fill` / `color` field. |
|
|
112
|
+
| `Plot.Contour` | Kernel-density contours per group — rings, or `filled` bands. |
|
|
113
|
+
|
|
114
|
+
Together they draw architecture charts such as Robert Martin's main sequence — see the Charts guide.
|
|
115
|
+
|
|
103
116
|
### `Plot.Root` props
|
|
104
117
|
|
|
105
118
|
| Prop | Type | Default | Description |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type Row = Record<string, unknown>
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
/** The plotted rows. */
|
|
6
|
+
rows: Row[]
|
|
7
|
+
/** Column fields, in order (`tableColumns` in lib/plot/spec.js). */
|
|
8
|
+
columns: string[]
|
|
9
|
+
/** The chart's title — names the table and becomes its caption. */
|
|
10
|
+
title?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { rows, columns, title = '' }: Props = $props()
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!-- The chart's data as a table: in the DOM for screen readers, never visible. -->
|
|
17
|
+
{#if rows.length > 0 && columns.length > 0}
|
|
18
|
+
<table class="plot-sr-table" aria-label={title || 'Chart data'}>
|
|
19
|
+
{#if title}
|
|
20
|
+
<caption>{title}</caption>
|
|
21
|
+
{/if}
|
|
22
|
+
<thead>
|
|
23
|
+
<tr>
|
|
24
|
+
{#each columns as col (col)}
|
|
25
|
+
<th scope="col">{col}</th>
|
|
26
|
+
{/each}
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody>
|
|
30
|
+
{#each rows as row, i (i)}
|
|
31
|
+
<tr>
|
|
32
|
+
{#each columns as col (col)}
|
|
33
|
+
<td>{row[col] ?? ''}</td>
|
|
34
|
+
{/each}
|
|
35
|
+
</tr>
|
|
36
|
+
{/each}
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
{/if}
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
/* Visually hidden — in DOM for screen readers, not visible */
|
|
43
|
+
.plot-sr-table {
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: 1px;
|
|
46
|
+
height: 1px;
|
|
47
|
+
padding: 0;
|
|
48
|
+
margin: -1px;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
clip: rect(0, 0, 0, 0);
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
border: 0;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Row = Record<string, unknown>;
|
|
2
|
+
type Props = {
|
|
3
|
+
/** The plotted rows. */
|
|
4
|
+
rows: Row[];
|
|
5
|
+
/** Column fields, in order (`tableColumns` in lib/plot/spec.js). */
|
|
6
|
+
columns: string[];
|
|
7
|
+
/** The chart's title — names the table and becomes its caption. */
|
|
8
|
+
title?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const DataTable: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type DataTable = ReturnType<typeof DataTable>;
|
|
12
|
+
export default DataTable;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte'
|
|
3
|
+
import type { PlotSpec, PlotHelpers } from '../lib/plot/types.js'
|
|
4
|
+
import { specGeomProps } from '../lib/plot/spec.js'
|
|
5
|
+
import Bar from '../geoms/Bar.svelte'
|
|
6
|
+
import Line from '../geoms/Line.svelte'
|
|
7
|
+
import Area from '../geoms/Area.svelte'
|
|
8
|
+
import Point from '../geoms/Point.svelte'
|
|
9
|
+
import Arc from '../geoms/Arc.svelte'
|
|
10
|
+
import Box from '../geoms/Box.svelte'
|
|
11
|
+
import Violin from '../geoms/Violin.svelte'
|
|
12
|
+
import Heatmap from '../geoms/Heatmap.svelte'
|
|
13
|
+
import Candlestick from '../geoms/Candlestick.svelte'
|
|
14
|
+
import Waterfall from '../geoms/Waterfall.svelte'
|
|
15
|
+
import Hexbin from '../geoms/Hexbin.svelte'
|
|
16
|
+
import Ribbon from '../geoms/Ribbon.svelte'
|
|
17
|
+
import Radar from '../geoms/Radar.svelte'
|
|
18
|
+
import Rule from '../geoms/Rule.svelte'
|
|
19
|
+
import Region from '../geoms/Region.svelte'
|
|
20
|
+
import Hull from '../geoms/Hull.svelte'
|
|
21
|
+
import Contour from '../geoms/Contour.svelte'
|
|
22
|
+
|
|
23
|
+
type Props = {
|
|
24
|
+
/** The chart spec; its `geoms` are drawn, and its channels are what each one inherits. */
|
|
25
|
+
spec?: PlotSpec
|
|
26
|
+
/** `helpers.geoms` replaces a built-in (or an annotation) by type name. */
|
|
27
|
+
helpers?: PlotHelpers
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let { spec = undefined, helpers = {} }: Props = $props()
|
|
31
|
+
|
|
32
|
+
// Geom component resolver for spec-driven mode. Typed as a lookup table, not the union of
|
|
33
|
+
// its members: a spec names geoms by string at runtime, exactly like `helpers.geoms`, and the
|
|
34
|
+
// union of every geom's Props has no single shape a generic call site can satisfy.
|
|
35
|
+
// `any` is the honest type for a heterogeneous table resolved by name — the same one the
|
|
36
|
+
// public `PlotHelpers.geoms` already declares in lib/plot/types.js.
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const GEOM_COMPONENTS: Record<string, Component<any>> = {
|
|
39
|
+
bar: Bar,
|
|
40
|
+
line: Line,
|
|
41
|
+
area: Area,
|
|
42
|
+
point: Point,
|
|
43
|
+
arc: Arc,
|
|
44
|
+
box: Box,
|
|
45
|
+
violin: Violin,
|
|
46
|
+
heatmap: Heatmap,
|
|
47
|
+
candlestick: Candlestick,
|
|
48
|
+
waterfall: Waterfall,
|
|
49
|
+
hexbin: Hexbin,
|
|
50
|
+
ribbon: Ribbon,
|
|
51
|
+
// Radar reads the generic x/y/color this path passes via its own aliases, and takes
|
|
52
|
+
// its axis order from `options.axes` — see Radar.svelte's Props.
|
|
53
|
+
radar: Radar,
|
|
54
|
+
hull: Hull,
|
|
55
|
+
contour: Contour
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Plane annotations read no data, so they take ONLY their own `props` — never the spec's
|
|
59
|
+
// field channels: a Region's `x`/`y` are ranges, and handing it the field name 'instability'
|
|
60
|
+
// would be a range of one string. A helper registered under the same name is a geom again.
|
|
61
|
+
const ANNOTATIONS = { rule: Rule, region: Region }
|
|
62
|
+
|
|
63
|
+
function resolveGeomComponent(type: string) {
|
|
64
|
+
return helpers?.geoms?.[type] ?? GEOM_COMPONENTS[type]
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<!-- Keyed by position, not type: two regions in one spec are normal, and a type key would be a
|
|
69
|
+
duplicate that aborts the whole render. An unknown type renders nothing. -->
|
|
70
|
+
{#each spec?.geoms ?? [] as geomSpec, i (`${geomSpec.type}-${i}`)}
|
|
71
|
+
{@const Annotation = ANNOTATIONS[geomSpec.type as keyof typeof ANNOTATIONS]}
|
|
72
|
+
{@const GeomComponent = resolveGeomComponent(geomSpec.type)}
|
|
73
|
+
{#if Annotation && !helpers?.geoms?.[geomSpec.type]}
|
|
74
|
+
<Annotation {...geomSpec.props ?? {}} />
|
|
75
|
+
{:else if GeomComponent}
|
|
76
|
+
<GeomComponent {...specGeomProps(geomSpec, spec)} />
|
|
77
|
+
{/if}
|
|
78
|
+
{/each}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import type { PlotSpec, PlotHelpers } from '../lib/plot/types.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** The chart spec; its `geoms` are drawn, and its channels are what each one inherits. */
|
|
5
|
+
spec?: PlotSpec;
|
|
6
|
+
/** `helpers.geoms` replaces a built-in (or an annotation) by type name. */
|
|
7
|
+
helpers?: PlotHelpers;
|
|
8
|
+
};
|
|
9
|
+
declare const SpecGeoms: Component<Props, {}, "">;
|
|
10
|
+
type SpecGeoms = ReturnType<typeof SpecGeoms>;
|
|
11
|
+
export default SpecGeoms;
|
package/dist/Plot.svelte
CHANGED
|
@@ -3,24 +3,14 @@
|
|
|
3
3
|
import type { Snippet } from 'svelte'
|
|
4
4
|
import { defaultPreset } from './lib/preset.js'
|
|
5
5
|
import type { PlotSpec, PlotHelpers } from './lib/plot/types.js'
|
|
6
|
+
import { resolvePlotConfig, resolveChrome, tableColumns } from './lib/plot/spec.js'
|
|
6
7
|
import PlotSurface from './PlotSurface.svelte'
|
|
7
8
|
import Axis from './Plot/Axis.svelte'
|
|
8
9
|
import Grid from './Plot/Grid.svelte'
|
|
9
10
|
import Legend from './Plot/Legend.svelte'
|
|
10
11
|
import Tooltip from './Plot/Tooltip.svelte'
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import Area from './geoms/Area.svelte'
|
|
14
|
-
import Point from './geoms/Point.svelte'
|
|
15
|
-
import Arc from './geoms/Arc.svelte'
|
|
16
|
-
import Box from './geoms/Box.svelte'
|
|
17
|
-
import Violin from './geoms/Violin.svelte'
|
|
18
|
-
import Heatmap from './geoms/Heatmap.svelte'
|
|
19
|
-
import Candlestick from './geoms/Candlestick.svelte'
|
|
20
|
-
import Waterfall from './geoms/Waterfall.svelte'
|
|
21
|
-
import Hexbin from './geoms/Hexbin.svelte'
|
|
22
|
-
import Ribbon from './geoms/Ribbon.svelte'
|
|
23
|
-
import Radar from './geoms/Radar.svelte'
|
|
12
|
+
import SpecGeoms from './Plot/SpecGeoms.svelte'
|
|
13
|
+
import DataTable from './Plot/DataTable.svelte'
|
|
24
14
|
import Highlight from './geoms/Highlight.svelte'
|
|
25
15
|
import Trend from './geoms/Trend.svelte'
|
|
26
16
|
|
|
@@ -66,6 +56,11 @@
|
|
|
66
56
|
axisOrigin?: [number | undefined, number | undefined]
|
|
67
57
|
/** Nudge an edge-pinned axis outward by N px (Q1 only). Also via `spec.axisOffset`. */
|
|
68
58
|
axisOffset?: number
|
|
59
|
+
/** Fix the x domain instead of inferring it from the data — e.g. `[0, 1]` for a metric
|
|
60
|
+
* plane defined by theory, not by where the rows fall. Also via `spec.xDomain`. */
|
|
61
|
+
xDomain?: unknown[]
|
|
62
|
+
/** Fix the y domain. Also via `spec.yDomain`. */
|
|
63
|
+
yDomain?: unknown[]
|
|
69
64
|
/** Animate marks on data/flip changes (opt-out for e.g. AnimatedPlot, which
|
|
70
65
|
* tweens its own frames). Enabled one frame after the width settles so the
|
|
71
66
|
* initial layout paints un-animated. Default `true`. */
|
|
@@ -104,6 +99,8 @@
|
|
|
104
99
|
selected = $bindable([]),
|
|
105
100
|
axisOrigin = undefined,
|
|
106
101
|
axisOffset = undefined,
|
|
102
|
+
xDomain = undefined,
|
|
103
|
+
yDomain = undefined,
|
|
107
104
|
animate = true,
|
|
108
105
|
children
|
|
109
106
|
}: Props = $props()
|
|
@@ -111,90 +108,43 @@
|
|
|
111
108
|
const chartPresetCtx = getContext<ChartPresetCtx | undefined>('chart-preset')
|
|
112
109
|
const chartPreset = $derived(chartPresetCtx?.current ?? defaultPreset)
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const chartTitle = $derived(spec?.title ?? title)
|
|
119
|
-
const chartSummary = $derived(spec?.summary ?? summary)
|
|
111
|
+
// Spec-over-prop precedence lives in lib/plot/spec.js — one table, not a `??` per field.
|
|
112
|
+
const chrome = $derived(
|
|
113
|
+
resolveChrome(spec, { grid, legend, title, summary, x, y })
|
|
114
|
+
)
|
|
120
115
|
|
|
121
116
|
// Accessible data table — screen reader fallback
|
|
122
117
|
const tableData = $derived(spec?.data ?? data)
|
|
123
|
-
const
|
|
124
|
-
// Dedupe: a channel may repeat (e.g. x === color), and the table's keyed each
|
|
125
|
-
// requires unique column names.
|
|
126
|
-
const cols = [
|
|
127
|
-
...new Set(
|
|
128
|
-
[spec?.x, spec?.y, spec?.color ?? spec?.fill].filter((c): c is string => Boolean(c))
|
|
129
|
-
)
|
|
130
|
-
]
|
|
131
|
-
if (cols.length > 0) return cols
|
|
132
|
-
const first = tableData[0]
|
|
133
|
-
return first ? Object.keys(first) : []
|
|
134
|
-
})
|
|
118
|
+
const columns = $derived(tableColumns(spec, tableData))
|
|
135
119
|
|
|
136
120
|
// Config for the shared PlotSurface (which owns PlotState, the responsive width, context,
|
|
137
121
|
// animation, patterns, and zoom). `width` is the fallback — PlotSurface observes the container.
|
|
138
122
|
function buildPlotConfig() {
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
continuousCategory: spec?.continuousCategory,
|
|
159
|
-
chartPreset,
|
|
160
|
-
onselect,
|
|
161
|
-
selectable
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Geoms from spec (spec-driven API)
|
|
166
|
-
const specGeoms = $derived(spec?.geoms ?? [])
|
|
167
|
-
|
|
168
|
-
const overlayX = $derived(spec?.x ?? x)
|
|
169
|
-
const overlayY = $derived(spec?.y ?? y)
|
|
170
|
-
|
|
171
|
-
// Geom component resolver for spec-driven mode
|
|
172
|
-
const GEOM_COMPONENTS = {
|
|
173
|
-
bar: Bar,
|
|
174
|
-
line: Line,
|
|
175
|
-
area: Area,
|
|
176
|
-
point: Point,
|
|
177
|
-
arc: Arc,
|
|
178
|
-
box: Box,
|
|
179
|
-
violin: Violin,
|
|
180
|
-
heatmap: Heatmap,
|
|
181
|
-
candlestick: Candlestick,
|
|
182
|
-
waterfall: Waterfall,
|
|
183
|
-
hexbin: Hexbin,
|
|
184
|
-
ribbon: Ribbon,
|
|
185
|
-
// Radar reads the generic x/y/color this path passes via its own aliases, and takes
|
|
186
|
-
// its axis order from `options.axes` — see Radar.svelte's Props.
|
|
187
|
-
radar: Radar
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function resolveGeomComponent(type: string) {
|
|
191
|
-
return helpers?.geoms?.[type] ?? GEOM_COMPONENTS[type as keyof typeof GEOM_COMPONENTS]
|
|
123
|
+
return resolvePlotConfig(
|
|
124
|
+
spec,
|
|
125
|
+
{
|
|
126
|
+
data,
|
|
127
|
+
width,
|
|
128
|
+
height,
|
|
129
|
+
mode,
|
|
130
|
+
margin,
|
|
131
|
+
helpers,
|
|
132
|
+
xDomain,
|
|
133
|
+
yDomain,
|
|
134
|
+
orientation,
|
|
135
|
+
axisOrigin,
|
|
136
|
+
axisOffset,
|
|
137
|
+
onselect,
|
|
138
|
+
selectable
|
|
139
|
+
},
|
|
140
|
+
chartPreset
|
|
141
|
+
)
|
|
192
142
|
}
|
|
193
143
|
</script>
|
|
194
144
|
|
|
195
145
|
<div class="plot-root">
|
|
196
|
-
{#if
|
|
197
|
-
<div class="plot-title" data-plot-title>{
|
|
146
|
+
{#if chrome.title}
|
|
147
|
+
<div class="plot-title" data-plot-title>{chrome.title}</div>
|
|
198
148
|
{/if}
|
|
199
149
|
|
|
200
150
|
<!-- The shared root shell (PlotState, responsive width, context, animation, patterns, zoom).
|
|
@@ -203,52 +153,33 @@
|
|
|
203
153
|
config={buildPlotConfig()}
|
|
204
154
|
{animate}
|
|
205
155
|
{zoom}
|
|
206
|
-
ariaLabel={
|
|
207
|
-
summary={
|
|
156
|
+
ariaLabel={chrome.title || 'Chart visualization'}
|
|
157
|
+
summary={chrome.summary}
|
|
208
158
|
bind:selected
|
|
209
159
|
>
|
|
210
160
|
<!-- Grid (behind everything) -->
|
|
211
|
-
{#if showGrid}
|
|
212
|
-
<Grid lines={gridLines} {xTicks} {yTicks} />
|
|
161
|
+
{#if chrome.showGrid}
|
|
162
|
+
<Grid lines={chrome.gridLines} {xTicks} {yTicks} />
|
|
213
163
|
{/if}
|
|
214
164
|
|
|
215
165
|
<!-- Declarative children (geom components) -->
|
|
216
166
|
{@render children?.()}
|
|
217
167
|
|
|
218
168
|
<!-- Spec-driven geoms -->
|
|
219
|
-
{
|
|
220
|
-
{@const GeomComponent = resolveGeomComponent(geomSpec.type)}
|
|
221
|
-
{#if GeomComponent}
|
|
222
|
-
<GeomComponent
|
|
223
|
-
x={geomSpec.x ?? spec?.x}
|
|
224
|
-
y={geomSpec.y ?? spec?.y}
|
|
225
|
-
color={geomSpec.color ?? spec?.color}
|
|
226
|
-
fill={geomSpec.fill ?? spec?.fill}
|
|
227
|
-
pattern={geomSpec.pattern}
|
|
228
|
-
symbol={geomSpec.symbol}
|
|
229
|
-
stat={geomSpec.stat}
|
|
230
|
-
label={geomSpec.label}
|
|
231
|
-
options={{
|
|
232
|
-
...(spec?.stack !== undefined ? { stack: spec.stack } : {}),
|
|
233
|
-
...(spec?.orientation !== undefined ? { orientation: spec.orientation } : {}),
|
|
234
|
-
...(geomSpec.options ?? {})
|
|
235
|
-
}}
|
|
236
|
-
/>
|
|
237
|
-
{/if}
|
|
238
|
-
{/each}
|
|
169
|
+
<SpecGeoms {spec} {helpers} />
|
|
239
170
|
|
|
240
171
|
<!-- Axes -->
|
|
241
172
|
{#if axes}
|
|
242
173
|
<Axis
|
|
243
174
|
type="x"
|
|
244
|
-
label={
|
|
175
|
+
label={chrome.xLabel}
|
|
245
176
|
format={xFormat}
|
|
246
177
|
ticks={xTicks}
|
|
247
178
|
{minorTicks}
|
|
248
179
|
/>
|
|
249
180
|
<Axis
|
|
250
181
|
type="y"
|
|
251
|
-
label={
|
|
182
|
+
label={chrome.yLabel}
|
|
252
183
|
format={yFormat}
|
|
253
184
|
ticks={yTicks}
|
|
254
185
|
{minorTicks}
|
|
@@ -256,16 +187,16 @@
|
|
|
256
187
|
{/if}
|
|
257
188
|
|
|
258
189
|
{#if trend !== null && trend !== undefined}
|
|
259
|
-
<Trend x={overlayX} y={overlayY} {trend} />
|
|
190
|
+
<Trend x={chrome.overlayX} y={chrome.overlayY} {trend} />
|
|
260
191
|
{/if}
|
|
261
192
|
|
|
262
193
|
{#if (highlight !== null && highlight !== undefined) || selectable || selected.length}
|
|
263
|
-
<Highlight x={overlayX} y={overlayY} {highlight} {label} />
|
|
194
|
+
<Highlight x={chrome.overlayX} y={chrome.overlayY} {highlight} {label} />
|
|
264
195
|
{/if}
|
|
265
196
|
|
|
266
197
|
<!-- HTML overlays — outside the svg but INSIDE the plot-state context. -->
|
|
267
198
|
{#snippet overlay()}
|
|
268
|
-
{#if showLegend}
|
|
199
|
+
{#if chrome.showLegend}
|
|
269
200
|
<Legend labels={spec?.labels ?? {}} />
|
|
270
201
|
{/if}
|
|
271
202
|
|
|
@@ -273,29 +204,7 @@
|
|
|
273
204
|
<Tooltip {tooltip} />
|
|
274
205
|
{/if}
|
|
275
206
|
|
|
276
|
-
{
|
|
277
|
-
<table class="plot-sr-table" aria-label={chartTitle || 'Chart data'}>
|
|
278
|
-
{#if chartTitle}
|
|
279
|
-
<caption>{chartTitle}</caption>
|
|
280
|
-
{/if}
|
|
281
|
-
<thead>
|
|
282
|
-
<tr>
|
|
283
|
-
{#each tableColumns as col (col)}
|
|
284
|
-
<th scope="col">{col}</th>
|
|
285
|
-
{/each}
|
|
286
|
-
</tr>
|
|
287
|
-
</thead>
|
|
288
|
-
<tbody>
|
|
289
|
-
{#each tableData as row, i (i)}
|
|
290
|
-
<tr>
|
|
291
|
-
{#each tableColumns as col (col)}
|
|
292
|
-
<td>{row[col] ?? ''}</td>
|
|
293
|
-
{/each}
|
|
294
|
-
</tr>
|
|
295
|
-
{/each}
|
|
296
|
-
</tbody>
|
|
297
|
-
</table>
|
|
298
|
-
{/if}
|
|
207
|
+
<DataTable rows={tableData} {columns} title={chrome.title} />
|
|
299
208
|
{/snippet}
|
|
300
209
|
</PlotSurface>
|
|
301
210
|
</div>
|
|
@@ -313,17 +222,4 @@
|
|
|
313
222
|
text-align: center;
|
|
314
223
|
margin-bottom: 4px;
|
|
315
224
|
}
|
|
316
|
-
|
|
317
|
-
/* Visually hidden — in DOM for screen readers, not visible */
|
|
318
|
-
.plot-sr-table {
|
|
319
|
-
position: absolute;
|
|
320
|
-
width: 1px;
|
|
321
|
-
height: 1px;
|
|
322
|
-
padding: 0;
|
|
323
|
-
margin: -1px;
|
|
324
|
-
overflow: hidden;
|
|
325
|
-
clip: rect(0, 0, 0, 0);
|
|
326
|
-
white-space: nowrap;
|
|
327
|
-
border: 0;
|
|
328
|
-
}
|
|
329
225
|
</style>
|
package/dist/Plot.svelte.d.ts
CHANGED
|
@@ -48,6 +48,11 @@ type Props = {
|
|
|
48
48
|
axisOrigin?: [number | undefined, number | undefined];
|
|
49
49
|
/** Nudge an edge-pinned axis outward by N px (Q1 only). Also via `spec.axisOffset`. */
|
|
50
50
|
axisOffset?: number;
|
|
51
|
+
/** Fix the x domain instead of inferring it from the data — e.g. `[0, 1]` for a metric
|
|
52
|
+
* plane defined by theory, not by where the rows fall. Also via `spec.xDomain`. */
|
|
53
|
+
xDomain?: unknown[];
|
|
54
|
+
/** Fix the y domain. Also via `spec.yDomain`. */
|
|
55
|
+
yDomain?: unknown[];
|
|
51
56
|
/** Animate marks on data/flip changes (opt-out for e.g. AnimatedPlot, which
|
|
52
57
|
* tweens its own frames). Enabled one frame after the width settles so the
|
|
53
58
|
* initial layout paints un-animated. Default `true`. */
|