@wick-charts/vue 0.4.1 → 0.5.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.
- package/README.md +5 -3
- package/dist/BarSeries.vue.js +44 -0
- package/dist/BarSeries.vue2.js +4 -0
- package/dist/CandlestickSeries.vue.js +45 -0
- package/dist/CandlestickSeries.vue2.js +4 -0
- package/dist/ChartContainer.vue.js +168 -0
- package/dist/ChartContainer.vue2.js +4 -0
- package/dist/LineSeries.vue.js +44 -0
- package/dist/LineSeries.vue2.js +4 -0
- package/dist/PieSeries.vue.js +34 -0
- package/dist/PieSeries.vue2.js +4 -0
- package/dist/composables.js +44 -0
- package/dist/context.js +25 -0
- package/dist/core/dist/animation/animator.js +72 -0
- package/dist/core/dist/animation/config.js +145 -0
- package/dist/core/dist/animation/easing.js +4 -0
- package/dist/core/dist/animation/scalar-spring.js +57 -0
- package/dist/core/dist/animation/spring.js +11 -0
- package/dist/core/dist/animation/time.js +19 -0
- package/dist/core/dist/animation/viewport-engine.js +174 -0
- package/dist/core/dist/animation/visible-range-spring.js +64 -0
- package/dist/core/dist/animation/y-range-hermite.js +72 -0
- package/dist/core/dist/animation/y-range-snap.js +31 -0
- package/dist/core/dist/animation/y-range-spring.js +59 -0
- package/dist/core/dist/axis/dom-labels.js +60 -0
- package/dist/core/dist/canvas-manager.js +109 -0
- package/dist/core/dist/chart/edge-indicators.js +26 -0
- package/dist/core/dist/chart/fit-to-data.js +9 -0
- package/dist/core/dist/chart/last-value.js +31 -0
- package/dist/core/dist/chart/options.js +35 -0
- package/dist/core/dist/chart/pan-zoom-math.js +66 -0
- package/dist/core/dist/chart/streaming-cadence.js +70 -0
- package/dist/core/dist/chart/streaming-target.js +22 -0
- package/dist/core/dist/chart/viewport-padding.js +6 -0
- package/dist/core/dist/chart/y-target.js +24 -0
- package/dist/core/dist/chart.js +1495 -0
- package/dist/core/dist/components/crosshair.js +9 -0
- package/dist/core/dist/components/edge-indicator.js +36 -0
- package/dist/core/dist/components/grid.js +22 -0
- package/dist/core/dist/components/marker.js +41 -0
- package/dist/core/dist/components/reference-line.js +48 -0
- package/dist/core/dist/components/time-region.js +35 -0
- package/dist/core/dist/data/decimation.js +54 -0
- package/dist/core/dist/data/store.js +76 -0
- package/dist/core/dist/data/sync.js +47 -0
- package/dist/core/dist/events.js +19 -0
- package/dist/core/dist/interactions/handler.js +84 -0
- package/dist/core/dist/interactions/pan.js +26 -0
- package/dist/core/dist/interactions/zoom.js +21 -0
- package/dist/core/dist/navigator/controller.js +374 -0
- package/dist/core/dist/navigator/decimate.js +44 -0
- package/dist/core/dist/navigator/interactions.js +28 -0
- package/dist/core/dist/navigator/render.js +68 -0
- package/dist/core/dist/perf/counting-context.js +19 -0
- package/dist/core/dist/perf/perf-hud.js +453 -0
- package/dist/core/dist/perf/perf-monitor.js +132 -0
- package/dist/core/dist/render-scheduler.js +31 -0
- package/dist/core/dist/scales/tick-tracker.js +110 -0
- package/dist/core/dist/scales/x-scale.js +145 -0
- package/dist/core/dist/scales/y-scale.js +156 -0
- package/dist/core/dist/series/bar.js +341 -0
- package/dist/core/dist/series/base-multi-layer.js +438 -0
- package/dist/core/dist/series/candlestick.js +481 -0
- package/dist/core/dist/series/definition.js +11 -0
- package/dist/core/dist/series/line.js +446 -0
- package/dist/core/dist/series/painters/builtins.js +36 -0
- package/dist/core/dist/series/painters/canvas-path.js +79 -0
- package/dist/core/dist/series/painters/resolve.js +32 -0
- package/dist/core/dist/series/pie.js +545 -0
- package/dist/core/dist/series/register-builtins.js +11 -0
- package/dist/core/dist/series/stack-math.js +17 -0
- package/dist/core/dist/snapshots.js +107 -0
- package/dist/core/dist/theme/create.js +176 -0
- package/dist/core/dist/theme/resolve.js +14 -0
- package/dist/core/dist/theme/themes/andromeda.js +33 -0
- package/dist/core/dist/theme/themes/ayu-mirage.js +33 -0
- package/dist/core/dist/theme/themes/catppuccin.js +33 -0
- package/dist/core/dist/theme/themes/dracula.js +35 -0
- package/dist/core/dist/theme/themes/github-light.js +34 -0
- package/dist/core/dist/theme/themes/gruvbox.js +33 -0
- package/dist/core/dist/theme/themes/handwritten.js +101 -0
- package/dist/core/dist/theme/themes/high-contrast.js +33 -0
- package/dist/core/dist/theme/themes/lavender-mist.js +33 -0
- package/dist/core/dist/theme/themes/light-pink.js +34 -0
- package/dist/core/dist/theme/themes/material-palenight.js +33 -0
- package/dist/core/dist/theme/themes/minimal-light.js +34 -0
- package/dist/core/dist/theme/themes/mint-breeze.js +33 -0
- package/dist/core/dist/theme/themes/monokai-pro.js +33 -0
- package/dist/core/dist/theme/themes/night-owl.js +35 -0
- package/dist/core/dist/theme/themes/one-dark-pro.js +33 -0
- package/dist/core/dist/theme/themes/panda.js +33 -0
- package/dist/core/dist/theme/themes/peach-cream.js +33 -0
- package/dist/core/dist/theme/themes/quiet-light.js +37 -0
- package/dist/core/dist/theme/themes/rose-pine-dawn.js +33 -0
- package/dist/core/dist/theme/themes/sand-dune.js +33 -0
- package/dist/core/dist/theme/themes/solarized-light.js +34 -0
- package/dist/core/dist/tooltip-position.js +10 -0
- package/dist/core/dist/utils/color.js +37 -0
- package/dist/core/dist/utils/format.js +29 -0
- package/dist/core/dist/utils/math.js +26 -0
- package/dist/core/dist/utils/poisoned-data-reporter.js +15 -0
- package/dist/core/dist/utils/time.js +41 -0
- package/dist/index.d.ts +1096 -63
- package/dist/index.js +142 -7754
- package/dist/ui/Crosshair.vue.js +53 -0
- package/dist/ui/Crosshair.vue2.js +4 -0
- package/dist/ui/InfoBar.vue.js +143 -0
- package/dist/ui/InfoBar.vue2.js +4 -0
- package/dist/ui/Legend.vue.js +212 -0
- package/dist/ui/Legend.vue2.js +4 -0
- package/dist/ui/Marker.vue.js +47 -0
- package/dist/ui/Marker.vue2.js +4 -0
- package/dist/ui/Navigator.vue.js +58 -0
- package/dist/ui/Navigator.vue2.js +4 -0
- package/dist/ui/NumberFlow.vue.js +69 -0
- package/dist/ui/NumberFlow.vue2.js +4 -0
- package/dist/ui/PieLegend.vue.js +132 -0
- package/dist/ui/PieLegend.vue2.js +4 -0
- package/dist/ui/PieTooltip.vue.js +135 -0
- package/dist/ui/PieTooltip.vue2.js +4 -0
- package/dist/ui/ReferenceLine.vue.js +44 -0
- package/dist/ui/ReferenceLine.vue2.js +4 -0
- package/dist/ui/TimeAxis.vue.js +43 -0
- package/dist/ui/TimeAxis.vue2.js +4 -0
- package/dist/ui/TimeRegion.vue.js +41 -0
- package/dist/ui/TimeRegion.vue2.js +4 -0
- package/dist/ui/Title.vue.js +54 -0
- package/dist/ui/Title.vue2.js +4 -0
- package/dist/ui/Tooltip.vue.js +195 -0
- package/dist/ui/Tooltip.vue2.js +4 -0
- package/dist/ui/YAxis.vue.js +42 -0
- package/dist/ui/YAxis.vue2.js +4 -0
- package/dist/ui/YLabel.vue.js +105 -0
- package/dist/ui/YLabel.vue2.js +4 -0
- package/package.json +2 -2
- package/src/BarSeries.vue +12 -13
- package/src/CandlestickSeries.vue +17 -6
- package/src/LineSeries.vue +12 -13
- package/src/PieSeries.vue +2 -1
- package/src/composables.ts +12 -2
- package/src/index.ts +42 -0
- package/src/ui/Crosshair.vue +28 -3
- package/src/ui/Legend.vue +1 -2
- package/src/ui/Marker.vue +62 -0
- package/src/ui/ReferenceLine.vue +58 -0
- package/src/ui/TimeRegion.vue +54 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineComponent as V, inject as C, computed as r, useSlots as w, ref as E, onMounted as L, onUnmounted as B, renderSlot as R, openBlock as n, createBlock as T, Teleport as D, createElementVNode as d, normalizeStyle as l, createElementBlock as a, Fragment as I, renderList as F, toDisplayString as u, createCommentVNode as v } from "vue";
|
|
2
|
+
import { formatCompact as P } from "../core/dist/utils/format.js";
|
|
3
|
+
import { LegendAnchorKey as K, LegendRightAnchorKey as M, useChartInstance as $, useTheme as j } from "../context.js";
|
|
4
|
+
const O = ["data-chart-pie-legend-position"], U = { style: { flex: 1, opacity: 0.8 } }, q = { style: { flex: 1, opacity: 0.8 } }, Q = /* @__PURE__ */ V({
|
|
5
|
+
__name: "PieLegend",
|
|
6
|
+
props: {
|
|
7
|
+
seriesId: {},
|
|
8
|
+
mode: { default: void 0 },
|
|
9
|
+
format: { type: Function, default: void 0 },
|
|
10
|
+
position: { default: "bottom" }
|
|
11
|
+
},
|
|
12
|
+
setup(m) {
|
|
13
|
+
const s = m, x = C(K), b = C(M);
|
|
14
|
+
if (!x || !b)
|
|
15
|
+
throw new Error("<PieLegend> must be used within <ChartContainer>: missing legend anchors.");
|
|
16
|
+
const S = r(() => s.position === "right" ? b.value : s.position === "bottom" ? x.value : null), e = r(() => s.mode ?? "both"), h = r(() => s.format ?? P), p = $(), _ = j(), A = w(), W = r(() => typeof A.default == "function"), c = E(0), k = () => {
|
|
17
|
+
c.value++;
|
|
18
|
+
};
|
|
19
|
+
L(() => {
|
|
20
|
+
p.on("overlayChange", k), p.getSeriesIds().length > 0 && c.value++;
|
|
21
|
+
}), B(() => {
|
|
22
|
+
p.off("overlayChange", k);
|
|
23
|
+
});
|
|
24
|
+
function N(f, g) {
|
|
25
|
+
if (g !== void 0) return g;
|
|
26
|
+
const t = f.getSeriesIdsByType("pie", { visibleOnly: !0 });
|
|
27
|
+
return t.length > 0 ? t[0] : null;
|
|
28
|
+
}
|
|
29
|
+
const o = r(() => _.value), z = r(() => (c.value, N(p, s.seriesId))), i = r(() => (c.value, z.value === null ? [] : p.getSliceInfo(z.value) ?? []));
|
|
30
|
+
return (f, g) => W.value && i.value.length > 0 ? R(f.$slots, "default", {
|
|
31
|
+
key: 0,
|
|
32
|
+
slices: i.value,
|
|
33
|
+
mode: e.value,
|
|
34
|
+
format: h.value
|
|
35
|
+
}) : i.value.length > 0 && S.value ? (n(), T(D, {
|
|
36
|
+
key: 1,
|
|
37
|
+
to: S.value
|
|
38
|
+
}, [
|
|
39
|
+
d("div", {
|
|
40
|
+
"data-chart-pie-legend": "",
|
|
41
|
+
"data-chart-pie-legend-position": m.position,
|
|
42
|
+
style: l({
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
gap: "6px",
|
|
46
|
+
padding: "6px 10px",
|
|
47
|
+
fontFamily: o.value.typography.fontFamily,
|
|
48
|
+
fontSize: o.value.typography.fontSize + "px",
|
|
49
|
+
color: o.value.tooltip.textColor,
|
|
50
|
+
pointerEvents: "auto"
|
|
51
|
+
})
|
|
52
|
+
}, [
|
|
53
|
+
(n(!0), a(I, null, F(i.value, (t, y) => (n(), a("div", {
|
|
54
|
+
key: y,
|
|
55
|
+
style: { display: "flex", alignItems: "center", gap: "10px" }
|
|
56
|
+
}, [
|
|
57
|
+
d("span", {
|
|
58
|
+
style: l({ width: "10px", height: "10px", borderRadius: "50%", background: t.color, flexShrink: 0 })
|
|
59
|
+
}, null, 4),
|
|
60
|
+
d("span", U, u(t.label), 1),
|
|
61
|
+
e.value === "value" || e.value === "both" ? (n(), a("span", {
|
|
62
|
+
key: 0,
|
|
63
|
+
style: l({
|
|
64
|
+
fontWeight: 600,
|
|
65
|
+
fontVariantNumeric: "tabular-nums",
|
|
66
|
+
minWidth: e.value === "value" ? "40px" : void 0,
|
|
67
|
+
textAlign: "right"
|
|
68
|
+
})
|
|
69
|
+
}, u(h.value(t.value)), 5)) : v("", !0),
|
|
70
|
+
e.value === "percent" || e.value === "both" ? (n(), a("span", {
|
|
71
|
+
key: 1,
|
|
72
|
+
style: l({
|
|
73
|
+
opacity: e.value === "percent" ? 1 : 0.5,
|
|
74
|
+
fontWeight: e.value === "percent" ? 600 : 400,
|
|
75
|
+
fontSize: (e.value === "percent" ? o.value.typography.fontSize : o.value.axis.fontSize) + "px",
|
|
76
|
+
fontVariantNumeric: "tabular-nums",
|
|
77
|
+
minWidth: "40px",
|
|
78
|
+
textAlign: "right"
|
|
79
|
+
})
|
|
80
|
+
}, u(t.percent.toFixed(1)) + "% ", 5)) : v("", !0)
|
|
81
|
+
]))), 128))
|
|
82
|
+
], 12, O)
|
|
83
|
+
], 8, ["to"])) : i.value.length > 0 ? (n(), a("div", {
|
|
84
|
+
key: 2,
|
|
85
|
+
"data-chart-pie-legend": "",
|
|
86
|
+
"data-chart-pie-legend-position": "overlay",
|
|
87
|
+
style: l({
|
|
88
|
+
display: "flex",
|
|
89
|
+
flexDirection: "column",
|
|
90
|
+
gap: "6px",
|
|
91
|
+
padding: "8px 12px",
|
|
92
|
+
fontFamily: o.value.typography.fontFamily,
|
|
93
|
+
fontSize: o.value.typography.fontSize + "px",
|
|
94
|
+
color: o.value.tooltip.textColor,
|
|
95
|
+
pointerEvents: "auto"
|
|
96
|
+
})
|
|
97
|
+
}, [
|
|
98
|
+
(n(!0), a(I, null, F(i.value, (t, y) => (n(), a("div", {
|
|
99
|
+
key: y,
|
|
100
|
+
style: { display: "flex", alignItems: "center", gap: "10px" }
|
|
101
|
+
}, [
|
|
102
|
+
d("span", {
|
|
103
|
+
style: l({ width: "10px", height: "10px", borderRadius: "50%", background: t.color, flexShrink: 0 })
|
|
104
|
+
}, null, 4),
|
|
105
|
+
d("span", q, u(t.label), 1),
|
|
106
|
+
e.value === "value" || e.value === "both" ? (n(), a("span", {
|
|
107
|
+
key: 0,
|
|
108
|
+
style: l({
|
|
109
|
+
fontWeight: 600,
|
|
110
|
+
fontVariantNumeric: "tabular-nums",
|
|
111
|
+
minWidth: e.value === "value" ? "40px" : void 0,
|
|
112
|
+
textAlign: "right"
|
|
113
|
+
})
|
|
114
|
+
}, u(h.value(t.value)), 5)) : v("", !0),
|
|
115
|
+
e.value === "percent" || e.value === "both" ? (n(), a("span", {
|
|
116
|
+
key: 1,
|
|
117
|
+
style: l({
|
|
118
|
+
opacity: e.value === "percent" ? 1 : 0.5,
|
|
119
|
+
fontWeight: e.value === "percent" ? 600 : 400,
|
|
120
|
+
fontSize: (e.value === "percent" ? o.value.typography.fontSize : o.value.axis.fontSize) + "px",
|
|
121
|
+
fontVariantNumeric: "tabular-nums",
|
|
122
|
+
minWidth: "40px",
|
|
123
|
+
textAlign: "right"
|
|
124
|
+
})
|
|
125
|
+
}, u(t.percent.toFixed(1)) + "% ", 5)) : v("", !0)
|
|
126
|
+
]))), 128))
|
|
127
|
+
], 4)) : v("", !0);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
export {
|
|
131
|
+
Q as default
|
|
132
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { defineComponent as H, computed as a, useSlots as O, ref as m, onMounted as P, onUnmounted as R, watchEffect as D, openBlock as x, createElementBlock as g, Fragment as B, unref as y, normalizeStyle as b, createElementVNode as r, toDisplayString as _, createCommentVNode as T, renderSlot as L } from "vue";
|
|
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";
|
|
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 } }, $ = { style: { fontWeight: 600 } }, j = ["data-measured"], G = 160, q = 70, te = /* @__PURE__ */ H({
|
|
7
|
+
__name: "PieTooltip",
|
|
8
|
+
props: {
|
|
9
|
+
seriesId: {},
|
|
10
|
+
format: { type: Function }
|
|
11
|
+
},
|
|
12
|
+
setup(F) {
|
|
13
|
+
const S = F, w = a(() => S.format ?? X), o = M(), i = Y(o), W = O(), p = a(() => typeof W.default == "function"), c = m(0), I = () => {
|
|
14
|
+
c.value++;
|
|
15
|
+
};
|
|
16
|
+
P(() => {
|
|
17
|
+
o.on("overlayChange", I);
|
|
18
|
+
}), R(() => {
|
|
19
|
+
o.off("overlayChange", I);
|
|
20
|
+
});
|
|
21
|
+
function E(e, t) {
|
|
22
|
+
if (t !== void 0) return t;
|
|
23
|
+
const v = e.getSeriesIdsByType("pie", { visibleOnly: !0 });
|
|
24
|
+
return v.length > 0 ? v[0] : null;
|
|
25
|
+
}
|
|
26
|
+
const s = a(() => (c.value, o.getTheme())), z = a(() => (c.value, E(o, S.seriesId))), n = a(() => (i.value, c.value, z.value === null ? null : o.getHoverInfo(z.value))), k = m(null), u = m(null);
|
|
27
|
+
let f = null;
|
|
28
|
+
D((e) => {
|
|
29
|
+
if (!p.value) return;
|
|
30
|
+
const t = k.value;
|
|
31
|
+
!t || typeof ResizeObserver > "u" || (f = new ResizeObserver((v) => {
|
|
32
|
+
const d = v[0]?.contentRect;
|
|
33
|
+
if (!d) return;
|
|
34
|
+
const h = u.value;
|
|
35
|
+
(!h || h.width !== d.width || h.height !== d.height) && (u.value = { width: d.width, height: d.height });
|
|
36
|
+
}), f.observe(t), e(() => {
|
|
37
|
+
f?.disconnect(), f = null;
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
const l = a(() => {
|
|
41
|
+
if (!i.value || !n.value) return null;
|
|
42
|
+
const e = o.getMediaSize();
|
|
43
|
+
if (p.value) {
|
|
44
|
+
const t = u.value;
|
|
45
|
+
return t ? C({
|
|
46
|
+
x: i.value.mediaX,
|
|
47
|
+
y: i.value.mediaY,
|
|
48
|
+
chartWidth: e.width,
|
|
49
|
+
chartHeight: e.height,
|
|
50
|
+
tooltipWidth: t.width,
|
|
51
|
+
tooltipHeight: t.height,
|
|
52
|
+
offsetX: 16,
|
|
53
|
+
offsetY: 16
|
|
54
|
+
}) : { left: 0, top: 0 };
|
|
55
|
+
}
|
|
56
|
+
return C({
|
|
57
|
+
x: i.value.mediaX,
|
|
58
|
+
y: i.value.mediaY,
|
|
59
|
+
chartWidth: e.width,
|
|
60
|
+
chartHeight: e.height,
|
|
61
|
+
tooltipWidth: G,
|
|
62
|
+
tooltipHeight: q,
|
|
63
|
+
offsetX: 16,
|
|
64
|
+
offsetY: 16
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return (e, t) => (x(), g(B, null, [
|
|
68
|
+
n.value && y(i) && l.value && !p.value ? (x(), g("div", {
|
|
69
|
+
key: 0,
|
|
70
|
+
style: b({
|
|
71
|
+
position: "absolute",
|
|
72
|
+
left: l.value.left + "px",
|
|
73
|
+
top: l.value.top + "px",
|
|
74
|
+
pointerEvents: "none",
|
|
75
|
+
background: s.value.tooltip.background,
|
|
76
|
+
backdropFilter: "blur(12px)",
|
|
77
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
78
|
+
border: "1px solid " + s.value.tooltip.borderColor,
|
|
79
|
+
borderRadius: "8px",
|
|
80
|
+
padding: "10px 14px",
|
|
81
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",
|
|
82
|
+
fontSize: s.value.typography.fontSize + "px",
|
|
83
|
+
fontFamily: s.value.typography.fontFamily,
|
|
84
|
+
color: s.value.tooltip.textColor,
|
|
85
|
+
zIndex: 10,
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
gap: "6px"
|
|
89
|
+
})
|
|
90
|
+
}, [
|
|
91
|
+
r("div", U, [
|
|
92
|
+
r("span", {
|
|
93
|
+
style: b({
|
|
94
|
+
width: "10px",
|
|
95
|
+
height: "10px",
|
|
96
|
+
borderRadius: "50%",
|
|
97
|
+
background: n.value.color,
|
|
98
|
+
flexShrink: 0
|
|
99
|
+
})
|
|
100
|
+
}, null, 4),
|
|
101
|
+
r("span", A, _(n.value.label), 1)
|
|
102
|
+
]),
|
|
103
|
+
r("div", N, [
|
|
104
|
+
r("span", V, _(w.value(n.value.value)), 1),
|
|
105
|
+
r("span", $, _(n.value.percent.toFixed(1)) + "%", 1)
|
|
106
|
+
])
|
|
107
|
+
], 4)) : T("", !0),
|
|
108
|
+
n.value && y(i) && l.value && p.value ? (x(), g("div", {
|
|
109
|
+
key: 1,
|
|
110
|
+
ref_key: "containerRef",
|
|
111
|
+
ref: k,
|
|
112
|
+
"data-measured": u.value !== null ? "true" : "false",
|
|
113
|
+
style: b({
|
|
114
|
+
position: "absolute",
|
|
115
|
+
left: l.value.left + "px",
|
|
116
|
+
top: l.value.top + "px",
|
|
117
|
+
pointerEvents: "none",
|
|
118
|
+
zIndex: 10,
|
|
119
|
+
width: "max-content",
|
|
120
|
+
maxWidth: y(o).getMediaSize().width + "px",
|
|
121
|
+
boxSizing: "border-box",
|
|
122
|
+
visibility: u.value !== null ? "visible" : "hidden"
|
|
123
|
+
})
|
|
124
|
+
}, [
|
|
125
|
+
L(e.$slots, "default", {
|
|
126
|
+
info: n.value,
|
|
127
|
+
format: w.value
|
|
128
|
+
})
|
|
129
|
+
], 12, j)) : T("", !0)
|
|
130
|
+
], 64));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
export {
|
|
134
|
+
te as default
|
|
135
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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({
|
|
4
|
+
__name: "ReferenceLine",
|
|
5
|
+
props: {
|
|
6
|
+
value: {},
|
|
7
|
+
time: {},
|
|
8
|
+
color: {},
|
|
9
|
+
label: {},
|
|
10
|
+
style: {},
|
|
11
|
+
width: {}
|
|
12
|
+
},
|
|
13
|
+
setup(o) {
|
|
14
|
+
const e = o, l = c();
|
|
15
|
+
let t = null;
|
|
16
|
+
return r(() => {
|
|
17
|
+
t = l.addLine({
|
|
18
|
+
value: e.value,
|
|
19
|
+
time: e.time,
|
|
20
|
+
color: e.color,
|
|
21
|
+
label: e.label,
|
|
22
|
+
style: e.style,
|
|
23
|
+
width: e.width
|
|
24
|
+
});
|
|
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],
|
|
29
|
+
() => {
|
|
30
|
+
t !== null && l.updateLine(t, {
|
|
31
|
+
value: e.value,
|
|
32
|
+
time: e.time,
|
|
33
|
+
color: e.color,
|
|
34
|
+
label: e.label,
|
|
35
|
+
style: e.style,
|
|
36
|
+
width: e.width
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
), (m, s) => u("", !0);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
p as default
|
|
44
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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";
|
|
3
|
+
import { useChartInstance as g } from "../context.js";
|
|
4
|
+
const _ = /* @__PURE__ */ r({
|
|
5
|
+
__name: "TimeAxis",
|
|
6
|
+
props: {
|
|
7
|
+
labelCount: {},
|
|
8
|
+
minLabelSpacing: {}
|
|
9
|
+
},
|
|
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
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
i(), c(() => [n.labelCount, n.minLabelSpacing], i), a(() => {
|
|
18
|
+
e.setTimeAxisLabelDensity({ labelCount: null, minLabelSpacing: null });
|
|
19
|
+
});
|
|
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", {
|
|
26
|
+
ref_key: "containerRef",
|
|
27
|
+
ref: t,
|
|
28
|
+
style: f({
|
|
29
|
+
position: "absolute",
|
|
30
|
+
left: "0",
|
|
31
|
+
bottom: "0",
|
|
32
|
+
right: o(e).yAxisWidth + "px",
|
|
33
|
+
height: o(e).xAxisHeight + "px",
|
|
34
|
+
pointerEvents: "none",
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center"
|
|
37
|
+
})
|
|
38
|
+
}, null, 4));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export {
|
|
42
|
+
_ as default
|
|
43
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineComponent as t, onMounted as n, onUnmounted as f, watch as a, createCommentVNode as i } from "vue";
|
|
2
|
+
import { useChartInstance as m } from "../context.js";
|
|
3
|
+
const d = /* @__PURE__ */ t({
|
|
4
|
+
__name: "TimeRegion",
|
|
5
|
+
props: {
|
|
6
|
+
from: {},
|
|
7
|
+
to: {},
|
|
8
|
+
fill: {},
|
|
9
|
+
label: {},
|
|
10
|
+
color: {}
|
|
11
|
+
},
|
|
12
|
+
setup(r) {
|
|
13
|
+
const o = r, e = m();
|
|
14
|
+
let l = null;
|
|
15
|
+
return n(() => {
|
|
16
|
+
l = e.addRegion({
|
|
17
|
+
from: o.from,
|
|
18
|
+
to: o.to,
|
|
19
|
+
fill: o.fill,
|
|
20
|
+
label: o.label,
|
|
21
|
+
color: o.color
|
|
22
|
+
});
|
|
23
|
+
}), f(() => {
|
|
24
|
+
l !== null && e.removeRegion(l), l = null;
|
|
25
|
+
}), a(
|
|
26
|
+
() => [o.from, o.to, o.fill, o.label, o.color],
|
|
27
|
+
() => {
|
|
28
|
+
l !== null && e.updateRegion(l, {
|
|
29
|
+
from: o.from,
|
|
30
|
+
to: o.to,
|
|
31
|
+
fill: o.fill,
|
|
32
|
+
label: o.label,
|
|
33
|
+
color: o.color
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
), (c, u) => i("", !0);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
d as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineComponent as f, inject as i, useSlots as h, computed as y, unref as e, openBlock as s, createBlock as d, Teleport as x, createElementVNode as l, normalizeStyle as a, renderSlot as p, createElementBlock as S, createTextVNode as g, toDisplayString as b, createCommentVNode as c } from "vue";
|
|
2
|
+
import { TitleAnchorKey as T, ThemeKey as C } from "../context.js";
|
|
3
|
+
const E = /* @__PURE__ */ f({
|
|
4
|
+
__name: "Title",
|
|
5
|
+
props: {
|
|
6
|
+
sub: {}
|
|
7
|
+
},
|
|
8
|
+
setup(n) {
|
|
9
|
+
const o = i(T), t = i(C), m = h(), u = y(() => typeof m.sub == "function");
|
|
10
|
+
if (!o)
|
|
11
|
+
throw new Error("<Title> must be used within <ChartContainer>: missing TitleAnchorKey.");
|
|
12
|
+
if (!t)
|
|
13
|
+
throw new Error("<Title> must be used within <ChartContainer>: missing ThemeKey.");
|
|
14
|
+
return (r, k) => e(o) ? (s(), d(x, {
|
|
15
|
+
key: 0,
|
|
16
|
+
to: e(o)
|
|
17
|
+
}, [
|
|
18
|
+
l("div", {
|
|
19
|
+
"data-chart-title": "",
|
|
20
|
+
style: a({
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "baseline",
|
|
23
|
+
gap: "6px",
|
|
24
|
+
padding: "6px 8px 0",
|
|
25
|
+
flexShrink: 0,
|
|
26
|
+
fontFamily: e(t).typography.fontFamily,
|
|
27
|
+
fontSize: e(t).typography.fontSize + "px",
|
|
28
|
+
fontWeight: 600,
|
|
29
|
+
color: e(t).tooltip.textColor,
|
|
30
|
+
pointerEvents: "none"
|
|
31
|
+
})
|
|
32
|
+
}, [
|
|
33
|
+
l("span", null, [
|
|
34
|
+
p(r.$slots, "default")
|
|
35
|
+
]),
|
|
36
|
+
u.value || n.sub ? (s(), S("span", {
|
|
37
|
+
key: 0,
|
|
38
|
+
style: a({
|
|
39
|
+
fontWeight: 400,
|
|
40
|
+
color: e(t).axis.textColor,
|
|
41
|
+
fontSize: e(t).axis.fontSize + "px"
|
|
42
|
+
})
|
|
43
|
+
}, [
|
|
44
|
+
p(r.$slots, "sub", {}, () => [
|
|
45
|
+
g(b(n.sub), 1)
|
|
46
|
+
])
|
|
47
|
+
], 4)) : c("", !0)
|
|
48
|
+
], 4)
|
|
49
|
+
], 8, ["to"])) : c("", !0);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
E as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
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 v, normalizeStyle as m, createElementVNode as p, toDisplayString as f, renderList as H, createCommentVNode as _, renderSlot as $ } from "vue";
|
|
2
|
+
import { buildHoverSnapshots as K } from "../core/dist/snapshots.js";
|
|
3
|
+
import { resolveCandlestickBodyColor as U } from "../core/dist/theme/resolve.js";
|
|
4
|
+
import { computeTooltipPosition as R } from "../core/dist/tooltip-position.js";
|
|
5
|
+
import { formatCompact as j, formatPriceAdaptive as q } from "../core/dist/utils/format.js";
|
|
6
|
+
import { formatDate as G, formatTime as J } from "../core/dist/utils/time.js";
|
|
7
|
+
import { useCrosshairPosition as Q } from "../composables.js";
|
|
8
|
+
import { useChartInstance as Z } from "../context.js";
|
|
9
|
+
const ee = {
|
|
10
|
+
key: 0,
|
|
11
|
+
style: { display: "grid", gridTemplateColumns: "auto 1fr", gap: "4px 12px" }
|
|
12
|
+
}, te = { style: { opacity: 0.5 } }, oe = {
|
|
13
|
+
key: 1,
|
|
14
|
+
style: { display: "flex", alignItems: "center", gap: "8px", padding: "2px 0" }
|
|
15
|
+
}, ae = { style: { opacity: 0.6, flex: "1" } }, le = ["data-measured"], ve = /* @__PURE__ */ P({
|
|
16
|
+
__name: "Tooltip",
|
|
17
|
+
props: {
|
|
18
|
+
sort: {},
|
|
19
|
+
format: { type: Function }
|
|
20
|
+
},
|
|
21
|
+
setup(A) {
|
|
22
|
+
const F = A, I = s(() => F.sort ?? "none"), C = s(
|
|
23
|
+
() => F.format ?? ((l, n) => n === "volume" ? j(l) : q(l))
|
|
24
|
+
), o = Z(), i = Q(o), S = w(0), W = () => {
|
|
25
|
+
S.value++;
|
|
26
|
+
};
|
|
27
|
+
D(() => {
|
|
28
|
+
o.on("overlayChange", W), o.getSeriesIds().length > 0 && S.value++;
|
|
29
|
+
}), M(() => {
|
|
30
|
+
o.off("overlayChange", W);
|
|
31
|
+
});
|
|
32
|
+
const t = s(() => o.getTheme()), O = s(() => o.getDataInterval()), d = s(() => (S.value, i.value ? K(o, {
|
|
33
|
+
time: i.value.time,
|
|
34
|
+
sort: I.value,
|
|
35
|
+
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 k = null;
|
|
38
|
+
Y((l) => {
|
|
39
|
+
if (!g.value) return;
|
|
40
|
+
const n = B.value;
|
|
41
|
+
!n || typeof ResizeObserver > "u" || (k = new ResizeObserver((e) => {
|
|
42
|
+
const a = e[0]?.contentRect;
|
|
43
|
+
if (!a) return;
|
|
44
|
+
const y = b.value;
|
|
45
|
+
(!y || y.width !== a.width || y.height !== a.height) && (b.value = { width: a.width, height: a.height });
|
|
46
|
+
}), k.observe(n), l(() => {
|
|
47
|
+
k?.disconnect(), k = null;
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
const h = s(() => {
|
|
51
|
+
if (!i.value || d.value.length === 0) return null;
|
|
52
|
+
const l = o.getMediaSize(), n = l.width - o.yAxisWidth, e = l.height - o.xAxisHeight;
|
|
53
|
+
if (g.value) {
|
|
54
|
+
const c = b.value;
|
|
55
|
+
return c ? R({
|
|
56
|
+
x: i.value.mediaX,
|
|
57
|
+
y: i.value.mediaY,
|
|
58
|
+
chartWidth: n,
|
|
59
|
+
chartHeight: e,
|
|
60
|
+
tooltipWidth: c.width,
|
|
61
|
+
tooltipHeight: c.height
|
|
62
|
+
}) : { left: 0, top: 0 };
|
|
63
|
+
}
|
|
64
|
+
const a = d.value.some((c) => "open" in c.data), y = d.value.filter((c) => !("open" in c.data)).length, L = 160, N = a ? 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
|
|
72
|
+
});
|
|
73
|
+
}), V = s(() => !g.value || b.value !== null);
|
|
74
|
+
function E(l) {
|
|
75
|
+
return "open" in l;
|
|
76
|
+
}
|
|
77
|
+
return (l, n) => (r(), u(x, null, [
|
|
78
|
+
v(i) && d.value.length > 0 && h.value && !g.value ? (r(), u("div", {
|
|
79
|
+
key: 0,
|
|
80
|
+
style: m({
|
|
81
|
+
position: "absolute",
|
|
82
|
+
left: h.value.left + "px",
|
|
83
|
+
top: h.value.top + "px",
|
|
84
|
+
pointerEvents: "none",
|
|
85
|
+
background: t.value.tooltip.background,
|
|
86
|
+
backdropFilter: "blur(12px)",
|
|
87
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
88
|
+
border: "1px solid " + t.value.tooltip.borderColor,
|
|
89
|
+
borderRadius: "8px",
|
|
90
|
+
padding: "10px 14px",
|
|
91
|
+
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,
|
|
94
|
+
fontVariantNumeric: "tabular-nums",
|
|
95
|
+
color: t.value.tooltip.textColor,
|
|
96
|
+
minWidth: "140px",
|
|
97
|
+
zIndex: 10,
|
|
98
|
+
transition: "opacity 0.15s ease"
|
|
99
|
+
})
|
|
100
|
+
}, [
|
|
101
|
+
p("div", {
|
|
102
|
+
style: m({
|
|
103
|
+
fontSize: t.value.axis.fontSize + "px",
|
|
104
|
+
color: t.value.axis.textColor,
|
|
105
|
+
marginBottom: "8px",
|
|
106
|
+
paddingBottom: "6px",
|
|
107
|
+
borderBottom: "1px solid " + t.value.tooltip.borderColor,
|
|
108
|
+
letterSpacing: "0.02em"
|
|
109
|
+
})
|
|
110
|
+
}, f(v(G)(z.value)) + " " + f(v(J)(z.value, O.value)), 5),
|
|
111
|
+
(r(!0), u(x, null, H(d.value, (e) => (r(), u(x, {
|
|
112
|
+
key: e.id
|
|
113
|
+
}, [
|
|
114
|
+
E(e.data) ? (r(), u("div", ee, [
|
|
115
|
+
(r(!0), u(x, null, H([
|
|
116
|
+
{ label: "Open", val: e.data.open, field: "open" },
|
|
117
|
+
{ label: "High", val: e.data.high, field: "high" },
|
|
118
|
+
{ label: "Low", val: e.data.low, field: "low" },
|
|
119
|
+
{ label: "Close", val: e.data.close, field: "close" }
|
|
120
|
+
], (a) => (r(), u(x, {
|
|
121
|
+
key: a.label
|
|
122
|
+
}, [
|
|
123
|
+
p("span", te, f(a.label), 1),
|
|
124
|
+
p("span", {
|
|
125
|
+
style: m({
|
|
126
|
+
fontWeight: 600,
|
|
127
|
+
color: v(U)(
|
|
128
|
+
e.data.close >= e.data.open ? t.value.candlestick.up.body : t.value.candlestick.down.body
|
|
129
|
+
),
|
|
130
|
+
textAlign: "right"
|
|
131
|
+
})
|
|
132
|
+
}, f(C.value(a.val, a.field)), 5)
|
|
133
|
+
], 64))), 128)),
|
|
134
|
+
e.data.volume != null ? (r(), u(x, { key: 0 }, [
|
|
135
|
+
n[0] || (n[0] = p("span", { style: { opacity: 0.5 } }, "Volume", -1)),
|
|
136
|
+
p("span", {
|
|
137
|
+
style: m({ fontWeight: 600, color: t.value.tooltip.textColor, textAlign: "right" })
|
|
138
|
+
}, f(C.value(e.data.volume, "volume")), 5)
|
|
139
|
+
], 64)) : _("", !0)
|
|
140
|
+
])) : (r(), u("div", oe, [
|
|
141
|
+
p("span", {
|
|
142
|
+
style: m({
|
|
143
|
+
width: "8px",
|
|
144
|
+
height: "8px",
|
|
145
|
+
borderRadius: "50%",
|
|
146
|
+
background: e.color,
|
|
147
|
+
flexShrink: 0
|
|
148
|
+
})
|
|
149
|
+
}, null, 4),
|
|
150
|
+
p("span", ae, f(e.label ?? "Value"), 1),
|
|
151
|
+
p("span", {
|
|
152
|
+
style: m({ fontWeight: 600, color: e.color })
|
|
153
|
+
}, f(C.value(e.data.value, "value")), 5)
|
|
154
|
+
]))
|
|
155
|
+
], 64))), 128))
|
|
156
|
+
], 4)) : _("", !0),
|
|
157
|
+
v(i) && d.value.length > 0 && h.value && g.value ? (r(), u("div", {
|
|
158
|
+
key: 1,
|
|
159
|
+
ref_key: "containerRef",
|
|
160
|
+
ref: B,
|
|
161
|
+
"data-measured": V.value ? "true" : "false",
|
|
162
|
+
style: m({
|
|
163
|
+
position: "absolute",
|
|
164
|
+
left: h.value.left + "px",
|
|
165
|
+
top: h.value.top + "px",
|
|
166
|
+
pointerEvents: "none",
|
|
167
|
+
background: t.value.tooltip.background,
|
|
168
|
+
backdropFilter: "blur(12px)",
|
|
169
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
170
|
+
border: "1px solid " + t.value.tooltip.borderColor,
|
|
171
|
+
borderRadius: "8px",
|
|
172
|
+
padding: "10px 14px",
|
|
173
|
+
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",
|
|
176
|
+
fontVariantNumeric: "tabular-nums",
|
|
177
|
+
color: t.value.tooltip.textColor,
|
|
178
|
+
width: "max-content",
|
|
179
|
+
maxWidth: v(o).getMediaSize().width - v(o).yAxisWidth + "px",
|
|
180
|
+
boxSizing: "border-box",
|
|
181
|
+
zIndex: 10,
|
|
182
|
+
visibility: b.value !== null ? "visible" : "hidden"
|
|
183
|
+
})
|
|
184
|
+
}, [
|
|
185
|
+
$(l.$slots, "default", {
|
|
186
|
+
snapshots: d.value,
|
|
187
|
+
time: z.value
|
|
188
|
+
})
|
|
189
|
+
], 12, le)) : _("", !0)
|
|
190
|
+
], 64));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
export {
|
|
194
|
+
ve as default
|
|
195
|
+
};
|