@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.
- package/README.md +2 -2
- package/dist/BandSeries.vue.js +50 -0
- package/dist/BandSeries.vue2.js +4 -0
- package/dist/ChartContainer.vue.js +45 -39
- package/dist/composables.js +39 -26
- package/dist/core/dist/animation/config.js +92 -75
- package/dist/core/dist/axis/dom-labels.js +56 -43
- package/dist/core/dist/chart/badge-animator.js +30 -22
- package/dist/core/dist/chart/edge-indicators.js +22 -21
- package/dist/core/dist/chart/last-value.js +33 -26
- package/dist/core/dist/chart/options.js +5 -5
- package/dist/core/dist/chart/scale-guards.js +26 -0
- package/dist/core/dist/chart/y-target.js +46 -19
- package/dist/core/dist/chart.js +670 -518
- package/dist/core/dist/components/crosshair.js +8 -8
- package/dist/core/dist/components/grid.js +26 -17
- package/dist/core/dist/components/marker.js +28 -28
- package/dist/core/dist/components/reference-line.js +16 -16
- package/dist/core/dist/data/decimation.js +58 -39
- package/dist/core/dist/interactions/handler.js +3 -2
- package/dist/core/dist/interactions/zoom.js +6 -5
- package/dist/core/dist/navigator/controller.js +47 -44
- package/dist/core/dist/perf/perf-hud.js +3 -3
- package/dist/core/dist/scales/log-scale.js +76 -0
- package/dist/core/dist/scales/y-scale.js +134 -35
- package/dist/core/dist/series/band.js +670 -0
- package/dist/core/dist/series/bar-intro.js +11 -11
- package/dist/core/dist/series/bar.js +301 -251
- package/dist/core/dist/series/base-multi-layer.js +100 -76
- package/dist/core/dist/series/candlestick.js +238 -235
- package/dist/core/dist/series/heatmap.js +5 -5
- package/dist/core/dist/series/line-intro.js +50 -40
- package/dist/core/dist/series/line.js +561 -483
- package/dist/core/dist/series/painters/builtins.js +4 -4
- package/dist/core/dist/series/painters/canvas-path.js +64 -52
- package/dist/core/dist/series/register-builtins.js +9 -8
- package/dist/core/dist/series/scale-stack.js +25 -0
- package/dist/core/dist/snapshots.js +36 -35
- package/dist/core/dist/tooltip-position.js +5 -5
- package/dist/core/dist/utils/point.js +10 -0
- package/dist/index.d.ts +501 -128
- package/dist/index.js +195 -189
- package/dist/ui/Crosshair.vue.js +14 -14
- package/dist/ui/HeatmapTooltip.vue.js +6 -6
- package/dist/ui/InfoBar.vue.js +100 -81
- package/dist/ui/PieTooltip.vue.js +4 -4
- package/dist/ui/TimeAxis.vue.js +23 -22
- package/dist/ui/Tooltip.vue.js +140 -111
- package/dist/ui/YAxis.vue.js +25 -24
- package/dist/ui/YLabel.vue.js +63 -70
- package/package.json +2 -2
- package/src/BandSeries.vue +87 -0
- package/src/ChartContainer.vue +20 -8
- package/src/composables.ts +35 -1
- package/src/index.ts +13 -0
- package/src/ui/Crosshair.vue +2 -2
- package/src/ui/InfoBar.vue +20 -1
- package/src/ui/TimeAxis.vue +7 -4
- package/src/ui/Tooltip.vue +40 -3
- package/src/ui/YAxis.vue +5 -3
- package/src/ui/YLabel.vue +5 -16
package/dist/ui/Tooltip.vue.js
CHANGED
|
@@ -1,145 +1,174 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { buildHoverSnapshots as
|
|
3
|
-
import { resolveCandlestickBodyColor as
|
|
4
|
-
import { computeTooltipPosition as
|
|
5
|
-
import { formatCompact as
|
|
6
|
-
import { formatDate as
|
|
7
|
-
import { useCrosshairPosition as
|
|
8
|
-
import { useChartInstance as
|
|
9
|
-
const
|
|
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
|
-
},
|
|
12
|
+
}, oe = { style: { opacity: 0.5 } }, ae = {
|
|
13
13
|
key: 1,
|
|
14
14
|
style: { display: "flex", alignItems: "center", gap: "8px", padding: "2px 0" }
|
|
15
|
-
},
|
|
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(
|
|
22
|
-
const
|
|
23
|
-
() =>
|
|
24
|
-
),
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
|
|
37
|
+
X(() => {
|
|
38
|
+
t.on("overlayChange", F), t.getSeriesIds().length > 0 && w.value++;
|
|
39
|
+
}), Y(() => {
|
|
40
|
+
t.off("overlayChange", F);
|
|
31
41
|
});
|
|
32
|
-
const
|
|
33
|
-
time:
|
|
34
|
-
sort:
|
|
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
|
-
}) : [])),
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
if (!
|
|
40
|
-
const
|
|
41
|
-
!
|
|
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
|
|
45
|
-
(!
|
|
46
|
-
}),
|
|
47
|
-
|
|
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
|
|
51
|
-
if (!
|
|
52
|
-
const a =
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
x:
|
|
57
|
-
y:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
65
|
-
return
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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 =
|
|
74
|
-
function
|
|
85
|
+
}), V = c(() => !y.value || b.value !== null);
|
|
86
|
+
function R(a) {
|
|
75
87
|
return "open" in a;
|
|
76
88
|
}
|
|
77
|
-
|
|
78
|
-
|
|
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:
|
|
95
|
+
style: h({
|
|
81
96
|
position: "absolute",
|
|
82
|
-
left:
|
|
83
|
-
top:
|
|
97
|
+
left: m.value.left + "px",
|
|
98
|
+
top: m.value.top + "px",
|
|
84
99
|
pointerEvents: "none",
|
|
85
|
-
background:
|
|
100
|
+
background: o.value.tooltip.background,
|
|
86
101
|
backdropFilter: "blur(12px)",
|
|
87
102
|
WebkitBackdropFilter: "blur(12px)",
|
|
88
|
-
border: "1px solid " +
|
|
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:
|
|
93
|
-
fontFamily:
|
|
107
|
+
fontSize: o.value.tooltip.fontSize + "px",
|
|
108
|
+
fontFamily: o.value.typography.fontFamily,
|
|
94
109
|
fontVariantNumeric: "tabular-nums",
|
|
95
|
-
color:
|
|
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
|
-
|
|
102
|
-
style:
|
|
103
|
-
fontSize:
|
|
104
|
-
color:
|
|
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 " +
|
|
122
|
+
borderBottom: "1px solid " + o.value.tooltip.borderColor,
|
|
108
123
|
letterSpacing: "0.02em"
|
|
109
124
|
})
|
|
110
|
-
},
|
|
111
|
-
(
|
|
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
|
-
|
|
115
|
-
(
|
|
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) => (
|
|
135
|
+
], (l) => (n(), r(x, {
|
|
121
136
|
key: l.label
|
|
122
137
|
}, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
style:
|
|
138
|
+
s("span", oe, d(l.label), 1),
|
|
139
|
+
s("span", {
|
|
140
|
+
style: h({
|
|
126
141
|
fontWeight: 600,
|
|
127
|
-
color:
|
|
128
|
-
e.data.close >= e.data.open ?
|
|
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
|
-
},
|
|
147
|
+
}, d(g.value(l.val, l.field)), 5)
|
|
133
148
|
], 64))), 128)),
|
|
134
|
-
e.data.volume != null ? (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
style:
|
|
138
|
-
},
|
|
139
|
-
], 64)) :
|
|
140
|
-
])) : (
|
|
141
|
-
|
|
142
|
-
style:
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
style:
|
|
153
|
-
},
|
|
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)) :
|
|
157
|
-
|
|
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:
|
|
191
|
+
style: h({
|
|
163
192
|
position: "absolute",
|
|
164
|
-
left:
|
|
165
|
-
top:
|
|
193
|
+
left: m.value.left + "px",
|
|
194
|
+
top: m.value.top + "px",
|
|
166
195
|
pointerEvents: "none",
|
|
167
|
-
background:
|
|
196
|
+
background: o.value.tooltip.background,
|
|
168
197
|
backdropFilter: "blur(12px)",
|
|
169
198
|
WebkitBackdropFilter: "blur(12px)",
|
|
170
|
-
border: "1px solid " +
|
|
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:
|
|
175
|
-
fontSize:
|
|
203
|
+
fontFamily: o.value.typography.fontFamily,
|
|
204
|
+
fontSize: o.value.tooltip.fontSize + "px",
|
|
176
205
|
fontVariantNumeric: "tabular-nums",
|
|
177
|
-
color:
|
|
206
|
+
color: o.value.tooltip.textColor,
|
|
178
207
|
width: "max-content",
|
|
179
|
-
maxWidth:
|
|
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
|
-
|
|
186
|
-
snapshots:
|
|
187
|
-
time:
|
|
214
|
+
K(a.$slots, "default", {
|
|
215
|
+
snapshots: f.value,
|
|
216
|
+
time: C.value
|
|
188
217
|
})
|
|
189
|
-
], 12,
|
|
218
|
+
], 12, re)) : z("", !0)
|
|
190
219
|
], 64));
|
|
191
220
|
}
|
|
192
221
|
});
|
|
193
222
|
export {
|
|
194
|
-
|
|
223
|
+
xe as default
|
|
195
224
|
};
|
package/dist/ui/YAxis.vue.js
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { mountAxisLabels as
|
|
3
|
-
import {
|
|
4
|
-
|
|
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(
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
labelCount:
|
|
17
|
-
minLabelSpacing:
|
|
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
|
-
|
|
21
|
-
let
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
}), (
|
|
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:
|
|
29
|
-
style:
|
|
29
|
+
ref: l,
|
|
30
|
+
style: x({
|
|
30
31
|
position: "absolute",
|
|
31
|
-
|
|
32
|
+
[i(e).yAxisPosition]: "0",
|
|
32
33
|
top: "0",
|
|
33
|
-
bottom:
|
|
34
|
-
width:
|
|
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
|
-
|
|
42
|
+
F as default
|
|
42
43
|
};
|
package/dist/ui/YLabel.vue.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { prefersReducedMotion as
|
|
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
|
|
6
|
-
const ie = /* @__PURE__ */
|
|
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
|
|
16
|
-
let p = null,
|
|
17
|
-
const
|
|
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
|
-
|
|
20
|
-
const t = s.value,
|
|
21
|
-
if (t === null || !
|
|
22
|
-
p = 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
|
|
26
|
-
(p === null ||
|
|
27
|
-
const { glide:
|
|
28
|
-
target:
|
|
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:
|
|
32
|
-
introFront:
|
|
31
|
+
firstVisible: S < 1 ? Z(e, t, m) : m,
|
|
32
|
+
introFront: S,
|
|
33
33
|
now: performance.now(),
|
|
34
|
-
glide:
|
|
34
|
+
glide: P,
|
|
35
35
|
countUp: U,
|
|
36
|
-
settleMs:
|
|
37
|
-
reducedMotion:
|
|
38
|
-
}),
|
|
39
|
-
(
|
|
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
|
|
42
|
-
|
|
41
|
+
function R() {
|
|
42
|
+
u === null && (u = requestAnimationFrame(L));
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
i.value++,
|
|
44
|
+
const f = () => {
|
|
45
|
+
i.value++, R();
|
|
46
46
|
};
|
|
47
47
|
G(() => {
|
|
48
|
-
e.setYLabel(!0), e.on("overlayChange",
|
|
49
|
-
}),
|
|
50
|
-
e.setYLabel(!1), e.off("overlayChange",
|
|
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
|
-
|
|
53
|
-
if (l
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
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
|
-
}),
|
|
64
|
+
}), C = a(() => {
|
|
72
65
|
i.value;
|
|
73
|
-
const t = e.yScale.getRange(),
|
|
74
|
-
return
|
|
75
|
-
}),
|
|
76
|
-
if (
|
|
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:
|
|
79
|
-
maximumFractionDigits:
|
|
71
|
+
minimumFractionDigits: C.value,
|
|
72
|
+
maximumFractionDigits: C.value,
|
|
80
73
|
useGrouping: !1
|
|
81
74
|
});
|
|
82
|
-
return (
|
|
75
|
+
return (n) => t.format(n);
|
|
83
76
|
});
|
|
84
|
-
return (t,
|
|
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:
|
|
88
|
-
y:
|
|
80
|
+
value: l.value.value,
|
|
81
|
+
y: h.value,
|
|
89
82
|
bgColor: V.value,
|
|
90
|
-
isLive:
|
|
91
|
-
direction:
|
|
92
|
-
format:
|
|
93
|
-
opacity:
|
|
94
|
-
}) : (w(), B
|
|
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:
|
|
89
|
+
style: Y({
|
|
97
90
|
position: "absolute",
|
|
98
|
-
left: "
|
|
99
|
-
right:
|
|
100
|
-
top:
|
|
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:
|
|
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:
|
|
102
|
+
style: Y({
|
|
110
103
|
position: "absolute",
|
|
111
|
-
|
|
112
|
-
top:
|
|
104
|
+
[g(e).yAxisPosition]: "4px",
|
|
105
|
+
top: h.value + "px",
|
|
113
106
|
transform: "translateY(-50%)",
|
|
114
|
-
opacity:
|
|
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
|
-
|
|
120
|
+
H(ae, {
|
|
128
121
|
value: D.value,
|
|
129
|
-
format:
|
|
122
|
+
format: F.value,
|
|
130
123
|
"spin-duration": 350
|
|
131
124
|
}, null, 8, ["value", "format"])
|
|
132
125
|
], 4)
|
|
133
126
|
], 64))
|
|
134
|
-
], 64)) :
|
|
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.
|
|
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.
|
|
48
|
+
"@wick-charts/core": "^0.6.4"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "vite build"
|