@wick-charts/vue 0.6.2 → 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 (61) 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 +45 -39
  5. package/dist/composables.js +39 -26
  6. package/dist/core/dist/animation/config.js +92 -75
  7. package/dist/core/dist/axis/dom-labels.js +56 -43
  8. package/dist/core/dist/chart/badge-animator.js +30 -22
  9. package/dist/core/dist/chart/edge-indicators.js +22 -21
  10. package/dist/core/dist/chart/last-value.js +33 -26
  11. package/dist/core/dist/chart/options.js +5 -5
  12. package/dist/core/dist/chart/scale-guards.js +26 -0
  13. package/dist/core/dist/chart/y-target.js +46 -19
  14. package/dist/core/dist/chart.js +670 -518
  15. package/dist/core/dist/components/crosshair.js +8 -8
  16. package/dist/core/dist/components/grid.js +26 -17
  17. package/dist/core/dist/components/marker.js +28 -28
  18. package/dist/core/dist/components/reference-line.js +16 -16
  19. package/dist/core/dist/data/decimation.js +58 -39
  20. package/dist/core/dist/interactions/handler.js +3 -2
  21. package/dist/core/dist/interactions/zoom.js +6 -5
  22. package/dist/core/dist/navigator/controller.js +47 -44
  23. package/dist/core/dist/perf/perf-hud.js +3 -3
  24. package/dist/core/dist/scales/log-scale.js +76 -0
  25. package/dist/core/dist/scales/y-scale.js +134 -35
  26. package/dist/core/dist/series/band.js +670 -0
  27. package/dist/core/dist/series/bar-intro.js +11 -11
  28. package/dist/core/dist/series/bar.js +301 -251
  29. package/dist/core/dist/series/base-multi-layer.js +100 -76
  30. package/dist/core/dist/series/candlestick.js +238 -235
  31. package/dist/core/dist/series/heatmap.js +5 -5
  32. package/dist/core/dist/series/line-intro.js +50 -40
  33. package/dist/core/dist/series/line.js +561 -483
  34. package/dist/core/dist/series/painters/builtins.js +4 -4
  35. package/dist/core/dist/series/painters/canvas-path.js +64 -52
  36. package/dist/core/dist/series/register-builtins.js +9 -8
  37. package/dist/core/dist/series/scale-stack.js +25 -0
  38. package/dist/core/dist/snapshots.js +36 -35
  39. package/dist/core/dist/tooltip-position.js +5 -5
  40. package/dist/core/dist/utils/point.js +10 -0
  41. package/dist/index.d.ts +501 -128
  42. package/dist/index.js +195 -189
  43. package/dist/ui/Crosshair.vue.js +14 -14
  44. package/dist/ui/HeatmapTooltip.vue.js +6 -6
  45. package/dist/ui/InfoBar.vue.js +100 -81
  46. package/dist/ui/PieTooltip.vue.js +4 -4
  47. package/dist/ui/TimeAxis.vue.js +23 -22
  48. package/dist/ui/Tooltip.vue.js +140 -111
  49. package/dist/ui/YAxis.vue.js +25 -24
  50. package/dist/ui/YLabel.vue.js +63 -70
  51. package/package.json +2 -2
  52. package/src/BandSeries.vue +87 -0
  53. package/src/ChartContainer.vue +20 -8
  54. package/src/composables.ts +35 -1
  55. package/src/index.ts +13 -0
  56. package/src/ui/Crosshair.vue +2 -2
  57. package/src/ui/InfoBar.vue +20 -1
  58. package/src/ui/TimeAxis.vue +7 -4
  59. package/src/ui/Tooltip.vue +40 -3
  60. package/src/ui/YAxis.vue +5 -3
  61. package/src/ui/YLabel.vue +5 -16
@@ -1,145 +1,174 @@
1
- import { defineComponent as P, computed as s, ref as w, onMounted as D, onUnmounted as M, useSlots as X, watchEffect as Y, openBlock as r, createElementBlock as u, Fragment as x, unref as p, normalizeStyle as m, createElementVNode as d, toDisplayString as f, renderList as H, createCommentVNode as _, renderSlot as Z } from "vue";
2
- import { buildHoverSnapshots as $ } from "../core/dist/snapshots.js";
3
- import { resolveCandlestickBodyColor as K } from "../core/dist/theme/resolve.js";
4
- import { computeTooltipPosition as R } from "../core/dist/tooltip-position.js";
5
- import { formatCompact as U, formatPriceAdaptive as j } from "../core/dist/utils/format.js";
6
- import { formatDate as q } from "../core/dist/utils/time.js";
7
- import { useCrosshairPosition as G } from "../composables.js";
8
- import { useChartInstance as J } from "../context.js";
9
- const Q = {
1
+ import { defineComponent as D, computed as c, ref as _, onMounted as X, onUnmounted as Y, useSlots as Z, watchEffect as $, openBlock as n, createElementBlock as r, Fragment as x, unref as v, normalizeStyle as h, createElementVNode as s, toDisplayString as d, renderList as H, createCommentVNode as z, renderSlot as K } from "vue";
2
+ import { buildHoverSnapshots as U } from "../core/dist/snapshots.js";
3
+ import { resolveCandlestickBodyColor as j } from "../core/dist/theme/resolve.js";
4
+ import { computeTooltipPosition as I } from "../core/dist/tooltip-position.js";
5
+ import { formatCompact as q, formatPriceAdaptive as G } from "../core/dist/utils/format.js";
6
+ import { formatDate as J } from "../core/dist/utils/time.js";
7
+ import { useCrosshairPosition as Q } from "../composables.js";
8
+ import { useChartInstance as ee } from "../context.js";
9
+ const te = {
10
10
  key: 0,
11
11
  style: { display: "grid", gridTemplateColumns: "auto 1fr", gap: "4px 12px" }
12
- }, ee = { style: { opacity: 0.5 } }, te = {
12
+ }, oe = { style: { opacity: 0.5 } }, ae = {
13
13
  key: 1,
14
14
  style: { display: "flex", alignItems: "center", gap: "8px", padding: "2px 0" }
15
- }, oe = { style: { opacity: 0.6, flex: "1" } }, le = ["data-measured"], ce = /* @__PURE__ */ P({
15
+ }, le = { style: {
16
+ opacity: 0.6,
17
+ flex: "1",
18
+ minWidth: 0,
19
+ overflow: "hidden",
20
+ textOverflow: "ellipsis",
21
+ whiteSpace: "nowrap"
22
+ } }, ie = {
23
+ key: 2,
24
+ style: { display: "flex", alignItems: "center", gap: "8px", padding: "2px 0" }
25
+ }, ne = { style: { opacity: 0.6, flex: "1" } }, re = ["data-measured"], xe = /* @__PURE__ */ D({
16
26
  __name: "Tooltip",
17
27
  props: {
18
28
  sort: {},
19
29
  format: { type: Function }
20
30
  },
21
- setup(I) {
22
- const F = I, A = s(() => F.sort ?? "none"), k = s(
23
- () => F.format ?? ((a, n) => n === "volume" ? U(a) : j(a))
24
- ), o = J(), i = G(o), C = w(0), W = () => {
25
- C.value++;
31
+ setup(L) {
32
+ const W = L, O = c(() => W.sort ?? "none"), g = c(
33
+ () => W.format ?? ((a, i) => i === "volume" ? q(a) : G(a))
34
+ ), t = ee(), u = Q(t), w = _(0), F = () => {
35
+ w.value++;
26
36
  };
27
- D(() => {
28
- o.on("overlayChange", W), o.getSeriesIds().length > 0 && C.value++;
29
- }), M(() => {
30
- o.off("overlayChange", W);
37
+ X(() => {
38
+ t.on("overlayChange", F), t.getSeriesIds().length > 0 && w.value++;
39
+ }), Y(() => {
40
+ t.off("overlayChange", F);
31
41
  });
32
- const t = s(() => o.getTheme()), O = s(() => o.getDataInterval()), c = s(() => (C.value, i.value ? $(o, {
33
- time: i.value.time,
34
- sort: A.value,
42
+ const o = c(() => t.getTheme()), A = c(() => t.getDataInterval()), f = c(() => (w.value, u.value ? U(t, {
43
+ time: u.value.time,
44
+ sort: O.value,
35
45
  cacheKey: "tooltip"
36
- }) : [])), z = s(() => i.value?.time ?? 0), T = X(), g = s(() => typeof T.default == "function"), B = w(null), b = w(null);
37
- let S = null;
38
- Y((a) => {
39
- if (!g.value) return;
40
- const n = B.value;
41
- !n || typeof ResizeObserver > "u" || (S = new ResizeObserver((e) => {
46
+ }) : [])), C = c(() => u.value?.time ?? 0), T = Z(), y = c(() => typeof T.default == "function"), B = _(null), b = _(null);
47
+ let k = null;
48
+ $((a) => {
49
+ if (!y.value) return;
50
+ const i = B.value;
51
+ !i || typeof ResizeObserver > "u" || (k = new ResizeObserver((e) => {
42
52
  const l = e[0]?.contentRect;
43
53
  if (!l) return;
44
- const y = b.value;
45
- (!y || y.width !== l.width || y.height !== l.height) && (b.value = { width: l.width, height: l.height });
46
- }), S.observe(n), a(() => {
47
- S?.disconnect(), S = null;
54
+ const S = b.value;
55
+ (!S || S.width !== l.width || S.height !== l.height) && (b.value = { width: l.width, height: l.height });
56
+ }), k.observe(i), a(() => {
57
+ k?.disconnect(), k = null;
48
58
  }));
49
59
  });
50
- const h = s(() => {
51
- if (!i.value || c.value.length === 0) return null;
52
- const a = o.getMediaSize(), n = a.width - o.yAxisWidth, e = a.height - o.xAxisHeight;
53
- if (g.value) {
54
- const v = b.value;
55
- return v ? R({
56
- x: i.value.mediaX,
57
- y: i.value.mediaY,
58
- chartWidth: n,
59
- chartHeight: e,
60
- tooltipWidth: v.width,
61
- tooltipHeight: v.height
62
- }) : { left: 0, top: 0 };
60
+ const m = c(() => {
61
+ if (!u.value || f.value.length === 0) return null;
62
+ const a = t.getMediaSize(), i = t.plotLeft, e = a.width - t.yAxisWidth, l = a.height - t.xAxisHeight;
63
+ if (y.value) {
64
+ const p = b.value;
65
+ return p ? I({
66
+ x: u.value.mediaX,
67
+ y: u.value.mediaY,
68
+ chartLeft: i,
69
+ chartWidth: e,
70
+ chartHeight: l,
71
+ tooltipWidth: p.width,
72
+ tooltipHeight: p.height
73
+ }) : { left: i, top: 0 };
63
74
  }
64
- const l = c.value.some((v) => "open" in v.data), y = c.value.filter((v) => !("open" in v.data)).length, L = 160, N = l ? 140 : 40 + y * 22;
65
- return R({
66
- x: i.value.mediaX,
67
- y: i.value.mediaY,
68
- chartWidth: n,
69
- chartHeight: e,
70
- tooltipWidth: L,
71
- tooltipHeight: N
75
+ const S = f.value.some((p) => "open" in p.data), M = f.value.filter((p) => !("open" in p.data)).length, N = f.value.some((p) => "high" in p.data && !("open" in p.data)) ? 220 : 160, P = S ? 140 : 40 + M * 22;
76
+ return I({
77
+ x: u.value.mediaX,
78
+ y: u.value.mediaY,
79
+ chartLeft: i,
80
+ chartWidth: e,
81
+ chartHeight: l,
82
+ tooltipWidth: N,
83
+ tooltipHeight: P
72
84
  });
73
- }), V = s(() => !g.value || b.value !== null);
74
- function E(a) {
85
+ }), V = c(() => !y.value || b.value !== null);
86
+ function R(a) {
75
87
  return "open" in a;
76
88
  }
77
- return (a, n) => (r(), u(x, null, [
78
- p(i) && c.value.length > 0 && h.value && !g.value ? (r(), u("div", {
89
+ function E(a) {
90
+ return "high" in a && !R(a);
91
+ }
92
+ return (a, i) => (n(), r(x, null, [
93
+ v(u) && f.value.length > 0 && m.value && !y.value ? (n(), r("div", {
79
94
  key: 0,
80
- style: m({
95
+ style: h({
81
96
  position: "absolute",
82
- left: h.value.left + "px",
83
- top: h.value.top + "px",
97
+ left: m.value.left + "px",
98
+ top: m.value.top + "px",
84
99
  pointerEvents: "none",
85
- background: t.value.tooltip.background,
100
+ background: o.value.tooltip.background,
86
101
  backdropFilter: "blur(12px)",
87
102
  WebkitBackdropFilter: "blur(12px)",
88
- border: "1px solid " + t.value.tooltip.borderColor,
103
+ border: "1px solid " + o.value.tooltip.borderColor,
89
104
  borderRadius: "8px",
90
105
  padding: "10px 14px",
91
106
  boxShadow: "0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",
92
- fontSize: t.value.tooltip.fontSize + "px",
93
- fontFamily: t.value.typography.fontFamily,
107
+ fontSize: o.value.tooltip.fontSize + "px",
108
+ fontFamily: o.value.typography.fontFamily,
94
109
  fontVariantNumeric: "tabular-nums",
95
- color: t.value.tooltip.textColor,
110
+ color: o.value.tooltip.textColor,
96
111
  minWidth: "140px",
97
112
  zIndex: 10,
98
113
  transition: "opacity 0.15s ease"
99
114
  })
100
115
  }, [
101
- d("div", {
102
- style: m({
103
- fontSize: t.value.axis.fontSize + "px",
104
- color: t.value.axis.textColor,
116
+ s("div", {
117
+ style: h({
118
+ fontSize: o.value.axis.fontSize + "px",
119
+ color: o.value.axis.textColor,
105
120
  marginBottom: "8px",
106
121
  paddingBottom: "6px",
107
- borderBottom: "1px solid " + t.value.tooltip.borderColor,
122
+ borderBottom: "1px solid " + o.value.tooltip.borderColor,
108
123
  letterSpacing: "0.02em"
109
124
  })
110
- }, f(p(q)(z.value, { locale: p(o).timeScale.getLocale(), timeZone: p(o).timeScale.getTimeZone() })) + " " + f(p(o).timeScale.formatX(z.value, O.value)), 5),
111
- (r(!0), u(x, null, H(c.value, (e) => (r(), u(x, {
125
+ }, d(v(J)(C.value, { locale: v(t).timeScale.getLocale(), timeZone: v(t).timeScale.getTimeZone() })) + " " + d(v(t).timeScale.formatX(C.value, A.value)), 5),
126
+ (n(!0), r(x, null, H(f.value, (e) => (n(), r(x, {
112
127
  key: e.id
113
128
  }, [
114
- E(e.data) ? (r(), u("div", Q, [
115
- (r(!0), u(x, null, H([
129
+ R(e.data) ? (n(), r("div", te, [
130
+ (n(!0), r(x, null, H([
116
131
  { label: "Open", val: e.data.open, field: "open" },
117
132
  { label: "High", val: e.data.high, field: "high" },
118
133
  { label: "Low", val: e.data.low, field: "low" },
119
134
  { label: "Close", val: e.data.close, field: "close" }
120
- ], (l) => (r(), u(x, {
135
+ ], (l) => (n(), r(x, {
121
136
  key: l.label
122
137
  }, [
123
- d("span", ee, f(l.label), 1),
124
- d("span", {
125
- style: m({
138
+ s("span", oe, d(l.label), 1),
139
+ s("span", {
140
+ style: h({
126
141
  fontWeight: 600,
127
- color: p(K)(
128
- e.data.close >= e.data.open ? t.value.candlestick.up.body : t.value.candlestick.down.body
142
+ color: v(j)(
143
+ e.data.close >= e.data.open ? o.value.candlestick.up.body : o.value.candlestick.down.body
129
144
  ),
130
145
  textAlign: "right"
131
146
  })
132
- }, f(k.value(l.val, l.field)), 5)
147
+ }, d(g.value(l.val, l.field)), 5)
133
148
  ], 64))), 128)),
134
- e.data.volume != null ? (r(), u(x, { key: 0 }, [
135
- n[0] || (n[0] = d("span", { style: { opacity: 0.5 } }, "Volume", -1)),
136
- d("span", {
137
- style: m({ fontWeight: 600, color: t.value.tooltip.textColor, textAlign: "right" })
138
- }, f(k.value(e.data.volume, "volume")), 5)
139
- ], 64)) : _("", !0)
140
- ])) : (r(), u("div", te, [
141
- d("span", {
142
- style: m({
149
+ e.data.volume != null ? (n(), r(x, { key: 0 }, [
150
+ i[0] || (i[0] = s("span", { style: { opacity: 0.5 } }, "Volume", -1)),
151
+ s("span", {
152
+ style: h({ fontWeight: 600, color: o.value.tooltip.textColor, textAlign: "right" })
153
+ }, d(g.value(e.data.volume, "volume")), 5)
154
+ ], 64)) : z("", !0)
155
+ ])) : E(e.data) ? (n(), r("div", ae, [
156
+ s("span", {
157
+ style: h({
158
+ width: "8px",
159
+ height: "8px",
160
+ borderRadius: "2px",
161
+ background: e.color,
162
+ flexShrink: 0
163
+ })
164
+ }, null, 4),
165
+ s("span", le, d(e.label ?? "Range"), 1),
166
+ s("span", {
167
+ style: h({ fontWeight: 600, color: e.color, whiteSpace: "nowrap" })
168
+ }, d(g.value(e.data.low, "low")) + " – " + d(g.value(e.data.high, "high")), 5)
169
+ ])) : (n(), r("div", ie, [
170
+ s("span", {
171
+ style: h({
143
172
  width: "8px",
144
173
  height: "8px",
145
174
  borderRadius: "50%",
@@ -147,49 +176,49 @@ const Q = {
147
176
  flexShrink: 0
148
177
  })
149
178
  }, null, 4),
150
- d("span", oe, f(e.label ?? "Value"), 1),
151
- d("span", {
152
- style: m({ fontWeight: 600, color: e.color })
153
- }, f(k.value(e.data.value, "value")), 5)
179
+ s("span", ne, d(e.label ?? "Value"), 1),
180
+ s("span", {
181
+ style: h({ fontWeight: 600, color: e.color })
182
+ }, d(g.value(e.data.value, "value")), 5)
154
183
  ]))
155
184
  ], 64))), 128))
156
- ], 4)) : _("", !0),
157
- p(i) && c.value.length > 0 && h.value && g.value ? (r(), u("div", {
185
+ ], 4)) : z("", !0),
186
+ v(u) && f.value.length > 0 && m.value && y.value ? (n(), r("div", {
158
187
  key: 1,
159
188
  ref_key: "containerRef",
160
189
  ref: B,
161
190
  "data-measured": V.value ? "true" : "false",
162
- style: m({
191
+ style: h({
163
192
  position: "absolute",
164
- left: h.value.left + "px",
165
- top: h.value.top + "px",
193
+ left: m.value.left + "px",
194
+ top: m.value.top + "px",
166
195
  pointerEvents: "none",
167
- background: t.value.tooltip.background,
196
+ background: o.value.tooltip.background,
168
197
  backdropFilter: "blur(12px)",
169
198
  WebkitBackdropFilter: "blur(12px)",
170
- border: "1px solid " + t.value.tooltip.borderColor,
199
+ border: "1px solid " + o.value.tooltip.borderColor,
171
200
  borderRadius: "8px",
172
201
  padding: "10px 14px",
173
202
  boxShadow: "0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",
174
- fontFamily: t.value.typography.fontFamily,
175
- fontSize: t.value.tooltip.fontSize + "px",
203
+ fontFamily: o.value.typography.fontFamily,
204
+ fontSize: o.value.tooltip.fontSize + "px",
176
205
  fontVariantNumeric: "tabular-nums",
177
- color: t.value.tooltip.textColor,
206
+ color: o.value.tooltip.textColor,
178
207
  width: "max-content",
179
- maxWidth: p(o).getMediaSize().width - p(o).yAxisWidth + "px",
208
+ maxWidth: v(t).getMediaSize().width - v(t).yAxisWidth + "px",
180
209
  boxSizing: "border-box",
181
210
  zIndex: 10,
182
211
  visibility: b.value !== null ? "visible" : "hidden"
183
212
  })
184
213
  }, [
185
- Z(a.$slots, "default", {
186
- snapshots: c.value,
187
- time: z.value
214
+ K(a.$slots, "default", {
215
+ snapshots: f.value,
216
+ time: C.value
188
217
  })
189
- ], 12, le)) : _("", !0)
218
+ ], 12, re)) : z("", !0)
190
219
  ], 64));
191
220
  }
192
221
  });
193
222
  export {
194
- ce as default
223
+ xe as default
195
224
  };
@@ -1,42 +1,43 @@
1
- import { defineComponent as m, ref as p, onMounted as r, watch as s, onUnmounted as o, openBlock as b, createElementBlock as f, normalizeStyle as y, unref as u } from "vue";
2
- import { mountAxisLabels as x } from "../core/dist/axis/dom-labels.js";
3
- import { useChartInstance as h } from "../context.js";
4
- const _ = /* @__PURE__ */ m({
1
+ import { defineComponent as p, ref as f, onMounted as u, watch as c, onUnmounted as a, openBlock as y, createElementBlock as b, normalizeStyle as x, unref as i } from "vue";
2
+ import { mountAxisLabels as L } from "../core/dist/axis/dom-labels.js";
3
+ import { useAxisLayout as A } from "../composables.js";
4
+ import { useChartInstance as S } from "../context.js";
5
+ const F = /* @__PURE__ */ p({
5
6
  __name: "YAxis",
6
7
  props: {
7
8
  format: { type: Function },
8
9
  labelCount: {},
9
10
  minLabelSpacing: {}
10
11
  },
11
- setup(c) {
12
- const e = c, n = h(), t = p(null), a = () => n.yScale.setFormat(e.format ?? null);
13
- r(a), s(() => e.format, a), o(() => n.yScale.setFormat(null));
14
- const i = () => {
15
- n.setYAxisLabelDensity({
16
- labelCount: e.labelCount ?? null,
17
- minLabelSpacing: e.minLabelSpacing ?? null
12
+ setup(m) {
13
+ const n = m, t = S(), e = A(t), l = f(null), s = () => t.yScale.setFormat(n.format ?? null);
14
+ u(s), c(() => n.format, s), a(() => t.yScale.setFormat(null));
15
+ const r = () => {
16
+ t.setYAxisLabelDensity({
17
+ labelCount: n.labelCount ?? null,
18
+ minLabelSpacing: n.minLabelSpacing ?? null
18
19
  });
19
20
  };
20
- i(), s(() => [e.labelCount, e.minLabelSpacing], i), o(() => n.setYAxisLabelDensity({ labelCount: null, minLabelSpacing: null }));
21
- let l = null;
22
- return r(() => {
23
- t.value !== null && (l = x({ chart: n, container: t.value, axis: "y" }));
24
- }), o(() => {
25
- l?.(), l = null;
26
- }), (L, S) => (b(), f("div", {
21
+ r(), c(() => [n.labelCount, n.minLabelSpacing], r), a(() => t.setYAxisLabelDensity({ labelCount: null, minLabelSpacing: null }));
22
+ let o = null;
23
+ return u(() => {
24
+ l.value !== null && (o = L({ chart: t, container: l.value, axis: "y" }));
25
+ }), a(() => {
26
+ o?.(), o = null;
27
+ }), (d, h) => (y(), b("div", {
27
28
  ref_key: "containerRef",
28
- ref: t,
29
- style: y({
29
+ ref: l,
30
+ style: x({
30
31
  position: "absolute",
31
- right: "0",
32
+ [i(e).yAxisPosition]: "0",
32
33
  top: "0",
33
- bottom: u(n).xAxisHeight + "px",
34
- width: u(n).yAxisWidth + "px",
34
+ bottom: i(e).xAxisHeight + "px",
35
+ width: i(e).yAxisWidth + "px",
35
36
  pointerEvents: "none"
36
37
  })
37
38
  }, null, 4));
38
39
  }
39
40
  });
40
41
  export {
41
- _ as default
42
+ F as default
42
43
  };
@@ -1,9 +1,9 @@
1
- import { defineComponent as q, useSlots as j, computed as n, ref as I, onMounted as G, onUnmounted as P, openBlock as w, createElementBlock as B, Fragment as A, renderSlot as W, createElementVNode as _, normalizeStyle as T, unref as H, createVNode as J, createCommentVNode as K } from "vue";
2
- import { prefersReducedMotion as Q } from "../core/dist/animation/reduced-motion.js";
3
- import { resolveAnimate as X, firstVisibleValue as Z, BadgeAnimator as ee } from "../core/dist/chart/badge-animator.js";
1
+ import { defineComponent as $, useSlots as j, computed as a, ref as I, onMounted as G, onUnmounted as O, openBlock as w, createElementBlock as A, Fragment as B, renderSlot as W, createElementVNode as _, normalizeStyle as Y, unref as g, createVNode as H, createCommentVNode as J } from "vue";
2
+ import { prefersReducedMotion as K } from "../core/dist/animation/reduced-motion.js";
3
+ import { resolveAnimate as Q, resolveYLabelSeriesId as X, firstVisibleValue as Z, BadgeAnimator as ee } from "../core/dist/chart/badge-animator.js";
4
4
  import { useChartInstance as te } from "../context.js";
5
- import ne from "./NumberFlow.vue.js";
6
- const ie = /* @__PURE__ */ q({
5
+ import ae from "./NumberFlow.vue.js";
6
+ const ie = /* @__PURE__ */ $({
7
7
  __name: "YLabel",
8
8
  props: {
9
9
  seriesId: {},
@@ -12,55 +12,48 @@ const ie = /* @__PURE__ */ q({
12
12
  animate: { type: [Boolean, Object] }
13
13
  },
14
14
  setup(z) {
15
- const f = z, e = te(), Y = j(), E = n(() => typeof Y.default == "function"), i = I(0), u = I(null);
16
- let p = null, g = null, o = null;
17
- const M = n(() => X(f.animate));
15
+ const c = z, e = te(), M = j(), E = a(() => typeof M.default == "function"), i = I(0), o = I(null);
16
+ let p = null, y = null, u = null;
17
+ const N = a(() => Q(c.animate));
18
18
  function L() {
19
- o = null;
20
- const t = s.value, l = t !== null ? e.getStackedLastValue(t) : null;
21
- if (t === null || !l) {
22
- p = null, g = null;
19
+ u = null;
20
+ const t = s.value, n = t !== null ? e.getStackedLastValue(t) : null;
21
+ if (t === null || !n) {
22
+ p = null, y = null;
23
23
  return;
24
24
  }
25
- const v = l.value;
26
- (p === null || g !== t) && (p = new ee(v), g = t);
27
- const { glide: d, countUp: U, settleMs: $ } = M.value, F = e.getIntroFront(t), c = p.frame({
28
- target: v,
25
+ const m = n.value;
26
+ (p === null || y !== t) && (p = new ee(m), y = t);
27
+ const { glide: P, countUp: U, settleMs: q } = N.value, S = e.getIntroFront(t), v = p.frame({
28
+ target: m,
29
29
  // Only needed for the intro count-up; skip the visible-range binary search
30
30
  // entirely once the reveal has settled (the hot streaming path).
31
- firstVisible: F < 1 ? Z(e, t, v) : v,
32
- introFront: F,
31
+ firstVisible: S < 1 ? Z(e, t, m) : m,
32
+ introFront: S,
33
33
  now: performance.now(),
34
- glide: d,
34
+ glide: P,
35
35
  countUp: U,
36
- settleMs: $,
37
- reducedMotion: Q()
38
- }), y = u.value;
39
- (y === null || y.positionValue !== c.positionValue || y.textValue !== c.textValue || y.opacity !== c.opacity) && (u.value = { positionValue: c.positionValue, textValue: c.textValue, opacity: c.opacity }), c.animating && o === null && (o = requestAnimationFrame(L));
36
+ settleMs: q,
37
+ reducedMotion: K()
38
+ }), d = o.value;
39
+ (d === null || d.positionValue !== v.positionValue || d.textValue !== v.textValue || d.opacity !== v.opacity) && (o.value = { positionValue: v.positionValue, textValue: v.textValue, opacity: v.opacity }), v.animating && u === null && (u = requestAnimationFrame(L));
40
40
  }
41
- function N() {
42
- o === null && (o = requestAnimationFrame(L));
41
+ function R() {
42
+ u === null && (u = requestAnimationFrame(L));
43
43
  }
44
- const m = () => {
45
- i.value++, N();
44
+ const f = () => {
45
+ i.value++, R();
46
46
  };
47
47
  G(() => {
48
- e.setYLabel(!0), e.on("overlayChange", m), e.on("viewportChange", m), e.getSeriesIds().length > 0 && m();
49
- }), P(() => {
50
- e.setYLabel(!1), e.off("overlayChange", m), e.off("viewportChange", m), o !== null && cancelAnimationFrame(o), o = null;
48
+ e.setYLabel(!0), e.on("overlayChange", f), e.on("viewportChange", f), e.getSeriesIds().length > 0 && f();
49
+ }), O(() => {
50
+ e.setYLabel(!1), e.off("overlayChange", f), e.off("viewportChange", f), u !== null && cancelAnimationFrame(u), u = null;
51
51
  });
52
- function O(t, l) {
53
- if (l !== void 0) return l;
54
- const v = t.getSeriesIdsByType("time", { visibleOnly: !0, singleLayerOnly: !0 });
55
- if (v.length > 0) return v[0];
56
- const d = t.getSeriesIdsByType("time", { visibleOnly: !0 });
57
- return d.length > 0 ? d[0] : null;
58
- }
59
- const s = n(() => (i.value, O(e, f.seriesId))), a = n(() => (i.value, s.value !== null ? e.getStackedLastValue(s.value) : null)), b = n(() => (i.value, s.value !== null ? e.getPreviousClose(s.value) : null)), r = n(() => (i.value, e.getTheme())), R = n(() => u.value !== null ? u.value.positionValue : a.value?.value ?? 0), D = n(() => u.value !== null ? u.value.textValue : a.value?.value ?? 0), h = n(() => u.value !== null ? u.value.opacity : s.value === null ? 1 : e.getIntroFront(s.value) < 1 ? 0 : 1), x = n(() => (i.value, a.value === null ? 0 : e.yScale.valueToY(R.value))), S = n(() => a.value === null || b.value === null ? "neutral" : a.value.value > b.value ? "up" : a.value.value < b.value ? "down" : "neutral"), V = n(() => {
60
- if (a.value === null) return r.value.yLabel.neutralBackground;
61
- if (!a.value.isLive) return r.value.axis.textColor;
62
- if (f.color) return f.color;
63
- switch (S.value) {
52
+ const s = a(() => (i.value, X(e, c.seriesId))), l = a(() => (i.value, s.value !== null ? e.getStackedLastValue(s.value) : null)), x = a(() => (i.value, s.value !== null ? e.getPreviousClose(s.value) : null)), r = a(() => (i.value, e.getTheme())), T = a(() => o.value !== null ? o.value.positionValue : l.value?.value ?? 0), D = a(() => o.value !== null ? o.value.textValue : l.value?.value ?? 0), b = a(() => o.value !== null ? o.value.opacity : s.value === null ? 1 : e.getIntroFront(s.value) < 1 ? 0 : 1), h = a(() => (i.value, l.value === null ? 0 : e.yScale.valueToY(T.value))), k = a(() => l.value === null || x.value === null ? "neutral" : l.value.value > x.value ? "up" : l.value.value < x.value ? "down" : "neutral"), V = a(() => {
53
+ if (l.value === null) return r.value.yLabel.neutralBackground;
54
+ if (!l.value.isLive) return r.value.axis.textColor;
55
+ if (c.color) return c.color;
56
+ switch (k.value) {
64
57
  case "up":
65
58
  return r.value.yLabel.upBackground;
66
59
  case "down":
@@ -68,50 +61,50 @@ const ie = /* @__PURE__ */ q({
68
61
  default:
69
62
  return r.value.yLabel.neutralBackground;
70
63
  }
71
- }), k = n(() => {
64
+ }), C = a(() => {
72
65
  i.value;
73
- const t = e.yScale.getRange(), l = t.max - t.min;
74
- return l < 0.1 ? 6 : l < 10 ? 4 : l < 1e3 ? 2 : 0;
75
- }), C = n(() => {
76
- if (f.format) return f.format;
66
+ const t = e.yScale.getRange(), n = t.max - t.min;
67
+ return n < 0.1 ? 6 : n < 10 ? 4 : n < 1e3 ? 2 : 0;
68
+ }), F = a(() => {
69
+ if (c.format) return c.format;
77
70
  const t = new Intl.NumberFormat("en-US", {
78
- minimumFractionDigits: k.value,
79
- maximumFractionDigits: k.value,
71
+ minimumFractionDigits: C.value,
72
+ maximumFractionDigits: C.value,
80
73
  useGrouping: !1
81
74
  });
82
- return (l) => t.format(l);
75
+ return (n) => t.format(n);
83
76
  });
84
- return (t, l) => a.value !== null ? (w(), B(A, { key: 0 }, [
77
+ return (t, n) => l.value !== null ? (w(), A(B, { key: 0 }, [
85
78
  E.value ? W(t.$slots, "default", {
86
79
  key: 0,
87
- value: a.value.value,
88
- y: x.value,
80
+ value: l.value.value,
81
+ y: h.value,
89
82
  bgColor: V.value,
90
- isLive: a.value.isLive,
91
- direction: S.value,
92
- format: C.value,
93
- opacity: h.value
94
- }) : (w(), B(A, { key: 1 }, [
83
+ isLive: l.value.isLive,
84
+ direction: k.value,
85
+ format: F.value,
86
+ opacity: b.value
87
+ }) : (w(), A(B, { key: 1 }, [
95
88
  _("div", {
96
- style: T({
89
+ style: Y({
97
90
  position: "absolute",
98
- left: "0",
99
- right: H(e).yAxisWidth + "px",
100
- top: x.value + "px",
91
+ left: g(e).plotLeft + "px",
92
+ right: (g(e).yAxisPosition === "left" ? 0 : g(e).yAxisWidth) + "px",
93
+ top: h.value + "px",
101
94
  height: "0",
102
95
  borderTop: "1px dashed " + V.value,
103
- opacity: h.value * 0.5,
96
+ opacity: b.value * 0.5,
104
97
  pointerEvents: "none",
105
98
  zIndex: 2
106
99
  })
107
100
  }, null, 4),
108
101
  _("div", {
109
- style: T({
102
+ style: Y({
110
103
  position: "absolute",
111
- right: "4px",
112
- top: x.value + "px",
104
+ [g(e).yAxisPosition]: "4px",
105
+ top: h.value + "px",
113
106
  transform: "translateY(-50%)",
114
- opacity: h.value,
107
+ opacity: b.value,
115
108
  pointerEvents: "auto",
116
109
  zIndex: 3,
117
110
  background: V.value,
@@ -124,14 +117,14 @@ const ie = /* @__PURE__ */ q({
124
117
  transition: "background-color 0.3s ease"
125
118
  })
126
119
  }, [
127
- J(ne, {
120
+ H(ae, {
128
121
  value: D.value,
129
- format: C.value,
122
+ format: F.value,
130
123
  "spin-duration": 350
131
124
  }, null, 8, ["value", "format"])
132
125
  ], 4)
133
126
  ], 64))
134
- ], 64)) : K("", !0);
127
+ ], 64)) : J("", !0);
135
128
  }
136
129
  });
137
130
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wick-charts/vue",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "High-performance canvas timeseries charts for Vue — candlestick, line, bar, pie. Tree-shakeable, zero runtime deps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "vue": ">=3.3.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@wick-charts/core": "^0.6.2"
48
+ "@wick-charts/core": "^0.6.4"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "vite build"