@swiftplot/vue 0.4.0 → 0.5.0

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 CHANGED
@@ -25,7 +25,7 @@ chart.update({ data: next }); // only what changed reaches the chart
25
25
  chart.destroy();
26
26
  ```
27
27
 
28
- - **Charts:** `lineChart`, `areaChart`, `barChart`, `scatterChart`, `comboChart`, `pieChart`, `funnelChart`, `radialBarChart`, `radarChart`, `heatmapChart`, `histogramChart`, `boxPlotChart`, `candlestickChart`, `sankeyChart`, `treemapChart` and `sunburstChart`. Each returns `{ update(props), destroy(), chart }`; `update` takes only the props that change, and `chart` is the underlying chart.
28
+ - **Charts:** `lineChart`, `areaChart`, `barChart`, `scatterChart`, `comboChart`, `pieChart`, `funnelChart`, `radialBarChart`, `radarChart`, `heatmapChart`, `histogramChart`, `boxPlotChart`, `candlestickChart`, `sankeyChart`, `treemapChart` and `sunburstChart`. Each returns `{ update(props), destroy(), overlay, chart }`; `update` takes only the props that change, `overlay` is the element for your own DOM (see "Drawing over the chart" under "Use"), and `chart` is the underlying chart.
29
29
  - **Data** is row objects, an object of columns (arrays or typed arrays, all of one length), a plain number array (`y` against its index, as the series `value`), or `[x, y]` pairs (the series `y`; a row of any other length throws), and for `treemapChart` and `sunburstChart` a nested `{ name, value, children }` or a list of them. Pairs are `[label, value]` on a pie, a funnel and radial bars, `[name, value]` on a radar and `[group, value]` on a box plot; a histogram takes no pairs, and a heatmap, candlesticks, a combo and a sankey take neither pairs nor numbers. On the line, area, bar and scatter charts long rows, `{ date, service, value }`, take `series: 'service'` and give one series per distinct value. `data` missing, `null` or empty draws an empty frame and never throws, so a chart can be created before its data arrives.
30
30
  - **Values:** a number, a `Date`, an ISO 8601 string (`2026-11-22`, `2026-11-22T10:00` or with a space, optional seconds and fraction, and `Z` or `+02:00` after a time) or other text. A field's first value that is not missing (`null`, `undefined`, `''`, `NaN`, an infinite number) decides its kind; later values of another kind, an invalid `Date` and an impossible date (`2026-13-40`, `T24:00`) are missing. Numbers held as text (`"12.5"`) are text and are not converted. A field of booleans or objects cannot be plotted.
31
31
  - **Dates** without a zone are read as UTC, so the same data draws the same chart on every machine; `xAxis: { utc: false }` reads them, and shows the axis, in local time.
@@ -78,11 +78,11 @@ chart.destroy();
78
78
 
79
79
  - **Marks added to a chart:** line, area, bar, scatter and combo charts take `rules` (`{ x }` or `{ y }`, with `text`, `dashed` and `color`), `zones` (`{ x: [from, to] }` or `{ y: [from, to] }`, with `text` and `color`) and `brush` (`true` or `{ axes }`; with `zoom` its release shows the range), whose range goes to `onBrush`. `errorBars: { low, high, cap, width }` on line, bar and scatter charts names two fields that are values on the y axis, not distances from y, for a chart of one unstacked `y`. A line takes `fill` (`true` or a gradient) and a scatter `alpha`, `ring` and `shape: 'tick'`.
80
80
  - **Stacking** counts a missing value as zero, so a stacked area has no gap where an unstacked one would. Long series are stacked over the union of their x values.
81
- - **Interaction state** (`view`, `hidden`, `selected`, `pointer`) is kept by the chart unless the prop is given; `onViewChange`, `onHiddenChange`, `onClick` and `onPointerChange` report it as in the explicit API. Changing `tooltip`, `legend`, `zoom`, `animate` or `brush` creates the chart again and keeps a zoomed window and hidden series.
81
+ - **Interaction state** (`view`, `hidden`, `selected`, `pointer`) is kept by the chart unless the prop is given; `onViewChange`, `onHiddenChange`, `onClick` and `onPointerChange` report it, and `onLayout` and `onHover` the geometry and the hover, as in the explicit API. Changing `tooltip`, `legend`, `zoom`, `animate` or `brush` creates the chart again and keeps a zoomed window and hidden series.
82
82
  - **`dataVersion`:** conversion is cached on the data's identity and length (each column's, for an object of columns). Pass new data, or after changing values in place, bump `dataVersion`: `chart.update({ dataVersion: ++version })`.
83
83
  - **Theme:** `theme` defaults to `'auto'`, which follows the computed CSS `color-scheme` of the chart's element: `dark` gives the dark theme, `light dark` follows the system setting and switches with it, anything else gives light. It is read when the chart is created, when the system setting changes and when the `theme` prop changes.
84
84
  - **`.spec()`** is the way out to the explicit API: `lineChart.spec({ data: rows, x: 'date', y: ['api', 'web'] })` returns the `plot()` options the chart would use. It needs no element and runs in Node; with the `'auto'` theme it gives no theme and the light palette.
85
- - **`mount(el, options)`** is `plot()` behind the same controller, for the explicit API in plain JavaScript: it takes the `plot()` options and returns `{ update(options), destroy(), chart }`. An update sends the core only the options that changed (marks compared by key, type and options), and leaves `view`, `hidden`, `selected` and `pointer` alone unless given. `use` is read once; `theme` is `light` unless given. `equal(a, b)`, which mount uses for that comparison, compares plain objects and arrays by value (cycles included) and anything else (typed arrays, functions, `Date`s) by identity; `plain(v)` tells whether `v` is a plain object or array.
85
+ - **`mount(el, options)`** is `plot()` behind the same controller, for the explicit API in plain JavaScript: it takes the `plot()` options and returns `{ update(options), destroy(), overlay, chart }`. An update sends the core only the options that changed (marks compared by key, type and options, and `theme` by identity, so a new theme object has the CSS variables read again), and leaves `view`, `hidden`, `selected` and `pointer` alone unless given. `use` is read once; `theme` is `light` unless given. `equal(a, b)`, which mount uses for that comparison, compares plain objects and arrays by value (cycles included) and anything else (typed arrays, functions, `Date`s) by identity; `plain(v)` tells whether `v` is a plain object or array.
86
86
 
87
87
  ## React and Vue
88
88
 
@@ -116,7 +116,23 @@ import { LineChart } from '@swiftplot/vue';
116
116
  <LineChart data={rows} x="date" y={['api', 'web']} zoom view={view} onViewChange={setView} />;
117
117
  ```
118
118
 
119
- In Vue the changes are events: `v-model:view`, `v-model:hidden` and `v-model:pointer`, `@click`, `@brush` and `@error` (`<LineChart :data="rows" zoom v-model:view="view" />`). `selected` is a plain prop: the app sets it, from a click for example.
119
+ In Vue the changes are events: `v-model:view`, `v-model:hidden` and `v-model:pointer`, `@click`, `@layout`, `@hover`, `@brush` and `@error` (`<LineChart :data="rows" zoom v-model:view="view" />`). `selected` is a plain prop: the app sets it, from a click for example.
120
+
121
+ - **Your own nodes over the chart:** every component renders them from the layout and the hover, in React from a function given as children, in Vue from the default slot. They are drawn with the layout the chart has taken. While an update fails React keeps the last good children, and Vue hides a slot whose hover or layout changed. `layout.xPx` and `layout.yPx` are there only with axes.
122
+
123
+ ```tsx
124
+ <ScatterChart data={rows} tooltip={false}>
125
+ {(layout, hover) =>
126
+ hover?.hit && <Tip style={{ position: 'absolute', left: hover.hit.px, top: hover.hit.py }} />
127
+ }
128
+ </ScatterChart>
129
+ ```
130
+
131
+ ```vue
132
+ <ScatterChart :data="rows" :tooltip="false" v-slot="{ layout, hover }">
133
+ <Tip v-if="hover?.hit" :hit="hover.hit" />
134
+ </ScatterChart>
135
+ ```
120
136
 
121
137
  - **`Plot`** takes every `plot()` option as a prop, to mix marks in a way no easy chart does, for a mark of your own, or to pass large typed arrays straight in. `use` is read when it mounts, as in `plot()`: change the component's `key` to change features. Its theme is `light` unless given; it does not follow the page as the easy charts do.
122
138
 
@@ -133,7 +149,7 @@ import { LineChart } from '@swiftplot/vue';
133
149
  - **Size:** `width` and `height` (px) size the `div`, and `style` wins over them; the chart measures the `div` and follows whatever resizes it (a class, a parent, a media query). With no height from `height`, `style` or CSS, the `div` fills a parent that has a height, else is 300 px tall, so `<LineChart data={rows} />` shows a chart on an ordinary page and a class added later wins, in a cascade layer (Tailwind) or not. The fallback is a `<style>` kept first in the document head (or the shadow root), inserted only for a chart with no height: under a Content Security Policy that blocks inline styles, give every chart a height (`height`, `style` or CSS). A chart mounted in a detached element falls back once the element is attached.
134
150
  - **Errors** (a missing field, an accessor or formatter that throws) go to `onError` in React or `@error` in Vue, and the last good chart stays; without a handler they are thrown to the nearest error boundary, or to Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`). A failed render is tried again when a chart prop other than a callback changes; a changed callback still reaches the last good chart. A failure is reported once until its error message, the data's length (each column's, for an object of columns) or another prop that is not a function changes, so inline props, data rebuilt during render and a handler that sets state cannot loop, unless the message itself changes on every attempt. Rows are never read, so new data of the same length that fails with the same message is not reported again.
135
151
  - **Server rendering:** the server renders the `div` alone, the client hydrates the same markup and creates the chart after hydration. The React entry is marked `'use client'`. The 300 px fallback is applied in the browser, so give a server-rendered chart a `height` (or a CSS height) to reserve its space before hydration.
136
- - **Performance:** each render compares props by identity and the chart then by value, so inline objects such as `xAxis={{ label: 'Day' }}` cost little. `data` built during render and inline accessors are converted again on every render, and an inline `xAxis.format` repaints the data: build them outside render, or with `useMemo` and `useCallback`. In Vue keep the data in a `shallowRef` and replace the array: a deep `ref` makes the app wrap every row for nothing the chart uses. Data changed in place with every prop unchanged is not noticed: pass a new array or bump `dataVersion`.
152
+ - **Performance:** each render compares props by identity and the chart then by value, so inline objects such as `xAxis={{ label: 'Day' }}` cost little. `theme` is the exception: replacing it is how a changed CSS variable is seen, so keep a theme object outside the component. `data` built during render and inline accessors are converted again on every render, and an inline `xAxis.format` repaints the data: build them outside render, or with `useMemo` and `useCallback`. In Vue keep the data in a `shallowRef` and replace the array: a deep `ref` makes the app wrap every row for nothing the chart uses. Data changed in place with every prop unchanged is not noticed: pass a new array or bump `dataVersion`.
137
153
 
138
154
  ## Use
139
155
 
@@ -170,6 +186,7 @@ chart.destroy();
170
186
  - **Error bars** are `errorBars({ x, y1, y2 })`, or `{ y, x1, x2 }` lying down.
171
187
  - **Candlesticks** are `candlestick({ x, open, high, low, close, color, up, down })`: a wick from low to high and a body from open to close, in `up` where the close is not below the open and in `down` where it is. `width` is the body's width in x units, 0.6 by default. A pointer anywhere on a candle hits it; a `nearest` tooltip gets the row, to read the four values from your own columns.
172
188
  - **Colours:** `palette` is eight series colours to give out in order, and `brand` the cyan-to-violet blend. `gradient(from, to, 'down' | 'up' | 'right' | 'left')` makes a blend of two colours; a number stands for the mark's own colour at that opacity. `line({ fill: true })` puts a faint fade of the line's colour under it. A blend goes in `area({ fill })`, `bar({ fill })`, `line({ stroke })` and `line({ fill })`, so `area({ x, y, color, fill: gradient(0.4, 0) })` fades an area out towards its baseline. `color` stays the one colour a legend and a tooltip show.
189
+ - **CSS variables:** a colour may be `var(--name)` or `var(--name, fallback)`, in marks, gradient stops, themes and an easy chart's `colors`, read at the chart's element. One with no value draws in the theme's `muted` and warns on the console. A value is kept until `theme` is replaced with another object, even an equal one: that is how a changed variable is seen, and why an inline theme object in React has the variables read on each render. On an easy chart, reading a changed variable needs a theme object, not `'auto'` or `'dark'`, and a copy of `dark` needs `colors: paletteDark` or your own `colors`. `sequential()` takes hex stops only, and a custom mark's own `addColorStop` takes no variable.
173
190
  - **Blends on other charts:** `sankey({ blend: true })` runs each ribbon from its source's colour into its target's; `funnel({ fill: gradient(a, b) })` puts one blend down the whole funnel; `arcs({ sweep: 0.8 })` and `radialBars({ sweep: 0.35 })` start each slice or bar at that opacity and bring it to full colour at its end; `treemap({ shade: 0.7 })` starts each branch at that opacity at its top, and `sunburst({ shade: 0.7 })` ends each at that opacity at the rim.
174
191
  - **Box plots** take `radius`, `medianWidth`, `whiskers` (their opacity) and `fill`: `box({ ..., radius: 4, medianWidth: 2.5, whiskers: 0.5, fill: gradient(0.4, 0.1) })`.
175
192
  - **Rounded bars and ringed points:** `bar({ radius: 6 })` rounds the value end of a bar that starts at zero, or all corners of one that floats, and `bar({ gap: 2 })` sets touching bars such as a histogram's two pixels apart; `dots({ ring: 2 })` draws rings round a white middle.
@@ -194,6 +211,7 @@ chart.destroy();
194
211
  );
195
212
  ```
196
213
 
214
+ - **Drawing over the chart:** `chart.overlay` is an element over the chart, under its tooltip, for your own DOM. `onLayout(layout)` gives the size, margin, shown domains and ticks, and, with axes, `xPx`, `yPx`, `xValue` and `yValue`, whenever they change; `onHover(hover)` gives the pointer in CSS pixels and the hit `onClick` would get with its anchor, `{ px, py, hit }`, and `null` as it leaves. The first `onLayout` runs inside `plot()`: to use `chart.overlay` in it, set it with `update()`. An axis's `to` and `from` must stay the same functions between updates, or state set from `onLayout` loops; data made anew with equal values does not make `onHover` loop. Data written in place and passed as a new view or array is compared by a copy of the hovered mark's, which of a list over 1000 values is a sample: a write to a row neither hovered nor sampled reports nothing. New data in a new array, not written in place, is compared whole. A child with `pointer-events: auto` passes the hover and the tooltip to the chart; clicks, the wheel and drags on it stay its own.
197
215
  - **Themes:** `theme: dark` colours the text, grid, tick marks and tooltip for a dark page; `light` is the default. The core never guesses dark mode: the app switches it, and `paletteDark` gives series colours for a dark surface. The charts of `swiftplot/charts` follow the page's `color-scheme` instead.
198
216
 
199
217
  ```ts
package/dist/bind.d.ts CHANGED
@@ -1,8 +1,12 @@
1
+ import type { Hover, Layout } from 'swiftplot';
1
2
  import { type Component, type Prop } from 'vue';
2
3
  export type Mount<P> = (el: HTMLElement, props: P) => {
3
4
  update(partial: Partial<P>): void;
4
5
  destroy(): void;
6
+ readonly overlay: HTMLElement;
5
7
  };
8
+ /** Rendered over the chart, in its overlay, from its layout and what the pointer is over. */
9
+ export type OverlaySlot = (props: Shown) => unknown;
6
10
  /** Every chart prop but the callbacks, which are listeners. */
7
11
  export type Declared<P> = {
8
12
  [K in Exclude<keyof P, `on${string}`>]-?: Prop<unknown> | null;
@@ -11,5 +15,9 @@ type Sized = {
11
15
  width?: number;
12
16
  height?: number;
13
17
  };
18
+ type Shown = {
19
+ layout: Layout;
20
+ hover: Hover | null;
21
+ };
14
22
  export declare function bind<P extends Sized, T extends Declared<P> = Declared<P>>(chart: Mount<P>, declared: T & Record<Exclude<keyof T, keyof Declared<P>>, never>): Component;
15
23
  export {};
package/dist/bind.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { equal, plain } from 'swiftplot/charts';
2
- import { defineComponent, h, normalizeStyle, onBeforeUnmount, onMounted, ref, toHandlerKey, toRaw, watch, } from 'vue';
2
+ import { defineComponent, Fragment, h, normalizeStyle, onBeforeUnmount, onMounted, onUpdated, ref, shallowRef, Teleport, toHandlerKey, toRaw, watch, withMemo, } from 'vue';
3
3
  /** The controller's callbacks and the events that report them. */
4
4
  const LISTENERS = {
5
5
  onClick: 'click',
@@ -7,6 +7,8 @@ const LISTENERS = {
7
7
  onHiddenChange: 'update:hidden',
8
8
  onPointerChange: 'update:pointer',
9
9
  onBrush: 'brush',
10
+ onLayout: 'layout',
11
+ onHover: 'hover',
10
12
  };
11
13
  const HOST_ONLY = new Set([
12
14
  'width',
@@ -116,6 +118,24 @@ function sheet(el) {
116
118
  });
117
119
  first.observe(parent, { childList: true });
118
120
  }
121
+ const Overlay = defineComponent({
122
+ props: ['shown', 'stale', 'slot'],
123
+ setup(props) {
124
+ const drawn = [];
125
+ let was;
126
+ return () => {
127
+ const shown = props.shown();
128
+ if (shown) {
129
+ drawn.length = 0;
130
+ was = shown;
131
+ withMemo([], () => h(Fragment, null, props.slot(shown)), drawn, 0);
132
+ }
133
+ else if (was && props.stale(was))
134
+ drawn.length = 0;
135
+ return drawn[0];
136
+ };
137
+ },
138
+ });
119
139
  export function bind(chart, declared) {
120
140
  return defineComponent({
121
141
  inheritAttrs: false,
@@ -124,11 +144,15 @@ export function bind(chart, declared) {
124
144
  onError: null,
125
145
  ...Object.fromEntries(Object.values(LISTENERS).map(e => [toHandlerKey(e), null])),
126
146
  },
127
- setup(props, { attrs, emit }) {
147
+ setup(props, { attrs, emit, slots }) {
128
148
  const host = ref();
129
149
  let bound;
130
- let applied;
131
- let attempted;
150
+ let slotted = false;
151
+ const overlay = shallowRef();
152
+ const layout = shallowRef();
153
+ const hover = shallowRef(null);
154
+ const applied = shallowRef();
155
+ const attempted = shallowRef();
132
156
  let reported;
133
157
  let sizing;
134
158
  // emit calls a .once listener (onClickOnce, an attr) on its first emit only, for the life of the component.
@@ -139,7 +163,39 @@ export function bind(chart, declared) {
139
163
  fired.add(event);
140
164
  emit(event, ...args);
141
165
  };
142
- const forward = Object.fromEntries(Object.entries(LISTENERS).map(([k, e]) => [k, (...args) => send(e, ...args)]));
166
+ const forward = Object.fromEntries(Object.entries(LISTENERS).map(([k, e]) => [
167
+ k,
168
+ (...args) => {
169
+ if (e === 'layout')
170
+ layout.value = args[0];
171
+ else if (e === 'hover')
172
+ hover.value = args[0];
173
+ send(e, ...args);
174
+ },
175
+ ]));
176
+ const chartProps = () => {
177
+ const now = {};
178
+ for (const [k, v] of Object.entries(props))
179
+ if (v !== undefined && !HOST_ONLY.has(k))
180
+ now[k] = toRaw(v);
181
+ return now;
182
+ };
183
+ // A compiled slot reads the app's state as it is now, so one called before the chart has taken that state, or
184
+ // while it cannot, meets a hover that names a row the new data lacks, or another frame's layout.
185
+ const shown = () => {
186
+ if (!layout.value || !applied.value || attempted.value !== applied.value)
187
+ return;
188
+ if (changed(applied.value, chartProps()).some(k => !callback(k)))
189
+ return;
190
+ // A chart with no room takes props without reporting their layout, and the core hides its root for as long.
191
+ if (overlay.value.parentElement.style.visibility === 'hidden')
192
+ return;
193
+ return { layout: layout.value, hover: hover.value };
194
+ };
195
+ const stale = (was) => attempted.value !== applied.value &&
196
+ // A failed update may make the last good chart again, which reports the same layout as a new object.
197
+ (JSON.stringify(was.layout) !== JSON.stringify(layout.value) ||
198
+ (!!was.hover && was.hover !== hover.value));
143
199
  const sync = () => {
144
200
  const el = host.value;
145
201
  const style = hostStyle(attrs.style);
@@ -149,28 +205,30 @@ export function bind(chart, declared) {
149
205
  sizing = next;
150
206
  // width and height size the host only: the core measures it on both axes, so its ResizeObserver
151
207
  // follows whatever else resizes the host (min-/max-, !important, a parent, a media query).
152
- const now = {};
153
- for (const [k, v] of Object.entries(props))
154
- if (v !== undefined && !HOST_ONLY.has(k))
155
- now[k] = toRaw(v);
208
+ const now = chartProps();
209
+ slotted = !!slots.default;
156
210
  for (const [k, e] of Object.entries(LISTENERS))
157
- if (listens(e))
211
+ if (listens(e) || (slotted && (e === 'layout' || e === 'hover')))
158
212
  now[k] = forward[k];
159
- const failed = attempted && attempted !== applied;
213
+ if (!now.onLayout)
214
+ layout.value = undefined;
215
+ if (!now.onHover)
216
+ hover.value = null;
217
+ const failed = attempted.value && attempted.value !== applied.value;
160
218
  // After a failure only a change to a prop other than a listener is tried again; listeners reach the last good chart.
161
- const held = failed && listens('error') && !changed(attempted, now).some(k => !callback(k));
162
- attempted = now;
219
+ const held = failed && listens('error') && !changed(attempted.value, now).some(k => !callback(k));
220
+ attempted.value = now;
163
221
  if (held && !bound)
164
222
  return;
165
223
  const callbacks = () => {
166
224
  const diff = {};
167
- for (const k of changed(applied, now))
225
+ for (const k of changed(applied.value, now))
168
226
  if (callback(k))
169
227
  diff[k] = now[k];
170
228
  if (!Object.keys(diff).length)
171
229
  return;
172
230
  bound.update(diff);
173
- applied = { ...applied, ...diff };
231
+ applied.value = { ...applied.value, ...diff };
174
232
  };
175
233
  try {
176
234
  if (!bound)
@@ -181,7 +239,7 @@ export function bind(chart, declared) {
181
239
  }
182
240
  else {
183
241
  const diff = {};
184
- for (const k of changed(applied, now))
242
+ for (const k of changed(applied.value, now))
185
243
  diff[k] = now[k];
186
244
  if (failed || Object.keys(diff).length)
187
245
  bound.update(diff);
@@ -199,12 +257,19 @@ export function bind(chart, declared) {
199
257
  send('error', e);
200
258
  return;
201
259
  }
202
- applied = now;
260
+ applied.value = now;
261
+ if (slotted)
262
+ overlay.value = bound.overlay;
203
263
  reported = undefined;
204
264
  };
205
265
  onMounted(sync);
206
266
  // attrs are not props, but reading them through setup's attrs is tracked, so class, style and id changes resize.
207
267
  watch(() => [{ ...props }, attrs.class, attrs.style, attrs.id], sync, { flush: 'post' });
268
+ // A slot that appears or goes changes no prop, so the watcher does not see it.
269
+ onUpdated(() => {
270
+ if (slotted !== !!slots.default)
271
+ sync();
272
+ });
208
273
  onBeforeUnmount(() => {
209
274
  detached?.unobserve(host.value);
210
275
  bound?.destroy();
@@ -219,7 +284,11 @@ export function bind(chart, declared) {
219
284
  ...(props.height !== undefined && { height: `${props.height}px` }),
220
285
  ...hostStyle(attrs.style),
221
286
  },
222
- });
287
+ },
288
+ // A child of the host rather than a second root, so $el, v-show and scoped styles keep meaning the host.
289
+ slots.default && overlay.value
290
+ ? [h(Teleport, { to: overlay.value }, [h(Overlay, { shown, stale, slot: slots.default })])]
291
+ : undefined);
223
292
  },
224
293
  });
225
294
  }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import type { Options } from 'swiftplot';
2
2
  import { type AreaChartProps as AreaProps, type BarChartProps as BarProps, type BoxPlotChartProps as BoxPlotProps, type CandlestickChartProps as CandlestickProps, type ComboChartProps as ComboProps, type FunnelChartProps as FunnelProps, type HeatmapChartProps as HeatmapProps, type HistogramChartProps as HistogramProps, type LineChartProps as LineProps, type PieChartProps as PieProps, type RadarChartProps as RadarProps, type RadialBarChartProps as RadialBarProps, type SankeyChartProps as SankeyProps, type ScatterChartProps as ScatterProps, type SunburstChartProps as SunburstProps, type TreemapChartProps as TreemapProps } from 'swiftplot/charts';
3
3
  import type { AllowedComponentProps, VNode, VNodeProps } from 'vue';
4
- /** The chart's change callbacks arrive as Vue listeners: `@click`, `@error` and `v-model:view`, `:hidden`, `:pointer`. */
4
+ import { type OverlaySlot } from './bind.js';
5
+ /** The chart's change callbacks arrive as Vue listeners: `@click`, `@layout`, `@hover`, `@error` and `v-model:view`, `:hidden`, `:pointer`. */
5
6
  export type Listeners = {
6
7
  onClick?: Options['onClick'];
8
+ onLayout?: Options['onLayout'];
9
+ onHover?: Options['onHover'];
7
10
  onError?: (error: unknown) => void;
8
11
  'onUpdate:view'?: Options['onViewChange'];
9
12
  'onUpdate:hidden'?: Options['onHiddenChange'];
@@ -34,21 +37,26 @@ export type PlotProps = Options & Listeners;
34
37
  type Host = AllowedComponentProps & VNodeProps & {
35
38
  id?: string;
36
39
  };
37
- export declare const LineChart: <D = undefined>(props: LineChartProps<D> & Host) => VNode;
38
- export declare const AreaChart: <D = undefined>(props: AreaChartProps<D> & Host) => VNode;
39
- export declare const BarChart: <D = undefined>(props: BarChartProps<D> & Host) => VNode;
40
- export declare const ScatterChart: <D = undefined>(props: ScatterChartProps<D> & Host) => VNode;
41
- export declare const PieChart: <D = undefined>(props: PieChartProps<D> & Host) => VNode;
42
- export declare const FunnelChart: <D = undefined>(props: FunnelChartProps<D> & Host) => VNode;
43
- export declare const RadialBarChart: <D = undefined>(props: RadialBarChartProps<D> & Host) => VNode;
44
- export declare const RadarChart: <D = undefined>(props: RadarChartProps<D> & Host) => VNode;
45
- export declare const HeatmapChart: <D = undefined>(props: HeatmapChartProps<D> & Host) => VNode;
46
- export declare const HistogramChart: <D = undefined>(props: HistogramChartProps<D> & Host) => VNode;
47
- export declare const BoxPlotChart: <D = undefined>(props: BoxPlotChartProps<D> & Host) => VNode;
48
- export declare const CandlestickChart: <D = undefined>(props: CandlestickChartProps<D> & Host) => VNode;
49
- export declare const ComboChart: <D = undefined>(props: ComboChartProps<D> & Host) => VNode;
50
- export declare const SankeyChart: <D = undefined>(props: SankeyChartProps<D> & Host) => VNode;
51
- export declare const TreemapChart: (props: TreemapChartProps & Host) => VNode;
52
- export declare const SunburstChart: (props: SunburstChartProps & Host) => VNode;
53
- export declare const Plot: (props: PlotProps & Host) => VNode;
40
+ type Context = {
41
+ slots: {
42
+ default?: OverlaySlot;
43
+ };
44
+ };
45
+ export declare const LineChart: <D = undefined>(props: LineChartProps<D> & Host, ctx?: Context) => VNode;
46
+ export declare const AreaChart: <D = undefined>(props: AreaChartProps<D> & Host, ctx?: Context) => VNode;
47
+ export declare const BarChart: <D = undefined>(props: BarChartProps<D> & Host, ctx?: Context) => VNode;
48
+ export declare const ScatterChart: <D = undefined>(props: ScatterChartProps<D> & Host, ctx?: Context) => VNode;
49
+ export declare const PieChart: <D = undefined>(props: PieChartProps<D> & Host, ctx?: Context) => VNode;
50
+ export declare const FunnelChart: <D = undefined>(props: FunnelChartProps<D> & Host, ctx?: Context) => VNode;
51
+ export declare const RadialBarChart: <D = undefined>(props: RadialBarChartProps<D> & Host, ctx?: Context) => VNode;
52
+ export declare const RadarChart: <D = undefined>(props: RadarChartProps<D> & Host, ctx?: Context) => VNode;
53
+ export declare const HeatmapChart: <D = undefined>(props: HeatmapChartProps<D> & Host, ctx?: Context) => VNode;
54
+ export declare const HistogramChart: <D = undefined>(props: HistogramChartProps<D> & Host, ctx?: Context) => VNode;
55
+ export declare const BoxPlotChart: <D = undefined>(props: BoxPlotChartProps<D> & Host, ctx?: Context) => VNode;
56
+ export declare const CandlestickChart: <D = undefined>(props: CandlestickChartProps<D> & Host, ctx?: Context) => VNode;
57
+ export declare const ComboChart: <D = undefined>(props: ComboChartProps<D> & Host, ctx?: Context) => VNode;
58
+ export declare const SankeyChart: <D = undefined>(props: SankeyChartProps<D> & Host, ctx?: Context) => VNode;
59
+ export declare const TreemapChart: (props: TreemapChartProps & Host, ctx?: Context) => VNode;
60
+ export declare const SunburstChart: (props: SunburstChartProps & Host, ctx?: Context) => VNode;
61
+ export declare const Plot: (props: PlotProps & Host, ctx?: Context) => VNode;
54
62
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftplot/vue",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Vue components for swiftplot charts",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "peerDependencies": {
23
23
  "vue": "^3.4",
24
- "swiftplot": "^0.4.0"
24
+ "swiftplot": "^0.5.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.19.2",
@@ -31,7 +31,7 @@
31
31
  "vitest": "^5.1.1",
32
32
  "vue": "^3.5.46",
33
33
  "vue-tsc": "^3.3.14",
34
- "swiftplot": "0.4.0"
34
+ "swiftplot": "0.5.0"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc -p tsconfig.build.json",