@wick-charts/vue 0.8.1 → 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.
Files changed (38) hide show
  1. package/dist/BandSeries.vue.js +25 -24
  2. package/dist/BarSeries.vue.js +27 -26
  3. package/dist/CandlestickSeries.vue.js +25 -24
  4. package/dist/HeatmapSeries.vue.js +21 -20
  5. package/dist/LineSeries.vue.js +24 -23
  6. package/dist/PieSeries.vue.js +25 -24
  7. package/dist/composables.js +63 -36
  8. package/dist/core/dist/axis/dom-labels.js +64 -53
  9. package/dist/core/dist/chart/options.js +1 -1
  10. package/dist/core/dist/chart/y-target.js +38 -32
  11. package/dist/core/dist/chart.js +475 -439
  12. package/dist/core/dist/data/decimation.js +52 -51
  13. package/dist/core/dist/data/store.js +38 -20
  14. package/dist/core/dist/data/sync.js +80 -69
  15. package/dist/core/dist/perf/perf-hud.js +3 -3
  16. package/dist/core/dist/scales/tick-tracker.js +2 -1
  17. package/dist/core/dist/series/band.js +1 -1
  18. package/dist/core/dist/series/bar.js +240 -211
  19. package/dist/core/dist/series/base-multi-layer.js +267 -249
  20. package/dist/core/dist/series/candlestick.js +116 -116
  21. package/dist/core/dist/series/line.js +540 -455
  22. package/dist/core/dist/snapshots.js +96 -77
  23. package/dist/index.d.ts +22 -4
  24. package/dist/ui/InfoBar.vue.js +68 -68
  25. package/dist/ui/NumberFlow.vue.js +36 -27
  26. package/dist/ui/Tooltip.vue.js +127 -130
  27. package/package.json +2 -2
  28. package/src/BandSeries.vue +5 -3
  29. package/src/BarSeries.vue +5 -3
  30. package/src/CandlestickSeries.vue +5 -4
  31. package/src/ChartContainer.vue +1 -1
  32. package/src/HeatmapSeries.vue +5 -4
  33. package/src/LineSeries.vue +5 -3
  34. package/src/PieSeries.vue +6 -5
  35. package/src/composables.ts +64 -1
  36. package/src/ui/InfoBar.vue +11 -3
  37. package/src/ui/NumberFlow.vue +17 -3
  38. package/src/ui/Tooltip.vue +23 -12
@@ -1,77 +1,88 @@
1
- import { resolveAxisTextColor as X, resolveAxisFontSize as w } from "../theme/resolve.js";
2
- import { clamp as z } from "../utils/math.js";
3
- const E = 0.01;
4
- function D(A) {
5
- const { chart: n, container: F, axis: a, scale: x } = A, s = /* @__PURE__ */ new Map();
6
- let g = null, h = null;
7
- function c() {
8
- return n.getYScale(x);
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 m() {
11
- return n.getYScaleColumn(x)?.position ?? n.yAxisPosition;
10
+ function h() {
11
+ return o.getYScaleColumn(g)?.position ?? o.yAxisPosition;
12
12
  }
13
13
  function Y() {
14
- return a === "x" ? n.timeScale.niceTickValues(n.getDataInterval()) : { ticks: c().niceTickValues(), tickInterval: 0 };
14
+ return a === "x" ? o.timeScale.niceTickValues(o.getDataInterval()) : { ticks: f().niceTickValues(), tickInterval: 0 };
15
15
  }
16
- function S(t, o) {
17
- return a === "x" ? n.timeScale.formatX(t, o) : c().formatY(t);
16
+ function k(t, n) {
17
+ return a === "x" ? o.timeScale.formatX(t, n) : f().formatY(t);
18
18
  }
19
- function $(t, o) {
19
+ function b(t, n) {
20
20
  if (a === "x") {
21
- t.style.left = `${n.timeScale.timeToSnappedX(o)}px`, n.timeScale.getType() === "category" && (t.style.maxWidth = `${n.timeScale.barWidthMedia(1)}px`);
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 = `${c().valueToSnappedY(o)}px`;
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 v(t, o) {
27
- t.style.color = X(o, a), t.style.fontSize = `${w(o, a)}px`, t.style.fontFamily = o.typography.fontFamily;
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 d(t, o) {
30
- const i = o === "left" ? "left" : "right", e = o === "left" ? "right" : "left";
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 b(t, o) {
34
- const i = n.headerHeight;
35
- if (a !== "y" || i <= 0 || m() !== "left") return 1;
36
- const e = w(o, a), p = c().valueToSnappedY(t) - e / 2;
37
- return z((p - i + e) / e, 0, 1);
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 I(t, o, i) {
50
+ function X(t, n, i) {
40
51
  const e = document.createElement("span");
41
- return e.textContent = S(t, o), e.style.position = "absolute", e.style.userSelect = "none", v(e, i), e.style.willChange = "opacity", a === "x" ? (e.style.transform = "translateX(-50%)", e.style.whiteSpace = "nowrap", n.timeScale.getType() === "category" && (e.style.overflow = "hidden", e.style.textOverflow = "ellipsis")) : (d(e, m()), e.style.transform = "translateY(-50%)", e.style.fontVariantNumeric = "tabular-nums"), F.appendChild(e), e;
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 f() {
44
- const t = n.getTheme(), o = t !== g;
45
- g = t;
46
- const i = m(), e = a === "y" && i !== h;
47
- h = i;
48
- const p = a === "x" ? n.timeScale.tickTracker : c().tickTracker, { ticks: V, tickInterval: k } = Y();
49
- p.setCurrentTicks(V);
50
- const { entries: W } = p.snapshot(), C = /* @__PURE__ */ new Set();
51
- for (const { value: l, opacity: y } of W) {
52
- if (y <= E) continue;
53
- C.add(l);
54
- let r = s.get(l);
55
- if (r === void 0)
56
- r = I(l, k, t), s.set(l, r);
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 T = S(l, k);
59
- r.textContent !== T && (r.textContent = T), o && v(r, t), e && d(r, i);
69
+ const W = k(l, m);
70
+ s.textContent !== W && (s.textContent = W), n && C(s, t), e && w(s, i);
60
71
  }
61
- $(r, l), r.style.opacity = String(y * b(l, t));
72
+ b(s, l), s.style.opacity = String(d * V(l, t));
62
73
  }
63
- for (const [l, y] of s)
64
- C.has(l) || (y.remove(), s.delete(l));
74
+ for (const [l, d] of c)
75
+ T.has(l) || (d.remove(), c.delete(l));
65
76
  }
66
- function u() {
67
- n.getAnimationState().animating || f();
77
+ function p() {
78
+ o.getAnimationState().animating || y();
68
79
  }
69
- return f(), n.on("tickFrame", f), n.on("viewportChange", u), n.on("overlayChange", u), () => {
70
- n.off("tickFrame", f), n.off("viewportChange", u), n.off("overlayChange", u);
71
- for (const t of s.values()) t.remove();
72
- s.clear();
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
- D as mountAxisLabels
87
+ N as mountAxisLabels
77
88
  };
@@ -21,7 +21,7 @@ const e = {
21
21
  top: 20,
22
22
  bottom: 20,
23
23
  right: { intervals: 3 },
24
- left: { intervals: 0 }
24
+ left: { intervals: 0.5 }
25
25
  };
26
26
  function f(t) {
27
27
  return {
@@ -1,52 +1,58 @@
1
1
  import { isPlottableOn as c } from "../scales/y-scale.js";
2
- import { isTimeSeriesRenderer as d } from "../series/types.js";
3
- function b(n) {
4
- const { targetVisible: a, series: t, allValues: o, plottable: r } = n, e = r ? { plottable: r } : void 0;
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 || !d(l.renderer)) continue;
8
- const m = l.renderer.getValueRange(a.from, a.to, e);
9
- m && (r && !r(m.max) || (m.max > i && (i = m.max), m.min < s && (!r || r(m.min)) && (s = m.min), o?.push(m.min, m.max)));
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(n) {
14
- const { raw: a, bounds: t, allValues: o, transform: r } = n;
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, a.min, a.max, o, "min"),
18
- max: u(t.max, a.max, a.min, o, "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(a.min), max: r.forward(a.max) };
25
+ const e = { min: r.forward(n.min), max: r.forward(n.max) };
21
26
  return {
22
- min: f({ bound: t.min, raw: a, scaledRaw: e, allValues: o, side: "min", transform: r }),
23
- max: f({ bound: t.max, raw: a, scaledRaw: e, allValues: o, side: "max", transform: r })
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(n) {
27
- const { bound: a, raw: t, scaledRaw: o, allValues: r, side: e, transform: s } = n, i = e === "min" ? "max" : "min";
28
- if (typeof a == "string" && a !== "auto")
29
- return u(a, o[e], o[i], [], e);
30
- const l = u(a, t[e], t[i], r, e), m = c(s, l);
31
- return s.forward(m ? l : t[e]);
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 g(n, a) {
34
- return a === null ? n : { min: a.inverse(n.min), max: a.inverse(n.max) };
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(n, a, t, o, r) {
37
- if (n === void 0 || n === "auto") return a;
38
- if (typeof n == "number") return n;
39
- if (typeof n == "function") return n(o);
40
- const e = String(n).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);
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 - a) || Math.abs(a) || 1;
43
- return a + s * i * l * (r === "max" ? 1 : -1);
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 a;
50
+ return n;
46
51
  }
47
52
  export {
48
- b as computeTargetYRange,
49
- g as fromScaleSpace,
53
+ p as computeTargetYRange,
54
+ v as fromScaleSpace,
50
55
  u as resolveBound,
51
- w as resolveYTarget
56
+ g as resolveYTarget,
57
+ w as widenFlatRange
52
58
  };