@wick-charts/vue 0.6.3 → 0.6.4
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 +2 -2
- package/dist/BandSeries.vue.js +50 -0
- package/dist/BandSeries.vue2.js +4 -0
- package/dist/ChartContainer.vue.js +16 -16
- package/dist/LineSeries.vue.js +2 -2
- package/dist/core/dist/animation/config.js +92 -75
- package/dist/core/dist/chart/badge-animator.js +30 -22
- package/dist/core/dist/chart/edge-indicators.js +22 -21
- package/dist/core/dist/chart/last-value.js +33 -26
- package/dist/core/dist/chart.js +168 -167
- package/dist/core/dist/data/decimation.js +58 -39
- package/dist/core/dist/navigator/controller.js +10 -10
- package/dist/core/dist/perf/perf-hud.js +6 -6
- package/dist/core/dist/series/band.js +670 -0
- package/dist/core/dist/series/bar.js +14 -14
- package/dist/core/dist/series/candlestick.js +31 -31
- package/dist/core/dist/series/heatmap.js +5 -5
- package/dist/core/dist/series/line-intro.js +47 -37
- package/dist/core/dist/series/line.js +485 -445
- package/dist/core/dist/series/painters/builtins.js +4 -4
- package/dist/core/dist/series/painters/canvas-path.js +64 -52
- package/dist/core/dist/series/register-builtins.js +9 -8
- package/dist/core/dist/snapshots.js +36 -35
- package/dist/core/dist/utils/point.js +10 -0
- package/dist/index.d.ts +255 -97
- package/dist/index.js +195 -191
- package/dist/ui/InfoBar.vue.js +100 -81
- package/dist/ui/Tooltip.vue.js +118 -91
- package/dist/ui/YLabel.vue.js +62 -69
- package/package.json +2 -2
- package/src/BandSeries.vue +87 -0
- package/src/index.ts +8 -0
- package/src/ui/InfoBar.vue +20 -1
- package/src/ui/Tooltip.vue +36 -2
- package/src/ui/YLabel.vue +2 -13
|
@@ -1,54 +1,73 @@
|
|
|
1
|
-
function D(t,
|
|
2
|
-
return t.length <=
|
|
1
|
+
function D(t, h) {
|
|
2
|
+
return t.length <= h ? t : v(
|
|
3
3
|
t,
|
|
4
|
-
|
|
4
|
+
h,
|
|
5
5
|
(l) => l.time,
|
|
6
6
|
(l) => l.value
|
|
7
7
|
);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (t.length <=
|
|
11
|
-
const l = Math.ceil(t.length /
|
|
12
|
-
for (let
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
for (let
|
|
16
|
-
t[
|
|
17
|
-
|
|
18
|
-
time: t[
|
|
19
|
-
open: t[
|
|
20
|
-
high:
|
|
21
|
-
low:
|
|
22
|
-
close: t[
|
|
23
|
-
volume:
|
|
9
|
+
function k(t, h) {
|
|
10
|
+
if (t.length <= h) return t;
|
|
11
|
+
const l = Math.ceil(t.length / h), u = [];
|
|
12
|
+
for (let o = 0; o < t.length; o += l) {
|
|
13
|
+
const n = Math.min(o + l, t.length);
|
|
14
|
+
let s = -1 / 0, i = 1 / 0, c = 0;
|
|
15
|
+
for (let r = o; r < n; r++)
|
|
16
|
+
t[r].high > s && (s = t[r].high), t[r].low < i && (i = t[r].low), c += t[r].volume ?? 0;
|
|
17
|
+
u.push({
|
|
18
|
+
time: t[o].time,
|
|
19
|
+
open: t[o].open,
|
|
20
|
+
high: s,
|
|
21
|
+
low: i,
|
|
22
|
+
close: t[n - 1].close,
|
|
23
|
+
volume: c
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return u;
|
|
27
27
|
}
|
|
28
|
-
function x(t,
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
function x(t, h) {
|
|
29
|
+
if (t.length <= h || h < 3) return t;
|
|
30
|
+
const l = t.length - 1, u = Math.ceil((t.length - 2) / (h - 2)), o = [t[0]];
|
|
31
|
+
for (let n = 1; n < l; n += u) {
|
|
32
|
+
const s = Math.min(n + u, l);
|
|
33
|
+
let i = 1 / 0, c = -1 / 0, r = !1;
|
|
34
|
+
for (let f = n; f < s; f++) {
|
|
35
|
+
const a = t[f];
|
|
36
|
+
if (!Number.isFinite(a.low) || !Number.isFinite(a.high)) {
|
|
37
|
+
r = !0;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
a.low < i && (i = a.low), a.high > c && (c = a.high);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
o.push(r ? { time: t[n].time, low: Number.NaN, high: Number.NaN } : { time: t[n].time, low: i, high: c });
|
|
43
|
+
}
|
|
44
|
+
return o.push(t[l]), o;
|
|
45
|
+
}
|
|
46
|
+
function v(t, h, l, u) {
|
|
47
|
+
if (h >= t.length || h < 3) return t;
|
|
48
|
+
const o = [t[0]], n = (t.length - 2) / (h - 2);
|
|
49
|
+
let s = 0;
|
|
50
|
+
for (let i = 0; i < h - 2; i++) {
|
|
51
|
+
const c = Math.floor((i + 1) * n) + 1, r = Math.min(Math.floor((i + 2) * n) + 1, t.length - 1);
|
|
52
|
+
let f = 0, a = 0;
|
|
53
|
+
const M = r, p = Math.min(Math.floor((i + 3) * n) + 1, t.length), g = p - M;
|
|
54
|
+
if (g > 0) {
|
|
55
|
+
for (let e = M; e < p; e++)
|
|
56
|
+
f += l(t[e]), a += u(t[e]);
|
|
57
|
+
f /= g, a /= g;
|
|
58
|
+
}
|
|
59
|
+
let w = -1, m = c;
|
|
60
|
+
const N = l(t[s]), b = u(t[s]);
|
|
61
|
+
for (let e = c; e < r; e++) {
|
|
62
|
+
const d = Math.abs((N - f) * (u(t[e]) - b) - (N - l(t[e])) * (a - b));
|
|
63
|
+
d > w && (w = d, m = e);
|
|
46
64
|
}
|
|
47
|
-
|
|
65
|
+
o.push(t[m]), s = m;
|
|
48
66
|
}
|
|
49
|
-
return
|
|
67
|
+
return o.push(t[t.length - 1]), o;
|
|
50
68
|
}
|
|
51
69
|
export {
|
|
70
|
+
x as decimateBandData,
|
|
52
71
|
D as decimateLineData,
|
|
53
|
-
|
|
72
|
+
k as decimateOHLCData
|
|
54
73
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_LINE_ENTRY as w } from "../animation/config.js";
|
|
2
2
|
import { XScale as T } from "../scales/x-scale.js";
|
|
3
|
-
import { YScale as
|
|
4
|
-
import { decimateCandles as
|
|
3
|
+
import { YScale as k } from "../scales/y-scale.js";
|
|
4
|
+
import { decimateCandles as R, decimateLinear as C } from "./decimate.js";
|
|
5
5
|
import { hitTest as b, computeSnapCenter as E, computePan as I, computeResize as $ } from "./interactions.js";
|
|
6
6
|
import { computeWindowGeometry as M, renderBackground as L, renderMiniCandlestick as V, renderMiniBar as N, renderMiniLine as P } from "./render.js";
|
|
7
7
|
import { Animator as S } from "../animation/animator.js";
|
|
@@ -22,7 +22,7 @@ class G {
|
|
|
22
22
|
// Own scales — both cover the full data span. The main chart's scales move
|
|
23
23
|
// with the viewport; these don't.
|
|
24
24
|
#u = new T();
|
|
25
|
-
#F = new
|
|
25
|
+
#F = new k();
|
|
26
26
|
#A = 0;
|
|
27
27
|
#m = 0;
|
|
28
28
|
#h = 1;
|
|
@@ -35,7 +35,7 @@ class G {
|
|
|
35
35
|
* `setData` (guards in-place mutation of a re-passed array); a buckets
|
|
36
36
|
* mismatch (resize) recomputes per entry.
|
|
37
37
|
*/
|
|
38
|
-
#
|
|
38
|
+
#k = /* @__PURE__ */ new Map();
|
|
39
39
|
/**
|
|
40
40
|
* Eases the alpha of the trailing bar/candle/line-segment from 0 → 1 over
|
|
41
41
|
* `DEFAULT_LINE_ENTRY` whenever {@link setData} reports a new last point
|
|
@@ -48,7 +48,7 @@ class G {
|
|
|
48
48
|
#o = null;
|
|
49
49
|
/** `time` of the last point we've ever seen — initialises after the first
|
|
50
50
|
* `setData`/render so the first paint doesn't trigger a fade-in. */
|
|
51
|
-
#
|
|
51
|
+
#R = null;
|
|
52
52
|
/** Series index in `lineSeriesList(data)` that owns the newest last-time,
|
|
53
53
|
* so the tail fade applies to the series that actually grew — not always
|
|
54
54
|
* the last entry in the stack. -1 for candlestick (single-series). */
|
|
@@ -76,7 +76,7 @@ class G {
|
|
|
76
76
|
}
|
|
77
77
|
setData(t) {
|
|
78
78
|
const e = F(t), i = e?.time ?? null;
|
|
79
|
-
if (i !== null && this.#
|
|
79
|
+
if (i !== null && this.#R !== null && i !== this.#R) {
|
|
80
80
|
const s = this.#o?.current ?? 0;
|
|
81
81
|
this.#o = new S({
|
|
82
82
|
initial: s,
|
|
@@ -85,7 +85,7 @@ class G {
|
|
|
85
85
|
lerp: (n, h, l) => n + (h - n) * l
|
|
86
86
|
}), this.#o.setTarget(1);
|
|
87
87
|
}
|
|
88
|
-
this.#
|
|
88
|
+
this.#R = i, this.#C = e?.seriesIndex ?? -1, this.#x = t, this.#k.clear(), this.#f();
|
|
89
89
|
}
|
|
90
90
|
setOptions(t) {
|
|
91
91
|
this.#v = t, this.#D(), this.#f();
|
|
@@ -254,7 +254,7 @@ class G {
|
|
|
254
254
|
this.#o !== null && (this.#o.tick(performance.now()), l = this.#o.current, this.#o.animating ? this.#f() : this.#o = null);
|
|
255
255
|
const r = Math.max(1, Math.round(this.#i)), a = this.#x;
|
|
256
256
|
if (a.type === "candlestick")
|
|
257
|
-
V(h, this.#q(a.points, r,
|
|
257
|
+
V(h, this.#q(a.points, r, R), l);
|
|
258
258
|
else {
|
|
259
259
|
const c = f(a), g = c.length === 1, d = this.#C >= 0 ? this.#C : c.length - 1;
|
|
260
260
|
for (let u = 0; u < c.length; u++) {
|
|
@@ -283,11 +283,11 @@ class G {
|
|
|
283
283
|
/** Decimate `points` into `buckets`, reusing the cached result while the
|
|
284
284
|
* source array ref and bucket count are unchanged. */
|
|
285
285
|
#q(t, e, i) {
|
|
286
|
-
const s = this.#
|
|
286
|
+
const s = this.#k.get(t);
|
|
287
287
|
if (s !== void 0 && s.buckets === e)
|
|
288
288
|
return s.result;
|
|
289
289
|
const n = i(t, e);
|
|
290
|
-
return this.#
|
|
290
|
+
return this.#k.set(t, { buckets: e, result: n }), n;
|
|
291
291
|
}
|
|
292
292
|
#G(t, e) {
|
|
293
293
|
if (e.to <= e.from) return;
|
|
@@ -10,7 +10,7 @@ function N(i) {
|
|
|
10
10
|
ownsMonitor: !e
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
const P = 100, z = 600, f = 250, F = 1e3 / 60, H = 1e3 / 120, m = 60, b = 4,
|
|
13
|
+
const P = 100, z = 600, f = 250, F = 1e3 / 60, H = 1e3 / 120, m = 60, b = 4, L = 34, S = 64, j = 24;
|
|
14
14
|
function I(i) {
|
|
15
15
|
let e = 0;
|
|
16
16
|
for (const t of i)
|
|
@@ -20,7 +20,7 @@ function I(i) {
|
|
|
20
20
|
function O(i) {
|
|
21
21
|
return -I(i) / 12;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const B = "#9aa6b6", c = "#5d6877", C = "#e8eef7", x = "#cdd6e2", y = "#3fd68f", V = "#f5c451", $ = "#f4756a", Y = "#5d6877", X = {
|
|
24
24
|
position: "absolute",
|
|
25
25
|
top: "8px",
|
|
26
26
|
right: "8px",
|
|
@@ -34,7 +34,7 @@ const V = "#9aa6b6", c = "#5d6877", C = "#e8eef7", x = "#cdd6e2", y = "#3fd68f",
|
|
|
34
34
|
border: "1px solid rgba(255, 255, 255, 0.09)",
|
|
35
35
|
borderRadius: "10px",
|
|
36
36
|
boxShadow: "0 10px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05)",
|
|
37
|
-
color:
|
|
37
|
+
color: B,
|
|
38
38
|
font: "10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
39
39
|
fontVariantNumeric: "tabular-nums",
|
|
40
40
|
letterSpacing: "0.02em",
|
|
@@ -50,7 +50,7 @@ function G(i) {
|
|
|
50
50
|
}`, i.head.appendChild(e);
|
|
51
51
|
}
|
|
52
52
|
function v(i) {
|
|
53
|
-
return i <= H ? y : i <= F ?
|
|
53
|
+
return i <= H ? y : i <= F ? V : $;
|
|
54
54
|
}
|
|
55
55
|
function A(i) {
|
|
56
56
|
return i >= 1e6 ? `${(i / 1e6).toFixed(1)}M` : i >= 1e4 ? `${(i / 1e3).toFixed(1)}k` : Math.round(i).toLocaleString("en-US");
|
|
@@ -233,7 +233,7 @@ class D {
|
|
|
233
233
|
}), this.element.insertBefore(this.sparkHost, this.element.firstChild)) : (Object.assign(this.sparkHost.style, {
|
|
234
234
|
position: "relative",
|
|
235
235
|
inset: "auto",
|
|
236
|
-
height: `${
|
|
236
|
+
height: `${L}px`,
|
|
237
237
|
marginTop: "7px",
|
|
238
238
|
borderRadius: "4px",
|
|
239
239
|
opacity: "1",
|
|
@@ -308,7 +308,7 @@ class D {
|
|
|
308
308
|
}
|
|
309
309
|
/** Keeps the plateau below the FPS number (mini) or the Y tick (strip). */
|
|
310
310
|
sparkPaddingTop() {
|
|
311
|
-
return this.mode === "mini" ?
|
|
311
|
+
return this.mode === "mini" ? j : 12;
|
|
312
312
|
}
|
|
313
313
|
/** Append one FPS sample to the sparkline chart and roll its window. */
|
|
314
314
|
appendSpark(e) {
|