@wick-charts/vue 0.6.4 → 0.8.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 +21 -7
- package/dist/BandSeries.vue.js +20 -18
- package/dist/BarSeries.vue.js +15 -13
- package/dist/CandlestickSeries.vue.js +31 -29
- package/dist/ChartContainer.vue.js +77 -70
- package/dist/LineSeries.vue.js +19 -17
- package/dist/composables.js +46 -36
- package/dist/core/dist/animation/viewport-engine.js +155 -96
- package/dist/core/dist/axis/dom-labels.js +56 -51
- package/dist/core/dist/chart/scale-guards.js +23 -5
- package/dist/core/dist/chart/x-guards.js +37 -0
- package/dist/core/dist/chart.js +1286 -843
- package/dist/core/dist/data/sync.js +37 -31
- package/dist/core/dist/navigator/controller.js +37 -37
- package/dist/core/dist/perf/perf-hud.js +3 -3
- package/dist/core/dist/scales/tick-tracker.js +2 -2
- package/dist/core/dist/scales/x-scale.js +167 -53
- package/dist/core/dist/scales/y-scale.js +36 -34
- package/dist/core/dist/series/band.js +266 -213
- package/dist/core/dist/series/bar.js +297 -291
- package/dist/core/dist/series/base-multi-layer.js +283 -237
- package/dist/core/dist/series/candlestick.js +1 -0
- package/dist/core/dist/series/line.js +21 -20
- package/dist/core/dist/snapshots.js +55 -43
- package/dist/index.d.ts +323 -58
- package/dist/index.js +9 -9
- package/dist/ui/Crosshair.vue.js +51 -27
- package/dist/ui/InfoBar.vue.js +37 -37
- package/dist/ui/Marker.vue.js +14 -11
- package/dist/ui/Navigator.vue.js +23 -23
- package/dist/ui/ReferenceLine.vue.js +19 -16
- package/dist/ui/Tooltip.vue.js +91 -86
- package/dist/ui/XAxis.vue.js +48 -0
- package/dist/ui/XAxis.vue2.js +4 -0
- package/dist/ui/YAxis.vue.js +44 -28
- package/dist/ui/YLabel.vue.js +78 -74
- package/package.json +9 -3
- package/src/BandSeries.vue +11 -6
- package/src/BarSeries.vue +13 -6
- package/src/CandlestickSeries.vue +9 -5
- package/src/ChartContainer.vue +20 -0
- package/src/LineSeries.vue +13 -6
- package/src/composables.ts +23 -4
- package/src/index.ts +8 -1
- package/src/ui/Crosshair.vue +41 -1
- package/src/ui/InfoBar.vue +2 -1
- package/src/ui/Marker.vue +5 -1
- package/src/ui/Navigator.vue +2 -1
- package/src/ui/ReferenceLine.vue +5 -1
- package/src/ui/Tooltip.vue +7 -4
- package/src/ui/{TimeAxis.vue → XAxis.vue} +18 -5
- package/src/ui/YAxis.vue +66 -12
- package/src/ui/YLabel.vue +35 -5
- package/dist/ui/TimeAxis.vue.js +0 -44
- package/dist/ui/TimeAxis.vue2.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_HISTORY_REVEAL as nt, DEFAULT_LINE_INTRO as lt, DEFAULT_LINE_PULSE as at, DEFAULT_LINE_SMOOTH as rt, DEFAULT_LINE_ENTRY as ht } from "../animation/config.js";
|
|
2
|
-
import { easeOutCubic as
|
|
2
|
+
import { easeOutCubic as $ } from "../animation/easing.js";
|
|
3
3
|
import { decimateLineData as q } from "../data/decimation.js";
|
|
4
4
|
import { hexToRgba as X } from "../utils/color.js";
|
|
5
5
|
import { lerp as N } from "../utils/math.js";
|
|
@@ -329,7 +329,7 @@ class Pt extends ut {
|
|
|
329
329
|
for (let h = 0; h < e.length; h++) {
|
|
330
330
|
const m = o[s + 1 + h];
|
|
331
331
|
if (!Number.isFinite(m.value)) return null;
|
|
332
|
-
const c =
|
|
332
|
+
const c = $(e[h].progress), x = i(m.time, m.value), n = this.axisLerp(r, x, c);
|
|
333
333
|
f.set(m.time, n), r = n;
|
|
334
334
|
}
|
|
335
335
|
return f;
|
|
@@ -490,7 +490,7 @@ class Pt extends ut {
|
|
|
490
490
|
if ((this.options.entryAnimation ?? "grow") !== "grow" || e !== m[m.length - 1]?.time || h.length === 0 || c < 0) return { x: f, y: r };
|
|
491
491
|
let x = s.timeToBitmapXExact(m[c].time);
|
|
492
492
|
for (let n = 0; n < h.length; n++)
|
|
493
|
-
x = N(x, s.timeToBitmapXExact(m[c + 1 + n].time),
|
|
493
|
+
x = N(x, s.timeToBitmapXExact(m[c + 1 + n].time), $(h[n].progress));
|
|
494
494
|
return { x, y: r };
|
|
495
495
|
}
|
|
496
496
|
/** Upper-edge vertex of layer `li` at column `t`, replayed from the last
|
|
@@ -519,7 +519,7 @@ class Pt extends ut {
|
|
|
519
519
|
for (let x = 0; x < e.length; x++) {
|
|
520
520
|
const n = o[s + 1 + x];
|
|
521
521
|
if (!r.isPlottable(n.value)) return null;
|
|
522
|
-
const p =
|
|
522
|
+
const p = $(e[x].progress), a = l.timeToBitmapXExact(n.time), g = r.valueToBitmapYExact(this.effectiveValue(t, i, n.time, n.value)), A = N(h, a, p), E = N(m, g, p);
|
|
523
523
|
c.set(n.time, { x: A, y: E }), h = A, m = E;
|
|
524
524
|
}
|
|
525
525
|
return c;
|
|
@@ -592,14 +592,14 @@ class Pt extends ut {
|
|
|
592
592
|
let a = this.stores[n].getVisibleData(l.from, l.to);
|
|
593
593
|
const g = i.mediaSize.width;
|
|
594
594
|
if (a.length > g * 2 && (a = q(a, Math.round(g * 1.5))), a.length < 2) continue;
|
|
595
|
-
const A = this.stores[n].last()?.value ?? a[a.length - 1].value, E = this.resolveLayerColor(n, A), B = this.buildThresholdPaint(t, E), L = a[a.length - 1], D = this.stores[n].last(), Y = D !== void 0 && L.time === D.time, z = Y ? this.entranceProgress(n, L.time) : 1, I = Y && m === "fade" && z < 1,
|
|
595
|
+
const A = this.stores[n].last()?.value ?? a[a.length - 1].value, E = this.resolveLayerColor(n, A), B = this.buildThresholdPaint(t, E), L = a[a.length - 1], D = this.stores[n].last(), Y = D !== void 0 && L.time === D.time, z = Y ? this.entranceProgress(n, L.time) : 1, I = Y && m === "fade" && z < 1, H = (Y ? this.trailingEndpoint(t, n) : null) ?? {
|
|
596
596
|
x: e.timeToBitmapXExact(L.time),
|
|
597
597
|
y: o.valueToBitmapYExact(this.effectiveValue(t, n, L.time, L.value))
|
|
598
|
-
}, W =
|
|
598
|
+
}, W = H.x, C = H.y, _ = Y && m === "grow" ? this.chainedTailPositions(t, n) : null, G = p < 1;
|
|
599
599
|
(G || I) && (s.save(), G && (s.globalAlpha *= p), I && (s.globalAlpha *= z));
|
|
600
|
-
const
|
|
600
|
+
const U = a.length - 1, u = [];
|
|
601
601
|
let v = null;
|
|
602
|
-
for (let d = 0; d <
|
|
602
|
+
for (let d = 0; d < U; d++) {
|
|
603
603
|
const S = a[d].value;
|
|
604
604
|
if (!o.isPlottable(S)) {
|
|
605
605
|
v = null;
|
|
@@ -614,7 +614,7 @@ class Pt extends ut {
|
|
|
614
614
|
v.push({ x: e.timeToBitmapXExact(a[d].time), y: F });
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
const M = a[
|
|
617
|
+
const M = a[U]?.value, b = Number.isFinite(W) && Number.isFinite(C) && o.isPlottable(M), P = m === "grow" && z < 1;
|
|
618
618
|
let T = null;
|
|
619
619
|
if (b && (v ? (v.push({ x: W, y: C }), T = v) : u.push([{ x: W, y: C }])), f && u.some((d) => d.length >= 2)) {
|
|
620
620
|
s.beginPath();
|
|
@@ -739,10 +739,10 @@ class Pt extends ut {
|
|
|
739
739
|
(!P || S > b) && (b = S), P = !0;
|
|
740
740
|
}
|
|
741
741
|
if (!P || b >= 1) break;
|
|
742
|
-
I.unshift(
|
|
742
|
+
I.unshift($(b));
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
|
-
const
|
|
745
|
+
const H = (u, v) => {
|
|
746
746
|
const M = v.length;
|
|
747
747
|
if (!(M === 0 || u.length < M + 1))
|
|
748
748
|
for (let b = 0; b < M; b++) {
|
|
@@ -759,23 +759,23 @@ class Pt extends ut {
|
|
|
759
759
|
_ = u;
|
|
760
760
|
break;
|
|
761
761
|
}
|
|
762
|
-
const G = C >= 0 ? this.getLayerAlpha(C) : 1,
|
|
762
|
+
const G = C >= 0 ? this.getLayerAlpha(C) : 1, U = n.map((u, v) => v === C ? Math.min(1, this.getLayerAlpha(v)) : 1);
|
|
763
763
|
for (let u = this.stores.length - 1; u >= 0; u--) {
|
|
764
764
|
const v = this.getLayerAlpha(u);
|
|
765
765
|
if (v <= 0) continue;
|
|
766
766
|
const M = this.stores[u].last()?.value ?? 0, b = this.resolveLayerColor(u, M), P = u === C, T = _ >= 0 && u === _ && G < 1, d = [];
|
|
767
767
|
for (let R = 0; R < a.length; R++) {
|
|
768
768
|
const V = u > 0 ? s.valueToBitmapYExact(D[u - 1][R]) : W;
|
|
769
|
-
let
|
|
770
|
-
P ?
|
|
769
|
+
let O = V;
|
|
770
|
+
P ? O = W : T && (O = V + (W - V) * (1 - G)), d.push([o.timeToBitmapXExact(a[R]), O]);
|
|
771
771
|
}
|
|
772
|
-
g === "grow" &&
|
|
772
|
+
g === "grow" && H(d, I);
|
|
773
773
|
const S = [];
|
|
774
774
|
for (let R = 0; R < a.length; R++) {
|
|
775
775
|
let V = s.valueToBitmapYExact(D[u][R]);
|
|
776
776
|
P && v < 1 && (V = W + (V - W) * v), S.push([o.timeToBitmapXExact(a[R]), V]);
|
|
777
777
|
}
|
|
778
|
-
g === "grow" &&
|
|
778
|
+
g === "grow" && H(S, I);
|
|
779
779
|
const w = st(S), F = tt(w, c, g === "grow" && I.length > 0), K = g === "fade" && z[u] < 1;
|
|
780
780
|
if (K && (l.save(), l.globalAlpha *= z[u]), this.options.area.visible && !this.introGhostPass) {
|
|
781
781
|
let R = S[0][1], V = d[0][1];
|
|
@@ -783,10 +783,10 @@ class Pt extends ut {
|
|
|
783
783
|
S[k][1] < R && (R = S[k][1]);
|
|
784
784
|
for (let k = 1; k < d.length; k++)
|
|
785
785
|
d[k][1] > V && (V = d[k][1]);
|
|
786
|
-
let
|
|
786
|
+
let O = X(b, 0.25);
|
|
787
787
|
if (V > R + 0.5) {
|
|
788
788
|
const k = l.createLinearGradient(0, R, 0, V);
|
|
789
|
-
k.addColorStop(0, X(b, 0.25)), k.addColorStop(1, X(b, 0.05)),
|
|
789
|
+
k.addColorStop(0, X(b, 0.25)), k.addColorStop(1, X(b, 0.05)), O = k;
|
|
790
790
|
}
|
|
791
791
|
if (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), P)
|
|
792
792
|
for (let k = d.length - 1; k >= 0; k--)
|
|
@@ -795,7 +795,7 @@ class Pt extends ut {
|
|
|
795
795
|
const k = st(d), ct = tt(k, c, g === "grow" && I.length > 0), Z = k[k.length - 1];
|
|
796
796
|
l.lineTo(Z.x, Z.y), gt(l, k, ct);
|
|
797
797
|
}
|
|
798
|
-
l.closePath(), l.fillStyle =
|
|
798
|
+
l.closePath(), l.fillStyle = O, l.fill();
|
|
799
799
|
}
|
|
800
800
|
const Q = h && v < 1;
|
|
801
801
|
if (Q && (l.save(), l.globalAlpha *= v), h && (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), l.strokeStyle = b, l.lineWidth = m, l.lineJoin = "round", l.lineCap = "round", l.stroke()), Q && l.restore(), this.options.points?.visible) {
|
|
@@ -804,7 +804,7 @@ class Pt extends ut {
|
|
|
804
804
|
}
|
|
805
805
|
K && l.restore();
|
|
806
806
|
}
|
|
807
|
-
this.stackedEdges = { times: a, cumulative: D, growChain: I, collapse:
|
|
807
|
+
this.stackedEdges = { times: a, cumulative: D, growChain: I, collapse: U };
|
|
808
808
|
}
|
|
809
809
|
/**
|
|
810
810
|
* Overlay hook: draws crosshair nearest-point dots and last-point pulse dots.
|
|
@@ -880,6 +880,7 @@ class Pt extends ut {
|
|
|
880
880
|
}
|
|
881
881
|
const Bt = {
|
|
882
882
|
type: "line",
|
|
883
|
+
xTypes: ["time", "numeric", "category"],
|
|
883
884
|
create: ({ theme: y, layerCount: t }, i) => new Pt(t, {
|
|
884
885
|
colors: t === 1 ? [y.line.color] : y.seriesColors.slice(0, t),
|
|
885
886
|
strokeWidth: y.line.width,
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { pointValue as
|
|
1
|
+
import { pointValue as m } from "./utils/point.js";
|
|
2
2
|
const f = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
function
|
|
3
|
+
function y(e, r) {
|
|
4
4
|
return f.get(e)?.get(r);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
|
|
6
|
+
function I(e, r, n) {
|
|
7
|
+
let o = f.get(e);
|
|
8
|
+
o || (o = /* @__PURE__ */ new Map(), f.set(e, o)), o.set(r, n);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
10
|
+
function g(e) {
|
|
11
|
+
const r = e.low !== void 0 && e.high !== void 0 ? { time: e.time, low: e.low, high: e.high } : { time: e.time, value: e.value };
|
|
12
|
+
return e.x !== void 0 && (r.x = e.x), r;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function h(e, r) {
|
|
14
15
|
if (r === "none" || e.length <= 1) return e;
|
|
15
16
|
const n = [...e];
|
|
16
|
-
return n.sort((
|
|
17
|
-
const
|
|
18
|
-
return r === "asc" ?
|
|
17
|
+
return n.sort((o, a) => {
|
|
18
|
+
const s = m(o.data), i = m(a.data);
|
|
19
|
+
return r === "asc" ? s - i : i - s;
|
|
19
20
|
}), n;
|
|
20
21
|
}
|
|
21
22
|
function u(e) {
|
|
@@ -29,31 +30,31 @@ function u(e) {
|
|
|
29
30
|
};
|
|
30
31
|
return Object.freeze(n);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
const n = r.sort ?? "none",
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
36
|
-
const
|
|
33
|
+
function S(e, r) {
|
|
34
|
+
const n = r.sort ?? "none", o = e.getOverlayVersion(), a = y(e, r.cacheKey);
|
|
35
|
+
if (a && a.version === o && a.time === r.time && a.sort === n)
|
|
36
|
+
return a.data;
|
|
37
|
+
const s = [];
|
|
37
38
|
for (const t of e.getSeriesIds()) {
|
|
38
39
|
if (!e.isSeriesVisible(t)) continue;
|
|
39
40
|
if (e.getSeriesLayers(t) !== null) {
|
|
40
41
|
const d = e.getLayerSnapshots(t, r.time);
|
|
41
42
|
if (!d) continue;
|
|
42
|
-
for (const
|
|
43
|
-
|
|
43
|
+
for (const l of d)
|
|
44
|
+
s.push(
|
|
44
45
|
u({
|
|
45
|
-
id: `${t}_layer${
|
|
46
|
+
id: `${t}_layer${l.layerIndex}`,
|
|
46
47
|
seriesId: t,
|
|
47
|
-
layerIndex:
|
|
48
|
-
label: e.getLayerLabel(t,
|
|
49
|
-
data:
|
|
50
|
-
color:
|
|
48
|
+
layerIndex: l.layerIndex,
|
|
49
|
+
label: e.getLayerLabel(t, l.layerIndex),
|
|
50
|
+
data: g(l),
|
|
51
|
+
color: l.color
|
|
51
52
|
})
|
|
52
53
|
);
|
|
53
54
|
continue;
|
|
54
55
|
}
|
|
55
56
|
const c = e.getDataAtTime(t, r.time);
|
|
56
|
-
c &&
|
|
57
|
+
c && s.push(
|
|
57
58
|
u({
|
|
58
59
|
id: t,
|
|
59
60
|
seriesId: t,
|
|
@@ -63,33 +64,43 @@ function p(e, r) {
|
|
|
63
64
|
})
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
|
-
const
|
|
67
|
-
return
|
|
67
|
+
const i = Object.freeze(h(s, n));
|
|
68
|
+
return I(e, r.cacheKey, { version: o, time: r.time, sort: n, data: i }), i;
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
const
|
|
70
|
+
function p(e, r) {
|
|
71
|
+
const { time: n, snapshots: o, interval: a } = r;
|
|
72
|
+
if (e.timeScale.getType() !== "numeric") return e.timeScale.formatX(n, a);
|
|
73
|
+
let s = n, i = Number.POSITIVE_INFINITY;
|
|
74
|
+
for (const t of o) {
|
|
75
|
+
const c = Math.abs(t.data.time - n), d = c === i && t.data.time <= s;
|
|
76
|
+
c > i || d || (i = c, s = t.data.time);
|
|
77
|
+
}
|
|
78
|
+
return e.timeScale.formatPointX(s, a);
|
|
79
|
+
}
|
|
80
|
+
function x(e, r) {
|
|
81
|
+
const n = r.sort ?? "none", o = e.getOverlayVersion(), a = y(e, r.cacheKey);
|
|
82
|
+
if (a && a.version === o && a.time === null && a.sort === n)
|
|
83
|
+
return a.data;
|
|
84
|
+
const s = [];
|
|
74
85
|
for (const t of e.getSeriesIds()) {
|
|
75
86
|
if (!e.isSeriesVisible(t)) continue;
|
|
76
87
|
const c = e.getLayerLastSnapshots(t);
|
|
77
88
|
if (c) {
|
|
78
|
-
for (const
|
|
79
|
-
|
|
89
|
+
for (const l of c)
|
|
90
|
+
s.push(
|
|
80
91
|
u({
|
|
81
|
-
id: `${t}_layer${
|
|
92
|
+
id: `${t}_layer${l.layerIndex}`,
|
|
82
93
|
seriesId: t,
|
|
83
|
-
layerIndex:
|
|
84
|
-
label: e.getLayerLabel(t,
|
|
85
|
-
data:
|
|
86
|
-
color:
|
|
94
|
+
layerIndex: l.layerIndex,
|
|
95
|
+
label: e.getLayerLabel(t, l.layerIndex),
|
|
96
|
+
data: g(l),
|
|
97
|
+
color: l.color
|
|
87
98
|
})
|
|
88
99
|
);
|
|
89
100
|
continue;
|
|
90
101
|
}
|
|
91
102
|
const d = e.getLastData(t);
|
|
92
|
-
d &&
|
|
103
|
+
d && s.push(
|
|
93
104
|
u({
|
|
94
105
|
id: t,
|
|
95
106
|
seriesId: t,
|
|
@@ -99,10 +110,11 @@ function S(e, r) {
|
|
|
99
110
|
})
|
|
100
111
|
);
|
|
101
112
|
}
|
|
102
|
-
const
|
|
103
|
-
return
|
|
113
|
+
const i = Object.freeze(h(s, n));
|
|
114
|
+
return I(e, r.cacheKey, { version: o, time: null, sort: n, data: i }), i;
|
|
104
115
|
}
|
|
105
116
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
S as buildHoverSnapshots,
|
|
118
|
+
x as buildLastSnapshots,
|
|
119
|
+
p as formatHeaderX
|
|
108
120
|
};
|