@swiftplot/vue 0.5.2 → 0.6.0-rc.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
@@ -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. `swiftplot/schema.json` is a JSON Schema of the
18
+ easy charts' props, for a model that answers with a chart as JSON.
18
19
 
19
20
  <img src="https://raw.githubusercontent.com/GusevP/swiftplot/main/assets/pan.gif" alt="Panning and zooming a line of a million points" width="640" />
20
21
 
@@ -97,12 +98,12 @@ Gzip size of the minified bundle of each entry in `site/scripts/size/`, built fr
97
98
 
98
99
  | entry | imports | KB |
99
100
  | ------------------ | ------------------------------------------------------- | ---: |
100
- | plot-line | `plot` and `line` from `swiftplot` | 14.4 |
101
- | plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` | 19.1 |
102
- | line-chart | `lineChart` from `swiftplot/charts` | 37.6 |
103
- | all-charts | every chart of `swiftplot/charts` | 54.7 |
104
- | react-line-chart | `LineChart` from `@swiftplot/react`, React not counted | 39.3 |
105
- | vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted | 39.8 |
101
+ | plot-line | `plot` and `line` from `swiftplot` | 15.4 |
102
+ | plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` | 20.7 |
103
+ | line-chart | `lineChart` from `swiftplot/charts` | 40.2 |
104
+ | all-charts | every chart of `swiftplot/charts` | 57.6 |
105
+ | react-line-chart | `LineChart` from `@swiftplot/react`, React not counted | 42.0 |
106
+ | vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted | 42.5 |
106
107
 
107
108
  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.
108
109
 
package/dist/bind.js CHANGED
@@ -51,6 +51,17 @@ const changed = (was, now) => [...new Set([...Object.keys(was), ...Object.keys(n
51
51
  const hostStyle = (style) => Object.fromEntries(Object.entries(normalizeStyle([style])).filter(([, v]) => v !== undefined && v !== null && v !== ''));
52
52
  const FALLBACK = 'data-swiftplot-fallback';
53
53
  const LAYER = 'data-swiftplot-fallback-layer';
54
+ // The text of styles.css, whose counter-reset tells a probe that the shipped file already applies in its root.
55
+ const RULE = `@layer swiftplot {
56
+ :where([data-swiftplot-fallback='fill']) {
57
+ height: 100%;
58
+ counter-reset: swiftplot-fallback;
59
+ }
60
+ :where([data-swiftplot-fallback='fixed']) {
61
+ height: 300px;
62
+ counter-reset: swiftplot-fallback;
63
+ }
64
+ }\n`;
54
65
  const styles = new WeakMap();
55
66
  const detached = new WeakMap();
56
67
  const windowOf = (el) => (el.ownerDocument?.defaultView ?? globalThis);
@@ -83,11 +94,20 @@ function fallback(el) {
83
94
  for (const h of ['fill', 'fixed']) {
84
95
  if (el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) > 0)
85
96
  break;
86
- sheet(el);
87
97
  el.setAttribute(FALLBACK, h);
98
+ if (h === 'fill' && !shipped(el))
99
+ sheet(el);
88
100
  }
89
101
  el.style.contain = contain;
90
102
  }
103
+ // A probe of its own rather than the host, whose counter-reset the app's CSS may set.
104
+ function shipped(el) {
105
+ const probe = el.appendChild(el.ownerDocument.createElement('swiftplot-probe'));
106
+ probe.setAttribute(FALLBACK, 'fill');
107
+ const on = windowOf(el).getComputedStyle(probe).counterReset === 'swiftplot-fallback 0';
108
+ probe.remove();
109
+ return on;
110
+ }
91
111
  function sheet(el) {
92
112
  const doc = el.ownerDocument;
93
113
  const root = el.getRootNode();
@@ -103,7 +123,10 @@ function sheet(el) {
103
123
  }
104
124
  const style = doc.createElement('style');
105
125
  style.setAttribute(LAYER, '');
106
- style.textContent = `@layer swiftplot { :where([${FALLBACK}=fill]) { height: 100% } :where([${FALLBACK}=fixed]) { height: 300px } }`;
126
+ // A script's nonce would not pass style-src, and a page may give scripts and styles different ones.
127
+ style.nonce =
128
+ [...doc.querySelectorAll('style[nonce], link[rel~="stylesheet" i][nonce]')].find(e => e.nonce)?.nonce ?? '';
129
+ style.textContent = RULE;
107
130
  parent.prepend(style);
108
131
  styles.set(root, style);
109
132
  // A sheet put first later (React 19 does so with its first precedence sheet) would declare its layers ahead of ours.
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const base = {
15
15
  height: null,
16
16
  margin: null,
17
17
  description: null,
18
+ empty: null,
18
19
  hidden: null,
19
20
  selected: null,
20
21
  pointer: null,
@@ -28,16 +29,19 @@ export const LineChart = /*#__PURE__*/ bind(lineChart, () => ({
28
29
  fill: flag,
29
30
  errorBars: null,
30
31
  join: bool,
32
+ cumulative: bool,
31
33
  }));
32
34
  export const AreaChart = /*#__PURE__*/ bind(areaChart, () => ({
33
35
  ...xy,
34
36
  curve: null,
35
37
  join: bool,
36
38
  stack: bool,
39
+ cumulative: bool,
37
40
  }));
38
41
  export const BarChart = /*#__PURE__*/ bind(barChart, () => ({
39
42
  ...xy,
40
43
  stack: bool,
44
+ cumulative: bool,
41
45
  errorBars: null,
42
46
  }));
43
47
  export const ScatterChart = /*#__PURE__*/ bind(scatterChart, () => ({
@@ -55,6 +59,7 @@ export const PieChart = /*#__PURE__*/ bind(pieChart, () => ({
55
59
  inner: null,
56
60
  text: bool,
57
61
  sweep: null,
62
+ center: null,
58
63
  }));
59
64
  export const FunnelChart = /*#__PURE__*/ bind(funnelChart, () => ({
60
65
  ...base,
@@ -92,6 +97,7 @@ export const HistogramChart = /*#__PURE__*/ bind(histogramChart, () => ({
92
97
  ...axes,
93
98
  x: null,
94
99
  bins: null,
100
+ cumulative: { type: [Boolean, String], default: undefined },
95
101
  }));
96
102
  export const BoxPlotChart = /*#__PURE__*/ bind(boxPlotChart, () => ({
97
103
  ...base,
@@ -123,6 +129,7 @@ export const ComboChart = /*#__PURE__*/ bind(comboChart, () => ({
123
129
  y2Lines: null,
124
130
  y2Bars: null,
125
131
  stack: bool,
132
+ cumulative: bool,
126
133
  }));
127
134
  export const SankeyChart = /*#__PURE__*/ bind(sankeyChart, () => ({
128
135
  ...base,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftplot/vue",
3
- "version": "0.5.2",
3
+ "version": "0.6.0-rc.0",
4
4
  "description": "Vue components for swiftplot charts",
5
5
  "keywords": [
6
6
  "chart",
@@ -22,19 +22,23 @@
22
22
  },
23
23
  "homepage": "https://swiftplot.dev",
24
24
  "type": "module",
25
- "sideEffects": false,
25
+ "sideEffects": [
26
+ "*.css"
27
+ ],
26
28
  "exports": {
27
29
  ".": {
28
30
  "types": "./dist/index.d.ts",
29
31
  "default": "./dist/index.js"
30
- }
32
+ },
33
+ "./styles.css": "./styles.css"
31
34
  },
32
35
  "files": [
33
- "dist"
36
+ "dist",
37
+ "styles.css"
34
38
  ],
35
39
  "peerDependencies": {
36
40
  "vue": "^3.4",
37
- "swiftplot": "^0.5.2"
41
+ "swiftplot": "^0.6.0-rc.0"
38
42
  },
39
43
  "devDependencies": {
40
44
  "@types/node": "^24.19.2",
@@ -44,7 +48,7 @@
44
48
  "vitest": "^5.1.1",
45
49
  "vue": "^3.5.46",
46
50
  "vue-tsc": "^3.3.14",
47
- "swiftplot": "0.5.2"
51
+ "swiftplot": "0.6.0-rc.0"
48
52
  },
49
53
  "scripts": {
50
54
  "build": "tsc -p tsconfig.build.json",
package/styles.css ADDED
@@ -0,0 +1,10 @@
1
+ @layer swiftplot {
2
+ :where([data-swiftplot-fallback='fill']) {
3
+ height: 100%;
4
+ counter-reset: swiftplot-fallback;
5
+ }
6
+ :where([data-swiftplot-fallback='fixed']) {
7
+ height: 300px;
8
+ counter-reset: swiftplot-fallback;
9
+ }
10
+ }