@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.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/dist/BandSeries.vue.js +50 -0
  3. package/dist/BandSeries.vue2.js +4 -0
  4. package/dist/ChartContainer.vue.js +16 -16
  5. package/dist/LineSeries.vue.js +2 -2
  6. package/dist/core/dist/animation/config.js +92 -75
  7. package/dist/core/dist/chart/badge-animator.js +30 -22
  8. package/dist/core/dist/chart/edge-indicators.js +22 -21
  9. package/dist/core/dist/chart/last-value.js +33 -26
  10. package/dist/core/dist/chart.js +168 -167
  11. package/dist/core/dist/data/decimation.js +58 -39
  12. package/dist/core/dist/navigator/controller.js +10 -10
  13. package/dist/core/dist/perf/perf-hud.js +6 -6
  14. package/dist/core/dist/series/band.js +670 -0
  15. package/dist/core/dist/series/bar.js +14 -14
  16. package/dist/core/dist/series/candlestick.js +31 -31
  17. package/dist/core/dist/series/heatmap.js +5 -5
  18. package/dist/core/dist/series/line-intro.js +47 -37
  19. package/dist/core/dist/series/line.js +485 -445
  20. package/dist/core/dist/series/painters/builtins.js +4 -4
  21. package/dist/core/dist/series/painters/canvas-path.js +64 -52
  22. package/dist/core/dist/series/register-builtins.js +9 -8
  23. package/dist/core/dist/snapshots.js +36 -35
  24. package/dist/core/dist/utils/point.js +10 -0
  25. package/dist/index.d.ts +255 -97
  26. package/dist/index.js +195 -191
  27. package/dist/ui/InfoBar.vue.js +100 -81
  28. package/dist/ui/Tooltip.vue.js +118 -91
  29. package/dist/ui/YLabel.vue.js +62 -69
  30. package/package.json +2 -2
  31. package/src/BandSeries.vue +87 -0
  32. package/src/index.ts +8 -0
  33. package/src/ui/InfoBar.vue +20 -1
  34. package/src/ui/Tooltip.vue +36 -2
  35. package/src/ui/YLabel.vue +2 -13
@@ -1,54 +1,73 @@
1
- function D(t, o) {
2
- return t.length <= o ? t : x(
1
+ function D(t, h) {
2
+ return t.length <= h ? t : v(
3
3
  t,
4
- o,
4
+ h,
5
5
  (l) => l.time,
6
6
  (l) => l.value
7
7
  );
8
8
  }
9
- function L(t, o) {
10
- if (t.length <= o) return t;
11
- const l = Math.ceil(t.length / o), c = [];
12
- for (let h = 0; h < t.length; h += l) {
13
- const s = Math.min(h + l, t.length);
14
- let r = -1 / 0, a = 1 / 0, f = 0;
15
- for (let n = h; n < s; n++)
16
- t[n].high > r && (r = t[n].high), t[n].low < a && (a = t[n].low), f += t[n].volume ?? 0;
17
- c.push({
18
- time: t[h].time,
19
- open: t[h].open,
20
- high: r,
21
- low: a,
22
- close: t[s - 1].close,
23
- volume: f
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 c;
26
+ return u;
27
27
  }
28
- function x(t, o, l, c) {
29
- if (o >= t.length || o < 3) return t;
30
- const h = [t[0]], s = (t.length - 2) / (o - 2);
31
- let r = 0;
32
- for (let a = 0; a < o - 2; a++) {
33
- const f = Math.floor((a + 1) * s) + 1, n = Math.min(Math.floor((a + 2) * s) + 1, t.length - 1);
34
- let u = 0, g = 0;
35
- const M = n, p = Math.min(Math.floor((a + 3) * s) + 1, t.length), e = p - M;
36
- if (e > 0) {
37
- for (let i = M; i < p; i++)
38
- u += l(t[i]), g += c(t[i]);
39
- u /= e, g /= e;
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
- let v = -1, m = f;
42
- const w = l(t[r]), b = c(t[r]);
43
- for (let i = f; i < n; i++) {
44
- const d = Math.abs((w - u) * (c(t[i]) - b) - (w - l(t[i])) * (g - b));
45
- d > v && (v = d, m = i);
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
- h.push(t[m]), r = m;
65
+ o.push(t[m]), s = m;
48
66
  }
49
- return h.push(t[t.length - 1]), h;
67
+ return o.push(t[t.length - 1]), o;
50
68
  }
51
69
  export {
70
+ x as decimateBandData,
52
71
  D as decimateLineData,
53
- L as decimateOHLCData
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 R } from "../scales/y-scale.js";
4
- import { decimateCandles as k, decimateLinear as C } from "./decimate.js";
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 R();
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
- #R = /* @__PURE__ */ new Map();
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
- #k = null;
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.#k !== null && i !== this.#k) {
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.#k = i, this.#C = e?.seriesIndex ?? -1, this.#x = t, this.#R.clear(), this.#f();
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, k), l);
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.#R.get(t);
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.#R.set(t, { buckets: e, result: n }), n;
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, j = 34, S = 64, L = 24;
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 V = "#9aa6b6", c = "#5d6877", C = "#e8eef7", x = "#cdd6e2", y = "#3fd68f", B = "#f5c451", $ = "#f4756a", Y = "#5d6877", X = {
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: V,
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 ? B : $;
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: `${j}px`,
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" ? L : 12;
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) {