@swiftplot/vue 0.8.0 → 0.9.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 +10 -9
- package/dist/bind.js +46 -17
- package/dist/index.js +37 -17
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,8 @@ project stands, what it lacks and what 1.0 needs: [swiftplot.dev/status](https:/
|
|
|
14
14
|
[Discussions](https://github.com/GusevP/swiftplot/discussions).
|
|
15
15
|
|
|
16
16
|
**For AI coding assistants:** [`llms-full.txt`](https://swiftplot.dev/llms-full.txt) is a guide to writing code with
|
|
17
|
-
swiftplot, and [`llms.txt`](https://swiftplot.dev/llms.txt) its index.
|
|
17
|
+
swiftplot, and [`llms.txt`](https://swiftplot.dev/llms.txt) its index. The guide for the version installed ships in the
|
|
18
|
+
package, at `node_modules/swiftplot/llms-full.txt`. `swiftplot/schema.json` is a JSON Schema of the
|
|
18
19
|
easy charts' props, for a model that answers with a chart as JSON; the recipes
|
|
19
20
|
[Charts for json-render](https://swiftplot.dev/guides/json-render) and [Vercel AI SDK](https://swiftplot.dev/guides/ai-sdk)
|
|
20
21
|
put it to work in those libraries.
|
|
@@ -100,14 +101,14 @@ Gzip size of the minified bundle of each entry in `site/scripts/size/`, built fr
|
|
|
100
101
|
|
|
101
102
|
| entry | imports | KB |
|
|
102
103
|
| ------------------ | ------------------------------------------------------- | ---: |
|
|
103
|
-
| plot-line | `plot` and `line` from `swiftplot` |
|
|
104
|
-
| plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` |
|
|
105
|
-
| line-chart | `lineChart` from `swiftplot/charts` |
|
|
106
|
-
| all-charts | every chart of `swiftplot/charts` |
|
|
107
|
-
| react-line-chart | `LineChart` from `@swiftplot/react`, React not counted |
|
|
108
|
-
| vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted |
|
|
109
|
-
| element-line | `define` from `swiftplot/element` with `lineChart` |
|
|
110
|
-
| element-all | `swiftplot/element/all`, every chart as `<swift-plot>` |
|
|
104
|
+
| plot-line | `plot` and `line` from `swiftplot` | 17.5 |
|
|
105
|
+
| plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` | 23.8 |
|
|
106
|
+
| line-chart | `lineChart` from `swiftplot/charts` | 53.2 |
|
|
107
|
+
| all-charts | every chart of `swiftplot/charts` | 73.5 |
|
|
108
|
+
| react-line-chart | `LineChart` from `@swiftplot/react`, React not counted | 55.3 |
|
|
109
|
+
| vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted | 56.0 |
|
|
110
|
+
| element-line | `define` from `swiftplot/element` with `lineChart` | 54.9 |
|
|
111
|
+
| element-all | `swiftplot/element/all`, every chart as `<swift-plot>` | 75.3 |
|
|
111
112
|
|
|
112
113
|
On chart-bench's page, which bundles `plot`, `line`, `area`, `ticks`, `dots`, `tooltip` and `animate`, swiftplot 0.5.0 adds 19.3 KB and uPlot 23.9 KB (`results/bundle.json`: the arm's page less the same page with no chart). uPlot ships more in its size: it is one module that comes whole, with its legend, cursor, selection and series types whether a page uses them or not.
|
|
113
114
|
|
package/dist/bind.js
CHANGED
|
@@ -191,6 +191,7 @@ export function bind(chart, declared) {
|
|
|
191
191
|
const attempted = shallowRef();
|
|
192
192
|
let reported;
|
|
193
193
|
let sizing;
|
|
194
|
+
let inline;
|
|
194
195
|
let drop;
|
|
195
196
|
// emit calls a .once listener (onClickOnce, an attr) on its first emit only, for the life of the component.
|
|
196
197
|
const fired = new Set();
|
|
@@ -241,6 +242,9 @@ export function bind(chart, declared) {
|
|
|
241
242
|
if ((!bound || !equal(next, sizing)) && style.height === undefined && props.height === undefined)
|
|
242
243
|
drop = fallback(el, install);
|
|
243
244
|
sizing = next;
|
|
245
|
+
// Without layout the core sizes the chart by the host's inline size, read again only on an update.
|
|
246
|
+
const size = [el.style.width, el.style.height];
|
|
247
|
+
const resized = !equal(size, inline);
|
|
244
248
|
// width and height size the host only: the core measures it on both axes, so its ResizeObserver
|
|
245
249
|
// follows whatever else resizes the host (min-/max-, !important, a parent, a media query).
|
|
246
250
|
const now = chartProps();
|
|
@@ -268,37 +272,62 @@ export function bind(chart, declared) {
|
|
|
268
272
|
bound.update(diff);
|
|
269
273
|
applied.value = { ...applied.value, ...diff };
|
|
270
274
|
};
|
|
275
|
+
const report = (e) => {
|
|
276
|
+
if (!listens('error'))
|
|
277
|
+
throw e;
|
|
278
|
+
const key = keyOf(e, now);
|
|
279
|
+
if (equal(reported, key))
|
|
280
|
+
return;
|
|
281
|
+
reported = key;
|
|
282
|
+
send('error', e);
|
|
283
|
+
};
|
|
284
|
+
const created = !bound;
|
|
285
|
+
let thrown;
|
|
286
|
+
let restore = false;
|
|
271
287
|
try {
|
|
272
|
-
if (
|
|
288
|
+
if (created)
|
|
273
289
|
bound = chart(el, now);
|
|
274
|
-
else if (held)
|
|
290
|
+
else if (held)
|
|
275
291
|
callbacks();
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
292
|
else {
|
|
279
293
|
const diff = {};
|
|
280
294
|
for (const k of changed(applied.value, now))
|
|
281
295
|
diff[k] = now[k];
|
|
282
|
-
if (
|
|
296
|
+
if (Object.keys(diff).length)
|
|
283
297
|
bound.update(diff);
|
|
298
|
+
else
|
|
299
|
+
restore = !!failed;
|
|
284
300
|
}
|
|
285
301
|
}
|
|
286
302
|
catch (e) {
|
|
303
|
+
thrown = { e };
|
|
287
304
|
if (bound)
|
|
288
305
|
callbacks();
|
|
289
|
-
if (!listens('error'))
|
|
290
|
-
throw e;
|
|
291
|
-
const key = keyOf(e, now);
|
|
292
|
-
if (equal(reported, key))
|
|
293
|
-
return;
|
|
294
|
-
reported = key;
|
|
295
|
-
send('error', e);
|
|
296
|
-
return;
|
|
297
306
|
}
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
|
|
301
|
-
|
|
307
|
+
let unmeasured;
|
|
308
|
+
if (bound) {
|
|
309
|
+
if (restore || (resized && !created))
|
|
310
|
+
try {
|
|
311
|
+
bound.update({});
|
|
312
|
+
}
|
|
313
|
+
catch (e) {
|
|
314
|
+
if (restore)
|
|
315
|
+
thrown = { e };
|
|
316
|
+
else
|
|
317
|
+
unmeasured = { e };
|
|
318
|
+
}
|
|
319
|
+
inline = size;
|
|
320
|
+
}
|
|
321
|
+
if (thrown)
|
|
322
|
+
report(thrown.e);
|
|
323
|
+
else if (!held) {
|
|
324
|
+
applied.value = now;
|
|
325
|
+
if (slotted)
|
|
326
|
+
overlay.value = bound.overlay;
|
|
327
|
+
reported = undefined;
|
|
328
|
+
}
|
|
329
|
+
if (unmeasured)
|
|
330
|
+
report(unmeasured.e);
|
|
302
331
|
};
|
|
303
332
|
const settle = () => due && sync();
|
|
304
333
|
onMounted(settle);
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import { areaChart, barChart, boxPlotChart, candlestickChart, comboChart, funnel
|
|
|
2
2
|
import { bind } from './bind.js';
|
|
3
3
|
const flag = { type: [Boolean, Object], default: undefined };
|
|
4
4
|
const bool = { type: Boolean, default: undefined };
|
|
5
|
-
const
|
|
5
|
+
const choice = { type: [Boolean, String], default: undefined };
|
|
6
|
+
const oneMark = {
|
|
6
7
|
data: null,
|
|
7
8
|
dataVersion: null,
|
|
8
9
|
colors: null,
|
|
@@ -23,19 +24,25 @@ const base = {
|
|
|
23
24
|
selected: null,
|
|
24
25
|
pointer: null,
|
|
25
26
|
};
|
|
26
|
-
const
|
|
27
|
+
const base = { ...oneMark, focused: null };
|
|
28
|
+
const axes = { xAxis: null, yAxis: null, grid: choice, zoom: flag, view: null };
|
|
27
29
|
const overlays = { rules: null, zones: null, brush: flag };
|
|
28
30
|
const xy = { ...base, ...axes, ...overlays, x: null, y: null, y2: null, series: null, y2Axis: null };
|
|
29
31
|
export const LineChart = /*#__PURE__*/ bind(lineChart, () => ({
|
|
30
32
|
...xy,
|
|
33
|
+
follow: bool,
|
|
31
34
|
curve: null,
|
|
32
35
|
fill: flag,
|
|
33
36
|
errorBars: null,
|
|
34
37
|
join: bool,
|
|
35
38
|
cumulative: bool,
|
|
39
|
+
dash: null,
|
|
40
|
+
dashes: null,
|
|
41
|
+
dashFrom: null,
|
|
36
42
|
}));
|
|
37
43
|
export const AreaChart = /*#__PURE__*/ bind(areaChart, () => ({
|
|
38
44
|
...xy,
|
|
45
|
+
follow: bool,
|
|
39
46
|
curve: null,
|
|
40
47
|
join: bool,
|
|
41
48
|
stack: bool,
|
|
@@ -46,35 +53,40 @@ export const BarChart = /*#__PURE__*/ bind(barChart, () => ({
|
|
|
46
53
|
stack: bool,
|
|
47
54
|
cumulative: bool,
|
|
48
55
|
errorBars: null,
|
|
49
|
-
text: { type: [Boolean, Function], default: undefined },
|
|
56
|
+
text: { type: [Boolean, Function, Object], default: undefined },
|
|
50
57
|
horizontal: bool,
|
|
58
|
+
color: null,
|
|
51
59
|
}));
|
|
52
60
|
export const ScatterChart = /*#__PURE__*/ bind(scatterChart, () => ({
|
|
53
61
|
...xy,
|
|
62
|
+
follow: bool,
|
|
54
63
|
r: null,
|
|
55
64
|
alpha: null,
|
|
56
65
|
ring: null,
|
|
57
66
|
shape: null,
|
|
67
|
+
shapes: null,
|
|
58
68
|
errorBars: null,
|
|
59
69
|
}));
|
|
60
70
|
export const PieChart = /*#__PURE__*/ bind(pieChart, () => ({
|
|
61
|
-
...
|
|
71
|
+
...oneMark,
|
|
62
72
|
label: null,
|
|
63
73
|
value: null,
|
|
64
74
|
inner: null,
|
|
65
75
|
text: bool,
|
|
66
76
|
sweep: null,
|
|
67
77
|
center: null,
|
|
78
|
+
stroke: null,
|
|
79
|
+
strokeWidth: null,
|
|
68
80
|
}));
|
|
69
81
|
export const FunnelChart = /*#__PURE__*/ bind(funnelChart, () => ({
|
|
70
|
-
...
|
|
82
|
+
...oneMark,
|
|
71
83
|
label: null,
|
|
72
84
|
value: null,
|
|
73
85
|
text: bool,
|
|
74
86
|
fill: null,
|
|
75
87
|
}));
|
|
76
88
|
export const RadialBarChart = /*#__PURE__*/ bind(radialBarChart, () => ({
|
|
77
|
-
...
|
|
89
|
+
...oneMark,
|
|
78
90
|
label: null,
|
|
79
91
|
value: null,
|
|
80
92
|
max: null,
|
|
@@ -89,34 +101,35 @@ export const RadarChart = /*#__PURE__*/ bind(radarChart, () => ({
|
|
|
89
101
|
fill: null,
|
|
90
102
|
}));
|
|
91
103
|
export const HeatmapChart = /*#__PURE__*/ bind(heatmapChart, () => ({
|
|
92
|
-
...
|
|
104
|
+
...oneMark,
|
|
93
105
|
x: null,
|
|
94
106
|
y: null,
|
|
95
107
|
value: null,
|
|
96
108
|
color: null,
|
|
97
109
|
xAxis: null,
|
|
98
110
|
yAxis: null,
|
|
99
|
-
grid:
|
|
111
|
+
grid: choice,
|
|
100
112
|
}));
|
|
101
113
|
export const HistogramChart = /*#__PURE__*/ bind(histogramChart, () => ({
|
|
102
|
-
...
|
|
114
|
+
...oneMark,
|
|
103
115
|
...axes,
|
|
104
116
|
x: null,
|
|
105
117
|
bins: null,
|
|
106
|
-
cumulative:
|
|
118
|
+
cumulative: choice,
|
|
107
119
|
}));
|
|
108
120
|
export const BoxPlotChart = /*#__PURE__*/ bind(boxPlotChart, () => ({
|
|
109
|
-
...
|
|
121
|
+
...oneMark,
|
|
110
122
|
x: null,
|
|
111
123
|
y: null,
|
|
112
124
|
fill: null,
|
|
113
125
|
xAxis: null,
|
|
114
126
|
yAxis: null,
|
|
115
|
-
grid:
|
|
127
|
+
grid: choice,
|
|
116
128
|
}));
|
|
117
129
|
export const CandlestickChart = /*#__PURE__*/ bind(candlestickChart, () => ({
|
|
118
|
-
...
|
|
130
|
+
...oneMark,
|
|
119
131
|
...axes,
|
|
132
|
+
follow: bool,
|
|
120
133
|
x: null,
|
|
121
134
|
open: null,
|
|
122
135
|
high: null,
|
|
@@ -129,6 +142,7 @@ export const ComboChart = /*#__PURE__*/ bind(comboChart, () => ({
|
|
|
129
142
|
...base,
|
|
130
143
|
...axes,
|
|
131
144
|
...overlays,
|
|
145
|
+
follow: bool,
|
|
132
146
|
y2Axis: null,
|
|
133
147
|
x: null,
|
|
134
148
|
lines: null,
|
|
@@ -137,9 +151,12 @@ export const ComboChart = /*#__PURE__*/ bind(comboChart, () => ({
|
|
|
137
151
|
y2Bars: null,
|
|
138
152
|
stack: bool,
|
|
139
153
|
cumulative: bool,
|
|
154
|
+
dash: null,
|
|
155
|
+
dashes: null,
|
|
156
|
+
dashFrom: null,
|
|
140
157
|
}));
|
|
141
158
|
export const SankeyChart = /*#__PURE__*/ bind(sankeyChart, () => ({
|
|
142
|
-
...
|
|
159
|
+
...oneMark,
|
|
143
160
|
source: null,
|
|
144
161
|
target: null,
|
|
145
162
|
value: null,
|
|
@@ -147,12 +164,12 @@ export const SankeyChart = /*#__PURE__*/ bind(sankeyChart, () => ({
|
|
|
147
164
|
text: bool,
|
|
148
165
|
}));
|
|
149
166
|
export const TreemapChart = /*#__PURE__*/ bind(treemapChart, () => ({
|
|
150
|
-
...
|
|
167
|
+
...oneMark,
|
|
151
168
|
text: bool,
|
|
152
169
|
shade: null,
|
|
153
170
|
}));
|
|
154
171
|
export const SunburstChart = /*#__PURE__*/ bind(sunburstChart, () => ({
|
|
155
|
-
...
|
|
172
|
+
...oneMark,
|
|
156
173
|
text: bool,
|
|
157
174
|
shade: null,
|
|
158
175
|
}));
|
|
@@ -163,17 +180,20 @@ export const Plot = /*#__PURE__*/ bind(mount, () => ({
|
|
|
163
180
|
x: null,
|
|
164
181
|
y: null,
|
|
165
182
|
y2: null,
|
|
166
|
-
grid:
|
|
183
|
+
grid: choice,
|
|
167
184
|
valueAxis: null,
|
|
168
185
|
frame: null,
|
|
169
186
|
marks: null,
|
|
170
187
|
use: null,
|
|
188
|
+
a11y: null,
|
|
189
|
+
table: null,
|
|
171
190
|
description: null,
|
|
172
191
|
locale: null,
|
|
173
192
|
dim: null,
|
|
174
193
|
theme: null,
|
|
175
194
|
view: null,
|
|
176
195
|
hidden: null,
|
|
196
|
+
focused: null,
|
|
177
197
|
selected: null,
|
|
178
198
|
pointer: null,
|
|
179
199
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftplot/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Vue components for swiftplot charts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"vue": "^3.4",
|
|
41
|
-
"swiftplot": "^0.
|
|
41
|
+
"swiftplot": "^0.9.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^24.19.2",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"vitest": "^5.1.1",
|
|
51
51
|
"vue": "^3.5.46",
|
|
52
52
|
"vue-tsc": "^3.3.14",
|
|
53
|
-
"swiftplot": "0.
|
|
53
|
+
"swiftplot": "0.9.1"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsc -p tsconfig.build.json",
|