@wick-charts/vue 0.8.0 → 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 (48) hide show
  1. package/README.md +2 -0
  2. package/dist/BandSeries.vue.js +43 -32
  3. package/dist/BarSeries.vue.js +44 -33
  4. package/dist/CandlestickSeries.vue.js +24 -23
  5. package/dist/ChartContainer.vue.js +1 -1
  6. package/dist/HeatmapSeries.vue.js +21 -20
  7. package/dist/LineSeries.vue.js +43 -32
  8. package/dist/PieSeries.vue.js +25 -24
  9. package/dist/composables.js +63 -36
  10. package/dist/core/dist/axis/dom-labels.js +64 -53
  11. package/dist/core/dist/chart/badge-animator.js +38 -28
  12. package/dist/core/dist/chart/options.js +1 -1
  13. package/dist/core/dist/chart/y-target.js +38 -32
  14. package/dist/core/dist/chart.js +852 -709
  15. package/dist/core/dist/data/decimation.js +52 -51
  16. package/dist/core/dist/data/store.js +38 -20
  17. package/dist/core/dist/data/sync.js +97 -59
  18. package/dist/core/dist/navigator/controller.js +11 -11
  19. package/dist/core/dist/perf/perf-hud.js +3 -3
  20. package/dist/core/dist/scales/tick-tracker.js +2 -1
  21. package/dist/core/dist/scales/time-ticks.js +99 -0
  22. package/dist/core/dist/scales/x-scale.js +33 -27
  23. package/dist/core/dist/series/band.js +83 -83
  24. package/dist/core/dist/series/bar.js +240 -211
  25. package/dist/core/dist/series/base-multi-layer.js +288 -240
  26. package/dist/core/dist/series/candlestick.js +168 -168
  27. package/dist/core/dist/series/line.js +545 -455
  28. package/dist/core/dist/snapshots.js +109 -86
  29. package/dist/core/dist/utils/point.js +4 -0
  30. package/dist/core/dist/utils/time.js +42 -26
  31. package/dist/index.d.ts +67 -28
  32. package/dist/ui/InfoBar.vue.js +69 -69
  33. package/dist/ui/NumberFlow.vue.js +36 -27
  34. package/dist/ui/Tooltip.vue.js +128 -131
  35. package/dist/ui/YLabel.vue.js +47 -47
  36. package/package.json +2 -2
  37. package/src/BandSeries.vue +20 -5
  38. package/src/BarSeries.vue +20 -5
  39. package/src/CandlestickSeries.vue +5 -4
  40. package/src/ChartContainer.vue +15 -9
  41. package/src/HeatmapSeries.vue +5 -4
  42. package/src/LineSeries.vue +20 -5
  43. package/src/PieSeries.vue +6 -5
  44. package/src/composables.ts +64 -1
  45. package/src/ui/InfoBar.vue +11 -3
  46. package/src/ui/NumberFlow.vue +17 -3
  47. package/src/ui/Tooltip.vue +23 -12
  48. package/src/ui/YLabel.vue +28 -27
@@ -1,60 +1,60 @@
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 = {
1
+ import { defineComponent as T, computed as s, inject as B, ref as W, onMounted as N, onUnmounted as R, useSlots as A, unref as t, openBlock as l, createBlock as D, Teleport as M, createElementVNode as r, normalizeStyle as i, renderSlot as O, createElementBlock as u, Fragment as m, toDisplayString as p, renderList as F, createCommentVNode as L } from "vue";
2
+ import { buildHoverSnapshots as P, buildLastSnapshots as $, formatHeaderX as j, formatRowValue as U } from "../core/dist/snapshots.js";
3
+ import { resolveCandlestickBodyColor as X } from "../core/dist/theme/resolve.js";
4
+ import { formatCompact as q, formatPriceAdaptive as G } from "../core/dist/utils/format.js";
5
+ import { useCrosshairPosition as J } from "../composables.js";
6
+ import { useChartInstance as Q, ThemeKey as Y, InfoBarAnchorKey as Z } from "../context.js";
7
+ const ee = {
8
8
  key: 0,
9
9
  style: { display: "inline-flex", alignItems: "center", gap: "4px" }
10
- }, ee = {
10
+ }, te = {
11
11
  key: 1,
12
12
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
13
- }, te = {
13
+ }, ae = {
14
14
  key: 2,
15
15
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
16
- }, se = /* @__PURE__ */ W({
16
+ }, ue = /* @__PURE__ */ T({
17
17
  __name: "InfoBar",
18
18
  props: {
19
19
  sort: {},
20
20
  format: { type: Function }
21
21
  },
22
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);
23
+ const k = E, C = s(() => k.sort ?? "none"), d = s(
24
+ () => k.format ?? ((a, _) => _ === "volume" ? q(a) : G(a))
25
+ ), n = Q(), g = J(n), o = B(Y), x = B(Z);
26
26
  if (!o)
27
27
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing ThemeKey.");
28
- if (!g)
28
+ if (!x)
29
29
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing InfoBarAnchorKey.");
30
- const h = N(0), C = () => {
30
+ const h = W(0), y = () => {
31
31
  h.value++;
32
32
  };
33
- T(() => {
34
- u.on("overlayChange", C), u.getSeriesIds().length > 0 && h.value++;
35
- }), A(() => {
36
- u.off("overlayChange", C);
33
+ N(() => {
34
+ n.on("overlayChange", y), n.on("seriesFrame", y), n.getSeriesIds().length > 0 && h.value++;
35
+ }), R(() => {
36
+ n.off("overlayChange", y), n.off("seriesFrame", y);
37
37
  });
38
- const x = i(() => {
38
+ const b = s(() => {
39
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");
40
+ const a = g.value;
41
+ return a === null ? null : P(n, { time: a.time, sort: C.value, cacheKey: "infobar-hover" });
42
+ }), H = s(() => (h.value, $(n, { sort: C.value, cacheKey: "infobar-last" }))), v = s(() => b.value !== null && b.value.length > 0), c = s(
43
+ () => v.value ? b.value : H.value
44
+ ), K = s(() => (h.value, n.getDataInterval())), S = s(() => c.value.length === 0 ? 0 : v.value && g.value ? g.value.time : Math.max(...c.value.map((a) => a.data.time))), V = A(), w = s(() => typeof V.default == "function");
45
45
  function I(a) {
46
46
  return "open" in a;
47
47
  }
48
- function V(a) {
48
+ function z(a) {
49
49
  return "high" in a && !I(a);
50
50
  }
51
- return (a, _) => t(g) && t(o) && c.value.length > 0 ? (n(), R($, {
51
+ return (a, _) => t(x) && t(o) && c.value.length > 0 ? (l(), D(M, {
52
52
  key: 0,
53
- to: t(g)
53
+ to: t(x)
54
54
  }, [
55
- l("div", {
55
+ r("div", {
56
56
  "data-tooltip-legend": "",
57
- style: r(
57
+ style: i(
58
58
  w.value ? {
59
59
  display: "flex",
60
60
  alignItems: "center",
@@ -62,7 +62,7 @@ const Z = {
62
62
  fontSize: t(o).typography.fontSize + "px",
63
63
  fontFamily: t(o).typography.fontFamily,
64
64
  fontVariantNumeric: "tabular-nums",
65
- opacity: m.value ? 1 : 0.6,
65
+ opacity: v.value ? 1 : 0.6,
66
66
  transition: "opacity 0.2s ease",
67
67
  pointerEvents: "none"
68
68
  } : {
@@ -75,57 +75,57 @@ const Z = {
75
75
  fontSize: t(o).typography.fontSize + "px",
76
76
  fontFamily: t(o).typography.fontFamily,
77
77
  fontVariantNumeric: "tabular-nums",
78
- opacity: m.value ? 1 : 0.6,
78
+ opacity: v.value ? 1 : 0.6,
79
79
  transition: "opacity 0.2s ease",
80
80
  pointerEvents: "none"
81
81
  }
82
82
  )
83
83
  }, [
84
- w.value ? D(a.$slots, "default", {
84
+ w.value ? O(a.$slots, "default", {
85
85
  key: 0,
86
86
  snapshots: c.value,
87
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, {
88
+ isHover: v.value
89
+ }) : (l(), u(m, { key: 1 }, [
90
+ r("span", {
91
+ style: i({ color: t(o).axis.textColor, marginRight: "2px" })
92
+ }, p(t(j)(t(n), { time: S.value, snapshots: c.value, interval: K.value })), 5),
93
+ (l(!0), u(m, null, F(c.value, (e) => (l(), u(m, {
94
94
  key: e.id
95
95
  }, [
96
- I(e.data) ? (n(), s("span", Z, [
97
- (n(!0), s(f, null, L([
96
+ I(e.data) ? (l(), u("span", ee, [
97
+ (l(!0), u(m, null, F([
98
98
  { label: "O", field: "open", val: e.data.open },
99
99
  { label: "H", field: "high", val: e.data.high },
100
100
  { label: "L", field: "low", val: e.data.low },
101
101
  { label: "C", field: "close", val: e.data.close }
102
- ], (v) => (n(), s(f, {
103
- key: v.label
102
+ ], (f) => (l(), u(m, {
103
+ key: f.label
104
104
  }, [
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)(
105
+ r("span", {
106
+ style: i({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
107
+ }, p(f.label), 5),
108
+ r("span", {
109
+ style: i({
110
+ color: t(X)(
111
111
  e.data.close >= e.data.open ? t(o).candlestick.up.body : t(o).candlestick.down.body
112
112
  ),
113
113
  fontWeight: 500,
114
114
  marginLeft: "2px"
115
115
  })
116
- }, p(d.value(v.val, v.field)), 5)
116
+ }, p(d.value(f.val, f.field)), 5)
117
117
  ], 64))), 128)),
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" })
118
+ e.data.volume != null ? (l(), u(m, { key: 0 }, [
119
+ r("span", {
120
+ style: i({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
121
121
  }, "V", 4),
122
- l("span", {
123
- style: r({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
122
+ r("span", {
123
+ style: i({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
124
124
  }, p(d.value(e.data.volume, "volume")), 5)
125
- ], 64)) : F("", !0)
126
- ])) : V(e.data) ? (n(), s("span", ee, [
127
- l("span", {
128
- style: r({
125
+ ], 64)) : L("", !0)
126
+ ])) : z(e.data) ? (l(), u("span", te, [
127
+ r("span", {
128
+ style: i({
129
129
  width: "6px",
130
130
  height: "6px",
131
131
  borderRadius: "1px",
@@ -133,12 +133,12 @@ const Z = {
133
133
  flexShrink: 0
134
134
  })
135
135
  }, null, 4),
136
- l("span", {
137
- style: r({ color: e.color, fontWeight: 500 })
136
+ r("span", {
137
+ style: i({ color: e.color, fontWeight: 500 })
138
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({
139
+ ])) : (l(), u("span", ae, [
140
+ r("span", {
141
+ style: i({
142
142
  width: "6px",
143
143
  height: "6px",
144
144
  borderRadius: "50%",
@@ -146,16 +146,16 @@ const Z = {
146
146
  flexShrink: 0
147
147
  })
148
148
  }, null, 4),
149
- l("span", {
150
- style: r({ color: e.color, fontWeight: 500 })
151
- }, p(d.value(e.data.value, "value")), 5)
149
+ r("span", {
150
+ style: i({ color: e.color, fontWeight: 500 })
151
+ }, p(t(U)(e, (f) => d.value(f, "value"))), 5)
152
152
  ]))
153
153
  ], 64))), 128))
154
154
  ], 64))
155
155
  ], 4)
156
- ], 8, ["to"])) : F("", !0);
156
+ ], 8, ["to"])) : L("", !0);
157
157
  }
158
158
  });
159
159
  export {
160
- se as default
160
+ ue as default
161
161
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as _, ref as b, onMounted as g, computed as c, openBlock as o, createElementBlock as l, Fragment as r, renderList as f, createElementVNode as m, normalizeStyle as k, toDisplayString as p } from "vue";
1
+ import { defineComponent as k, ref as f, onMounted as N, computed as m, watch as I, openBlock as a, createElementBlock as l, Fragment as r, renderList as d, createElementVNode as y, normalizeStyle as w, toDisplayString as v } from "vue";
2
2
  const x = { style: {
3
3
  display: "inline-flex",
4
4
  fontVariantNumeric: "tabular-nums",
@@ -14,7 +14,7 @@ const x = { style: {
14
14
  }, F = {
15
15
  key: 1,
16
16
  style: { display: "inline-block" }
17
- }, w = /* @__PURE__ */ _({
17
+ }, S = /* @__PURE__ */ k({
18
18
  __name: "NumberFlow",
19
19
  props: {
20
20
  value: {},
@@ -22,48 +22,57 @@ const x = { style: {
22
22
  locale: { default: "en-US" },
23
23
  spinDuration: { default: 350 }
24
24
  },
25
- setup(a) {
26
- const s = a, i = b(!1);
27
- g(() => {
25
+ setup(h) {
26
+ const o = h, i = f(!1);
27
+ N(() => {
28
28
  i.value = !0;
29
29
  });
30
- const d = c(() => {
31
- const t = s.format;
32
- if (typeof t == "function") return t;
33
- const n = new Intl.NumberFormat(s.locale, typeof t == "object" ? t : void 0);
34
- return (e) => n.format(e);
35
- }), y = c(() => {
36
- const t = d.value(s.value), n = [];
37
- for (const e of t)
38
- e >= "0" && e <= "9" ? n.push({ type: "digit", value: e }) : n.push({ type: "symbol", value: e });
30
+ const u = m(() => {
31
+ const e = o.format;
32
+ if (typeof e == "function") return e;
33
+ const n = new Intl.NumberFormat(o.locale, typeof e == "object" ? e : void 0);
34
+ return (t) => n.format(t);
35
+ }), _ = m(() => {
36
+ const e = u.value(o.value), n = [];
37
+ for (const t of e)
38
+ t >= "0" && t <= "9" ? n.push({ type: "digit", value: t }) : n.push({ type: "symbol", value: t });
39
39
  return n;
40
- }), v = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
41
- return (t, n) => (o(), l("span", x, [
42
- (o(!0), l(r, null, f(y.value, (e, h) => (o(), l(r, { key: h }, [
43
- e.type === "digit" ? (o(), l("span", D, [
44
- m("span", {
45
- style: k({
40
+ }), s = f(o.spinDuration);
41
+ let c = Number.NEGATIVE_INFINITY;
42
+ I(
43
+ () => u.value(o.value),
44
+ () => {
45
+ const e = performance.now(), n = e - c < o.spinDuration;
46
+ c = e, s.value = n ? 0 : o.spinDuration;
47
+ }
48
+ );
49
+ const b = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
50
+ return (e, n) => (a(), l("span", x, [
51
+ (a(!0), l(r, null, d(_.value, (t, g) => (a(), l(r, { key: g }, [
52
+ t.type === "digit" ? (a(), l("span", D, [
53
+ y("span", {
54
+ style: w({
46
55
  display: "flex",
47
56
  flexDirection: "column",
48
- transform: "translateY(" + -parseInt(e.value) * 1.2 + "em)",
49
- transition: i.value ? "transform " + a.spinDuration + "ms cubic-bezier(0.16, 1, 0.3, 1)" : "none"
57
+ transform: "translateY(" + -parseInt(t.value) * 1.2 + "em)",
58
+ transition: i.value && s.value > 0 ? "transform " + s.value + "ms cubic-bezier(0.16, 1, 0.3, 1)" : "none"
50
59
  })
51
60
  }, [
52
- (o(), l(r, null, f(v, (u) => m("span", {
53
- key: u,
61
+ (a(), l(r, null, d(b, (p) => y("span", {
62
+ key: p,
54
63
  style: {
55
64
  display: "flex",
56
65
  alignItems: "center",
57
66
  justifyContent: "center",
58
67
  height: "1.2em"
59
68
  }
60
- }, p(u), 1)), 64))
69
+ }, v(p), 1)), 64))
61
70
  ], 4)
62
- ])) : (o(), l("span", F, p(e.value), 1))
71
+ ])) : (a(), l("span", F, v(t.value), 1))
63
72
  ], 64))), 128))
64
73
  ]));
65
74
  }
66
75
  });
67
76
  export {
68
- w as default
77
+ S as default
69
78
  };