@wick-charts/vue 0.6.0 → 0.6.2
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 +27 -3
- package/dist/ChartContainer.vue.js +99 -69
- package/dist/core/dist/animation/config.js +66 -64
- package/dist/core/dist/animation/intro-wave.js +19 -21
- package/dist/core/dist/animation/reduced-motion.js +6 -0
- package/dist/core/dist/axis/dom-labels.js +14 -14
- package/dist/core/dist/chart/badge-animator.js +15 -19
- package/dist/core/dist/chart/options.js +27 -16
- package/dist/core/dist/chart.js +673 -442
- package/dist/core/dist/components/crosshair.js +8 -6
- package/dist/core/dist/components/grid.js +21 -17
- package/dist/core/dist/interactions/handler.js +36 -20
- package/dist/core/dist/navigator/controller.js +12 -12
- package/dist/core/dist/scales/tick-tracker.js +2 -2
- package/dist/core/dist/scales/x-scale.js +47 -32
- package/dist/core/dist/scales/y-scale.js +39 -21
- package/dist/core/dist/series/bar.js +24 -24
- package/dist/core/dist/series/candlestick.js +20 -20
- package/dist/core/dist/series/heatmap.js +16 -16
- package/dist/core/dist/series/line.js +461 -401
- package/dist/core/dist/utils/pixel-grid.js +10 -0
- package/dist/index.d.ts +123 -1
- package/dist/ui/YLabel.vue.js +19 -18
- package/package.json +2 -2
- package/src/ChartContainer.vue +116 -1
package/README.md
CHANGED
|
@@ -72,6 +72,30 @@ chart.setSeriesData(seriesId, data);
|
|
|
72
72
|
|
|
73
73
|
There's no separate `@wick-charts/core` package on npm — the three framework packages are the supported way to install the engine.
|
|
74
74
|
|
|
75
|
+
### Drop-in `<script>` — no build step
|
|
76
|
+
|
|
77
|
+
For a CodePen, JSFiddle, or a plain HTML page, load the prebuilt UMD bundle from a CDN — no npm, no bundler. It exposes the whole engine (every `ChartInstance`, series def, theme, and painter) as a `WickCharts` global:
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<div id="chart" style="width: 640px; height: 320px"></div>
|
|
81
|
+
|
|
82
|
+
<script src="https://cdn.jsdelivr.net/npm/@wick-charts/react/dist/wick-charts.umd.min.js"></script>
|
|
83
|
+
<script>
|
|
84
|
+
const { ChartInstance, LineSeriesDef } = WickCharts;
|
|
85
|
+
|
|
86
|
+
const chart = new ChartInstance(document.getElementById('chart'));
|
|
87
|
+
const id = chart.addSeries(LineSeriesDef);
|
|
88
|
+
chart.setLayerColors(id, ['#22c55e']);
|
|
89
|
+
chart.setSeriesData(id, [
|
|
90
|
+
{ time: Date.now() - 2 * 86_400_000, value: 100 },
|
|
91
|
+
{ time: Date.now() - 86_400_000, value: 118 },
|
|
92
|
+
{ time: Date.now(), value: 109 },
|
|
93
|
+
]);
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The same file is on unpkg (`https://unpkg.com/@wick-charts/react/dist/wick-charts.umd.min.js`); pin a version with `@x.y.z` for production. ~72 kB gzipped, self-contained.
|
|
98
|
+
|
|
75
99
|
## Bundle size
|
|
76
100
|
|
|
77
101
|
Packages ship per-module ESM with `sideEffects: false`, and each series component carries its own renderer — your bundler only ships the chart types you import.
|
|
@@ -80,9 +104,9 @@ Tree-shaken React scenarios via `pnpm size` (esbuild, minified, browser target,
|
|
|
80
104
|
|
|
81
105
|
| Scenario | Raw | Gzip | Brotli |
|
|
82
106
|
|---|---:|---:|---:|
|
|
83
|
-
| Candlestick only |
|
|
84
|
-
| Line only |
|
|
85
|
-
| Full React |
|
|
107
|
+
| Candlestick only | 109.8 kB | 34.1 kB | 30.0 kB |
|
|
108
|
+
| Line only | 125.6 kB | 38.7 kB | 33.8 kB |
|
|
109
|
+
| Full React | 253.5 kB | 78.1 kB | 65.6 kB |
|
|
86
110
|
|
|
87
111
|
## Migration
|
|
88
112
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ChartInstance as
|
|
3
|
-
import { deepEqual as
|
|
4
|
-
import { catppuccin as
|
|
5
|
-
import { ChartKey as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as U, ref as r, shallowRef as P, provide as l, computed as v, onMounted as G, nextTick as g, onUnmounted as I, watch as d, openBlock as y, createElementBlock as m, normalizeStyle as q, createElementVNode as o, createCommentVNode as w, renderSlot as J } from "vue";
|
|
2
|
+
import { ChartInstance as T } from "./core/dist/chart.js";
|
|
3
|
+
import { deepEqual as z } from "./core/dist/utils/deep-equal.js";
|
|
4
|
+
import { catppuccin as Q } from "./core/dist/theme/themes/catppuccin.js";
|
|
5
|
+
import { ChartKey as W, ThemeKey as X, TitleAnchorKey as Y, InfoBarAnchorKey as Z, LegendAnchorKey as ee, LegendRightAnchorKey as te, NavigatorAnchorKey as ie } from "./context.js";
|
|
6
|
+
const ae = { style: { display: "flex", "flex-direction": "row", flex: "1", "min-height": "0" } }, oe = { style: { display: "flex", "flex-direction": "column", flex: "1", "min-width": "0", "min-height": "0" } }, ne = {
|
|
7
7
|
key: 0,
|
|
8
8
|
"data-chart-header": "",
|
|
9
9
|
style: { "flex-shrink": "0", display: "flex", "flex-direction": "column", "pointer-events": "none" }
|
|
10
|
-
},
|
|
10
|
+
}, re = {
|
|
11
11
|
key: 1,
|
|
12
12
|
"data-chart-series-overlay": "",
|
|
13
13
|
style: { position: "absolute", inset: "0", "pointer-events": "none", "z-index": "3" }
|
|
14
|
-
},
|
|
14
|
+
}, H = 24, ce = /* @__PURE__ */ U({
|
|
15
15
|
__name: "ChartContainer",
|
|
16
16
|
props: {
|
|
17
|
-
theme: { default: () =>
|
|
17
|
+
theme: { default: () => Q.theme },
|
|
18
18
|
axis: {},
|
|
19
19
|
padding: {},
|
|
20
20
|
viewport: {},
|
|
@@ -22,6 +22,7 @@ const X = { style: { display: "flex", "flex-direction": "row", flex: "1", "min-h
|
|
|
22
22
|
gradient: { type: Boolean, default: !0 },
|
|
23
23
|
interactive: { type: Boolean, default: !0 },
|
|
24
24
|
grid: {},
|
|
25
|
+
fade: { type: [Boolean, Object], default: void 0 },
|
|
25
26
|
headerLayout: { default: "overlay" },
|
|
26
27
|
animations: { type: [Boolean, Object] },
|
|
27
28
|
perf: {},
|
|
@@ -33,76 +34,105 @@ const X = { style: { display: "flex", "flex-direction": "row", flex: "1", "min-h
|
|
|
33
34
|
onVisibleRangeChange: {},
|
|
34
35
|
onCrosshairMove: {}
|
|
35
36
|
},
|
|
36
|
-
setup(
|
|
37
|
-
const e =
|
|
38
|
-
l(
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
setup(b) {
|
|
38
|
+
const e = b, s = r(), a = P(null), x = P(e.theme), c = e.perf, p = e.onEdgeReached, C = r(null), R = r(null), k = r(null), _ = r(null), E = r(null), B = r(null);
|
|
39
|
+
l(W, a), l(X, x), l(Y, R), l(Z, k), l(ee, _), l(te, E), l(ie, B);
|
|
40
|
+
let f = null;
|
|
41
|
+
const u = r(0), O = v(() => e.fade === !1 ? !1 : typeof e.fade == "object" ? e.fade.top !== void 0 || e.fade.overlap !== void 0 : e.fade === !0), S = v(() => {
|
|
42
|
+
if (!O.value) return 0;
|
|
43
|
+
const t = typeof e.fade == "object" ? e.fade.overlap : void 0;
|
|
44
|
+
return t !== void 0 ? Math.max(0, t) : u.value / 2;
|
|
45
|
+
}), j = v(() => {
|
|
46
|
+
if (!O.value) return 0;
|
|
47
|
+
if (typeof e.fade == "object" && e.fade.top !== void 0) return e.fade.top;
|
|
48
|
+
const t = e.headerLayout === "overlay" ? u.value : 0;
|
|
49
|
+
return t > 0 ? t + H : H;
|
|
50
|
+
}), L = v(
|
|
51
|
+
() => e.headerLayout === "overlay" ? Math.max(0, u.value - S.value) : 0
|
|
52
|
+
);
|
|
53
|
+
function A() {
|
|
54
|
+
if (!a.value) return;
|
|
55
|
+
const i = { top: (e.padding?.top ?? 20) + L.value };
|
|
56
|
+
e.padding?.bottom !== void 0 && (i.bottom = e.padding.bottom), e.padding?.right !== void 0 && (i.right = e.padding.right), e.padding?.left !== void 0 && (i.left = e.padding.left), a.value.setPadding(i);
|
|
57
|
+
}
|
|
58
|
+
function M(t) {
|
|
59
|
+
if (e.fade === !1) {
|
|
60
|
+
t.fade = { top: 0, right: 0, left: 0 };
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof e.fade != "object") return;
|
|
64
|
+
const i = {};
|
|
65
|
+
e.fade.top !== void 0 && (i.top = e.fade.top), e.fade.right !== void 0 && (i.right = e.fade.right), e.fade.left !== void 0 && (i.left = e.fade.left), t.fade = i;
|
|
66
|
+
}
|
|
67
|
+
function $() {
|
|
68
|
+
if (!a.value) return;
|
|
69
|
+
if (e.fade === !1) {
|
|
70
|
+
a.value.setFade({ top: 0, right: 0, left: 0 });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const t = { top: j.value };
|
|
74
|
+
typeof e.fade == "object" && (e.fade.right !== void 0 && (t.right = e.fade.right), e.fade.left !== void 0 && (t.left = e.fade.left)), a.value.setFade(t);
|
|
45
75
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
const t = e.headerLayout === "overlay" ?
|
|
76
|
+
function V() {
|
|
77
|
+
f?.disconnect(), f = null;
|
|
78
|
+
const t = e.headerLayout === "overlay" ? C.value : null;
|
|
49
79
|
if (!t) {
|
|
50
|
-
|
|
80
|
+
u.value = 0, A();
|
|
51
81
|
return;
|
|
52
82
|
}
|
|
53
83
|
const i = () => {
|
|
54
|
-
|
|
84
|
+
u.value = t.getBoundingClientRect().height, A();
|
|
55
85
|
};
|
|
56
|
-
i(),
|
|
86
|
+
i(), f = new ResizeObserver(i), f.observe(t);
|
|
57
87
|
}
|
|
58
|
-
function
|
|
59
|
-
t.on("pointClick", (
|
|
88
|
+
function K(t) {
|
|
89
|
+
t.on("pointClick", (n) => e.onPointClick?.(n)), t.on("pointDoubleClick", (n) => e.onPointDoubleClick?.(n)), t.on("seriesHover", (n) => e.onSeriesHover?.(n)), t.on("crosshairMove", (n) => e.onCrosshairMove?.(n));
|
|
60
90
|
const i = () => e.onVisibleRangeChange?.(t.getVisibleRange());
|
|
61
91
|
t.on("viewportChange", i), t.on("dataUpdate", i), t.on("seriesChange", i);
|
|
62
92
|
}
|
|
63
|
-
|
|
64
|
-
if (!
|
|
93
|
+
G(async () => {
|
|
94
|
+
if (!s.value) return;
|
|
65
95
|
const t = {};
|
|
66
|
-
e.axis && (t.axis = e.axis), e.theme && (t.theme = e.theme), e.padding && (t.padding = e.padding), e.viewport && (t.viewport = e.viewport), e.interactive !== void 0 && (t.interactive = e.interactive), e.grid !== void 0 && (t.grid = e.grid),
|
|
67
|
-
}),
|
|
68
|
-
|
|
96
|
+
e.axis && (t.axis = e.axis), e.theme && (t.theme = e.theme), e.padding && (t.padding = e.padding), e.viewport && (t.viewport = e.viewport), e.interactive !== void 0 && (t.interactive = e.interactive), e.grid !== void 0 && (t.grid = e.grid), c !== void 0 && (t.perf = c), p && (t.onEdgeReached = p), e.animations !== void 0 && (t.animations = e.animations), M(t), a.value = new T(s.value, t), K(a.value), e.onReady?.(a.value), await g(), V();
|
|
97
|
+
}), I(() => {
|
|
98
|
+
f?.disconnect(), f = null, a.value?.destroy(), a.value = null;
|
|
69
99
|
}), d(
|
|
70
100
|
() => e.headerLayout,
|
|
71
101
|
async () => {
|
|
72
|
-
|
|
102
|
+
a.value && (await g(), V());
|
|
73
103
|
}
|
|
74
104
|
), d(
|
|
75
105
|
() => e.theme,
|
|
76
106
|
(t) => {
|
|
77
|
-
|
|
107
|
+
a.value && t && (a.value.setTheme(t), x.value = t);
|
|
78
108
|
}
|
|
79
109
|
), d(
|
|
80
110
|
() => e.axis,
|
|
81
111
|
(t) => {
|
|
82
|
-
|
|
112
|
+
a.value && t && a.value.setAxis(t);
|
|
83
113
|
},
|
|
84
114
|
{ deep: !0 }
|
|
85
115
|
), d(
|
|
86
116
|
() => e.grid?.visible,
|
|
87
117
|
() => {
|
|
88
|
-
|
|
118
|
+
a.value && e.grid !== void 0 && a.value.setGrid(e.grid);
|
|
89
119
|
}
|
|
90
120
|
);
|
|
91
|
-
let
|
|
121
|
+
let D = e.animations;
|
|
92
122
|
d(
|
|
93
123
|
() => e.animations,
|
|
94
124
|
async (t) => {
|
|
95
|
-
if (
|
|
96
|
-
|
|
125
|
+
if (z(t, D) || (D = t, !a.value || !s.value)) return;
|
|
126
|
+
a.value.destroy(), a.value = null, await g();
|
|
97
127
|
const i = {};
|
|
98
|
-
e.axis && (i.axis = e.axis), e.theme && (i.theme = e.theme), e.padding && (i.padding = e.padding), e.viewport && (i.viewport = e.viewport), e.interactive !== void 0 && (i.interactive = e.interactive), e.grid !== void 0 && (i.grid = e.grid),
|
|
128
|
+
e.axis && (i.axis = e.axis), e.theme && (i.theme = e.theme), e.padding && (i.padding = e.padding), e.viewport && (i.viewport = e.viewport), e.interactive !== void 0 && (i.interactive = e.interactive), e.grid !== void 0 && (i.grid = e.grid), c !== void 0 && (i.perf = c), p && (i.onEdgeReached = p), t !== void 0 && (i.animations = t), M(i), a.value = new T(s.value, i), K(a.value), e.onReady?.(a.value);
|
|
99
129
|
}
|
|
100
130
|
);
|
|
101
|
-
let
|
|
131
|
+
let h;
|
|
102
132
|
d(
|
|
103
|
-
() => [
|
|
133
|
+
() => [a.value, e.visibleRange],
|
|
104
134
|
async ([t, i]) => {
|
|
105
|
-
!t || i === void 0 ||
|
|
135
|
+
!t || i === void 0 || h !== void 0 && h.instance === t && z(h.spec, i) || (h = { instance: t, spec: i }, await g(), t.setVisibleRange(i));
|
|
106
136
|
},
|
|
107
137
|
{ immediate: !0 }
|
|
108
138
|
), d(
|
|
@@ -111,75 +141,75 @@ const X = { style: { display: "flex", "flex-direction": "row", flex: "1", "min-h
|
|
|
111
141
|
e.padding?.bottom,
|
|
112
142
|
typeof e.padding?.right == "object" ? e.padding.right.intervals : e.padding?.right,
|
|
113
143
|
typeof e.padding?.left == "object" ? e.padding.left.intervals : e.padding?.left,
|
|
114
|
-
|
|
144
|
+
L.value
|
|
115
145
|
],
|
|
116
|
-
|
|
117
|
-
);
|
|
118
|
-
const
|
|
119
|
-
const t =
|
|
120
|
-
return `position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 240px; overflow: hidden; background: ${e.gradient ? `linear-gradient(to bottom, ${i} 0%, ${
|
|
146
|
+
A
|
|
147
|
+
), d(() => [a.value, j.value, e.fade], $, { immediate: !0 });
|
|
148
|
+
const N = v(() => {
|
|
149
|
+
const t = x.value, [i, n] = t?.chartGradient ?? ["transparent", "transparent"], F = t?.background ?? "transparent";
|
|
150
|
+
return `position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 240px; overflow: hidden; background: ${e.gradient ? `linear-gradient(to bottom, ${i} 0%, ${F} 70%, ${n} 100%)` : F}`;
|
|
121
151
|
});
|
|
122
|
-
return (t, i) => (
|
|
123
|
-
style:
|
|
152
|
+
return (t, i) => (y(), m("div", {
|
|
153
|
+
style: q(N.value)
|
|
124
154
|
}, [
|
|
125
|
-
o("div",
|
|
126
|
-
o("div",
|
|
127
|
-
|
|
155
|
+
o("div", ae, [
|
|
156
|
+
o("div", oe, [
|
|
157
|
+
b.headerLayout === "inline" ? (y(), m("div", ne, [
|
|
128
158
|
o("div", {
|
|
129
159
|
ref_key: "titleAnchor",
|
|
130
|
-
ref:
|
|
160
|
+
ref: R,
|
|
131
161
|
"data-chart-title-anchor": ""
|
|
132
162
|
}, null, 512),
|
|
133
163
|
o("div", {
|
|
134
164
|
ref_key: "infoBarAnchor",
|
|
135
|
-
ref:
|
|
165
|
+
ref: k,
|
|
136
166
|
"data-tooltip-legend-anchor": ""
|
|
137
167
|
}, null, 512)
|
|
138
|
-
])) :
|
|
168
|
+
])) : w("", !0),
|
|
139
169
|
o("div", {
|
|
140
170
|
ref_key: "containerRef",
|
|
141
|
-
ref:
|
|
171
|
+
ref: s,
|
|
142
172
|
style: { position: "relative", flex: "1", "min-width": "0", "min-height": "0", overflow: "hidden" }
|
|
143
173
|
}, [
|
|
144
|
-
|
|
174
|
+
b.headerLayout === "overlay" ? (y(), m("div", {
|
|
145
175
|
key: 0,
|
|
146
176
|
ref_key: "topOverlayRef",
|
|
147
|
-
ref:
|
|
177
|
+
ref: C,
|
|
148
178
|
"data-chart-top-overlay": "",
|
|
149
179
|
style: { position: "absolute", top: "0", left: "0", right: "0", "z-index": "2", "pointer-events": "none", display: "flex", "flex-direction": "column" }
|
|
150
180
|
}, [
|
|
151
181
|
o("div", {
|
|
152
182
|
ref_key: "titleAnchor",
|
|
153
|
-
ref:
|
|
183
|
+
ref: R,
|
|
154
184
|
"data-chart-title-anchor": ""
|
|
155
185
|
}, null, 512),
|
|
156
186
|
o("div", {
|
|
157
187
|
ref_key: "infoBarAnchor",
|
|
158
|
-
ref:
|
|
188
|
+
ref: k,
|
|
159
189
|
"data-tooltip-legend-anchor": ""
|
|
160
190
|
}, null, 512)
|
|
161
|
-
], 512)) :
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
])) :
|
|
191
|
+
], 512)) : w("", !0),
|
|
192
|
+
a.value ? (y(), m("div", re, [
|
|
193
|
+
J(t.$slots, "default")
|
|
194
|
+
])) : w("", !0)
|
|
165
195
|
], 512)
|
|
166
196
|
]),
|
|
167
197
|
o("div", {
|
|
168
198
|
ref_key: "legendRightAnchor",
|
|
169
|
-
ref:
|
|
199
|
+
ref: E,
|
|
170
200
|
"data-legend-right-anchor": "",
|
|
171
201
|
style: { flex: "0 0 auto" }
|
|
172
202
|
}, null, 512)
|
|
173
203
|
]),
|
|
174
204
|
o("div", {
|
|
175
205
|
ref_key: "legendAnchor",
|
|
176
|
-
ref:
|
|
206
|
+
ref: _,
|
|
177
207
|
"data-legend-anchor": "",
|
|
178
208
|
style: { flex: "0 0 auto" }
|
|
179
209
|
}, null, 512),
|
|
180
210
|
o("div", {
|
|
181
211
|
ref_key: "navigatorAnchor",
|
|
182
|
-
ref:
|
|
212
|
+
ref: B,
|
|
183
213
|
"data-navigator-anchor": "",
|
|
184
214
|
style: { flex: "0 0 auto" }
|
|
185
215
|
}, null, 512)
|
|
@@ -187,5 +217,5 @@ const X = { style: { display: "flex", "flex-direction": "row", flex: "1", "min-h
|
|
|
187
217
|
}
|
|
188
218
|
});
|
|
189
219
|
export {
|
|
190
|
-
|
|
220
|
+
ce as default
|
|
191
221
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { spring as
|
|
1
|
+
import { spring as U } from "./spring.js";
|
|
2
2
|
import { resolveAnimationTime as r } from "./time.js";
|
|
3
|
-
import { hermite as
|
|
3
|
+
import { hermite as S } from "./y-range-hermite.js";
|
|
4
4
|
import { snap as u } from "./y-range-snap.js";
|
|
5
|
-
const
|
|
5
|
+
const E = 250, p = 250, h = 500, ss = 400, k = E, g = p, I = h, N = 600, R = E, v = p, Y = h, O = E, C = p, b = h, x = 600, P = 250, H = 600, K = 300, G = 200, B = 150, X = 250, _ = 2500, m = 500, $ = 100, w = 250, j = 250, V = 400, f = {
|
|
6
6
|
line: { entryMs: 0, smoothMs: 0, pulseMs: 0, introMs: 0 },
|
|
7
7
|
candlestick: { entryMs: 0, smoothMs: 0, introMs: 0 },
|
|
8
8
|
bar: { entryMs: 0, smoothMs: 0, introMs: 0 },
|
|
9
9
|
pie: { entryMs: 0, updateMs: 0 },
|
|
10
10
|
heatmap: { entryMs: 0, updateMs: 0 }
|
|
11
11
|
};
|
|
12
|
-
function
|
|
12
|
+
function q(i) {
|
|
13
13
|
if (i !== null && typeof i == "object")
|
|
14
14
|
return {
|
|
15
|
-
stickyMs: r(i.max,
|
|
15
|
+
stickyMs: r(i.max, _),
|
|
16
16
|
stickyFloorMs: r(i.min, m)
|
|
17
17
|
};
|
|
18
18
|
if (i === void 0)
|
|
19
|
-
return { stickyMs:
|
|
20
|
-
const e = r(i,
|
|
19
|
+
return { stickyMs: _, stickyFloorMs: m };
|
|
20
|
+
const e = r(i, _);
|
|
21
21
|
return { stickyMs: e, stickyFloorMs: e };
|
|
22
22
|
}
|
|
23
23
|
class y {
|
|
@@ -39,32 +39,33 @@ class y {
|
|
|
39
39
|
{
|
|
40
40
|
y: { curve: u(), settleMs: 0, stickyMs: 0, stickyFloorMs: 0, gestureMs: 0 },
|
|
41
41
|
x: { curve: u(), settleMs: 0, gestureMs: 0 },
|
|
42
|
-
ticksMs: 0
|
|
42
|
+
ticksMs: 0,
|
|
43
|
+
gridMs: 0
|
|
43
44
|
},
|
|
44
45
|
0,
|
|
45
|
-
|
|
46
|
+
f
|
|
46
47
|
);
|
|
47
|
-
const s = e === !0 || e === void 0 ? void 0 : e, t = s?.axis, M = t === !1 ? !1 : t?.y, o = t === !1 ? !1 : t?.x, n = t === !1 ? !1 : t?.ticks, a = s?.toggle, c = s?.series,
|
|
48
|
+
const s = e === !0 || e === void 0 ? void 0 : e, t = s?.axis, M = t === !1 ? !1 : t?.y, o = t === !1 ? !1 : t?.x, n = t === !1 ? !1 : t?.ticks, a = t === !1 ? !1 : t?.grid, l = s?.toggle, c = s?.series, T = M === !1 ? {
|
|
48
49
|
curve: u(),
|
|
49
50
|
settleMs: 0,
|
|
50
51
|
stickyMs: 0,
|
|
51
52
|
stickyFloorMs: 0,
|
|
52
53
|
gestureMs: 0
|
|
53
54
|
} : {
|
|
54
|
-
curve: M?.curve ??
|
|
55
|
-
settleMs: r(M?.settle,
|
|
56
|
-
...
|
|
57
|
-
gestureMs: r(M?.gesture,
|
|
58
|
-
},
|
|
55
|
+
curve: M?.curve ?? S(),
|
|
56
|
+
settleMs: r(M?.settle, X),
|
|
57
|
+
...q(M?.sticky),
|
|
58
|
+
gestureMs: r(M?.gesture, $)
|
|
59
|
+
}, A = o === !1 ? {
|
|
59
60
|
curve: u(),
|
|
60
61
|
settleMs: 0,
|
|
61
62
|
gestureMs: 0
|
|
62
63
|
} : {
|
|
63
|
-
curve: o?.curve ??
|
|
64
|
-
settleMs: r(o?.settle,
|
|
65
|
-
gestureMs: r(o?.gesture,
|
|
66
|
-
},
|
|
67
|
-
return new y({ y:
|
|
64
|
+
curve: o?.curve ?? U(),
|
|
65
|
+
settleMs: r(o?.settle, G),
|
|
66
|
+
gestureMs: r(o?.gesture, B)
|
|
67
|
+
}, L = n === !1 ? 0 : r(n, j), d = a === !1 ? 0 : r(a, V), D = r(l, w), F = z(c);
|
|
68
|
+
return new y({ y: T, x: A, ticksMs: L, gridMs: d }, D, F);
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* Per-renderer-type chart-level option payload — merged BEFORE user
|
|
@@ -105,8 +106,8 @@ class y {
|
|
|
105
106
|
overrides(e) {
|
|
106
107
|
const s = {};
|
|
107
108
|
if (e === "line") {
|
|
108
|
-
const { entryMs: n, smoothMs: a, pulseMs:
|
|
109
|
-
return n === 0 && (s.entryMs = 0), a === 0 && (s.smoothMs = 0),
|
|
109
|
+
const { entryMs: n, smoothMs: a, pulseMs: l, introMs: c } = this.series.line;
|
|
110
|
+
return n === 0 && (s.entryMs = 0), a === 0 && (s.smoothMs = 0), l === 0 && (s.pulseMs = 0), c === 0 && (s.introMs = 0), s;
|
|
110
111
|
}
|
|
111
112
|
if (e === "pie")
|
|
112
113
|
return this.series.pie.entryMs === 0 && (s.entryMs = 0), s;
|
|
@@ -120,53 +121,54 @@ class y {
|
|
|
120
121
|
return t === 0 && (s.entryMs = 0), M === 0 && (s.smoothMs = 0), o === 0 && (s.introMs = 0), s;
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
-
if (i === !1) return
|
|
124
|
+
function z(i) {
|
|
125
|
+
if (i === !1) return f;
|
|
125
126
|
const e = i?.line, s = i?.candlestick, t = i?.bar, M = i?.pie, o = i?.heatmap, n = e === !1 ? { entryMs: 0, smoothMs: 0, pulseMs: 0, introMs: 0 } : {
|
|
126
|
-
entryMs: r(e?.entry,
|
|
127
|
-
smoothMs: r(e?.smooth,
|
|
128
|
-
pulseMs: r(e?.pulse,
|
|
129
|
-
introMs: r(e?.intro,
|
|
127
|
+
entryMs: r(e?.entry, k),
|
|
128
|
+
smoothMs: r(e?.smooth, g),
|
|
129
|
+
pulseMs: r(e?.pulse, N),
|
|
130
|
+
introMs: r(e?.intro, I)
|
|
130
131
|
}, a = s === !1 ? { entryMs: 0, smoothMs: 0, introMs: 0 } : {
|
|
131
|
-
entryMs: r(s?.entry,
|
|
132
|
-
smoothMs: r(s?.smooth,
|
|
133
|
-
introMs: r(s?.intro,
|
|
134
|
-
},
|
|
135
|
-
entryMs: r(t?.entry,
|
|
136
|
-
smoothMs: r(t?.smooth,
|
|
137
|
-
introMs: r(t?.intro,
|
|
138
|
-
},
|
|
139
|
-
entryMs: r(M?.entry,
|
|
140
|
-
updateMs: r(M?.update,
|
|
141
|
-
},
|
|
142
|
-
entryMs: r(o?.entry,
|
|
143
|
-
updateMs: r(o?.update,
|
|
132
|
+
entryMs: r(s?.entry, R),
|
|
133
|
+
smoothMs: r(s?.smooth, v),
|
|
134
|
+
introMs: r(s?.intro, Y)
|
|
135
|
+
}, l = t === !1 ? { entryMs: 0, smoothMs: 0, introMs: 0 } : {
|
|
136
|
+
entryMs: r(t?.entry, O),
|
|
137
|
+
smoothMs: r(t?.smooth, C),
|
|
138
|
+
introMs: r(t?.intro, b)
|
|
139
|
+
}, c = M === !1 ? { entryMs: 0, updateMs: 0 } : {
|
|
140
|
+
entryMs: r(M?.entry, x),
|
|
141
|
+
updateMs: r(M?.update, P)
|
|
142
|
+
}, T = o === !1 ? { entryMs: 0, updateMs: 0 } : {
|
|
143
|
+
entryMs: r(o?.entry, H),
|
|
144
|
+
updateMs: r(o?.update, K)
|
|
144
145
|
};
|
|
145
|
-
return { line: n, candlestick: a, bar:
|
|
146
|
+
return { line: n, candlestick: a, bar: l, pie: c, heatmap: T };
|
|
146
147
|
}
|
|
147
148
|
export {
|
|
148
149
|
y as AnimationConfig,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
k as
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
150
|
+
O as DEFAULT_BAR_ENTRY,
|
|
151
|
+
b as DEFAULT_BAR_INTRO,
|
|
152
|
+
C as DEFAULT_BAR_SMOOTH,
|
|
153
|
+
R as DEFAULT_CANDLESTICK_ENTRY,
|
|
154
|
+
Y as DEFAULT_CANDLESTICK_INTRO,
|
|
155
|
+
v as DEFAULT_CANDLESTICK_SMOOTH,
|
|
156
|
+
V as DEFAULT_GRID_MS,
|
|
157
|
+
H as DEFAULT_HEATMAP_ENTRY,
|
|
158
|
+
K as DEFAULT_HEATMAP_UPDATE,
|
|
159
|
+
ss as DEFAULT_HISTORY_REVEAL,
|
|
160
|
+
k as DEFAULT_LINE_ENTRY,
|
|
161
|
+
I as DEFAULT_LINE_INTRO,
|
|
162
|
+
N as DEFAULT_LINE_PULSE,
|
|
163
|
+
g as DEFAULT_LINE_SMOOTH,
|
|
164
|
+
x as DEFAULT_PIE_ENTRY,
|
|
165
|
+
P as DEFAULT_PIE_UPDATE,
|
|
166
|
+
j as DEFAULT_TICKS_MS,
|
|
167
|
+
w as DEFAULT_TOGGLE_MS,
|
|
168
|
+
B as DEFAULT_X_GESTURE_MS,
|
|
169
|
+
G as DEFAULT_X_SETTLE_MS,
|
|
170
|
+
$ as DEFAULT_Y_GESTURE_MS,
|
|
171
|
+
X as DEFAULT_Y_SETTLE_MS,
|
|
172
|
+
_ as DEFAULT_Y_STICKY_MAX_MS,
|
|
171
173
|
m as DEFAULT_Y_STICKY_MIN_MS
|
|
172
174
|
};
|
|
@@ -1,68 +1,66 @@
|
|
|
1
1
|
import { easeOutCubic as h, easeInOutCubic as n } from "./easing.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { prefersReducedMotion as u } from "./reduced-motion.js";
|
|
3
|
+
class o {
|
|
4
|
+
#i = 0;
|
|
4
5
|
/** `null` = armed but awaiting the first tick to stamp the start. */
|
|
5
6
|
#t = null;
|
|
6
|
-
#
|
|
7
|
+
#s = !0;
|
|
7
8
|
/** Clock forwarded by the renderer's `tickAnimations` — keeps test
|
|
8
9
|
* harnesses (which stub `performance.now`) in control of progression. */
|
|
9
|
-
#
|
|
10
|
+
#r = 0;
|
|
10
11
|
/**
|
|
11
12
|
* Arm the wave for the upcoming first paint. No-op (stays settled) when
|
|
12
13
|
* the duration is zero/negative or the user prefers reduced motion.
|
|
13
14
|
*/
|
|
14
15
|
arm(t) {
|
|
15
16
|
if (t <= 0 || u()) {
|
|
16
|
-
this.#
|
|
17
|
+
this.#s = !0;
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
this.#
|
|
20
|
+
this.#i = t, this.#t = null, this.#s = !1;
|
|
20
21
|
}
|
|
21
22
|
/** True while the wave still has frames to produce. */
|
|
22
23
|
get active() {
|
|
23
|
-
return !this.#
|
|
24
|
+
return !this.#s;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Advance the clock. Call once per render pass, before any progress
|
|
27
28
|
* reads. Settles the wave once the full `2 × durationMs` window elapsed.
|
|
28
29
|
*/
|
|
29
30
|
tick(t) {
|
|
30
|
-
this.#
|
|
31
|
+
this.#s || (this.#r = t, this.#t === null && (this.#t = t), t - this.#t >= this.#i * 2 && (this.#s = !0));
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Eased entrance progress in `[0, 1]` for an element at normalized
|
|
34
35
|
* x-position `position` (0 = left edge of the visible window, 1 = right).
|
|
35
36
|
*/
|
|
36
37
|
progressAt(t) {
|
|
37
|
-
if (this.#
|
|
38
|
+
if (this.#s) return 1;
|
|
38
39
|
if (this.#t === null) return 0;
|
|
39
|
-
const
|
|
40
|
-
return h(
|
|
40
|
+
const r = i(t) * this.#i, e = i((this.#r - this.#t - r) / this.#i);
|
|
41
|
+
return h(e);
|
|
41
42
|
}
|
|
42
43
|
/** Eased reveal-front position in `[0, 1]` across the full wave window. */
|
|
43
44
|
sweep() {
|
|
44
|
-
if (this.#
|
|
45
|
+
if (this.#s) return 1;
|
|
45
46
|
if (this.#t === null) return 0;
|
|
46
|
-
const t =
|
|
47
|
+
const t = i((this.#r - this.#t) / (this.#i * 2));
|
|
47
48
|
return n(t);
|
|
48
49
|
}
|
|
49
50
|
/** Raw (unclamped-by-easing) linear wave progress — drives fades that need
|
|
50
51
|
* to key off wall-clock position, e.g. the line head-glow bell curve. */
|
|
51
52
|
linear() {
|
|
52
|
-
return this.#
|
|
53
|
+
return this.#s ? 1 : this.#t === null ? 0 : i((this.#r - this.#t) / (this.#i * 2));
|
|
53
54
|
}
|
|
54
55
|
/** Abort the wave — everything reads settled from the next frame. Called
|
|
55
56
|
* when the user pans/zooms mid-intro. */
|
|
56
57
|
finish() {
|
|
57
|
-
this.#
|
|
58
|
+
this.#s = !0;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
function s
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
function u() {
|
|
64
|
-
return typeof matchMedia != "function" ? !1 : matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
61
|
+
function i(s) {
|
|
62
|
+
return s <= 0 ? 0 : s >= 1 ? 1 : s;
|
|
65
63
|
}
|
|
66
64
|
export {
|
|
67
|
-
|
|
65
|
+
o as IntroWave
|
|
68
66
|
};
|