@wick-charts/vue 0.5.0 → 0.6.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 +18 -3
- package/dist/BarSeries.vue.js +26 -20
- package/dist/CandlestickSeries.vue.js +30 -24
- package/dist/ChartContainer.vue.js +88 -65
- package/dist/HeatmapSeries.vue.js +40 -0
- package/dist/HeatmapSeries.vue2.js +4 -0
- package/dist/LineSeries.vue.js +26 -20
- package/dist/PieSeries.vue.js +24 -18
- package/dist/core/dist/animation/animator.js +21 -21
- package/dist/core/dist/animation/config.js +114 -87
- package/dist/core/dist/animation/easing.js +3 -1
- package/dist/core/dist/animation/intro-wave.js +68 -0
- package/dist/core/dist/axis/dom-labels.js +13 -14
- package/dist/core/dist/chart/badge-animator.js +56 -0
- package/dist/core/dist/chart/edge-indicators.js +28 -13
- package/dist/core/dist/chart/last-value.js +18 -17
- package/dist/core/dist/chart/y-target.js +13 -12
- package/dist/core/dist/chart.js +908 -626
- package/dist/core/dist/components/annotation-chip.js +28 -0
- package/dist/core/dist/components/edge-indicator.js +58 -26
- package/dist/core/dist/components/loading-indicator.js +46 -0
- package/dist/core/dist/components/marker.js +49 -31
- package/dist/core/dist/components/reference-line.js +27 -36
- package/dist/core/dist/components/time-region.js +30 -28
- package/dist/core/dist/data/store.js +38 -19
- package/dist/core/dist/data/sync.js +60 -38
- package/dist/core/dist/heatmap-tooltip.js +16 -0
- package/dist/core/dist/interactions/handler.js +67 -43
- package/dist/core/dist/perf/perf-hud.js +2 -2
- package/dist/core/dist/scales/x-scale.js +85 -37
- package/dist/core/dist/scales/y-scale.js +38 -27
- package/dist/core/dist/series/bar-intro.js +18 -0
- package/dist/core/dist/series/bar.js +337 -205
- package/dist/core/dist/series/base-multi-layer.js +224 -96
- package/dist/core/dist/series/candlestick-intro.js +57 -0
- package/dist/core/dist/series/candlestick.js +454 -276
- package/dist/core/dist/series/heatmap.js +387 -0
- package/dist/core/dist/series/line-intro.js +85 -0
- package/dist/core/dist/series/line.js +590 -282
- package/dist/core/dist/series/painters/builtins.js +2 -2
- package/dist/core/dist/series/pie.js +396 -259
- package/dist/core/dist/series/register-builtins.js +8 -7
- package/dist/core/dist/series/types.js +6 -0
- package/dist/core/dist/series/wave-intro.js +26 -0
- package/dist/core/dist/theme/create.js +69 -63
- package/dist/core/dist/theme/themes/mint-breeze.js +2 -2
- package/dist/core/dist/theme/themes/sand-dune.js +2 -2
- package/dist/core/dist/utils/color.js +109 -34
- package/dist/core/dist/utils/deep-equal.js +18 -0
- package/dist/core/dist/utils/time.js +25 -19
- package/dist/index.d.ts +1411 -122
- package/dist/index.js +177 -130
- package/dist/ui/Crosshair.vue.js +20 -21
- package/dist/ui/HeatmapTooltip.vue.js +96 -0
- package/dist/ui/HeatmapTooltip.vue2.js +4 -0
- package/dist/ui/InfoBar.vue.js +46 -47
- package/dist/ui/Legend.vue.js +80 -79
- package/dist/ui/PieLegend.vue.js +5 -5
- package/dist/ui/PieTooltip.vue.js +77 -67
- package/dist/ui/Tooltip.vue.js +60 -60
- package/dist/ui/YAxis.vue.js +2 -2
- package/dist/ui/YLabel.vue.js +94 -61
- package/package.json +2 -2
- package/src/BarSeries.vue +23 -7
- package/src/CandlestickSeries.vue +23 -7
- package/src/ChartContainer.vue +134 -12
- package/src/HeatmapSeries.vue +69 -0
- package/src/LineSeries.vue +23 -7
- package/src/PieSeries.vue +22 -6
- package/src/index.ts +84 -3
- package/src/ui/Crosshair.vue +1 -2
- package/src/ui/HeatmapTooltip.vue +144 -0
- package/src/ui/InfoBar.vue +1 -2
- package/src/ui/Legend.vue +13 -0
- package/src/ui/Marker.vue +1 -1
- package/src/ui/PieTooltip.vue +10 -0
- package/src/ui/ReferenceLine.vue +2 -2
- package/src/ui/TimeRegion.vue +2 -2
- package/src/ui/Tooltip.vue +2 -2
- package/src/ui/YLabel.vue +123 -8
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isLightColor as m, hexToRgba as T } from "../utils/color.js";
|
|
2
|
+
const y = 7, b = 3.5, v = 5, w = 4.5, B = 6, C = 0.92, M = 0.12, S = 0.6, Y = "rgba(15, 20, 35, 0.1)", A = "rgba(0, 0, 0, 0.4)", L = 3, k = 1;
|
|
3
|
+
function E(o) {
|
|
4
|
+
const { context: t, theme: i, label: s, hpr: r, vpr: c } = o;
|
|
5
|
+
return t.font = f(i, r), {
|
|
6
|
+
width: t.measureText(s).width + y * r * 2,
|
|
7
|
+
height: i.yLabel.fontSize * r + b * c * 2
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function X(o) {
|
|
11
|
+
const { context: t, theme: i, color: s, label: r, x: c, y: l, width: e, height: a, hpr: n, vpr: h, tail: d } = o;
|
|
12
|
+
H({ context: t, x: c, y: l, width: e, height: a, hpr: n, tail: d }), t.save(), t.shadowColor = m(i.background) ? Y : A, t.shadowBlur = L * n, t.shadowOffsetY = k * h, t.fillStyle = T(i.background, C), t.fill(), t.restore(), t.fillStyle = T(s, M), t.fill(), t.strokeStyle = T(s, S), t.lineWidth = Math.max(1, Math.round(n)), t.stroke(), t.font = f(i, n), t.textAlign = "center", t.textBaseline = "middle", t.fillStyle = i.tooltip.textColor, t.fillText(r, c + e / 2, l + a / 2);
|
|
13
|
+
}
|
|
14
|
+
function f(o, t) {
|
|
15
|
+
return `500 ${o.yLabel.fontSize * t}px ${o.typography.fontFamily}`;
|
|
16
|
+
}
|
|
17
|
+
function H({ context: o, x: t, y: i, width: s, height: r, hpr: c, tail: l }) {
|
|
18
|
+
const e = Math.min(v * c, s / 2, r / 2), a = t + s, n = i + r, h = w * c, d = t + e + h, x = a - e - h, p = l === void 0 ? 0 : I(l.tipX, d, x), u = l !== void 0 && l.tipY < i, g = l !== void 0 && l.tipY > n;
|
|
19
|
+
o.beginPath(), o.moveTo(t + e, i), l !== void 0 && u && (o.lineTo(p - h, i), o.lineTo(l.tipX, l.tipY), o.lineTo(p + h, i)), o.lineTo(a - e, i), o.arcTo(a, i, a, i + e, e), o.lineTo(a, n - e), o.arcTo(a, n, a - e, n, e), l !== void 0 && g && (o.lineTo(p + h, n), o.lineTo(l.tipX, l.tipY), o.lineTo(p - h, n)), o.lineTo(t + e, n), o.arcTo(t, n, t, n - e, e), o.lineTo(t, i + e), o.arcTo(t, i, t + e, i, e), o.closePath();
|
|
20
|
+
}
|
|
21
|
+
function I(o, t, i) {
|
|
22
|
+
return t > i ? (t + i) / 2 : Math.max(t, Math.min(i, o));
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
B as CHIP_TAIL_HEIGHT_MEDIA,
|
|
26
|
+
X as drawChip,
|
|
27
|
+
E as measureChip
|
|
28
|
+
};
|
|
@@ -1,36 +1,68 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { state:
|
|
3
|
-
if (
|
|
4
|
-
const
|
|
5
|
-
if (Number.isFinite(
|
|
6
|
-
if (
|
|
7
|
-
|
|
1
|
+
function $(t) {
|
|
2
|
+
const { state: i } = t;
|
|
3
|
+
if (i === "idle" || i === "has-more") return;
|
|
4
|
+
const a = t.timeScale.timeToX(t.boundaryTime);
|
|
5
|
+
if (Number.isFinite(a)) {
|
|
6
|
+
if (i === "loading") {
|
|
7
|
+
t.customIndicator ? S(t, a, t.customIndicator) : y(t, a);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
i === "no-data" && R(t, a);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
function S({
|
|
14
|
+
scope: t,
|
|
15
|
+
theme: i,
|
|
16
|
+
chartMediaWidth: a,
|
|
17
|
+
chartMediaHeight: n,
|
|
18
|
+
side: l,
|
|
19
|
+
now: e,
|
|
20
|
+
resolveEdgeAnchor: o,
|
|
21
|
+
resolveEdgeBarSpacing: s,
|
|
22
|
+
reportPlaceholders: c
|
|
23
|
+
}, h, g) {
|
|
24
|
+
const { context: r, horizontalPixelRatio: d, verticalPixelRatio: m } = t, x = Math.min(150, a), f = l === "right" ? h : h - x;
|
|
25
|
+
r.save(), r.beginPath(), r.rect(
|
|
26
|
+
f * d,
|
|
27
|
+
0,
|
|
28
|
+
x * d,
|
|
29
|
+
n * m
|
|
30
|
+
), r.clip(), r.translate(f * d, 0);
|
|
31
|
+
const u = o?.() ?? null, P = s?.() ?? void 0;
|
|
32
|
+
g({
|
|
33
|
+
scope: t,
|
|
34
|
+
theme: i,
|
|
35
|
+
chartMediaWidth: x,
|
|
36
|
+
chartMediaHeight: n,
|
|
37
|
+
now: e,
|
|
38
|
+
side: l,
|
|
39
|
+
edgeValueY: u?.valueY,
|
|
40
|
+
seriesKind: u?.seriesKind,
|
|
41
|
+
barSpacing: P,
|
|
42
|
+
reportPlaceholders: c
|
|
43
|
+
}), r.restore();
|
|
44
|
+
}
|
|
45
|
+
function y({ scope: t, theme: i, chartMediaHeight: a, side: n, now: l }, e) {
|
|
46
|
+
const { context: o, horizontalPixelRatio: s, verticalPixelRatio: c } = t, h = 3 * s, g = 8 * s, r = 24 * s, d = e * s, m = n === "right" ? d + r : d - r, x = a / 2 * c, f = l % 900 / 900, u = Math.floor(f * 3), P = M(i.axis.textColor ?? "#787b86", 0.3), b = i.axis.textColor ?? "#787b86";
|
|
47
|
+
o.save();
|
|
48
|
+
for (let p = 0; p < 3; p++) {
|
|
49
|
+
const v = (p - 1) * g, I = m + v;
|
|
50
|
+
o.beginPath(), o.arc(I, x, h, 0, Math.PI * 2), o.fillStyle = p === u ? b : P, o.fill();
|
|
19
51
|
}
|
|
20
|
-
|
|
52
|
+
o.restore();
|
|
21
53
|
}
|
|
22
|
-
function
|
|
23
|
-
const { context:
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
54
|
+
function R({ scope: t, theme: i, chartMediaHeight: a, side: n }, l) {
|
|
55
|
+
const { context: e, horizontalPixelRatio: o, verticalPixelRatio: s } = t, c = Math.round(l * o) + 0.5;
|
|
56
|
+
e.save(), e.strokeStyle = M(i.axis.textColor ?? "#787b86", 0.6), e.lineWidth = 1, e.setLineDash([4 * o, 4 * o]), e.beginPath(), e.moveTo(c, 0), e.lineTo(c, a * s), e.stroke(), e.setLineDash([]);
|
|
57
|
+
const h = 10 * o, g = n === "right" ? c - h : c + h, r = 18 * s;
|
|
58
|
+
e.fillStyle = i.axis.textColor ?? "#787b86", e.font = `${11 * o}px ${i.typography.fontFamily}`, e.textAlign = n === "right" ? "right" : "left", e.textBaseline = "top", e.fillText("No more data", g, r), e.restore();
|
|
27
59
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
const n = parseInt(
|
|
32
|
-
return `rgba(${n}, ${
|
|
60
|
+
function M(t, i) {
|
|
61
|
+
const a = /^#([0-9a-f]{6})$/i.exec(t.trim());
|
|
62
|
+
if (!a) return t;
|
|
63
|
+
const n = parseInt(a[1].slice(0, 2), 16), l = parseInt(a[1].slice(2, 4), 16), e = parseInt(a[1].slice(4, 6), 16);
|
|
64
|
+
return `rgba(${n}, ${l}, ${e}, ${i})`;
|
|
33
65
|
}
|
|
34
66
|
export {
|
|
35
|
-
|
|
67
|
+
$ as renderEdgeIndicator
|
|
36
68
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { hexToRgba as d } from "../utils/color.js";
|
|
2
|
+
const F = 6, J = 24, K = 0.55, u = 5, z = 1400, g = 35, O = ({
|
|
3
|
+
scope: E,
|
|
4
|
+
theme: G,
|
|
5
|
+
chartMediaWidth: h,
|
|
6
|
+
chartMediaHeight: H,
|
|
7
|
+
now: I,
|
|
8
|
+
side: W,
|
|
9
|
+
edgeValueY: X,
|
|
10
|
+
barSpacing: p,
|
|
11
|
+
seriesKind: b,
|
|
12
|
+
reportPlaceholders: v
|
|
13
|
+
}) => {
|
|
14
|
+
const { context: o, horizontalPixelRatio: a, verticalPixelRatio: e } = E, l = G.axis.textColor ?? "#787b86", w = X ?? H / 2, m = W === "right", i = p && p > 4 ? p : J, T = Math.max(3, i * K), _ = b === void 0 || b === "candlestick", k = Math.min(H * 0.22, 34), A = Math.max(3, Math.min(F, Math.floor(h / i)));
|
|
15
|
+
o.save();
|
|
16
|
+
const y = [];
|
|
17
|
+
for (let t = 0; t < A; t++) {
|
|
18
|
+
const f = m ? i * 0.7 + t * i : h - i * 0.7 - t * i, x = Math.sin(t * 1.1 + 0.6) * 0.4, M = t === 0 ? w : w + x * k * 1.4, r = Math.max(6, k * (0.5 + 0.5 * Math.abs(Math.cos(t * 0.8))));
|
|
19
|
+
y.push({ x: f, y: M, halfHeight: r, width: T });
|
|
20
|
+
const s = f * a, R = T * a, n = (M - r) * e, S = r * 2 * e;
|
|
21
|
+
o.fillStyle = d(l, 0.16), o.fillRect(s - R / 2, n, R, S), _ && (o.strokeStyle = d(l, 0.12), o.lineWidth = Math.max(1, a), o.beginPath(), o.moveTo(s, n - u * e), o.lineTo(s, n), o.moveTo(s, n + S), o.lineTo(s, n + S + u * e), o.stroke());
|
|
22
|
+
}
|
|
23
|
+
v !== void 0 && v(
|
|
24
|
+
y.map((t) => ({
|
|
25
|
+
offsetX: m ? t.x : h - t.x,
|
|
26
|
+
y: t.y,
|
|
27
|
+
halfHeight: t.halfHeight,
|
|
28
|
+
width: t.width
|
|
29
|
+
}))
|
|
30
|
+
);
|
|
31
|
+
const B = h + g * 2, P = I % z / z * B - g, C = m ? P : h - P, c = o.createLinearGradient(
|
|
32
|
+
(C - g) * a,
|
|
33
|
+
0,
|
|
34
|
+
(C + g) * a,
|
|
35
|
+
0
|
|
36
|
+
);
|
|
37
|
+
c.addColorStop(0, d(l, 0)), c.addColorStop(0.5, d(l, 0.35)), c.addColorStop(1, d(l, 0)), o.fillStyle = c;
|
|
38
|
+
for (const t of y) {
|
|
39
|
+
const f = t.x * a, x = t.width * a, M = (t.y - t.halfHeight) * e, r = t.halfHeight * 2 * e;
|
|
40
|
+
o.fillRect(f - x / 2, M, x, r);
|
|
41
|
+
}
|
|
42
|
+
o.restore();
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
O as skeletonLoadingIndicator
|
|
46
|
+
};
|
|
@@ -1,41 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const { scope:
|
|
6
|
-
if (!Number.isFinite(
|
|
7
|
-
const
|
|
8
|
-
|
|
1
|
+
import { hexToRgba as g } from "../utils/color.js";
|
|
2
|
+
import { measureChip as I, drawChip as T, CHIP_TAIL_HEIGHT_MEDIA as S } from "./annotation-chip.js";
|
|
3
|
+
const y = 4, H = 5, k = 9, W = 3, C = 4;
|
|
4
|
+
function Y(e) {
|
|
5
|
+
const { scope: a, timeScale: r, yScale: l, theme: s, marker: t, phase: n, plotWidth: o, plotHeight: p } = e, { context: h, horizontalPixelRatio: i, verticalPixelRatio: d } = a, c = r.timeToBitmapX(t.time), b = l.valueToBitmapY(t.value);
|
|
6
|
+
if (!Number.isFinite(c) || !Number.isFinite(b)) return;
|
|
7
|
+
const m = y * i, f = t.shape === "arrow-up" || t.shape === "arrow-down", x = t.label !== void 0 && t.label !== "";
|
|
8
|
+
h.save(), t.pulse && R({ context: h, bx: c, by: b, color: t.color, radius: m, hpr: i, phase: n }), f && x || _({ context: h, bx: c, by: b, color: t.color, radius: m, hpr: i, vpr: d, shape: t.shape }), t.label !== void 0 && t.label !== "" && A({
|
|
9
|
+
context: h,
|
|
10
|
+
bx: c,
|
|
11
|
+
by: b,
|
|
12
|
+
color: t.color,
|
|
13
|
+
theme: s,
|
|
14
|
+
hpr: i,
|
|
15
|
+
vpr: d,
|
|
16
|
+
label: t.label,
|
|
17
|
+
shape: t.shape,
|
|
18
|
+
plotWidth: o,
|
|
19
|
+
plotHeight: p
|
|
20
|
+
}), h.restore();
|
|
9
21
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
22
|
+
function R({ context: e, bx: a, by: r, color: l, radius: s, hpr: t, phase: n }) {
|
|
23
|
+
const o = 0.4 + 0.6 * Math.abs(Math.sin(n * 2 * Math.PI)), p = s + 4 * t * o;
|
|
24
|
+
e.beginPath(), e.arc(a, r, p, 0, Math.PI * 2), e.fillStyle = g(l, o * 0.3), e.fill();
|
|
13
25
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
26
|
+
function _({ context: e, bx: a, by: r, color: l, radius: s, hpr: t, vpr: n, shape: o }) {
|
|
27
|
+
if (o === "dot") {
|
|
28
|
+
e.beginPath(), e.arc(a, r, s, 0, Math.PI * 2), e.fillStyle = l, e.fill();
|
|
17
29
|
return;
|
|
18
30
|
}
|
|
19
|
-
if (
|
|
20
|
-
|
|
31
|
+
if (o === "circle") {
|
|
32
|
+
e.beginPath(), e.arc(a, r, s, 0, Math.PI * 2), e.strokeStyle = l, e.lineWidth = Math.max(1, Math.round(1.5 * t)), e.stroke();
|
|
21
33
|
return;
|
|
22
34
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
35
|
+
const p = H * t, h = k * n, i = o === "arrow-down" ? -1 : 1;
|
|
36
|
+
e.beginPath(), e.moveTo(a, r), e.lineTo(a - p, r + i * h), e.lineTo(a + p, r + i * h), e.closePath(), e.fillStyle = l, e.fill();
|
|
25
37
|
}
|
|
26
|
-
function
|
|
27
|
-
const h =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
function A(e) {
|
|
39
|
+
const { context: a, bx: r, by: l, color: s, theme: t, hpr: n, vpr: o, label: p, shape: h, plotWidth: i, plotHeight: d } = e, { width: c, height: b } = I({ context: a, theme: t, label: p, hpr: n, vpr: o }), m = S * o, f = C * n, x = h === "arrow-up" || h === "arrow-down" ? 0 : (y + W) * o, v = x + m + b;
|
|
40
|
+
let u = h !== "arrow-up";
|
|
41
|
+
u && l - v < 0 && (u = !1), !u && l + v > d && (u = !0);
|
|
42
|
+
const w = u ? l - x : l + x, M = u ? w - m - b : w + m, P = Math.max(f, Math.min(r - c / 2, i - c - f));
|
|
43
|
+
T({
|
|
44
|
+
context: a,
|
|
45
|
+
theme: t,
|
|
46
|
+
color: s,
|
|
47
|
+
label: p,
|
|
48
|
+
x: P,
|
|
49
|
+
y: M,
|
|
50
|
+
width: c,
|
|
51
|
+
height: b,
|
|
52
|
+
hpr: n,
|
|
53
|
+
vpr: o,
|
|
54
|
+
tail: { tipX: r, tipY: w }
|
|
55
|
+
});
|
|
38
56
|
}
|
|
39
57
|
export {
|
|
40
|
-
|
|
58
|
+
Y as renderMarker
|
|
41
59
|
};
|
|
@@ -1,48 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const { scope:
|
|
5
|
-
if (
|
|
6
|
-
const
|
|
7
|
-
if (!Number.isFinite(
|
|
8
|
-
|
|
1
|
+
import { measureChip as T, drawChip as b } from "./annotation-chip.js";
|
|
2
|
+
const v = 4, x = 6;
|
|
3
|
+
function S(c) {
|
|
4
|
+
const { scope: m, timeScale: r, yScale: d, theme: p, line: o, plotWidth: a, plotHeight: h } = c, { context: e, horizontalPixelRatio: n, verticalPixelRatio: s } = m;
|
|
5
|
+
if (e.save(), e.strokeStyle = o.color, o.style === "dashed" && e.setLineDash([v * n, v * n]), o.orientation === "horizontal") {
|
|
6
|
+
const t = d.valueToBitmapY(o.coord);
|
|
7
|
+
if (!Number.isFinite(t) || t < 0 || t > h) {
|
|
8
|
+
e.restore();
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const l = Math.max(1, Math.round(o.width * s)), i = Math.round(t) + (l % 2 === 1 ? 0.5 : 0);
|
|
12
|
+
e.lineWidth = l, e.beginPath(), e.moveTo(0, i), e.lineTo(a, i), e.stroke();
|
|
13
13
|
} else {
|
|
14
|
-
const
|
|
15
|
-
if (!Number.isFinite(
|
|
16
|
-
|
|
14
|
+
const t = r.timeToBitmapX(o.coord);
|
|
15
|
+
if (!Number.isFinite(t) || t < 0 || t > a) {
|
|
16
|
+
e.restore();
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const l = Math.max(1, Math.round(o.width * n)), i = Math.round(t) + (l % 2 === 1 ? 0.5 : 0);
|
|
20
|
+
e.lineWidth = l, e.beginPath(), e.moveTo(i, 0), e.lineTo(i, h), e.stroke();
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
e.setLineDash([]), o.label !== void 0 && M({ context: e, theme: p, line: o, timeScale: r, yScale: d, plotWidth: a, hpr: n, vpr: s }), e.restore();
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (l.orientation === "horizontal")
|
|
32
|
-
u = n, p = f.valueToBitmapY(l.coord) - x / 2;
|
|
24
|
+
function M({ context: c, theme: m, line: r, timeScale: d, yScale: p, plotWidth: o, hpr: a, vpr: h }) {
|
|
25
|
+
const e = r.label;
|
|
26
|
+
if (e === void 0) return;
|
|
27
|
+
const { width: n, height: s } = T({ context: c, theme: m, label: e, hpr: a, vpr: h }), t = x * a, l = x * h;
|
|
28
|
+
let i, u;
|
|
29
|
+
if (r.orientation === "horizontal")
|
|
30
|
+
i = t, u = p.valueToBitmapY(r.coord) - s / 2;
|
|
33
31
|
else {
|
|
34
|
-
const
|
|
35
|
-
|
|
32
|
+
const f = d.timeToBitmapX(r.coord);
|
|
33
|
+
i = Math.min(f + t, o - n - t), u = l;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
x: u,
|
|
39
|
-
y: p,
|
|
40
|
-
width: y,
|
|
41
|
-
height: x,
|
|
42
|
-
radius: 3 * r,
|
|
43
|
-
corners: { tl: !0, tr: !0, br: !0, bl: !0 }
|
|
44
|
-
}), i.fillStyle = h.yLabel.textColor, i.fillText(t, u + d, p + x / 2);
|
|
35
|
+
b({ context: c, theme: m, color: r.color, label: e, x: i, y: u, width: n, height: s, hpr: a, vpr: h });
|
|
45
36
|
}
|
|
46
37
|
export {
|
|
47
|
-
|
|
38
|
+
S as renderReferenceLine
|
|
48
39
|
};
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { fillRoundedRect as d } from "../series/painters/canvas-path.js";
|
|
2
1
|
import { hexToRgba as g } from "../utils/color.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { measureChip as b, drawChip as v } from "./annotation-chip.js";
|
|
3
|
+
const d = 0.5, f = 6;
|
|
4
|
+
function w(t) {
|
|
5
|
+
const { scope: i, timeScale: l, theme: n, region: e, plotWidth: r, plotHeight: a } = t, { context: o, horizontalPixelRatio: m, verticalPixelRatio: u } = i, c = l.timeToBitmapX(e.from), s = e.to === null ? r : l.timeToBitmapX(e.to);
|
|
6
|
+
if (!Number.isFinite(c) || !Number.isFinite(s)) return;
|
|
7
|
+
const h = Math.max(0, Math.min(c, s)), p = Math.min(r, Math.max(c, s));
|
|
8
|
+
p <= 0 || h >= r || p <= h || (o.save(), o.fillStyle = e.fill, o.fillRect(h, 0, p - h, a), o.globalAlpha = d, o.strokeStyle = e.color, o.lineWidth = Math.max(1, Math.round(m)), x(o, c, r, a), e.to !== null && x(o, s, r, a), o.globalAlpha = 1, e.label && M({ context: o, theme: n, region: e, left: h, hpr: m, vpr: u }), o.restore());
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
10
|
+
function x(t, i, l, n) {
|
|
11
|
+
i < 0 || i > l || (t.beginPath(), t.moveTo(i, 0), t.lineTo(i, n), t.stroke());
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
function M({ context: t, theme: i, region: l, left: n, hpr: e, vpr: r }) {
|
|
14
|
+
const a = l.label;
|
|
15
|
+
if (a === void 0) return;
|
|
16
|
+
const { width: o, height: m } = b({ context: t, theme: i, label: a, hpr: e, vpr: r });
|
|
17
|
+
v({
|
|
18
|
+
context: t,
|
|
19
|
+
theme: i,
|
|
20
|
+
color: l.color,
|
|
21
|
+
label: a,
|
|
22
|
+
x: n + f * e,
|
|
23
|
+
y: f * r,
|
|
24
|
+
width: o,
|
|
25
|
+
height: m,
|
|
26
|
+
hpr: e,
|
|
27
|
+
vpr: r
|
|
28
|
+
});
|
|
27
29
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
return { color:
|
|
30
|
+
function C(t, i) {
|
|
31
|
+
const l = t.color ?? i.axis.textColor, n = t.fill ?? g(l, 0.08);
|
|
32
|
+
return { color: l, fill: n };
|
|
31
33
|
}
|
|
32
34
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
w as renderTimeRegion,
|
|
36
|
+
C as resolveTimeRegionColors
|
|
35
37
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { EventEmitter as
|
|
1
|
+
import { EventEmitter as d } from "../events.js";
|
|
2
2
|
import { binarySearch as n } from "../utils/math.js";
|
|
3
|
-
class
|
|
3
|
+
class u extends d {
|
|
4
4
|
data = [];
|
|
5
5
|
_visible = !0;
|
|
6
6
|
cachedRange = null;
|
|
7
7
|
cachedResult = [];
|
|
8
|
+
// Dev-only, warn-once-per-instance: these two conditions are almost always
|
|
9
|
+
// a persistent bug in the caller's feed (not a one-off), so a per-call
|
|
10
|
+
// warning would just spam the console on every tick.
|
|
11
|
+
warnedUnsorted = !1;
|
|
12
|
+
warnedOutOfOrderAppend = !1;
|
|
8
13
|
setVisible(t) {
|
|
9
14
|
this._visible = t;
|
|
10
15
|
}
|
|
@@ -12,17 +17,21 @@ class g extends l {
|
|
|
12
17
|
return this._visible;
|
|
13
18
|
}
|
|
14
19
|
setData(t) {
|
|
15
|
-
let
|
|
16
|
-
for (let
|
|
17
|
-
if (t[
|
|
18
|
-
|
|
20
|
+
let a = !0;
|
|
21
|
+
for (let e = 1; e < t.length; e++)
|
|
22
|
+
if (t[e].time < t[e - 1].time) {
|
|
23
|
+
a = !1;
|
|
19
24
|
break;
|
|
20
25
|
}
|
|
21
|
-
|
|
26
|
+
!a && process.env.NODE_ENV !== "production" && !this.warnedUnsorted && (this.warnedUnsorted = !0, console.warn(
|
|
27
|
+
"[wick-charts] data is not sorted by time — re-sorting on every setData() call is wasted work. Sort your feed by `time` ascending before passing it in."
|
|
28
|
+
)), this.data = a ? t.slice() : [...t].sort((e, i) => e.time - i.time), this.cachedRange = null, this.emit("update");
|
|
22
29
|
}
|
|
23
30
|
append(t) {
|
|
24
31
|
if (this.data.length > 0 && t.time <= this.data[this.data.length - 1].time) {
|
|
25
|
-
this.
|
|
32
|
+
process.env.NODE_ENV !== "production" && !this.warnedOutOfOrderAppend && (this.warnedOutOfOrderAppend = !0, console.warn(
|
|
33
|
+
`[wick-charts] append() received time ${t.time}, not after the last point's time ${this.data[this.data.length - 1].time} — treating it as an overwrite of the last point instead of a new one. If you meant to append, check your feed for out-of-order or duplicate timestamps.`
|
|
34
|
+
)), this.updateLast(t);
|
|
26
35
|
return;
|
|
27
36
|
}
|
|
28
37
|
this.data.push(t), this.cachedRange = null, this.emit("update");
|
|
@@ -30,6 +39,16 @@ class g extends l {
|
|
|
30
39
|
updateLast(t) {
|
|
31
40
|
this.data.length !== 0 && (this.data[this.data.length - 1] = t, this.cachedRange = null, this.emit("update"));
|
|
32
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Insert older points at the front of the buffer (history prepend). The
|
|
44
|
+
* caller guarantees `points` are sorted ascending and all strictly before
|
|
45
|
+
* the current first point — the sync reconciler only routes here after
|
|
46
|
+
* proving the untouched suffix matches the previous data, so the boundary
|
|
47
|
+
* is already validated and no re-sort is needed here. No-op on empty input.
|
|
48
|
+
*/
|
|
49
|
+
prepend(t) {
|
|
50
|
+
t.length !== 0 && (this.data = t.concat(this.data), this.cachedRange = null, this.emit("update"));
|
|
51
|
+
}
|
|
33
52
|
trimStart(t) {
|
|
34
53
|
if (!(t <= 0 || this.data.length === 0)) {
|
|
35
54
|
if (t >= this.data.length) {
|
|
@@ -42,11 +61,11 @@ class g extends l {
|
|
|
42
61
|
getAll() {
|
|
43
62
|
return this.data;
|
|
44
63
|
}
|
|
45
|
-
getVisibleData(t,
|
|
64
|
+
getVisibleData(t, a) {
|
|
46
65
|
if (this.data.length === 0) return [];
|
|
47
|
-
if (this.cachedRange && this.cachedRange.from === t && this.cachedRange.to ===
|
|
48
|
-
const
|
|
49
|
-
return this.cachedResult = this.data.slice(
|
|
66
|
+
if (this.cachedRange && this.cachedRange.from === t && this.cachedRange.to === a) return this.cachedResult;
|
|
67
|
+
const e = Math.max(0, n(this.data, t, (s) => s.time) - 1), i = Math.min(this.data.length, n(this.data, a, (s) => s.time) + 1);
|
|
68
|
+
return this.cachedResult = this.data.slice(e, i), this.cachedRange = { from: t, to: a }, this.cachedResult;
|
|
50
69
|
}
|
|
51
70
|
first() {
|
|
52
71
|
return this.data[0];
|
|
@@ -60,17 +79,17 @@ class g extends l {
|
|
|
60
79
|
isEmpty() {
|
|
61
80
|
return this.data.length === 0;
|
|
62
81
|
}
|
|
63
|
-
findNearest(t,
|
|
82
|
+
findNearest(t, a) {
|
|
64
83
|
if (this.data.length === 0) return null;
|
|
65
|
-
const
|
|
66
|
-
let i = null,
|
|
67
|
-
for (let
|
|
68
|
-
const
|
|
69
|
-
|
|
84
|
+
const e = n(this.data, t, (h) => h.time);
|
|
85
|
+
let i = null, s = a;
|
|
86
|
+
for (let h = Math.max(0, e - 1); h <= Math.min(this.data.length - 1, e + 1); h++) {
|
|
87
|
+
const r = Math.abs(this.data[h].time - t);
|
|
88
|
+
r <= s && (s = r, i = this.data[h]);
|
|
70
89
|
}
|
|
71
90
|
return i;
|
|
72
91
|
}
|
|
73
92
|
}
|
|
74
93
|
export {
|
|
75
|
-
|
|
94
|
+
u as TimeSeriesStore
|
|
76
95
|
};
|