@wick-charts/vue 0.6.4 → 0.7.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.
Files changed (55) hide show
  1. package/README.md +4 -4
  2. package/dist/BandSeries.vue.js +20 -18
  3. package/dist/BarSeries.vue.js +15 -13
  4. package/dist/CandlestickSeries.vue.js +31 -29
  5. package/dist/ChartContainer.vue.js +77 -70
  6. package/dist/LineSeries.vue.js +19 -17
  7. package/dist/composables.js +46 -36
  8. package/dist/core/dist/animation/viewport-engine.js +155 -96
  9. package/dist/core/dist/axis/dom-labels.js +56 -51
  10. package/dist/core/dist/chart/scale-guards.js +23 -5
  11. package/dist/core/dist/chart/x-guards.js +37 -0
  12. package/dist/core/dist/chart.js +1286 -843
  13. package/dist/core/dist/data/sync.js +37 -31
  14. package/dist/core/dist/navigator/controller.js +37 -37
  15. package/dist/core/dist/perf/perf-hud.js +3 -3
  16. package/dist/core/dist/scales/tick-tracker.js +2 -2
  17. package/dist/core/dist/scales/x-scale.js +167 -53
  18. package/dist/core/dist/scales/y-scale.js +36 -34
  19. package/dist/core/dist/series/band.js +266 -213
  20. package/dist/core/dist/series/bar.js +297 -291
  21. package/dist/core/dist/series/base-multi-layer.js +283 -237
  22. package/dist/core/dist/series/candlestick.js +1 -0
  23. package/dist/core/dist/series/line.js +21 -20
  24. package/dist/core/dist/snapshots.js +55 -43
  25. package/dist/index.d.ts +323 -58
  26. package/dist/index.js +9 -9
  27. package/dist/ui/Crosshair.vue.js +51 -27
  28. package/dist/ui/InfoBar.vue.js +37 -37
  29. package/dist/ui/Marker.vue.js +14 -11
  30. package/dist/ui/Navigator.vue.js +23 -23
  31. package/dist/ui/ReferenceLine.vue.js +19 -16
  32. package/dist/ui/Tooltip.vue.js +91 -86
  33. package/dist/ui/XAxis.vue.js +48 -0
  34. package/dist/ui/XAxis.vue2.js +4 -0
  35. package/dist/ui/YAxis.vue.js +44 -28
  36. package/dist/ui/YLabel.vue.js +78 -74
  37. package/package.json +2 -2
  38. package/src/BandSeries.vue +11 -6
  39. package/src/BarSeries.vue +13 -6
  40. package/src/CandlestickSeries.vue +9 -5
  41. package/src/ChartContainer.vue +20 -0
  42. package/src/LineSeries.vue +13 -6
  43. package/src/composables.ts +23 -4
  44. package/src/index.ts +8 -1
  45. package/src/ui/Crosshair.vue +41 -1
  46. package/src/ui/InfoBar.vue +2 -1
  47. package/src/ui/Marker.vue +5 -1
  48. package/src/ui/Navigator.vue +2 -1
  49. package/src/ui/ReferenceLine.vue +5 -1
  50. package/src/ui/Tooltip.vue +7 -4
  51. package/src/ui/{TimeAxis.vue → XAxis.vue} +18 -5
  52. package/src/ui/YAxis.vue +66 -12
  53. package/src/ui/YLabel.vue +35 -5
  54. package/dist/ui/TimeAxis.vue.js +0 -44
  55. package/dist/ui/TimeAxis.vue2.js +0 -4
@@ -650,6 +650,7 @@ function O(a, t, i) {
650
650
  }
651
651
  const zt = {
652
652
  type: "candlestick",
653
+ xTypes: ["time"],
653
654
  create: ({ theme: a }, t) => new xt(new lt(), {
654
655
  up: { ...a.candlestick.up },
655
656
  down: { ...a.candlestick.down },
@@ -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 U } from "../animation/easing.js";
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 = U(e[h].progress), x = i(m.time, m.value), n = this.axisLerp(r, x, 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), U(h[n].progress));
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 = U(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);
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, O = (Y ? this.trailingEndpoint(t, n) : null) ?? {
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 = O.x, C = O.y, _ = Y && m === "grow" ? this.chainedTailPositions(t, n) : null, G = p < 1;
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 $ = a.length - 1, u = [];
600
+ const U = a.length - 1, u = [];
601
601
  let v = null;
602
- for (let d = 0; d < $; 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[$]?.value, b = Number.isFinite(W) && Number.isFinite(C) && o.isPlottable(M), P = m === "grow" && z < 1;
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(U(b));
742
+ I.unshift($(b));
743
743
  }
744
744
  }
745
- const O = (u, v) => {
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, $ = n.map((u, v) => v === C ? Math.min(1, this.getLayerAlpha(v)) : 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 H = V;
770
- P ? H = W : T && (H = V + (W - V) * (1 - G)), d.push([o.timeToBitmapXExact(a[R]), H]);
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" && O(d, I);
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" && O(S, I);
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 H = X(b, 0.25);
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)), H = k;
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 = H, l.fill();
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 y } from "./utils/point.js";
1
+ import { pointValue as m } from "./utils/point.js";
2
2
  const f = /* @__PURE__ */ new WeakMap();
3
- function g(e, r) {
3
+ function y(e, r) {
4
4
  return f.get(e)?.get(r);
5
5
  }
6
- function h(e, r, n) {
7
- let a = f.get(e);
8
- a || (a = /* @__PURE__ */ new Map(), f.set(e, a)), a.set(r, n);
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 I(e) {
11
- return e.low !== void 0 && e.high !== void 0 ? { time: e.time, low: e.low, high: e.high } : { time: e.time, value: e.value };
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 b(e, r) {
14
+ function h(e, r) {
14
15
  if (r === "none" || e.length <= 1) return e;
15
16
  const n = [...e];
16
- return n.sort((a, s) => {
17
- const i = y(a.data), l = y(s.data);
18
- return r === "asc" ? i - l : l - i;
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 p(e, r) {
33
- const n = r.sort ?? "none", a = e.getOverlayVersion(), s = g(e, r.cacheKey);
34
- if (s && s.version === a && s.time === r.time && s.sort === n)
35
- return s.data;
36
- const i = [];
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 o of d)
43
- i.push(
43
+ for (const l of d)
44
+ s.push(
44
45
  u({
45
- id: `${t}_layer${o.layerIndex}`,
46
+ id: `${t}_layer${l.layerIndex}`,
46
47
  seriesId: t,
47
- layerIndex: o.layerIndex,
48
- label: e.getLayerLabel(t, o.layerIndex),
49
- data: I(o),
50
- color: o.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 && i.push(
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 l = Object.freeze(b(i, n));
67
- return h(e, r.cacheKey, { version: a, time: r.time, sort: n, data: l }), l;
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 S(e, r) {
70
- const n = r.sort ?? "none", a = e.getOverlayVersion(), s = g(e, r.cacheKey);
71
- if (s && s.version === a && s.time === null && s.sort === n)
72
- return s.data;
73
- const i = [];
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 o of c)
79
- i.push(
89
+ for (const l of c)
90
+ s.push(
80
91
  u({
81
- id: `${t}_layer${o.layerIndex}`,
92
+ id: `${t}_layer${l.layerIndex}`,
82
93
  seriesId: t,
83
- layerIndex: o.layerIndex,
84
- label: e.getLayerLabel(t, o.layerIndex),
85
- data: I(o),
86
- color: o.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 && i.push(
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 l = Object.freeze(b(i, n));
103
- return h(e, r.cacheKey, { version: a, time: null, sort: n, data: l }), l;
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
- p as buildHoverSnapshots,
107
- S as buildLastSnapshots
117
+ S as buildHoverSnapshots,
118
+ x as buildLastSnapshots,
119
+ p as formatHeaderX
108
120
  };