@wick-charts/vue 0.8.0 → 0.8.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 +2 -0
- package/dist/BandSeries.vue.js +43 -32
- package/dist/BarSeries.vue.js +44 -33
- package/dist/CandlestickSeries.vue.js +24 -23
- package/dist/ChartContainer.vue.js +1 -1
- package/dist/HeatmapSeries.vue.js +21 -20
- package/dist/LineSeries.vue.js +43 -32
- package/dist/PieSeries.vue.js +25 -24
- package/dist/composables.js +63 -36
- package/dist/core/dist/axis/dom-labels.js +64 -53
- package/dist/core/dist/chart/badge-animator.js +38 -28
- package/dist/core/dist/chart/options.js +1 -1
- package/dist/core/dist/chart/y-target.js +38 -32
- package/dist/core/dist/chart.js +852 -709
- package/dist/core/dist/data/decimation.js +52 -51
- package/dist/core/dist/data/store.js +38 -20
- package/dist/core/dist/data/sync.js +97 -59
- package/dist/core/dist/navigator/controller.js +11 -11
- package/dist/core/dist/perf/perf-hud.js +3 -3
- package/dist/core/dist/scales/tick-tracker.js +2 -1
- package/dist/core/dist/scales/time-ticks.js +99 -0
- package/dist/core/dist/scales/x-scale.js +33 -27
- package/dist/core/dist/series/band.js +83 -83
- package/dist/core/dist/series/bar.js +240 -211
- package/dist/core/dist/series/base-multi-layer.js +288 -240
- package/dist/core/dist/series/candlestick.js +168 -168
- package/dist/core/dist/series/line.js +545 -455
- package/dist/core/dist/snapshots.js +109 -86
- package/dist/core/dist/utils/point.js +4 -0
- package/dist/core/dist/utils/time.js +42 -26
- package/dist/index.d.ts +67 -28
- package/dist/ui/InfoBar.vue.js +69 -69
- package/dist/ui/NumberFlow.vue.js +36 -27
- package/dist/ui/Tooltip.vue.js +128 -131
- package/dist/ui/YLabel.vue.js +47 -47
- package/package.json +2 -2
- package/src/BandSeries.vue +20 -5
- package/src/BarSeries.vue +20 -5
- package/src/CandlestickSeries.vue +5 -4
- package/src/ChartContainer.vue +15 -9
- package/src/HeatmapSeries.vue +5 -4
- package/src/LineSeries.vue +20 -5
- package/src/PieSeries.vue +6 -5
- package/src/composables.ts +64 -1
- package/src/ui/InfoBar.vue +11 -3
- package/src/ui/NumberFlow.vue +17 -3
- package/src/ui/Tooltip.vue +23 -12
- package/src/ui/YLabel.vue +28 -27
|
@@ -1,77 +1,88 @@
|
|
|
1
|
-
import { resolveAxisTextColor as
|
|
2
|
-
import { clamp as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const { chart:
|
|
6
|
-
let
|
|
7
|
-
function
|
|
8
|
-
return
|
|
1
|
+
import { resolveAxisTextColor as P, resolveAxisFontSize as $ } from "../theme/resolve.js";
|
|
2
|
+
import { clamp as A } from "../utils/math.js";
|
|
3
|
+
const D = 0.01;
|
|
4
|
+
function N(F) {
|
|
5
|
+
const { chart: o, container: M, axis: a, scale: g } = F, c = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
let S = null, v = null;
|
|
7
|
+
function f() {
|
|
8
|
+
return o.getYScale(g);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function h() {
|
|
11
|
+
return o.getYScaleColumn(g)?.position ?? o.yAxisPosition;
|
|
12
12
|
}
|
|
13
13
|
function Y() {
|
|
14
|
-
return a === "x" ?
|
|
14
|
+
return a === "x" ? o.timeScale.niceTickValues(o.getDataInterval()) : { ticks: f().niceTickValues(), tickInterval: 0 };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return a === "x" ?
|
|
16
|
+
function k(t, n) {
|
|
17
|
+
return a === "x" ? o.timeScale.formatX(t, n) : f().formatY(t);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function b(t, n) {
|
|
20
20
|
if (a === "x") {
|
|
21
|
-
|
|
21
|
+
o.timeScale.getType() === "category" && (t.style.maxWidth = `${o.timeScale.barWidthMedia(1)}px`), t.style.left = `${z(t, o.timeScale.timeToSnappedX(n))}px`;
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
t.style.top = `${
|
|
24
|
+
t.style.top = `${f().valueToSnappedY(n)}px`;
|
|
25
|
+
}
|
|
26
|
+
function z(t, n) {
|
|
27
|
+
if (!(n >= 0 && n <= o.timeScale.getMediaWidth())) return n;
|
|
28
|
+
const i = I(t) / 2, e = i - o.getAxisColumnWidth("left"), r = o.timeScale.getMediaWidth() + o.getAxisColumnWidth("right") - i;
|
|
29
|
+
return e > r ? n : A(n, e, r);
|
|
25
30
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
31
|
+
function I(t) {
|
|
32
|
+
const { fontSize: n, fontFamily: i, maxWidth: e } = t.style, r = `${t.textContent ?? ""}|${n}|${i}|${e}`, u = x.get(t);
|
|
33
|
+
if (u !== void 0 && u.key === r) return u.width;
|
|
34
|
+
const m = t.offsetWidth;
|
|
35
|
+
return x.set(t, { key: r, width: m }), m;
|
|
28
36
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
37
|
+
function C(t, n) {
|
|
38
|
+
t.style.color = P(n, a), t.style.fontSize = `${$(n, a)}px`, t.style.fontFamily = n.typography.fontFamily;
|
|
39
|
+
}
|
|
40
|
+
function w(t, n) {
|
|
41
|
+
const i = n === "left" ? "left" : "right", e = n === "left" ? "right" : "left";
|
|
31
42
|
t.style[i] = "8px", t.style[e] = "";
|
|
32
43
|
}
|
|
33
|
-
function
|
|
34
|
-
const i =
|
|
35
|
-
if (a !== "y" || i <= 0 ||
|
|
36
|
-
const e =
|
|
37
|
-
return
|
|
44
|
+
function V(t, n) {
|
|
45
|
+
const i = o.headerHeight;
|
|
46
|
+
if (a !== "y" || i <= 0 || h() !== "left") return 1;
|
|
47
|
+
const e = $(n, a), r = f().valueToSnappedY(t) - e / 2;
|
|
48
|
+
return A((r - i + e) / e, 0, 1);
|
|
38
49
|
}
|
|
39
|
-
function
|
|
50
|
+
function X(t, n, i) {
|
|
40
51
|
const e = document.createElement("span");
|
|
41
|
-
return e.textContent =
|
|
52
|
+
return e.textContent = k(t, n), e.style.position = "absolute", e.style.userSelect = "none", C(e, i), e.style.willChange = "opacity", a === "x" ? (e.style.transform = "translateX(-50%)", e.style.whiteSpace = "nowrap", o.timeScale.getType() === "category" && (e.style.overflow = "hidden", e.style.textOverflow = "ellipsis")) : (w(e, h()), e.style.transform = "translateY(-50%)", e.style.fontVariantNumeric = "tabular-nums"), M.appendChild(e), e;
|
|
42
53
|
}
|
|
43
|
-
function
|
|
44
|
-
const t =
|
|
45
|
-
|
|
46
|
-
const i =
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const { entries:
|
|
51
|
-
for (const { value: l, opacity:
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
56
|
-
|
|
54
|
+
function y() {
|
|
55
|
+
const t = o.getTheme(), n = t !== S;
|
|
56
|
+
S = t;
|
|
57
|
+
const i = h(), e = a === "y" && i !== v;
|
|
58
|
+
v = i;
|
|
59
|
+
const r = a === "x" ? o.timeScale.tickTracker : f().tickTracker, { ticks: u, tickInterval: m } = Y();
|
|
60
|
+
r.setCurrentTicks(u);
|
|
61
|
+
const { entries: E } = r.snapshot(), T = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const { value: l, opacity: d } of E) {
|
|
63
|
+
if (d <= D) continue;
|
|
64
|
+
T.add(l);
|
|
65
|
+
let s = c.get(l);
|
|
66
|
+
if (s === void 0)
|
|
67
|
+
s = X(l, m, t), c.set(l, s);
|
|
57
68
|
else {
|
|
58
|
-
const
|
|
59
|
-
|
|
69
|
+
const W = k(l, m);
|
|
70
|
+
s.textContent !== W && (s.textContent = W), n && C(s, t), e && w(s, i);
|
|
60
71
|
}
|
|
61
|
-
|
|
72
|
+
b(s, l), s.style.opacity = String(d * V(l, t));
|
|
62
73
|
}
|
|
63
|
-
for (const [l,
|
|
64
|
-
|
|
74
|
+
for (const [l, d] of c)
|
|
75
|
+
T.has(l) || (d.remove(), c.delete(l));
|
|
65
76
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
77
|
+
function p() {
|
|
78
|
+
o.getAnimationState().animating || y();
|
|
68
79
|
}
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
for (const t of
|
|
72
|
-
|
|
80
|
+
return y(), o.on("tickFrame", y), o.on("viewportChange", p), o.on("overlayChange", p), () => {
|
|
81
|
+
o.off("tickFrame", y), o.off("viewportChange", p), o.off("overlayChange", p);
|
|
82
|
+
for (const t of c.values()) t.remove();
|
|
83
|
+
c.clear();
|
|
73
84
|
};
|
|
74
85
|
}
|
|
75
86
|
export {
|
|
76
|
-
|
|
87
|
+
N as mountAxisLabels
|
|
77
88
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScalarSpring as g } from "../animation/scalar-spring.js";
|
|
2
|
-
const
|
|
2
|
+
const u = 320, m = 0.15;
|
|
3
3
|
class b {
|
|
4
4
|
#t;
|
|
5
5
|
#e;
|
|
@@ -8,53 +8,63 @@ class b {
|
|
|
8
8
|
this.#t = new g(i), this.#e = i;
|
|
9
9
|
}
|
|
10
10
|
frame(i) {
|
|
11
|
-
const { target: t, firstVisible:
|
|
12
|
-
if (
|
|
13
|
-
return this.#t.snap(t, { now:
|
|
11
|
+
const { target: t, firstVisible: s, introFront: r, now: n, glide: a = !0, countUp: l = !0, reducedMotion: f = !1 } = i;
|
|
12
|
+
if (f || !a && !l)
|
|
13
|
+
return this.#t.snap(t, { now: n }), this.#e = t, this.#i = !0, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
|
|
14
14
|
if (r < 1) {
|
|
15
|
-
const
|
|
16
|
-
return this.#t.snap(o, { now:
|
|
15
|
+
const p = s + (t - s) * r, o = l ? p : t;
|
|
16
|
+
return this.#t.snap(o, { now: n }), this.#e = o, this.#i = !0, { positionValue: o, textValue: o, opacity: this.#n(r), animating: !0 };
|
|
17
17
|
}
|
|
18
18
|
if (!this.#i)
|
|
19
|
-
return this.#t.snap(t, { now:
|
|
19
|
+
return this.#t.snap(t, { now: n }), this.#e = t, this.#i = !0, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
|
|
20
20
|
if (!a)
|
|
21
|
-
return this.#t.snap(t, { now:
|
|
22
|
-
const c = i.settleMs ??
|
|
21
|
+
return this.#t.snap(t, { now: n }), this.#e = t, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
|
|
22
|
+
const c = i.settleMs ?? u;
|
|
23
23
|
if (c <= 0)
|
|
24
|
-
return this.#t.snap(t, { now:
|
|
25
|
-
Math.abs(t - this.#e) >
|
|
26
|
-
const
|
|
27
|
-
return { positionValue: this.#t.current, textValue: t, opacity: 1, animating:
|
|
24
|
+
return this.#t.snap(t, { now: n }), this.#e = t, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
|
|
25
|
+
Math.abs(t - this.#e) > y && (this.#t.retarget(t, { now: n, settleMs: c }), this.#e = t);
|
|
26
|
+
const h = this.#t.tick(n);
|
|
27
|
+
return { positionValue: this.#t.current, textValue: t, opacity: 1, animating: h };
|
|
28
28
|
}
|
|
29
|
-
#
|
|
30
|
-
return i >= 1 ? 1 :
|
|
29
|
+
#n(i) {
|
|
30
|
+
return i >= 1 ? 1 : V(i / m);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const y = 1e-9;
|
|
34
|
+
function V(e) {
|
|
35
35
|
return e <= 0 ? 0 : e >= 1 ? 1 : e;
|
|
36
36
|
}
|
|
37
37
|
function w(e) {
|
|
38
|
-
return e === !1 ? { glide: !1, countUp: !1, settleMs: 0 } : e === void 0 || e === !0 ? { glide: !0, countUp: !0, settleMs:
|
|
38
|
+
return e === !1 ? { glide: !1, countUp: !1, settleMs: 0 } : e === void 0 || e === !0 ? { glide: !0, countUp: !0, settleMs: u } : {
|
|
39
39
|
glide: e.glide ?? !0,
|
|
40
40
|
countUp: e.countUp ?? !0,
|
|
41
|
-
settleMs: e.settleMs ??
|
|
41
|
+
settleMs: e.settleMs ?? u
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const d = 20;
|
|
45
|
+
function x(e) {
|
|
46
|
+
if (!(e > 0)) return 6;
|
|
47
|
+
if (e >= 1e3) return 0;
|
|
48
|
+
if (e >= 10) return 2;
|
|
49
|
+
if (e >= 0.1) return 4;
|
|
50
|
+
const i = Math.ceil(-Math.log10(e));
|
|
51
|
+
return Math.min(d, Math.max(6, i + 2));
|
|
47
52
|
}
|
|
48
|
-
function S(e, i) {
|
|
53
|
+
function S(e, i, t) {
|
|
54
|
+
const { from: s } = e.getVisibleRange();
|
|
55
|
+
return e.getStackedValueAtTime(i, s) ?? t;
|
|
56
|
+
}
|
|
57
|
+
function v(e, i) {
|
|
49
58
|
if (i !== void 0) return i;
|
|
50
|
-
const t = new Set(e.getSeriesIdsByType("band")),
|
|
59
|
+
const t = new Set(e.getSeriesIdsByType("band")), s = (a) => !t.has(a), r = e.getSeriesIdsByType("time", { visibleOnly: !0, singleLayerOnly: !0 }).filter(s);
|
|
51
60
|
if (r.length > 0) return r[0];
|
|
52
|
-
const
|
|
53
|
-
return
|
|
61
|
+
const n = e.getSeriesIdsByType("time", { visibleOnly: !0 }).filter(s);
|
|
62
|
+
return n.length > 0 ? n[0] : null;
|
|
54
63
|
}
|
|
55
64
|
export {
|
|
56
65
|
b as BadgeAnimator,
|
|
57
|
-
|
|
66
|
+
S as firstVisibleValue,
|
|
58
67
|
w as resolveAnimate,
|
|
59
|
-
|
|
68
|
+
v as resolveYLabelSeriesId,
|
|
69
|
+
x as yLabelFractionDigits
|
|
60
70
|
};
|
|
@@ -1,52 +1,58 @@
|
|
|
1
1
|
import { isPlottableOn as c } from "../scales/y-scale.js";
|
|
2
|
-
import { isTimeSeriesRenderer as
|
|
3
|
-
function
|
|
4
|
-
const { targetVisible:
|
|
2
|
+
import { isTimeSeriesRenderer as x } from "../series/types.js";
|
|
3
|
+
function p(a) {
|
|
4
|
+
const { targetVisible: n, series: t, allValues: m, plottable: r } = a, e = r ? { plottable: r } : void 0;
|
|
5
5
|
let s = 1 / 0, i = -1 / 0;
|
|
6
6
|
for (const l of t) {
|
|
7
|
-
if (!l.visible || !
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
if (!l.visible || !x(l.renderer)) continue;
|
|
8
|
+
const o = l.renderer.getValueRange(n.from, n.to, e);
|
|
9
|
+
o && (r && !r(o.max) || (o.max > i && (i = o.max), o.min < s && (!r || r(o.min)) && (s = o.min), m?.push(o.min, o.max)));
|
|
10
10
|
}
|
|
11
11
|
return i === -1 / 0 ? null : (s === 1 / 0 && (s = i), { min: s, max: i });
|
|
12
12
|
}
|
|
13
|
-
function w(
|
|
14
|
-
|
|
13
|
+
function w(a) {
|
|
14
|
+
if (a.max !== a.min) return a;
|
|
15
|
+
const n = a.min === 0 ? 1 : Math.abs(a.min) * 0.05;
|
|
16
|
+
return { min: a.min - n, max: a.max + n };
|
|
17
|
+
}
|
|
18
|
+
function g(a) {
|
|
19
|
+
const { raw: n, bounds: t, allValues: m, transform: r } = a;
|
|
15
20
|
if (r === null)
|
|
16
21
|
return {
|
|
17
|
-
min: u(t.min,
|
|
18
|
-
max: u(t.max,
|
|
22
|
+
min: u(t.min, n.min, n.max, m, "min"),
|
|
23
|
+
max: u(t.max, n.max, n.min, m, "max")
|
|
19
24
|
};
|
|
20
|
-
const e = { min: r.forward(
|
|
25
|
+
const e = { min: r.forward(n.min), max: r.forward(n.max) };
|
|
21
26
|
return {
|
|
22
|
-
min: f({ bound: t.min, raw:
|
|
23
|
-
max: f({ bound: t.max, raw:
|
|
27
|
+
min: f({ bound: t.min, raw: n, scaledRaw: e, allValues: m, side: "min", transform: r }),
|
|
28
|
+
max: f({ bound: t.max, raw: n, scaledRaw: e, allValues: m, side: "max", transform: r })
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
|
-
function f(
|
|
27
|
-
const { bound:
|
|
28
|
-
if (typeof
|
|
29
|
-
return u(
|
|
30
|
-
const l = u(
|
|
31
|
-
return s.forward(
|
|
31
|
+
function f(a) {
|
|
32
|
+
const { bound: n, raw: t, scaledRaw: m, allValues: r, side: e, transform: s } = a, i = e === "min" ? "max" : "min";
|
|
33
|
+
if (typeof n == "string" && n !== "auto")
|
|
34
|
+
return u(n, m[e], m[i], [], e);
|
|
35
|
+
const l = u(n, t[e], t[i], r, e), o = c(s, l);
|
|
36
|
+
return s.forward(o ? l : t[e]);
|
|
32
37
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
38
|
+
function v(a, n) {
|
|
39
|
+
return n === null ? a : { min: n.inverse(a.min), max: n.inverse(a.max) };
|
|
35
40
|
}
|
|
36
|
-
function u(
|
|
37
|
-
if (
|
|
38
|
-
if (typeof
|
|
39
|
-
if (typeof
|
|
40
|
-
const e = String(
|
|
41
|
+
function u(a, n, t, m, r) {
|
|
42
|
+
if (a === void 0 || a === "auto") return n;
|
|
43
|
+
if (typeof a == "number") return a;
|
|
44
|
+
if (typeof a == "function") return a(m);
|
|
45
|
+
const e = String(a).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);
|
|
41
46
|
if (e) {
|
|
42
|
-
const s = e[1] === "-" ? -1 : 1, i = parseFloat(e[2]) / 100, l = Math.abs(t -
|
|
43
|
-
return
|
|
47
|
+
const s = e[1] === "-" ? -1 : 1, i = parseFloat(e[2]) / 100, l = Math.abs(t - n) || Math.abs(n) || 1;
|
|
48
|
+
return n + s * i * l * (r === "max" ? 1 : -1);
|
|
44
49
|
}
|
|
45
|
-
return
|
|
50
|
+
return n;
|
|
46
51
|
}
|
|
47
52
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
p as computeTargetYRange,
|
|
54
|
+
v as fromScaleSpace,
|
|
50
55
|
u as resolveBound,
|
|
51
|
-
|
|
56
|
+
g as resolveYTarget,
|
|
57
|
+
w as widenFlatRange
|
|
52
58
|
};
|