@wick-charts/vue 0.6.3 → 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 (67) hide show
  1. package/README.md +6 -6
  2. package/dist/BandSeries.vue.js +52 -0
  3. package/dist/BandSeries.vue2.js +4 -0
  4. package/dist/BarSeries.vue.js +15 -13
  5. package/dist/CandlestickSeries.vue.js +31 -29
  6. package/dist/ChartContainer.vue.js +75 -68
  7. package/dist/LineSeries.vue.js +19 -17
  8. package/dist/composables.js +46 -36
  9. package/dist/core/dist/animation/config.js +92 -75
  10. package/dist/core/dist/animation/viewport-engine.js +155 -96
  11. package/dist/core/dist/axis/dom-labels.js +56 -51
  12. package/dist/core/dist/chart/badge-animator.js +30 -22
  13. package/dist/core/dist/chart/edge-indicators.js +22 -21
  14. package/dist/core/dist/chart/last-value.js +33 -26
  15. package/dist/core/dist/chart/scale-guards.js +23 -5
  16. package/dist/core/dist/chart/x-guards.js +37 -0
  17. package/dist/core/dist/chart.js +1286 -842
  18. package/dist/core/dist/data/decimation.js +58 -39
  19. package/dist/core/dist/data/sync.js +37 -31
  20. package/dist/core/dist/navigator/controller.js +41 -41
  21. package/dist/core/dist/perf/perf-hud.js +3 -3
  22. package/dist/core/dist/scales/tick-tracker.js +2 -2
  23. package/dist/core/dist/scales/x-scale.js +167 -53
  24. package/dist/core/dist/scales/y-scale.js +36 -34
  25. package/dist/core/dist/series/band.js +723 -0
  26. package/dist/core/dist/series/bar.js +297 -291
  27. package/dist/core/dist/series/base-multi-layer.js +283 -237
  28. package/dist/core/dist/series/candlestick.js +32 -31
  29. package/dist/core/dist/series/heatmap.js +5 -5
  30. package/dist/core/dist/series/line-intro.js +47 -37
  31. package/dist/core/dist/series/line.js +489 -448
  32. package/dist/core/dist/series/painters/builtins.js +4 -4
  33. package/dist/core/dist/series/painters/canvas-path.js +64 -52
  34. package/dist/core/dist/series/register-builtins.js +9 -8
  35. package/dist/core/dist/snapshots.js +59 -46
  36. package/dist/core/dist/utils/point.js +10 -0
  37. package/dist/index.d.ts +552 -129
  38. package/dist/index.js +195 -191
  39. package/dist/ui/Crosshair.vue.js +51 -27
  40. package/dist/ui/InfoBar.vue.js +98 -79
  41. package/dist/ui/Marker.vue.js +14 -11
  42. package/dist/ui/Navigator.vue.js +23 -23
  43. package/dist/ui/ReferenceLine.vue.js +19 -16
  44. package/dist/ui/Tooltip.vue.js +116 -84
  45. package/dist/ui/XAxis.vue.js +48 -0
  46. package/dist/ui/XAxis.vue2.js +4 -0
  47. package/dist/ui/YAxis.vue.js +44 -28
  48. package/dist/ui/YLabel.vue.js +82 -85
  49. package/package.json +2 -2
  50. package/src/BandSeries.vue +92 -0
  51. package/src/BarSeries.vue +13 -6
  52. package/src/CandlestickSeries.vue +9 -5
  53. package/src/ChartContainer.vue +20 -0
  54. package/src/LineSeries.vue +13 -6
  55. package/src/composables.ts +23 -4
  56. package/src/index.ts +16 -1
  57. package/src/ui/Crosshair.vue +41 -1
  58. package/src/ui/InfoBar.vue +22 -2
  59. package/src/ui/Marker.vue +5 -1
  60. package/src/ui/Navigator.vue +2 -1
  61. package/src/ui/ReferenceLine.vue +5 -1
  62. package/src/ui/Tooltip.vue +43 -6
  63. package/src/ui/{TimeAxis.vue → XAxis.vue} +18 -5
  64. package/src/ui/YAxis.vue +66 -12
  65. package/src/ui/YLabel.vue +37 -18
  66. package/dist/ui/TimeAxis.vue.js +0 -44
  67. package/dist/ui/TimeAxis.vue2.js +0 -4
@@ -1,62 +1,68 @@
1
- import { defineComponent as V, computed as n, inject as B, ref as N, onMounted as T, onUnmounted as W, useSlots as A, unref as e, openBlock as l, createBlock as O, Teleport as D, createElementVNode as i, normalizeStyle as s, renderSlot as M, createElementBlock as u, Fragment as p, toDisplayString as m, renderList as _, createCommentVNode as F } from "vue";
2
- import { buildHoverSnapshots as P, buildLastSnapshots as R } from "../core/dist/snapshots.js";
3
- import { resolveCandlestickBodyColor as $ } from "../core/dist/theme/resolve.js";
4
- import { formatCompact as j, formatPriceAdaptive as U } from "../core/dist/utils/format.js";
5
- import { useCrosshairPosition as X } from "../composables.js";
6
- import { useChartInstance as q, ThemeKey as G, InfoBarAnchorKey as J } from "../context.js";
7
- const Q = {
1
+ import { defineComponent as W, computed as i, inject as B, ref as N, onMounted as T, onUnmounted as A, useSlots as O, unref as t, openBlock as n, createBlock as R, Teleport as $, createElementVNode as l, normalizeStyle as r, renderSlot as D, createElementBlock as s, Fragment as f, toDisplayString as p, renderList as L, createCommentVNode as F } from "vue";
2
+ import { buildHoverSnapshots as M, buildLastSnapshots as P, formatHeaderX as j } from "../core/dist/snapshots.js";
3
+ import { resolveCandlestickBodyColor as U } from "../core/dist/theme/resolve.js";
4
+ import { formatCompact as X, formatPriceAdaptive as q } from "../core/dist/utils/format.js";
5
+ import { useCrosshairPosition as G } from "../composables.js";
6
+ import { useChartInstance as J, ThemeKey as Q, InfoBarAnchorKey as Y } from "../context.js";
7
+ const Z = {
8
8
  key: 0,
9
9
  style: { display: "inline-flex", alignItems: "center", gap: "4px" }
10
- }, Y = {
10
+ }, ee = {
11
11
  key: 1,
12
12
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
13
- }, le = /* @__PURE__ */ V({
13
+ }, te = {
14
+ key: 2,
15
+ style: { display: "inline-flex", alignItems: "center", gap: "3px" }
16
+ }, se = /* @__PURE__ */ W({
14
17
  __name: "InfoBar",
15
18
  props: {
16
19
  sort: {},
17
20
  format: { type: Function }
18
21
  },
19
- setup(L) {
20
- const C = L, b = n(() => C.sort ?? "none"), y = n(
21
- () => C.format ?? ((o, w) => w === "volume" ? j(o) : U(o))
22
- ), r = q(), h = X(r), a = B(G), g = B(J);
23
- if (!a)
22
+ setup(E) {
23
+ const b = E, k = i(() => b.sort ?? "none"), d = i(
24
+ () => b.format ?? ((a, _) => _ === "volume" ? X(a) : q(a))
25
+ ), u = J(), y = G(u), o = B(Q), g = B(Y);
26
+ if (!o)
24
27
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing ThemeKey.");
25
28
  if (!g)
26
29
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing InfoBarAnchorKey.");
27
- const v = N(0), S = () => {
28
- v.value++;
30
+ const h = N(0), C = () => {
31
+ h.value++;
29
32
  };
30
33
  T(() => {
31
- r.on("overlayChange", S), r.getSeriesIds().length > 0 && v.value++;
32
- }), W(() => {
33
- r.off("overlayChange", S);
34
+ u.on("overlayChange", C), u.getSeriesIds().length > 0 && h.value++;
35
+ }), A(() => {
36
+ u.off("overlayChange", C);
34
37
  });
35
- const x = n(() => {
36
- v.value;
37
- const o = h.value;
38
- return o === null ? null : P(r, { time: o.time, sort: b.value, cacheKey: "infobar-hover" });
39
- }), E = n(() => (v.value, R(r, { sort: b.value, cacheKey: "infobar-last" }))), c = n(() => x.value !== null && x.value.length > 0), f = n(
40
- () => c.value ? x.value : E.value
41
- ), K = n(() => r.getDataInterval()), k = n(() => f.value.length === 0 ? 0 : c.value && h.value ? h.value.time : Math.max(...f.value.map((o) => o.data.time))), z = A(), I = n(() => typeof z.default == "function");
42
- function H(o) {
43
- return "open" in o;
38
+ const x = i(() => {
39
+ h.value;
40
+ const a = y.value;
41
+ return a === null ? null : M(u, { time: a.time, sort: k.value, cacheKey: "infobar-hover" });
42
+ }), H = i(() => (h.value, P(u, { sort: k.value, cacheKey: "infobar-last" }))), m = i(() => x.value !== null && x.value.length > 0), c = i(
43
+ () => m.value ? x.value : H.value
44
+ ), K = i(() => u.getDataInterval()), S = i(() => c.value.length === 0 ? 0 : m.value && y.value ? y.value.time : Math.max(...c.value.map((a) => a.data.time))), z = O(), w = i(() => typeof z.default == "function");
45
+ function I(a) {
46
+ return "open" in a;
47
+ }
48
+ function V(a) {
49
+ return "high" in a && !I(a);
44
50
  }
45
- return (o, w) => e(g) && e(a) && f.value.length > 0 ? (l(), O(D, {
51
+ return (a, _) => t(g) && t(o) && c.value.length > 0 ? (n(), R($, {
46
52
  key: 0,
47
- to: e(g)
53
+ to: t(g)
48
54
  }, [
49
- i("div", {
55
+ l("div", {
50
56
  "data-tooltip-legend": "",
51
- style: s(
52
- I.value ? {
57
+ style: r(
58
+ w.value ? {
53
59
  display: "flex",
54
60
  alignItems: "center",
55
61
  flexShrink: 0,
56
- fontSize: e(a).typography.fontSize + "px",
57
- fontFamily: e(a).typography.fontFamily,
62
+ fontSize: t(o).typography.fontSize + "px",
63
+ fontFamily: t(o).typography.fontFamily,
58
64
  fontVariantNumeric: "tabular-nums",
59
- opacity: c.value ? 1 : 0.6,
65
+ opacity: m.value ? 1 : 0.6,
60
66
  transition: "opacity 0.2s ease",
61
67
  pointerEvents: "none"
62
68
  } : {
@@ -66,70 +72,83 @@ const Q = {
66
72
  flexWrap: "wrap",
67
73
  padding: "4px 8px",
68
74
  flexShrink: 0,
69
- fontSize: e(a).typography.fontSize + "px",
70
- fontFamily: e(a).typography.fontFamily,
75
+ fontSize: t(o).typography.fontSize + "px",
76
+ fontFamily: t(o).typography.fontFamily,
71
77
  fontVariantNumeric: "tabular-nums",
72
- opacity: c.value ? 1 : 0.6,
78
+ opacity: m.value ? 1 : 0.6,
73
79
  transition: "opacity 0.2s ease",
74
80
  pointerEvents: "none"
75
81
  }
76
82
  )
77
83
  }, [
78
- I.value ? M(o.$slots, "default", {
84
+ w.value ? D(a.$slots, "default", {
79
85
  key: 0,
80
- snapshots: f.value,
81
- time: k.value,
82
- isHover: c.value
83
- }) : (l(), u(p, { key: 1 }, [
84
- i("span", {
85
- style: s({ color: e(a).axis.textColor, marginRight: "2px" })
86
- }, m(e(r).timeScale.formatX(k.value, K.value)), 5),
87
- (l(!0), u(p, null, _(f.value, (t) => (l(), u(p, {
88
- key: t.id
86
+ snapshots: c.value,
87
+ time: S.value,
88
+ isHover: m.value
89
+ }) : (n(), s(f, { key: 1 }, [
90
+ l("span", {
91
+ style: r({ color: t(o).axis.textColor, marginRight: "2px" })
92
+ }, p(t(j)(t(u), { time: S.value, snapshots: c.value, interval: K.value })), 5),
93
+ (n(!0), s(f, null, L(c.value, (e) => (n(), s(f, {
94
+ key: e.id
89
95
  }, [
90
- H(t.data) ? (l(), u("span", Q, [
91
- (l(!0), u(p, null, _([
92
- { label: "O", field: "open", val: t.data.open },
93
- { label: "H", field: "high", val: t.data.high },
94
- { label: "L", field: "low", val: t.data.low },
95
- { label: "C", field: "close", val: t.data.close }
96
- ], (d) => (l(), u(p, {
97
- key: d.label
96
+ I(e.data) ? (n(), s("span", Z, [
97
+ (n(!0), s(f, null, L([
98
+ { label: "O", field: "open", val: e.data.open },
99
+ { label: "H", field: "high", val: e.data.high },
100
+ { label: "L", field: "low", val: e.data.low },
101
+ { label: "C", field: "close", val: e.data.close }
102
+ ], (v) => (n(), s(f, {
103
+ key: v.label
98
104
  }, [
99
- i("span", {
100
- style: s({ color: e(a).axis.textColor, opacity: 0.5, marginLeft: "5px" })
101
- }, m(d.label), 5),
102
- i("span", {
103
- style: s({
104
- color: e($)(
105
- t.data.close >= t.data.open ? e(a).candlestick.up.body : e(a).candlestick.down.body
105
+ l("span", {
106
+ style: r({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
107
+ }, p(v.label), 5),
108
+ l("span", {
109
+ style: r({
110
+ color: t(U)(
111
+ e.data.close >= e.data.open ? t(o).candlestick.up.body : t(o).candlestick.down.body
106
112
  ),
107
113
  fontWeight: 500,
108
114
  marginLeft: "2px"
109
115
  })
110
- }, m(y.value(d.val, d.field)), 5)
116
+ }, p(d.value(v.val, v.field)), 5)
111
117
  ], 64))), 128)),
112
- t.data.volume != null ? (l(), u(p, { key: 0 }, [
113
- i("span", {
114
- style: s({ color: e(a).axis.textColor, opacity: 0.5, marginLeft: "5px" })
118
+ e.data.volume != null ? (n(), s(f, { key: 0 }, [
119
+ l("span", {
120
+ style: r({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
115
121
  }, "V", 4),
116
- i("span", {
117
- style: s({ color: e(a).axis.textColor, fontWeight: 500, marginLeft: "2px" })
118
- }, m(y.value(t.data.volume, "volume")), 5)
122
+ l("span", {
123
+ style: r({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
124
+ }, p(d.value(e.data.volume, "volume")), 5)
119
125
  ], 64)) : F("", !0)
120
- ])) : (l(), u("span", Y, [
121
- i("span", {
122
- style: s({
126
+ ])) : V(e.data) ? (n(), s("span", ee, [
127
+ l("span", {
128
+ style: r({
129
+ width: "6px",
130
+ height: "6px",
131
+ borderRadius: "1px",
132
+ background: e.color,
133
+ flexShrink: 0
134
+ })
135
+ }, null, 4),
136
+ l("span", {
137
+ style: r({ color: e.color, fontWeight: 500 })
138
+ }, p(d.value(e.data.low, "low")) + " – " + p(d.value(e.data.high, "high")), 5)
139
+ ])) : (n(), s("span", te, [
140
+ l("span", {
141
+ style: r({
123
142
  width: "6px",
124
143
  height: "6px",
125
144
  borderRadius: "50%",
126
- background: t.color,
145
+ background: e.color,
127
146
  flexShrink: 0
128
147
  })
129
148
  }, null, 4),
130
- i("span", {
131
- style: s({ color: t.color, fontWeight: 500 })
132
- }, m(y.value(t.data.value, "value")), 5)
149
+ l("span", {
150
+ style: r({ color: e.color, fontWeight: 500 })
151
+ }, p(d.value(e.data.value, "value")), 5)
133
152
  ]))
134
153
  ], 64))), 128))
135
154
  ], 64))
@@ -138,5 +157,5 @@ const Q = {
138
157
  }
139
158
  });
140
159
  export {
141
- le as default
160
+ se as default
142
161
  };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as s, onMounted as o, onUnmounted as t, watch as u, createCommentVNode as n } from "vue";
2
- import { useChartInstance as p } from "../context.js";
2
+ import { useChartInstance as c } from "../context.js";
3
3
  const h = /* @__PURE__ */ s({
4
4
  __name: "Marker",
5
5
  props: {
@@ -9,37 +9,40 @@ const h = /* @__PURE__ */ s({
9
9
  shape: {},
10
10
  pulse: { type: Boolean },
11
11
  label: {},
12
- color: {}
12
+ color: {},
13
+ scale: {}
13
14
  },
14
- setup(a) {
15
- const e = a, r = p();
15
+ setup(r) {
16
+ const e = r, a = c();
16
17
  let l = null;
17
18
  return o(() => {
18
- l = r.addMarker({
19
+ l = a.addMarker({
19
20
  time: e.time,
20
21
  value: e.value,
21
22
  seriesId: e.seriesId,
22
23
  shape: e.shape,
23
24
  pulse: e.pulse,
24
25
  label: e.label,
25
- color: e.color
26
+ color: e.color,
27
+ scale: e.scale
26
28
  });
27
29
  }), t(() => {
28
- l !== null && r.removeMarker(l), l = null;
30
+ l !== null && a.removeMarker(l), l = null;
29
31
  }), u(
30
- () => [e.time, e.value, e.seriesId, e.shape, e.pulse, e.label, e.color],
32
+ () => [e.time, e.value, e.seriesId, e.shape, e.pulse, e.label, e.color, e.scale],
31
33
  () => {
32
- l !== null && r.updateMarker(l, {
34
+ l !== null && a.updateMarker(l, {
33
35
  time: e.time,
34
36
  value: e.value,
35
37
  seriesId: e.seriesId,
36
38
  shape: e.shape,
37
39
  pulse: e.pulse,
38
40
  label: e.label,
39
- color: e.color
41
+ color: e.color,
42
+ scale: e.scale
40
43
  });
41
44
  }
42
- ), (i, m) => n("", !0);
45
+ ), (p, i) => n("", !0);
43
46
  }
44
47
  });
45
48
  export {
@@ -1,58 +1,58 @@
1
- import { defineComponent as f, inject as n, ref as m, shallowRef as d, computed as p, watch as i, onBeforeUnmount as g, unref as u, openBlock as y, createBlock as _, Teleport as w, createElementVNode as C, normalizeStyle as N, createCommentVNode as k } from "vue";
2
- import { NavigatorController as R } from "../core/dist/navigator/controller.js";
3
- import { NavigatorAnchorKey as x, ChartKey as B, ThemeKey as K } from "../context.js";
4
- const V = /* @__PURE__ */ f({
1
+ import { defineComponent as d, inject as n, ref as p, shallowRef as g, computed as u, watch as l, onBeforeUnmount as y, unref as c, openBlock as _, createBlock as w, Teleport as N, createElementVNode as k, normalizeStyle as C, createCommentVNode as R } from "vue";
2
+ import { NavigatorController as x } from "../core/dist/navigator/controller.js";
3
+ import { NavigatorAnchorKey as B, ChartKey as K, ThemeKey as T } from "../context.js";
4
+ const S = /* @__PURE__ */ d({
5
5
  __name: "Navigator",
6
6
  props: {
7
7
  data: {},
8
8
  height: {}
9
9
  },
10
- setup(c) {
11
- const t = c, a = n(x), l = n(B), h = n(K);
12
- if (!a || !l || !h)
10
+ setup(v) {
11
+ const t = v, a = n(B), r = n(K), h = n(T);
12
+ if (!a || !r || !h)
13
13
  throw new Error("<Navigator> must be used within <ChartContainer>.");
14
- const s = m(null), o = d(null), v = p(() => t.height ?? h.value.navigator.height);
15
- return i(
16
- [s, () => l.value],
17
- ([e, r]) => {
18
- !e || !r || o.value || (o.value = new R({
14
+ const s = p(null), o = g(null), m = u(() => t.height ?? h.value.navigator.height), f = u(() => r.value?.checkTimeOnlyFeature("Navigator") ?? !1);
15
+ return l(
16
+ [s, () => r.value],
17
+ ([e, i]) => {
18
+ !e || !i || o.value || (o.value = new x({
19
19
  container: e,
20
- chart: r,
20
+ chart: i,
21
21
  data: t.data,
22
22
  options: t.height !== void 0 ? { height: t.height } : void 0
23
23
  }));
24
24
  },
25
25
  { flush: "post", immediate: !0 }
26
- ), i(
26
+ ), l(
27
27
  () => t.data,
28
28
  (e) => {
29
29
  o.value?.setData(e);
30
30
  }
31
- ), i(
31
+ ), l(
32
32
  () => t.height,
33
33
  (e) => {
34
34
  o.value?.setOptions(e !== void 0 ? { height: e } : {});
35
35
  }
36
- ), g(() => {
36
+ ), y(() => {
37
37
  o.value?.destroy(), o.value = null;
38
- }), (e, r) => u(a) ? (y(), _(w, {
38
+ }), (e, i) => c(a) && f.value ? (_(), w(N, {
39
39
  key: 0,
40
- to: u(a)
40
+ to: c(a)
41
41
  }, [
42
- C("div", {
42
+ k("div", {
43
43
  ref_key: "stripRef",
44
44
  ref: s,
45
45
  "data-chart-navigator": "",
46
- style: N({
46
+ style: C({
47
47
  position: "relative",
48
48
  width: "100%",
49
- height: v.value + "px",
49
+ height: m.value + "px",
50
50
  flexShrink: 0
51
51
  })
52
52
  }, null, 4)
53
- ], 8, ["to"])) : k("", !0);
53
+ ], 8, ["to"])) : R("", !0);
54
54
  }
55
55
  });
56
56
  export {
57
- V as default
57
+ S as default
58
58
  };
@@ -1,6 +1,6 @@
1
- import { defineComponent as n, onMounted as r, onUnmounted as a, watch as i, createCommentVNode as u } from "vue";
2
- import { useChartInstance as c } from "../context.js";
3
- const p = /* @__PURE__ */ n({
1
+ import { defineComponent as a, onMounted as n, onUnmounted as r, watch as c, createCommentVNode as i } from "vue";
2
+ import { useChartInstance as s } from "../context.js";
3
+ const p = /* @__PURE__ */ a({
4
4
  __name: "ReferenceLine",
5
5
  props: {
6
6
  value: {},
@@ -8,35 +8,38 @@ const p = /* @__PURE__ */ n({
8
8
  color: {},
9
9
  label: {},
10
10
  style: {},
11
- width: {}
11
+ width: {},
12
+ scale: {}
12
13
  },
13
14
  setup(o) {
14
- const e = o, l = c();
15
- let t = null;
16
- return r(() => {
17
- t = l.addLine({
15
+ const e = o, t = s();
16
+ let l = null;
17
+ return n(() => {
18
+ l = t.addLine({
18
19
  value: e.value,
19
20
  time: e.time,
20
21
  color: e.color,
21
22
  label: e.label,
22
23
  style: e.style,
23
- width: e.width
24
+ width: e.width,
25
+ scale: e.scale
24
26
  });
25
- }), a(() => {
26
- t !== null && l.removeLine(t), t = null;
27
- }), i(
28
- () => [e.value, e.time, e.color, e.label, e.style, e.width],
27
+ }), r(() => {
28
+ l !== null && t.removeLine(l), l = null;
29
+ }), c(
30
+ () => [e.value, e.time, e.color, e.label, e.style, e.width, e.scale],
29
31
  () => {
30
- t !== null && l.updateLine(t, {
32
+ l !== null && t.updateLine(l, {
31
33
  value: e.value,
32
34
  time: e.time,
33
35
  color: e.color,
34
36
  label: e.label,
35
37
  style: e.style,
36
- width: e.width
38
+ width: e.width,
39
+ scale: e.scale
37
40
  });
38
41
  }
39
- ), (m, s) => u("", !0);
42
+ ), (u, m) => i("", !0);
40
43
  }
41
44
  });
42
45
  export {