@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,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 D, createElementVNode as l, normalizeStyle as r, renderSlot as M, createElementBlock as s, Fragment as c, toDisplayString as p, renderList as F, createCommentVNode as L } from "vue";
2
+ import { buildHoverSnapshots as P, buildLastSnapshots as $ } from "../core/dist/snapshots.js";
3
+ import { resolveCandlestickBodyColor as j } from "../core/dist/theme/resolve.js";
4
+ import { formatCompact as U, formatPriceAdaptive as X } from "../core/dist/utils/format.js";
5
+ import { useCrosshairPosition as q } from "../composables.js";
6
+ import { useChartInstance as G, ThemeKey as J, InfoBarAnchorKey as Q } from "../context.js";
7
+ const Y = {
8
8
  key: 0,
9
9
  style: { display: "inline-flex", alignItems: "center", gap: "4px" }
10
- }, Y = {
10
+ }, Z = {
11
11
  key: 1,
12
12
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
13
- }, le = /* @__PURE__ */ V({
13
+ }, ee = {
14
+ key: 2,
15
+ style: { display: "inline-flex", alignItems: "center", gap: "3px" }
16
+ }, ie = /* @__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"), f = i(
24
+ () => b.format ?? ((a, _) => _ === "volume" ? U(a) : X(a))
25
+ ), u = G(), y = q(u), o = B(J), g = B(Q);
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 : P(u, { time: a.time, sort: k.value, cacheKey: "infobar-hover" });
42
+ }), K = i(() => (h.value, $(u, { sort: k.value, cacheKey: "infobar-last" }))), m = i(() => x.value !== null && x.value.length > 0), d = i(
43
+ () => m.value ? x.value : K.value
44
+ ), z = i(() => u.getDataInterval()), S = i(() => d.value.length === 0 ? 0 : m.value && y.value ? y.value.time : Math.max(...d.value.map((a) => a.data.time))), H = O(), w = i(() => typeof H.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) && d.value.length > 0 ? (n(), R(D, {
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,77 +72,90 @@ 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 ? M(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: d.value,
87
+ time: S.value,
88
+ isHover: m.value
89
+ }) : (n(), s(c, { key: 1 }, [
90
+ l("span", {
91
+ style: r({ color: t(o).axis.textColor, marginRight: "2px" })
92
+ }, p(t(u).timeScale.formatX(S.value, z.value)), 5),
93
+ (n(!0), s(c, null, F(d.value, (e) => (n(), s(c, {
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", Y, [
97
+ (n(!0), s(c, null, F([
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(c, {
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(j)(
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(f.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(c, { 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)
119
- ], 64)) : F("", !0)
120
- ])) : (l(), u("span", Y, [
121
- i("span", {
122
- style: s({
122
+ l("span", {
123
+ style: r({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
124
+ }, p(f.value(e.data.volume, "volume")), 5)
125
+ ], 64)) : L("", !0)
126
+ ])) : V(e.data) ? (n(), s("span", Z, [
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(f.value(e.data.low, "low")) + " – " + p(f.value(e.data.high, "high")), 5)
139
+ ])) : (n(), s("span", ee, [
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(f.value(e.data.value, "value")), 5)
133
152
  ]))
134
153
  ], 64))), 128))
135
154
  ], 64))
136
155
  ], 4)
137
- ], 8, ["to"])) : F("", !0);
156
+ ], 8, ["to"])) : L("", !0);
138
157
  }
139
158
  });
140
159
  export {
141
- le as default
160
+ ie as default
142
161
  };
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as H, computed as a, useSlots as R, ref as x, onMounted as O, onUnmounted as P, watchEffect as B, openBlock as m, createElementBlock as g, Fragment as D, unref as b, normalizeStyle as y, createElementVNode as s, toDisplayString as _, createCommentVNode as I, renderSlot as L } from "vue";
2
2
  import { computeTooltipPosition as C } from "../core/dist/tooltip-position.js";
3
- import { formatCompact as X } from "../core/dist/utils/format.js";
4
- import { useCrosshairPosition as Y } from "../composables.js";
5
- import { useChartInstance as M } from "../context.js";
3
+ import { formatCompact as M } from "../core/dist/utils/format.js";
4
+ import { useCrosshairPosition as X } from "../composables.js";
5
+ import { useChartInstance as Y } from "../context.js";
6
6
  const U = { style: { display: "flex", alignItems: "center", gap: "8px" } }, A = { style: { fontWeight: 600 } }, N = { style: { display: "flex", justifyContent: "space-between", gap: "16px" } }, V = { style: { opacity: 0.6 } }, j = { style: { fontWeight: 600 } }, G = ["data-measured"], $ = 160, q = 70, te = /* @__PURE__ */ H({
7
7
  __name: "PieTooltip",
8
8
  props: {
@@ -10,7 +10,7 @@ const U = { style: { display: "flex", alignItems: "center", gap: "8px" } }, A =
10
10
  format: { type: Function }
11
11
  },
12
12
  setup(T) {
13
- const S = T, k = a(() => S.format ?? X), i = M(), l = Y(i), W = R(), d = a(() => typeof W.default == "function"), c = x(0), w = () => {
13
+ const S = T, k = a(() => S.format ?? M), i = Y(), l = X(i), W = R(), d = a(() => typeof W.default == "function"), c = x(0), w = () => {
14
14
  c.value++;
15
15
  };
16
16
  O(() => {
@@ -1,36 +1,37 @@
1
- import { defineComponent as r, ref as u, watch as c, onUnmounted as a, onMounted as p, openBlock as m, createElementBlock as b, normalizeStyle as f, unref as o } from "vue";
2
- import { mountAxisLabels as x } from "../core/dist/axis/dom-labels.js";
1
+ import { defineComponent as c, computed as p, ref as m, watch as f, onUnmounted as u, onMounted as x, openBlock as b, createElementBlock as y, normalizeStyle as h, unref as o } from "vue";
2
+ import { mountAxisLabels as L } from "../core/dist/axis/dom-labels.js";
3
+ import { useAxisLayout as d } from "../composables.js";
3
4
  import { useChartInstance as g } from "../context.js";
4
- const _ = /* @__PURE__ */ r({
5
+ const D = /* @__PURE__ */ c({
5
6
  __name: "TimeAxis",
6
7
  props: {
7
8
  labelCount: {},
8
9
  minLabelSpacing: {}
9
10
  },
10
- setup(s) {
11
- const n = s, e = g(), t = u(null), i = () => {
12
- e.setTimeAxisLabelDensity({
13
- labelCount: n.labelCount ?? null,
14
- minLabelSpacing: n.minLabelSpacing ?? null
11
+ setup(r) {
12
+ const e = r, n = g(), t = d(n), a = p(() => t.value.yAxisPosition === "left"), l = m(null), s = () => {
13
+ n.setTimeAxisLabelDensity({
14
+ labelCount: e.labelCount ?? null,
15
+ minLabelSpacing: e.minLabelSpacing ?? null
15
16
  });
16
17
  };
17
- i(), c(() => [n.labelCount, n.minLabelSpacing], i), a(() => {
18
- e.setTimeAxisLabelDensity({ labelCount: null, minLabelSpacing: null });
18
+ s(), f(() => [e.labelCount, e.minLabelSpacing], s), u(() => {
19
+ n.setTimeAxisLabelDensity({ labelCount: null, minLabelSpacing: null });
19
20
  });
20
- let l = null;
21
- return p(() => {
22
- t.value !== null && (l = x({ chart: e, container: t.value, axis: "x" }));
23
- }), a(() => {
24
- l?.(), l = null;
25
- }), (h, y) => (m(), b("div", {
21
+ let i = null;
22
+ return x(() => {
23
+ l.value !== null && (i = L({ chart: n, container: l.value, axis: "x" }));
24
+ }), u(() => {
25
+ i?.(), i = null;
26
+ }), (A, v) => (b(), y("div", {
26
27
  ref_key: "containerRef",
27
- ref: t,
28
- style: f({
28
+ ref: l,
29
+ style: h({
29
30
  position: "absolute",
30
- left: "0",
31
+ left: (a.value ? o(t).yAxisWidth : 0) + "px",
31
32
  bottom: "0",
32
- right: o(e).yAxisWidth + "px",
33
- height: o(e).xAxisHeight + "px",
33
+ right: (a.value ? 0 : o(t).yAxisWidth) + "px",
34
+ height: o(t).xAxisHeight + "px",
34
35
  pointerEvents: "none",
35
36
  display: "flex",
36
37
  alignItems: "center"
@@ -39,5 +40,5 @@ const _ = /* @__PURE__ */ r({
39
40
  }
40
41
  });
41
42
  export {
42
- _ as default
43
+ D as default
43
44
  };