@wick-charts/vue 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/BandSeries.vue.js +43 -32
- package/dist/BarSeries.vue.js +44 -33
- package/dist/CandlestickSeries.vue.js +24 -23
- package/dist/ChartContainer.vue.js +1 -1
- package/dist/HeatmapSeries.vue.js +21 -20
- package/dist/LineSeries.vue.js +43 -32
- package/dist/PieSeries.vue.js +25 -24
- package/dist/composables.js +63 -36
- package/dist/core/dist/axis/dom-labels.js +64 -53
- package/dist/core/dist/chart/badge-animator.js +38 -28
- package/dist/core/dist/chart/options.js +1 -1
- package/dist/core/dist/chart/y-target.js +38 -32
- package/dist/core/dist/chart.js +852 -709
- package/dist/core/dist/data/decimation.js +52 -51
- package/dist/core/dist/data/store.js +38 -20
- package/dist/core/dist/data/sync.js +97 -59
- package/dist/core/dist/navigator/controller.js +11 -11
- package/dist/core/dist/perf/perf-hud.js +3 -3
- package/dist/core/dist/scales/tick-tracker.js +2 -1
- package/dist/core/dist/scales/time-ticks.js +99 -0
- package/dist/core/dist/scales/x-scale.js +33 -27
- package/dist/core/dist/series/band.js +83 -83
- package/dist/core/dist/series/bar.js +240 -211
- package/dist/core/dist/series/base-multi-layer.js +288 -240
- package/dist/core/dist/series/candlestick.js +168 -168
- package/dist/core/dist/series/line.js +545 -455
- package/dist/core/dist/snapshots.js +109 -86
- package/dist/core/dist/utils/point.js +4 -0
- package/dist/core/dist/utils/time.js +42 -26
- package/dist/index.d.ts +67 -28
- package/dist/ui/InfoBar.vue.js +69 -69
- package/dist/ui/NumberFlow.vue.js +36 -27
- package/dist/ui/Tooltip.vue.js +128 -131
- package/dist/ui/YLabel.vue.js +47 -47
- package/package.json +2 -2
- package/src/BandSeries.vue +20 -5
- package/src/BarSeries.vue +20 -5
- package/src/CandlestickSeries.vue +5 -4
- package/src/ChartContainer.vue +15 -9
- package/src/HeatmapSeries.vue +5 -4
- package/src/LineSeries.vue +20 -5
- package/src/PieSeries.vue +6 -5
- package/src/composables.ts +64 -1
- package/src/ui/InfoBar.vue +11 -3
- package/src/ui/NumberFlow.vue +17 -3
- package/src/ui/Tooltip.vue +23 -12
- package/src/ui/YLabel.vue +28 -27
|
@@ -1,81 +1,85 @@
|
|
|
1
|
-
import { DEFAULT_HISTORY_REVEAL as
|
|
2
|
-
import { easeOutCubic as
|
|
3
|
-
import { decimateLineData as
|
|
4
|
-
import { hexToRgba as
|
|
5
|
-
import { lerp as
|
|
6
|
-
import { BaseMultiLayerSeries as
|
|
7
|
-
import { unfoldIntro as
|
|
8
|
-
import { buildCurveSegments as
|
|
9
|
-
import { resolveLinePainter as
|
|
10
|
-
import { ScaleStack as
|
|
11
|
-
const
|
|
1
|
+
import { DEFAULT_HISTORY_REVEAL as it, DEFAULT_LINE_INTRO as ot, DEFAULT_LINE_PULSE as st, DEFAULT_LINE_SMOOTH as nt, DEFAULT_LINE_ENTRY as lt } from "../animation/config.js";
|
|
2
|
+
import { easeOutCubic as J } from "../animation/easing.js";
|
|
3
|
+
import { decimateLineData as Z } from "../data/decimation.js";
|
|
4
|
+
import { hexToRgba as B } from "../utils/color.js";
|
|
5
|
+
import { lerp as G } from "../utils/math.js";
|
|
6
|
+
import { BaseMultiLayerSeries as ht } from "./base-multi-layer.js";
|
|
7
|
+
import { unfoldIntro as ct, scaleMean as ut, backfillSweepIntro as ft } from "./line-intro.js";
|
|
8
|
+
import { buildCurveSegments as j, replaySegmentsForward as q, replaySegmentsReversed as mt } from "./painters/canvas-path.js";
|
|
9
|
+
import { resolveLinePainter as pt } from "./painters/resolve.js";
|
|
10
|
+
import { ScaleStack as tt } from "./scale-stack.js";
|
|
11
|
+
const gt = {
|
|
12
12
|
colors: ["#2962FF"],
|
|
13
13
|
strokeWidth: 1,
|
|
14
14
|
area: { visible: !0 },
|
|
15
15
|
pulse: !0,
|
|
16
16
|
stacking: "off",
|
|
17
17
|
curve: "straight",
|
|
18
|
-
entryMs:
|
|
19
|
-
smoothMs:
|
|
20
|
-
pulseMs:
|
|
21
|
-
introMs:
|
|
22
|
-
historyRevealMs:
|
|
18
|
+
entryMs: lt,
|
|
19
|
+
smoothMs: nt,
|
|
20
|
+
pulseMs: st,
|
|
21
|
+
introMs: ot,
|
|
22
|
+
historyRevealMs: it
|
|
23
23
|
};
|
|
24
|
-
function
|
|
25
|
-
const t =
|
|
24
|
+
function et(S) {
|
|
25
|
+
const t = S.areaFill, i = t !== void 0 && S.area === void 0 ? { visible: !!t } : S.area;
|
|
26
26
|
return {
|
|
27
|
-
...
|
|
27
|
+
...S,
|
|
28
28
|
area: i,
|
|
29
|
-
entryMs:
|
|
30
|
-
smoothMs:
|
|
31
|
-
pulseMs:
|
|
32
|
-
introMs:
|
|
33
|
-
historyRevealMs:
|
|
29
|
+
entryMs: S.entryMs === !1 ? 0 : S.entryMs ?? lt,
|
|
30
|
+
smoothMs: S.smoothMs === !1 ? 0 : S.smoothMs ?? nt,
|
|
31
|
+
pulseMs: S.pulseMs === !1 ? 0 : S.pulseMs ?? st,
|
|
32
|
+
introMs: S.introMs === !1 ? 0 : S.introMs ?? ot,
|
|
33
|
+
historyRevealMs: S.historyRevealMs === !1 ? 0 : S.historyRevealMs ?? it
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function Q(S) {
|
|
37
|
+
return S.map(([t, i]) => ({ x: t, y: i }));
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
function
|
|
41
|
-
const { resolve: e, lerp: o =
|
|
42
|
-
if (
|
|
43
|
-
if (t <=
|
|
44
|
-
const s =
|
|
39
|
+
const K = 0.15, dt = ft();
|
|
40
|
+
function _(S, t, i) {
|
|
41
|
+
const { resolve: e, lerp: o = G } = i;
|
|
42
|
+
if (S.length === 0) return null;
|
|
43
|
+
if (t <= S[0].time) return Number.isFinite(S[0].value) ? e(S[0]) : null;
|
|
44
|
+
const s = S[S.length - 1];
|
|
45
45
|
if (t >= s.time) return Number.isFinite(s.value) ? e(s) : null;
|
|
46
|
-
let
|
|
47
|
-
for (;
|
|
48
|
-
const c =
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
|
|
46
|
+
let h = 0, l = S.length - 1;
|
|
47
|
+
for (; l - h > 1; ) {
|
|
48
|
+
const c = h + l >> 1;
|
|
49
|
+
S[c].time <= t ? h = c : l = c;
|
|
50
|
+
}
|
|
51
|
+
const u = S[h];
|
|
52
|
+
if (u.time === t) return Number.isFinite(u.value) ? e(u) : null;
|
|
53
|
+
const r = S[l];
|
|
54
|
+
if (!Number.isFinite(u.value) || !Number.isFinite(r.value)) return null;
|
|
55
|
+
const f = r.time - u.time;
|
|
56
|
+
return f <= 0 ? e(u) : o(e(u), e(r), (t - u.time) / f);
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
let i = 0, e =
|
|
58
|
+
function vt(S, t) {
|
|
59
|
+
let i = 0, e = S.length - 1;
|
|
58
60
|
for (; i <= e; ) {
|
|
59
61
|
const o = i + e >> 1;
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
+
if (S[o] === t) return o;
|
|
63
|
+
S[o] < t ? i = o + 1 : e = o - 1;
|
|
62
64
|
}
|
|
63
65
|
return -1;
|
|
64
66
|
}
|
|
65
|
-
class
|
|
67
|
+
class xt extends ht {
|
|
66
68
|
kind = "line";
|
|
67
69
|
areaGradientCache = /* @__PURE__ */ new Map();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
/** First palette slot of the theme default colours — see `SeriesCreateEnv.paletteIndex`. */
|
|
71
|
+
#t;
|
|
72
|
+
constructor(t, i, e = 0) {
|
|
73
|
+
super(t), this.options = et({ ...gt, ...i }), this.#t = e;
|
|
70
74
|
}
|
|
71
75
|
updateOptions(t) {
|
|
72
|
-
this.options =
|
|
76
|
+
this.options = et({ ...this.options, ...t });
|
|
73
77
|
}
|
|
74
78
|
getStacking() {
|
|
75
79
|
return this.options.stacking;
|
|
76
80
|
}
|
|
77
81
|
applyTheme(t, i) {
|
|
78
|
-
const e =
|
|
82
|
+
const e = at({ theme: t, layerCount: this.stores.length, paletteIndex: this.#t });
|
|
79
83
|
this.updateOptions({ colors: e }), this.options.strokeWidth === i.line.width && this.updateOptions({ strokeWidth: t.line.width });
|
|
80
84
|
}
|
|
81
85
|
isEntryEnabled() {
|
|
@@ -96,18 +100,18 @@ class Pt extends ut {
|
|
|
96
100
|
return !1;
|
|
97
101
|
}
|
|
98
102
|
render(t) {
|
|
99
|
-
this.tickAnimations(performance.now()), this.lastYScale = t.yScale;
|
|
103
|
+
this.tickAnimations(performance.now()), this.lastYScale = t.yScale, this.lastTimeScale = t.timeScale;
|
|
100
104
|
const { context: i } = t.scope;
|
|
101
105
|
this.historyDirectives = null;
|
|
102
106
|
const e = this.historyRange;
|
|
103
107
|
if (this.historyWave.active && e !== null) {
|
|
104
|
-
const
|
|
105
|
-
|
|
108
|
+
const l = this.options.historyReveal ?? dt;
|
|
109
|
+
l !== "none" && (this.historyDirectives = l(this.buildHistoryFrame(t, e)));
|
|
106
110
|
}
|
|
107
111
|
const o = this.historyDirectives, s = o?.ghostAlpha ?? 0;
|
|
108
112
|
s > 0 && (i.save(), i.globalAlpha *= s, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, i.restore());
|
|
109
|
-
const
|
|
110
|
-
this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)),
|
|
113
|
+
const h = this.applyHistoryClip(t, o, e);
|
|
114
|
+
this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)), h && i.restore(), o?.heads !== void 0 && o.heads.length > 0 && this.drawIntroHeads(t, o.heads, this.historyWave.linear());
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
117
|
* Initial-load intro pass: the resolved LineIntroFn describes this frame
|
|
@@ -117,14 +121,14 @@ class Pt extends ut {
|
|
|
117
121
|
renderWithIntro(t) {
|
|
118
122
|
const i = this.resolveIntro()(this.buildIntroFrame(t));
|
|
119
123
|
this.introDirectives = i;
|
|
120
|
-
const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize,
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
e.save(), e.beginPath(), e.rect(
|
|
124
|
+
const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize, h = i.ghostAlpha ?? 0;
|
|
125
|
+
h > 0 && (e.save(), e.globalAlpha *= h, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, e.restore());
|
|
126
|
+
const l = i.clip, u = l !== void 0 && (l.fromX !== void 0 || l.toX !== void 0);
|
|
127
|
+
if (u) {
|
|
128
|
+
const r = l.fromX ?? 0, f = l.toX ?? o;
|
|
129
|
+
e.save(), e.beginPath(), e.rect(r, 0, Math.max(0, f - r), s), e.clip();
|
|
126
130
|
}
|
|
127
|
-
this.renderBody(t),
|
|
131
|
+
this.renderBody(t), u && e.restore(), i.heads !== void 0 && i.heads.length > 0 && this.drawIntroHeads(t, i.heads, this.introWave.linear());
|
|
128
132
|
}
|
|
129
133
|
/**
|
|
130
134
|
* Apply the history reveal's clip directive, mapped from reveal space
|
|
@@ -135,8 +139,8 @@ class Pt extends ut {
|
|
|
135
139
|
applyHistoryClip(t, i, e) {
|
|
136
140
|
const o = i?.clip;
|
|
137
141
|
if (o === void 0 || e === null || o.fromX === void 0 && o.toX === void 0) return !1;
|
|
138
|
-
const { context: s } = t.scope, { width:
|
|
139
|
-
return s.save(), s.beginPath(), s.rect(
|
|
142
|
+
const { context: s } = t.scope, { width: h, height: l } = t.scope.bitmapSize, u = t.timeScale.timeToBitmapXExact(e.to), r = Math.abs(u - t.timeScale.timeToBitmapXExact(e.from)), f = Math.max(2, (this.options.strokeWidth ?? 1) * t.scope.horizontalPixelRatio), c = o.fromX ?? 0, v = o.toX ?? r;
|
|
143
|
+
return s.save(), s.beginPath(), s.rect(u - v - f, 0, Math.max(0, v - c + f), l), s.rect(u, 0, Math.max(0, h - u), l), s.clip(), !0;
|
|
140
144
|
}
|
|
141
145
|
renderBody(t) {
|
|
142
146
|
this.options.stacking === "off" ? (this.stackedEdges = null, this.renderOff(t)) : this.renderStacked(t, this.options.stacking === "percent");
|
|
@@ -162,11 +166,13 @@ class Pt extends ut {
|
|
|
162
166
|
historyDirectives = null;
|
|
163
167
|
/** Y scale of the last render — value queries run without a render context. */
|
|
164
168
|
lastYScale = null;
|
|
169
|
+
/** Time scale of the last render — places a share query's column in the intro wave. */
|
|
170
|
+
lastTimeScale = null;
|
|
165
171
|
/** Default intro, built lazily — one instance per renderer. */
|
|
166
172
|
defaultIntro = null;
|
|
167
173
|
resolveIntro() {
|
|
168
174
|
const t = this.options.introAnimation;
|
|
169
|
-
return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro =
|
|
175
|
+
return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro = ct()), this.defaultIntro);
|
|
170
176
|
}
|
|
171
177
|
/**
|
|
172
178
|
* Frame context handed to the intro fn — progress plus memoized data
|
|
@@ -198,45 +204,45 @@ class Pt extends ut {
|
|
|
198
204
|
});
|
|
199
205
|
}
|
|
200
206
|
buildFrame(t, i) {
|
|
201
|
-
const { timeScale: e, yScale: o, scope: s } = t, { progress:
|
|
202
|
-
let
|
|
203
|
-
const
|
|
204
|
-
let
|
|
205
|
-
return
|
|
207
|
+
const { timeScale: e, yScale: o, scope: s } = t, { progress: h, range: l, width: u } = i, r = this.options.stacking === "percent", f = new Array(this.stores.length), c = new Array(this.stores.length);
|
|
208
|
+
let v, a;
|
|
209
|
+
const g = (n) => {
|
|
210
|
+
let d = f[n];
|
|
211
|
+
return d === void 0 && (d = this.stores[n]?.getVisibleData(l.from, l.to) ?? [], f[n] = d), d;
|
|
206
212
|
};
|
|
207
213
|
return {
|
|
208
|
-
progress:
|
|
209
|
-
range:
|
|
210
|
-
width:
|
|
214
|
+
progress: h,
|
|
215
|
+
range: l,
|
|
216
|
+
width: u,
|
|
211
217
|
height: o.getMediaHeight() * s.verticalPixelRatio,
|
|
212
218
|
stacking: this.options.stacking,
|
|
213
|
-
timeToX: (
|
|
214
|
-
xToTime: (
|
|
215
|
-
valueToY: (
|
|
216
|
-
lerpValue: (
|
|
219
|
+
timeToX: (n) => e.timeToBitmapXExact(n),
|
|
220
|
+
xToTime: (n) => e.xToTime(n / s.horizontalPixelRatio),
|
|
221
|
+
valueToY: (n) => o.valueToBitmapYExact(n),
|
|
222
|
+
lerpValue: (n, d, M) => o.lerpValue(n, d, M),
|
|
217
223
|
layerCount: this.stores.length,
|
|
218
|
-
layerData:
|
|
219
|
-
layerMean: (
|
|
220
|
-
let
|
|
221
|
-
return
|
|
224
|
+
layerData: g,
|
|
225
|
+
layerMean: (n) => {
|
|
226
|
+
let d = c[n];
|
|
227
|
+
return d === void 0 && (r ? (v ??= this.meanShares(g, o), d = v[n]) : d = ut(g(n), o), c[n] = d), d;
|
|
222
228
|
},
|
|
223
229
|
primaryPath: () => {
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
for (let
|
|
227
|
-
if (this.getLayerAlpha(
|
|
228
|
-
const
|
|
229
|
-
if (!(
|
|
230
|
-
|
|
231
|
-
x: e.timeToBitmapXExact(
|
|
232
|
-
y: o.valueToBitmapYExact(
|
|
233
|
-
time:
|
|
230
|
+
if (a === void 0) {
|
|
231
|
+
a = null;
|
|
232
|
+
for (let n = 0; n < this.stores.length; n++) {
|
|
233
|
+
if (this.getLayerAlpha(n) <= 0 || !this.stores[n].isVisible()) continue;
|
|
234
|
+
const d = g(n).filter((M) => o.isPlottable(M.value));
|
|
235
|
+
if (!(d.length < 2)) {
|
|
236
|
+
a = d.map((M) => ({
|
|
237
|
+
x: e.timeToBitmapXExact(M.time),
|
|
238
|
+
y: o.valueToBitmapYExact(M.value),
|
|
239
|
+
time: M.time
|
|
234
240
|
}));
|
|
235
241
|
break;
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
|
-
return
|
|
245
|
+
return a;
|
|
240
246
|
}
|
|
241
247
|
};
|
|
242
248
|
}
|
|
@@ -250,12 +256,36 @@ class Pt extends ut {
|
|
|
250
256
|
const s = super.effectiveValue(t, i, e, o);
|
|
251
257
|
return this.options.stacking === "percent" ? s : this.introValue(t, { layerIndex: i, time: e, value: s });
|
|
252
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* The line stack's reading of a percent column (see `renderStacked`): each
|
|
261
|
+
* layer's current value at `time` times its alpha, 0 for a layer yet to
|
|
262
|
+
* start, over one signed total, then through the intro's share transform and
|
|
263
|
+
* the 100% cap; a total at or below 0 is a gap.
|
|
264
|
+
*/
|
|
265
|
+
percentShares(t) {
|
|
266
|
+
const i = /* @__PURE__ */ new Map();
|
|
267
|
+
let e = 0;
|
|
268
|
+
for (let l = 0; l < this.stores.length; l++) {
|
|
269
|
+
const u = this.getLayerAlpha(l);
|
|
270
|
+
if (u <= 0) continue;
|
|
271
|
+
const r = this.stores[l].getAll(), f = r.length > 0 && t < r[0].time ? 0 : _(r, t, { resolve: (c) => this.snapshotValue(l, c.time, c.value) });
|
|
272
|
+
f !== null && (i.set(l, f * u), e += f * u);
|
|
273
|
+
}
|
|
274
|
+
if (e <= 0) return null;
|
|
275
|
+
const o = this.lastTimeScale, s = /* @__PURE__ */ new Map();
|
|
276
|
+
let h = 0;
|
|
277
|
+
for (const [l, u] of i) {
|
|
278
|
+
const r = { layerIndex: l, time: t, value: u, total: e }, f = o === null ? Math.max(0, u / e * 100) : this.introShare({ timeScale: o }, r), c = Math.min(100, h + f);
|
|
279
|
+
s.set(l, c - h), h = c;
|
|
280
|
+
}
|
|
281
|
+
return s;
|
|
282
|
+
}
|
|
253
283
|
/** Layer's share of its column in percent, passed through the intro value transform. */
|
|
254
284
|
introShare(t, i) {
|
|
255
|
-
const { layerIndex: e, time: o, value: s, total:
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
258
|
-
return Math.max(0, this.introValue(t, { layerIndex: e, time: o, value:
|
|
285
|
+
const { layerIndex: e, time: o, value: s, total: h } = i;
|
|
286
|
+
if (h <= 0) return s;
|
|
287
|
+
const l = s / h * 100;
|
|
288
|
+
return Math.max(0, this.introValue(t, { layerIndex: e, time: o, value: l }));
|
|
259
289
|
}
|
|
260
290
|
/**
|
|
261
291
|
* What `layerMean` reports on a percent stack: each layer's mean share over
|
|
@@ -264,41 +294,41 @@ class Pt extends ut {
|
|
|
264
294
|
*/
|
|
265
295
|
meanShares(t, i) {
|
|
266
296
|
const e = this.stores.length, o = /* @__PURE__ */ new Set();
|
|
267
|
-
for (let
|
|
268
|
-
for (const
|
|
269
|
-
o.add(
|
|
270
|
-
const s = new Array(e).fill(0),
|
|
271
|
-
let
|
|
272
|
-
for (const
|
|
273
|
-
let
|
|
297
|
+
for (let r = 0; r < e; r++)
|
|
298
|
+
for (const f of t(r))
|
|
299
|
+
o.add(f.time);
|
|
300
|
+
const s = new Array(e).fill(0), h = new Array(e).fill(!1), l = new Array(e);
|
|
301
|
+
let u = 0;
|
|
302
|
+
for (const r of o) {
|
|
303
|
+
let f = 0;
|
|
274
304
|
for (let c = 0; c < e; c++) {
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
278
|
-
const
|
|
279
|
-
|
|
305
|
+
l[c] = null;
|
|
306
|
+
const v = this.getLayerAlpha(c), a = t(c);
|
|
307
|
+
if (v <= 0 || a.length === 0 || r < a[0].time) continue;
|
|
308
|
+
const g = _(a, r, { resolve: (n) => n.value });
|
|
309
|
+
g === null || !i.isPlottable(g) || (l[c] = g * v, f += g * v);
|
|
280
310
|
}
|
|
281
|
-
if (!(
|
|
282
|
-
|
|
311
|
+
if (!(f <= 0)) {
|
|
312
|
+
u++;
|
|
283
313
|
for (let c = 0; c < e; c++) {
|
|
284
|
-
const
|
|
285
|
-
|
|
314
|
+
const v = l[c];
|
|
315
|
+
v !== null && (s[c] += v / f * 100, h[c] = !0);
|
|
286
316
|
}
|
|
287
317
|
}
|
|
288
318
|
}
|
|
289
|
-
return s.map((
|
|
319
|
+
return s.map((r, f) => h[f] ? r / u : null);
|
|
290
320
|
}
|
|
291
321
|
/** The active history-reveal or intro value transform applied to one value. */
|
|
292
322
|
introValue(t, i) {
|
|
293
|
-
const { layerIndex: e, time: o, value: s } = i,
|
|
294
|
-
if (
|
|
295
|
-
const
|
|
296
|
-
return
|
|
323
|
+
const { layerIndex: e, time: o, value: s } = i, h = this.historyWave.active ? this.historyDirectives?.value : void 0, l = this.historyRange;
|
|
324
|
+
if (h !== void 0 && l !== null && o < l.to) {
|
|
325
|
+
const v = l.to - l.from, a = v > 0 ? Math.min(1, Math.max(0, (l.to - o) / v)) : 0;
|
|
326
|
+
return h({ layerIndex: e, time: o, value: s, position: a });
|
|
297
327
|
}
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
300
|
-
const
|
|
301
|
-
return
|
|
328
|
+
const u = this.introWave.active ? this.introDirectives?.value : void 0;
|
|
329
|
+
if (u === void 0) return s;
|
|
330
|
+
const r = t.timeScale.getRange(), f = r.to - r.from, c = f > 0 ? Math.min(1, Math.max(0, (o - r.from) / f)) : 0;
|
|
331
|
+
return u({ layerIndex: e, time: o, value: s, position: c });
|
|
302
332
|
}
|
|
303
333
|
/**
|
|
304
334
|
* Extends the base last-value query with the 'grow' entrance's value-space
|
|
@@ -322,22 +352,22 @@ class Pt extends ut {
|
|
|
322
352
|
if (e.length === 0) return null;
|
|
323
353
|
const o = this.stores[t].getAll(), s = o.length - 1 - e.length;
|
|
324
354
|
if (s < 0) return null;
|
|
325
|
-
const
|
|
326
|
-
if (!Number.isFinite(
|
|
327
|
-
let
|
|
328
|
-
const
|
|
329
|
-
for (let
|
|
330
|
-
const
|
|
331
|
-
if (!Number.isFinite(
|
|
332
|
-
const c =
|
|
333
|
-
|
|
355
|
+
const h = o[s];
|
|
356
|
+
if (!Number.isFinite(h.value)) return null;
|
|
357
|
+
let l = i(h.time, h.value);
|
|
358
|
+
const u = /* @__PURE__ */ new Map();
|
|
359
|
+
for (let r = 0; r < e.length; r++) {
|
|
360
|
+
const f = o[s + 1 + r];
|
|
361
|
+
if (!Number.isFinite(f.value)) return null;
|
|
362
|
+
const c = J(e[r].progress), v = i(f.time, f.value), a = this.axisLerp(l, v, c);
|
|
363
|
+
u.set(f.time, a), l = a;
|
|
334
364
|
}
|
|
335
|
-
return
|
|
365
|
+
return u;
|
|
336
366
|
}
|
|
337
367
|
/** `lerp` along the last rendered Y axis — plain before the first render. */
|
|
338
368
|
axisLerp(t, i, e) {
|
|
339
369
|
const o = this.lastYScale;
|
|
340
|
-
return o === null ?
|
|
370
|
+
return o === null ? G(t, i, e) : o.lerpValue(t, i, e);
|
|
341
371
|
}
|
|
342
372
|
/**
|
|
343
373
|
* Glowing pulse dots riding the intro's head anchors — the line reads as
|
|
@@ -347,22 +377,22 @@ class Pt extends ut {
|
|
|
347
377
|
*/
|
|
348
378
|
drawIntroHeads(t, i, e) {
|
|
349
379
|
if (this.options.stacking !== "off") return;
|
|
350
|
-
const o = Math.min(1, e /
|
|
351
|
-
if (
|
|
352
|
-
const { scope:
|
|
353
|
-
for (const
|
|
354
|
-
for (let
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
const c = this.introHeadAnchor(t,
|
|
380
|
+
const o = Math.min(1, e / K), s = Math.min(1, (1 - e) / K), h = Math.max(0, Math.min(o, s));
|
|
381
|
+
if (h <= 0) return;
|
|
382
|
+
const { scope: l } = t;
|
|
383
|
+
for (const u of i)
|
|
384
|
+
for (let r = 0; r < this.stores.length; r++) {
|
|
385
|
+
const f = this.getLayerAlpha(r);
|
|
386
|
+
if (f <= 0 || !this.stores[r].isVisible()) continue;
|
|
387
|
+
const c = this.introHeadAnchor(t, r, u);
|
|
358
388
|
c !== null && this.drawPulse({
|
|
359
|
-
ctx:
|
|
389
|
+
ctx: l.context,
|
|
360
390
|
x: c.x,
|
|
361
391
|
y: c.y,
|
|
362
|
-
color: this.resolveLayerColor(
|
|
363
|
-
pixelRatio:
|
|
392
|
+
color: this.resolveLayerColor(r, c.value),
|
|
393
|
+
pixelRatio: l.horizontalPixelRatio,
|
|
364
394
|
phase: e * 2,
|
|
365
|
-
alpha:
|
|
395
|
+
alpha: h * f
|
|
366
396
|
});
|
|
367
397
|
}
|
|
368
398
|
}
|
|
@@ -378,30 +408,30 @@ class Pt extends ut {
|
|
|
378
408
|
* visible range, not the data span) and jumps back on settle.
|
|
379
409
|
*/
|
|
380
410
|
introHeadAnchor(t, i, e) {
|
|
381
|
-
const { timeScale: o, yScale: s } = t,
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (!s.isPlottable(
|
|
411
|
+
const { timeScale: o, yScale: s } = t, h = o.getRange(), l = this.stores[i].getVisibleData(h.from, h.to);
|
|
412
|
+
if (l.length === 0) return null;
|
|
413
|
+
const u = this.stores[i].last();
|
|
414
|
+
if (u !== void 0 && e.time >= u.time) {
|
|
415
|
+
if (!s.isPlottable(u.value)) return null;
|
|
386
416
|
const c = this.trailingEndpoint(t, i);
|
|
387
|
-
return c === null ? null : { x: c.x, y: c.y, value:
|
|
417
|
+
return c === null ? null : { x: c.x, y: c.y, value: u.value };
|
|
388
418
|
}
|
|
389
|
-
const
|
|
390
|
-
if (e.time <=
|
|
391
|
-
if (!s.isPlottable(
|
|
392
|
-
const c = this.effectiveValue(t, i,
|
|
419
|
+
const r = l[0];
|
|
420
|
+
if (e.time <= r.time) {
|
|
421
|
+
if (!s.isPlottable(r.value)) return null;
|
|
422
|
+
const c = this.effectiveValue(t, i, r.time, r.value);
|
|
393
423
|
return {
|
|
394
|
-
x: o.timeToBitmapXExact(
|
|
424
|
+
x: o.timeToBitmapXExact(r.time),
|
|
395
425
|
y: s.valueToBitmapYExact(c),
|
|
396
|
-
value:
|
|
426
|
+
value: r.value
|
|
397
427
|
};
|
|
398
428
|
}
|
|
399
|
-
const
|
|
429
|
+
const f = _(l, e.time, {
|
|
400
430
|
resolve: (c) => this.effectiveValue(t, i, c.time, c.value),
|
|
401
431
|
// Along the axis, so the dot stays on the straight segment the stroke draws.
|
|
402
|
-
lerp: (c,
|
|
432
|
+
lerp: (c, v, a) => !s.isPlottable(c) || !s.isPlottable(v) ? Number.NaN : s.lerpValue(c, v, a)
|
|
403
433
|
});
|
|
404
|
-
return
|
|
434
|
+
return f === null || !s.isPlottable(f) ? null : { x: e.x, y: s.valueToBitmapYExact(f), value: f };
|
|
405
435
|
}
|
|
406
436
|
/**
|
|
407
437
|
* Rendered positions of the layer's still-unsettled trailing points, keyed
|
|
@@ -426,51 +456,53 @@ class Pt extends ut {
|
|
|
426
456
|
* it (see `renderStacked`'s `valueMaps` comment for the full rationale).
|
|
427
457
|
*/
|
|
428
458
|
stackedValueAt(t, i, e) {
|
|
429
|
-
const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow",
|
|
459
|
+
const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow", h = new Array(this.stores.length), l = (a) => {
|
|
430
460
|
if (!s) return null;
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
return
|
|
435
|
-
},
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
return
|
|
440
|
-
resolve: (
|
|
461
|
+
const g = h[a];
|
|
462
|
+
if (g !== void 0) return g;
|
|
463
|
+
const n = this.chainedTailValues(a, (d, M) => this.effectiveValue(t, a, d, M));
|
|
464
|
+
return h[a] = n, n;
|
|
465
|
+
}, u = (a) => {
|
|
466
|
+
const g = this.stores[a].getAll();
|
|
467
|
+
if (g.length === 0 || e < g[0].time) return null;
|
|
468
|
+
const n = l(a);
|
|
469
|
+
return _(g, e, {
|
|
470
|
+
resolve: (d) => n?.get(d.time) ?? this.effectiveValue(t, a, d.time, d.value)
|
|
441
471
|
});
|
|
442
|
-
}, { yScale:
|
|
443
|
-
if (
|
|
444
|
-
const
|
|
445
|
-
for (let
|
|
446
|
-
const
|
|
447
|
-
|
|
472
|
+
}, { yScale: r } = t;
|
|
473
|
+
if (r.getTransform() !== null && !o) {
|
|
474
|
+
const a = new tt(r);
|
|
475
|
+
for (let g = 0; g <= i; g++) {
|
|
476
|
+
const n = this.getLayerAlpha(g), d = n > 0 ? u(g) : null;
|
|
477
|
+
d !== null && r.isPlottable(d) && a.push(d, n);
|
|
448
478
|
}
|
|
449
|
-
return
|
|
479
|
+
return a.edge;
|
|
450
480
|
}
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
const
|
|
455
|
-
if (o &&
|
|
456
|
-
const
|
|
457
|
-
return
|
|
481
|
+
const f = (a) => {
|
|
482
|
+
const g = this.getLayerAlpha(a);
|
|
483
|
+
if (g <= 0) return null;
|
|
484
|
+
const n = this.stores[a].getAll();
|
|
485
|
+
if (o && n.length > 0 && e < n[0].time) return 0;
|
|
486
|
+
const d = u(a);
|
|
487
|
+
return d === null ? null : d * g;
|
|
458
488
|
};
|
|
459
489
|
let c = 0;
|
|
460
|
-
if (o)
|
|
461
|
-
for (let
|
|
462
|
-
c +=
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
490
|
+
if (o) {
|
|
491
|
+
for (let a = 0; a < this.stores.length; a++)
|
|
492
|
+
c += f(a) ?? 0;
|
|
493
|
+
if (c <= 0) return Number.NaN;
|
|
494
|
+
}
|
|
495
|
+
let v = 0;
|
|
496
|
+
for (let a = 0; a <= i; a++) {
|
|
497
|
+
const g = f(a);
|
|
498
|
+
if (g !== null)
|
|
467
499
|
if (o) {
|
|
468
|
-
const
|
|
469
|
-
|
|
500
|
+
const n = this.introShare(t, { layerIndex: a, time: e, value: g, total: c });
|
|
501
|
+
v = Math.min(100, v + n);
|
|
470
502
|
} else
|
|
471
|
-
|
|
503
|
+
v += g;
|
|
472
504
|
}
|
|
473
|
-
return
|
|
505
|
+
return v;
|
|
474
506
|
}
|
|
475
507
|
/**
|
|
476
508
|
* Bitmap position for layer `li`'s stacked boundary at time `t`.
|
|
@@ -486,41 +518,41 @@ class Pt extends ut {
|
|
|
486
518
|
stackedPositionAt(t, i, e) {
|
|
487
519
|
const o = this.paintedStackVertex(t, i, e);
|
|
488
520
|
if (o !== null) return o;
|
|
489
|
-
const { timeScale: s, yScale:
|
|
490
|
-
if ((this.options.entryAnimation ?? "grow") !== "grow" || e !==
|
|
491
|
-
let
|
|
492
|
-
for (let
|
|
493
|
-
|
|
494
|
-
return { x, y:
|
|
521
|
+
const { timeScale: s, yScale: h } = t, l = h.valueToBitmapYExact(this.stackedValueAt(t, i, e)), u = s.timeToBitmapXExact(e), r = this.unsettledTail(i), f = this.stores[i].getAll(), c = f.length - 1 - r.length;
|
|
522
|
+
if ((this.options.entryAnimation ?? "grow") !== "grow" || e !== f[f.length - 1]?.time || r.length === 0 || c < 0) return { x: u, y: l };
|
|
523
|
+
let v = s.timeToBitmapXExact(f[c].time);
|
|
524
|
+
for (let a = 0; a < r.length; a++)
|
|
525
|
+
v = G(v, s.timeToBitmapXExact(f[c + 1 + a].time), J(r[a].progress));
|
|
526
|
+
return { x: v, y: l };
|
|
495
527
|
}
|
|
496
528
|
/** Upper-edge vertex of layer `li` at column `t`, replayed from the last
|
|
497
529
|
* stacked frame's data-space record against `ctx`'s scales. */
|
|
498
530
|
paintedStackVertex(t, i, e) {
|
|
499
531
|
const o = this.stackedEdges, s = o?.cumulative[i];
|
|
500
532
|
if (o === null || s === void 0) return null;
|
|
501
|
-
const { times:
|
|
502
|
-
if (
|
|
503
|
-
const { timeScale:
|
|
504
|
-
if (
|
|
505
|
-
let
|
|
506
|
-
for (let
|
|
507
|
-
|
|
508
|
-
return { x:
|
|
533
|
+
const { times: h, growChain: l, collapse: u } = o, r = vt(h, e);
|
|
534
|
+
if (r < 0) return null;
|
|
535
|
+
const { timeScale: f, yScale: c } = t, v = t.scope.bitmapSize.height, a = u[i] ?? 1, g = c.valueToBitmapYExact(s[r]), n = a >= 1 ? g : v + (g - v) * a, d = h.length - l.length;
|
|
536
|
+
if (r < d) return { x: f.timeToBitmapXExact(e), y: n };
|
|
537
|
+
let M = f.timeToBitmapXExact(h[d - 1]);
|
|
538
|
+
for (let x = 0; x <= r - d; x++)
|
|
539
|
+
M = G(M, f.timeToBitmapXExact(h[d + x]), l[x]);
|
|
540
|
+
return { x: M, y: n };
|
|
509
541
|
}
|
|
510
542
|
chainedTailPositions(t, i) {
|
|
511
543
|
const e = this.unsettledTail(i);
|
|
512
544
|
if (e.length === 0) return null;
|
|
513
545
|
const o = this.stores[i].getAll(), s = o.length - 1 - e.length;
|
|
514
546
|
if (s < 0) return null;
|
|
515
|
-
const { timeScale:
|
|
516
|
-
if (!
|
|
517
|
-
let
|
|
547
|
+
const { timeScale: h, yScale: l } = t, u = o[s];
|
|
548
|
+
if (!l.isPlottable(u.value)) return null;
|
|
549
|
+
let r = h.timeToBitmapXExact(u.time), f = l.valueToBitmapYExact(this.effectiveValue(t, i, u.time, u.value));
|
|
518
550
|
const c = /* @__PURE__ */ new Map();
|
|
519
|
-
for (let
|
|
520
|
-
const
|
|
521
|
-
if (!
|
|
522
|
-
const
|
|
523
|
-
c.set(
|
|
551
|
+
for (let v = 0; v < e.length; v++) {
|
|
552
|
+
const a = o[s + 1 + v];
|
|
553
|
+
if (!l.isPlottable(a.value)) return null;
|
|
554
|
+
const g = J(e[v].progress), n = h.timeToBitmapXExact(a.time), d = l.valueToBitmapYExact(this.effectiveValue(t, i, a.time, a.value)), M = G(r, n, g), x = G(f, d, g);
|
|
555
|
+
c.set(a.time, { x: M, y: x }), r = M, f = x;
|
|
524
556
|
}
|
|
525
557
|
return c;
|
|
526
558
|
}
|
|
@@ -537,8 +569,8 @@ class Pt extends ut {
|
|
|
537
569
|
trailingEndpoint(t, i) {
|
|
538
570
|
const e = this.stores[i].last();
|
|
539
571
|
if (!e) return null;
|
|
540
|
-
const { timeScale: o, yScale: s } = t,
|
|
541
|
-
return (this.options.entryAnimation ?? "grow") !== "grow" ? { x:
|
|
572
|
+
const { timeScale: o, yScale: s } = t, h = o.timeToBitmapXExact(e.time), l = s.valueToBitmapYExact(this.effectiveValue(t, i, e.time, e.value));
|
|
573
|
+
return (this.options.entryAnimation ?? "grow") !== "grow" ? { x: h, y: l } : this.chainedTailPositions(t, i)?.get(e.time) ?? { x: h, y: l };
|
|
542
574
|
}
|
|
543
575
|
/**
|
|
544
576
|
* Vertical stroke + area gradients for `options.threshold`, pinned to the
|
|
@@ -552,10 +584,10 @@ class Pt extends ut {
|
|
|
552
584
|
buildThresholdPaint(t, i) {
|
|
553
585
|
const e = this.options.threshold;
|
|
554
586
|
if (!e) return null;
|
|
555
|
-
const { scope: o, yScale: s } = t, { context:
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
return
|
|
587
|
+
const { scope: o, yScale: s } = t, { context: h } = o, l = o.bitmapSize.height, u = e.above, r = e.below ?? i, f = Math.min(1, Math.max(0, s.valueToBitmapYExact(e.value) / l)), c = Math.min(6 * o.verticalPixelRatio, l * 0.02) / l, v = Math.max(0, f - c), a = Math.min(1, f + c), g = h.createLinearGradient(0, 0, 0, l);
|
|
588
|
+
g.addColorStop(0, u), g.addColorStop(v, u), g.addColorStop(a, r), g.addColorStop(1, r);
|
|
589
|
+
const n = h.createLinearGradient(0, 0, 0, l);
|
|
590
|
+
return n.addColorStop(0, B(u, 0.26)), n.addColorStop(v, B(u, 0.14)), n.addColorStop(a, B(r, 0.1)), n.addColorStop(1, B(r, 0.01)), { stroke: g, area: n };
|
|
559
591
|
}
|
|
560
592
|
/**
|
|
561
593
|
* Dot markers at each data point (`options.points`). Callers pass the same
|
|
@@ -568,243 +600,281 @@ class Pt extends ut {
|
|
|
568
600
|
drawPointMarkers(t) {
|
|
569
601
|
const i = this.options.points;
|
|
570
602
|
if (!i?.visible) return;
|
|
571
|
-
const { context: e, points: o, pixelRatio: s, color:
|
|
603
|
+
const { context: e, points: o, pixelRatio: s, color: h } = t;
|
|
572
604
|
if (o.length === 0) return;
|
|
573
|
-
const
|
|
574
|
-
if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) <
|
|
605
|
+
const l = Math.max(1, (i.radius ?? 3) * s);
|
|
606
|
+
if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) < l * 3)) {
|
|
575
607
|
e.beginPath();
|
|
576
|
-
for (const
|
|
577
|
-
e.moveTo(
|
|
578
|
-
e.fillStyle = i.color ??
|
|
608
|
+
for (const u of o)
|
|
609
|
+
e.moveTo(u.x + l, u.y), e.arc(u.x, u.y, l, 0, Math.PI * 2);
|
|
610
|
+
e.fillStyle = i.color ?? h, e.fill();
|
|
579
611
|
}
|
|
580
612
|
}
|
|
581
613
|
/** Each layer drawn independently */
|
|
582
614
|
renderOff(t) {
|
|
583
|
-
const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i,
|
|
615
|
+
const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i, h = e.getRange(), { verticalPixelRatio: l } = i, u = this.options.strokeWidth > 0, r = Math.max(1, Math.round(this.options.strokeWidth * l)), f = this.options.entryAnimation ?? "grow", c = pt(this.options.linePainter ?? this.options.curve ?? "straight"), v = {
|
|
584
616
|
ctx: s,
|
|
585
617
|
theme: t.theme,
|
|
586
618
|
horizontalPixelRatio: i.horizontalPixelRatio,
|
|
587
|
-
verticalPixelRatio:
|
|
619
|
+
verticalPixelRatio: l
|
|
588
620
|
};
|
|
589
|
-
for (let
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
let
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
const
|
|
596
|
-
x: e.timeToBitmapXExact(
|
|
597
|
-
y: o.valueToBitmapYExact(this.effectiveValue(t,
|
|
598
|
-
},
|
|
599
|
-
(
|
|
600
|
-
const
|
|
601
|
-
let
|
|
602
|
-
for (let
|
|
603
|
-
const
|
|
604
|
-
if (!o.isPlottable(
|
|
605
|
-
|
|
621
|
+
for (let a = 0; a < this.stores.length; a++) {
|
|
622
|
+
const g = this.getLayerAlpha(a);
|
|
623
|
+
if (g <= 0) continue;
|
|
624
|
+
let n = this.stores[a].getVisibleData(h.from, h.to);
|
|
625
|
+
const d = i.mediaSize.width;
|
|
626
|
+
if (n.length > d * 2 && (n = Z(n, Math.round(d * 1.5))), n.length < 2) continue;
|
|
627
|
+
const M = this.lastFinitePoint(a)?.value ?? n[n.length - 1].value, x = this.resolveLayerColor(a, M), w = this.buildThresholdPaint(t, x), R = n[n.length - 1], C = this.stores[a].last(), W = C !== void 0 && R.time === C.time, H = W ? this.entranceProgress(a, R.time) : 1, D = W && f === "fade" && H < 1, N = (W ? this.trailingEndpoint(t, a) : null) ?? {
|
|
628
|
+
x: e.timeToBitmapXExact(R.time),
|
|
629
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, a, R.time, R.value))
|
|
630
|
+
}, O = N.x, X = N.y, Y = W && f === "grow" ? this.chainedTailPositions(t, a) : null, z = g < 1;
|
|
631
|
+
(z || D) && (s.save(), z && (s.globalAlpha *= g), D && (s.globalAlpha *= H));
|
|
632
|
+
const $ = n.length - 1, F = [];
|
|
633
|
+
let V = null;
|
|
634
|
+
for (let p = 0; p < $; p++) {
|
|
635
|
+
const y = n[p].value;
|
|
636
|
+
if (!o.isPlottable(y)) {
|
|
637
|
+
V = null;
|
|
606
638
|
continue;
|
|
607
639
|
}
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
|
|
640
|
+
V || (V = [], F.push(V));
|
|
641
|
+
const P = Y?.get(n[p].time);
|
|
642
|
+
if (P)
|
|
643
|
+
V.push({ x: P.x, y: P.y });
|
|
612
644
|
else {
|
|
613
|
-
const
|
|
614
|
-
|
|
645
|
+
const E = o.valueToBitmapYExact(this.effectiveValue(t, a, n[p].time, y));
|
|
646
|
+
V.push({ x: e.timeToBitmapXExact(n[p].time), y: E });
|
|
615
647
|
}
|
|
616
648
|
}
|
|
617
|
-
const
|
|
618
|
-
let
|
|
619
|
-
if (b && (
|
|
649
|
+
const m = n[$]?.value, b = Number.isFinite(O) && Number.isFinite(X) && o.isPlottable(m), T = f === "grow" && H < 1;
|
|
650
|
+
let k = null;
|
|
651
|
+
if (b && (V ? (V.push({ x: O, y: X }), k = V) : F.push([{ x: O, y: X }])), u && F.some((p) => p.length >= 2)) {
|
|
620
652
|
s.beginPath();
|
|
621
|
-
for (const
|
|
622
|
-
|
|
623
|
-
s.strokeStyle =
|
|
653
|
+
for (const p of F)
|
|
654
|
+
p.length < 2 || c(v, { points: p, color: x, lineWidth: r, closing: !1, grew: T && p === k });
|
|
655
|
+
s.strokeStyle = w ? w.stroke : x, s.lineWidth = r, s.lineJoin = "round", s.lineCap = "round", s.stroke();
|
|
624
656
|
}
|
|
625
|
-
if (
|
|
626
|
-
const
|
|
627
|
-
let
|
|
628
|
-
for (const
|
|
629
|
-
|
|
630
|
-
|
|
657
|
+
if (u) {
|
|
658
|
+
const p = Math.max(1, r / 2);
|
|
659
|
+
let y = !1;
|
|
660
|
+
for (const P of F)
|
|
661
|
+
P.length === 1 && (y || (s.beginPath(), y = !0), s.moveTo(P[0].x + p, P[0].y), s.arc(P[0].x, P[0].y, p, 0, Math.PI * 2));
|
|
662
|
+
y && (s.fillStyle = x, s.fill());
|
|
631
663
|
}
|
|
632
664
|
if (this.options.area.visible && !this.introGhostPass) {
|
|
633
|
-
const
|
|
634
|
-
let
|
|
635
|
-
if (
|
|
636
|
-
|
|
665
|
+
const p = i.bitmapSize.height;
|
|
666
|
+
let y;
|
|
667
|
+
if (w)
|
|
668
|
+
y = w.area;
|
|
637
669
|
else {
|
|
638
|
-
const
|
|
639
|
-
|
|
670
|
+
const I = String(a), A = this.areaGradientCache.get(I);
|
|
671
|
+
A && A.bottomY === p && A.color === x ? y = A.gradient : (y = s.createLinearGradient(0, 0, 0, p), y.addColorStop(0, B(x, 0.12)), y.addColorStop(1, B(x, 0.01)), this.areaGradientCache.set(I, { gradient: y, bottomY: p, color: x }));
|
|
672
|
+
}
|
|
673
|
+
s.fillStyle = y, s.beginPath();
|
|
674
|
+
const P = r + i.horizontalPixelRatio;
|
|
675
|
+
let E = null;
|
|
676
|
+
for (const I of F) {
|
|
677
|
+
if (I.length < 2) continue;
|
|
678
|
+
const A = I[0], L = I[I.length - 1];
|
|
679
|
+
E !== null && A.x - E.x <= P && (s.moveTo(E.x, E.y), s.lineTo(A.x, A.y), s.lineTo(A.x, p), s.lineTo(E.x, p), s.closePath()), c(v, { points: I, color: x, lineWidth: r, closing: !0, grew: T && I === k }), s.lineTo(L.x, p), s.lineTo(A.x, p), s.closePath(), E = L;
|
|
640
680
|
}
|
|
641
|
-
s.
|
|
642
|
-
for (const w of u)
|
|
643
|
-
w.length < 2 || (s.beginPath(), c(x, { points: w, color: E, lineWidth: h, closing: !0, grew: P && w === T }), s.lineTo(w[w.length - 1].x, d), s.lineTo(w[0].x, d), s.closePath(), s.fill());
|
|
681
|
+
s.fill();
|
|
644
682
|
}
|
|
645
683
|
if (this.options.points?.visible) {
|
|
646
|
-
const
|
|
647
|
-
for (const
|
|
648
|
-
for (const
|
|
649
|
-
this.drawPointMarkers({ context: s, points:
|
|
684
|
+
const p = [];
|
|
685
|
+
for (const y of F)
|
|
686
|
+
for (const P of y) p.push(P);
|
|
687
|
+
this.drawPointMarkers({ context: s, points: p, pixelRatio: i.horizontalPixelRatio, color: x });
|
|
650
688
|
}
|
|
651
|
-
(
|
|
689
|
+
(D || z) && s.restore();
|
|
652
690
|
}
|
|
653
691
|
}
|
|
654
692
|
/** Stacked area rendering */
|
|
655
693
|
renderStacked(t, i) {
|
|
656
|
-
const { scope: e, timeScale: o, yScale: s } = t, { context:
|
|
657
|
-
if (this.getLayerAlpha(
|
|
658
|
-
let
|
|
659
|
-
return
|
|
660
|
-
}),
|
|
661
|
-
for (const
|
|
662
|
-
for (const
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
694
|
+
const { scope: e, timeScale: o, yScale: s } = t, { context: h } = e, l = o.getRange(), { verticalPixelRatio: u } = e, r = this.options.strokeWidth > 0, f = Math.max(1, Math.round(this.options.strokeWidth * u)), c = this.options.curve ?? "straight", v = e.mediaSize.width, a = this.stores.map((m, b) => {
|
|
695
|
+
if (this.getLayerAlpha(b) <= 0) return [];
|
|
696
|
+
let T = m.getVisibleData(l.from, l.to);
|
|
697
|
+
return T.length > v * 2 && (T = Z(T, Math.round(v * 1.5))), T;
|
|
698
|
+
}), g = /* @__PURE__ */ new Set();
|
|
699
|
+
for (const m of a)
|
|
700
|
+
for (const b of m) g.add(b.time);
|
|
701
|
+
const n = Array.from(g).sort((m, b) => m - b);
|
|
702
|
+
if (n.length < 2) {
|
|
665
703
|
this.stackedEdges = null;
|
|
666
704
|
return;
|
|
667
705
|
}
|
|
668
|
-
const
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
for (const
|
|
673
|
-
if (
|
|
674
|
-
const
|
|
675
|
-
|
|
706
|
+
const d = this.options.entryAnimation ?? "grow", M = a.map((m, b) => {
|
|
707
|
+
const T = /* @__PURE__ */ new Map();
|
|
708
|
+
if (m.length === 0) return T;
|
|
709
|
+
const k = m[0].time, p = d === "grow" ? this.chainedTailValues(b, (P, E) => this.effectiveValue(t, b, P, E)) : null, y = (P) => p?.get(P.time) ?? this.effectiveValue(t, b, P.time, P.value);
|
|
710
|
+
for (const P of n) {
|
|
711
|
+
if (P < k) continue;
|
|
712
|
+
const E = _(m, P, { resolve: y });
|
|
713
|
+
E !== null && T.set(P, E);
|
|
676
714
|
}
|
|
677
|
-
return
|
|
678
|
-
}),
|
|
679
|
-
const
|
|
680
|
-
return
|
|
681
|
-
},
|
|
682
|
-
for (let
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
const
|
|
686
|
-
for (let
|
|
687
|
-
const
|
|
688
|
-
|
|
715
|
+
return T;
|
|
716
|
+
}), x = this.stores.map((m, b) => this.getLayerAlpha(b)), w = (m, b) => {
|
|
717
|
+
const T = M[m].get(b);
|
|
718
|
+
return T === void 0 ? void 0 : T * x[m];
|
|
719
|
+
}, R = s.getTransform() !== null && !i, C = Array.from({ length: this.stores.length }, () => new Array(n.length).fill(0)), W = new Array(n.length).fill(!1);
|
|
720
|
+
for (let m = 0; m < n.length; m++) {
|
|
721
|
+
const b = n[m];
|
|
722
|
+
if (R) {
|
|
723
|
+
const p = new tt(s);
|
|
724
|
+
for (let y = 0; y < this.stores.length; y++) {
|
|
725
|
+
const P = M[y].get(b);
|
|
726
|
+
P !== void 0 && s.isPlottable(P) && p.push(P, x[y]), C[y][m] = p.edge;
|
|
689
727
|
}
|
|
690
728
|
continue;
|
|
691
729
|
}
|
|
692
|
-
let
|
|
730
|
+
let T = 0;
|
|
693
731
|
if (i)
|
|
694
|
-
for (let
|
|
695
|
-
const
|
|
696
|
-
|
|
732
|
+
for (let p = 0; p < this.stores.length; p++) {
|
|
733
|
+
const y = w(p, b);
|
|
734
|
+
y !== void 0 && s.isPlottable(y) && (T += y);
|
|
697
735
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
736
|
+
if (i && T <= 0) {
|
|
737
|
+
W[m] = !0;
|
|
738
|
+
for (let p = 0; p < this.stores.length; p++)
|
|
739
|
+
C[p][m] = Number.NaN;
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
let k = 0;
|
|
743
|
+
for (let p = 0; p < this.stores.length; p++) {
|
|
744
|
+
const y = w(p, b);
|
|
745
|
+
let P = y !== void 0 && s.isPlottable(y) ? y : null;
|
|
746
|
+
const E = a[p];
|
|
747
|
+
if (i && E.length > 0 && b < E[0].time && (P = 0), P !== null)
|
|
704
748
|
if (i) {
|
|
705
|
-
const
|
|
706
|
-
|
|
749
|
+
const I = this.introShare(t, { layerIndex: p, time: b, value: P, total: T });
|
|
750
|
+
k = Math.min(100, k + I);
|
|
707
751
|
} else
|
|
708
|
-
|
|
709
|
-
|
|
752
|
+
k += P;
|
|
753
|
+
C[p][m] = k;
|
|
710
754
|
}
|
|
711
755
|
}
|
|
712
|
-
const
|
|
713
|
-
for (let
|
|
714
|
-
const
|
|
715
|
-
for (let
|
|
716
|
-
if (this.getLayerAlpha(
|
|
717
|
-
const
|
|
718
|
-
if (
|
|
719
|
-
let
|
|
720
|
-
for (let
|
|
721
|
-
if (
|
|
722
|
-
|
|
756
|
+
const H = /* @__PURE__ */ new Map();
|
|
757
|
+
for (let m = 0; m < n.length; m++) H.set(n[m], m);
|
|
758
|
+
const D = new Array(this.stores.length).fill(1);
|
|
759
|
+
for (let m = 0; m < this.stores.length; m++) {
|
|
760
|
+
if (this.getLayerAlpha(m) <= 0) continue;
|
|
761
|
+
const b = this.unsettledTail(m), T = b.length;
|
|
762
|
+
if (T === 0) continue;
|
|
763
|
+
let k = !0;
|
|
764
|
+
for (let p = 0; p < T; p++)
|
|
765
|
+
if (H.get(b[p].time) !== n.length - T + p) {
|
|
766
|
+
k = !1;
|
|
723
767
|
break;
|
|
724
768
|
}
|
|
725
|
-
|
|
769
|
+
k && (D[m] = b[T - 1].progress);
|
|
726
770
|
}
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
729
|
-
const
|
|
730
|
-
for (let
|
|
731
|
-
const
|
|
732
|
-
let
|
|
733
|
-
for (let
|
|
734
|
-
if (this.getLayerAlpha(
|
|
735
|
-
const
|
|
736
|
-
for (;
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
739
|
-
(!
|
|
771
|
+
const N = [];
|
|
772
|
+
if (d === "grow") {
|
|
773
|
+
const m = a.map((b) => b.length - 1);
|
|
774
|
+
for (let b = n.length - 1; b >= 1; b--) {
|
|
775
|
+
const T = n[b];
|
|
776
|
+
let k = 1, p = !1;
|
|
777
|
+
for (let y = 0; y < a.length; y++) {
|
|
778
|
+
if (this.getLayerAlpha(y) <= 0) continue;
|
|
779
|
+
const P = a[y];
|
|
780
|
+
for (; m[y] >= 0 && P[m[y]].time > T; ) m[y]--;
|
|
781
|
+
if (m[y] < 0 || P[m[y]].time !== T) continue;
|
|
782
|
+
const E = this.entranceProgress(y, T);
|
|
783
|
+
(!p || E > k) && (k = E), p = !0;
|
|
740
784
|
}
|
|
741
|
-
if (!
|
|
742
|
-
|
|
785
|
+
if (!p || k >= 1) break;
|
|
786
|
+
N.unshift(J(k));
|
|
743
787
|
}
|
|
744
788
|
}
|
|
745
|
-
const
|
|
746
|
-
const
|
|
747
|
-
if (!(
|
|
748
|
-
for (let
|
|
749
|
-
const
|
|
750
|
-
|
|
789
|
+
const O = (m, b) => {
|
|
790
|
+
const T = b.length;
|
|
791
|
+
if (!(T === 0 || m.length < T + 1))
|
|
792
|
+
for (let k = 0; k < T; k++) {
|
|
793
|
+
const p = m.length - T + k;
|
|
794
|
+
m[p][0] = G(m[p - 1][0], m[p][0], b[k]);
|
|
751
795
|
}
|
|
752
|
-
},
|
|
753
|
-
let
|
|
754
|
-
for (let
|
|
755
|
-
if (!(this.getLayerAlpha(
|
|
756
|
-
if (
|
|
757
|
-
|
|
796
|
+
}, X = e.bitmapSize.height;
|
|
797
|
+
let Y = -1, z = -1;
|
|
798
|
+
for (let m = 0; m < this.stores.length; m++)
|
|
799
|
+
if (!(this.getLayerAlpha(m) <= 0))
|
|
800
|
+
if (Y < 0)
|
|
801
|
+
Y = m;
|
|
758
802
|
else {
|
|
759
|
-
|
|
803
|
+
z = m;
|
|
760
804
|
break;
|
|
761
805
|
}
|
|
762
|
-
const
|
|
763
|
-
for (let
|
|
764
|
-
const
|
|
765
|
-
if (
|
|
766
|
-
const
|
|
767
|
-
for (let
|
|
768
|
-
const
|
|
769
|
-
let
|
|
770
|
-
|
|
806
|
+
const $ = Y >= 0 ? this.getLayerAlpha(Y) : 1, F = a.map((m, b) => b === Y ? Math.min(1, this.getLayerAlpha(b)) : 1), V = yt(W);
|
|
807
|
+
for (let m = this.stores.length - 1; m >= 0; m--) {
|
|
808
|
+
const b = this.getLayerAlpha(m);
|
|
809
|
+
if (b <= 0) continue;
|
|
810
|
+
const T = this.lastFinitePoint(m)?.value ?? 0, k = this.resolveLayerColor(m, T), p = m === Y, y = z >= 0 && m === z && $ < 1, P = [];
|
|
811
|
+
for (let A = 0; A < n.length; A++) {
|
|
812
|
+
const L = m > 0 ? s.valueToBitmapYExact(C[m - 1][A]) : X;
|
|
813
|
+
let U = L;
|
|
814
|
+
p ? U = X : y && (U = L + (X - L) * (1 - $)), P.push([o.timeToBitmapXExact(n[A]), U]);
|
|
771
815
|
}
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
for (let
|
|
775
|
-
let
|
|
776
|
-
|
|
816
|
+
d === "grow" && O(P, N);
|
|
817
|
+
const E = [];
|
|
818
|
+
for (let A = 0; A < n.length; A++) {
|
|
819
|
+
let L = s.valueToBitmapYExact(C[m][A]);
|
|
820
|
+
p && b < 1 && (L = X + (L - X) * b), E.push([o.timeToBitmapXExact(n[A]), L]);
|
|
777
821
|
}
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
if (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), P)
|
|
792
|
-
for (let k = d.length - 1; k >= 0; k--)
|
|
793
|
-
l.lineTo(d[k][0], d[k][1]);
|
|
794
|
-
else {
|
|
795
|
-
const k = st(d), ct = tt(k, c, g === "grow" && I.length > 0), Z = k[k.length - 1];
|
|
796
|
-
l.lineTo(Z.x, Z.y), gt(l, k, ct);
|
|
797
|
-
}
|
|
798
|
-
l.closePath(), l.fillStyle = O, l.fill();
|
|
822
|
+
d === "grow" && O(E, N);
|
|
823
|
+
const I = d === "fade" && D[m] < 1;
|
|
824
|
+
I && (h.save(), h.globalAlpha *= D[m]);
|
|
825
|
+
for (const A of V) {
|
|
826
|
+
const L = d === "grow" && N.length > 0 && A.to === n.length;
|
|
827
|
+
this.drawStackSlice({
|
|
828
|
+
ctx: t,
|
|
829
|
+
lowerXY: P.slice(A.from, A.to),
|
|
830
|
+
upperXY: E.slice(A.from, A.to),
|
|
831
|
+
layer: { color: k, alpha: b, isBottomVisible: p },
|
|
832
|
+
curve: { kind: c, growing: L, hasStroke: r, lineWidth: f }
|
|
833
|
+
});
|
|
799
834
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
R && (l.save(), l.globalAlpha *= v), this.drawPointMarkers({ context: l, points: w, pixelRatio: e.horizontalPixelRatio, color: b }), R && l.restore();
|
|
835
|
+
if (this.options.points?.visible) {
|
|
836
|
+
const A = Q(E).filter((U, rt) => !W[rt]), L = b < 1;
|
|
837
|
+
L && (h.save(), h.globalAlpha *= b), this.drawPointMarkers({ context: h, points: A, pixelRatio: e.horizontalPixelRatio, color: k }), L && h.restore();
|
|
804
838
|
}
|
|
805
|
-
|
|
839
|
+
I && h.restore();
|
|
806
840
|
}
|
|
807
|
-
this.stackedEdges = { times:
|
|
841
|
+
this.stackedEdges = { times: n, cumulative: C, growChain: N, collapse: F };
|
|
842
|
+
}
|
|
843
|
+
/** Fill and stroke of one layer's slice over one run of stacked columns. */
|
|
844
|
+
drawStackSlice(t) {
|
|
845
|
+
const { lowerXY: i, upperXY: e } = t, { context: o } = t.ctx.scope, { color: s, alpha: h, isBottomVisible: l } = t.layer, { kind: u, growing: r, hasStroke: f, lineWidth: c } = t.curve, v = Q(e);
|
|
846
|
+
if (v.length === 1) {
|
|
847
|
+
f && this.drawStackDot({ context: o, point: v[0], color: s, lineWidth: c, alpha: h });
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
const a = j(v, u, r);
|
|
851
|
+
if (this.options.area.visible && !this.introGhostPass) {
|
|
852
|
+
let n = e[0][1], d = i[0][1];
|
|
853
|
+
for (let x = 1; x < e.length; x++)
|
|
854
|
+
e[x][1] < n && (n = e[x][1]);
|
|
855
|
+
for (let x = 1; x < i.length; x++)
|
|
856
|
+
i[x][1] > d && (d = i[x][1]);
|
|
857
|
+
let M = B(s, 0.25);
|
|
858
|
+
if (d > n + 0.5) {
|
|
859
|
+
const x = o.createLinearGradient(0, n, 0, d);
|
|
860
|
+
x.addColorStop(0, B(s, 0.25)), x.addColorStop(1, B(s, 0.05)), M = x;
|
|
861
|
+
}
|
|
862
|
+
if (o.beginPath(), o.moveTo(v[0].x, v[0].y), q(o, a), l)
|
|
863
|
+
for (let x = i.length - 1; x >= 0; x--)
|
|
864
|
+
o.lineTo(i[x][0], i[x][1]);
|
|
865
|
+
else {
|
|
866
|
+
const x = Q(i), w = j(x, u, r), R = x[x.length - 1];
|
|
867
|
+
o.lineTo(R.x, R.y), mt(o, x, w);
|
|
868
|
+
}
|
|
869
|
+
o.closePath(), o.fillStyle = M, o.fill();
|
|
870
|
+
}
|
|
871
|
+
const g = f && h < 1;
|
|
872
|
+
g && (o.save(), o.globalAlpha *= h), f && (o.beginPath(), o.moveTo(v[0].x, v[0].y), q(o, a), o.strokeStyle = s, o.lineWidth = c, o.lineJoin = "round", o.lineCap = "round", o.stroke()), g && o.restore();
|
|
873
|
+
}
|
|
874
|
+
/** A stroke-wide dot for a lone stacked column, faded with its layer like the stroke. */
|
|
875
|
+
drawStackDot(t) {
|
|
876
|
+
const { context: i, point: e, color: o, lineWidth: s, alpha: h } = t, l = Math.max(1, s / 2);
|
|
877
|
+
i.save(), i.globalAlpha *= h, i.beginPath(), i.moveTo(e.x + l, e.y), i.arc(e.x, e.y, l, 0, Math.PI * 2), i.fillStyle = o, i.fill(), i.restore();
|
|
808
878
|
}
|
|
809
879
|
/**
|
|
810
880
|
* Overlay hook: draws crosshair nearest-point dots and last-point pulse dots.
|
|
@@ -812,55 +882,60 @@ class Pt extends ut {
|
|
|
812
882
|
*/
|
|
813
883
|
drawOverlay(t) {
|
|
814
884
|
this.tickAnimations(performance.now());
|
|
815
|
-
const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval:
|
|
885
|
+
const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval: h } = t, l = i, u = this.options.pulseMs, r = u > 0 ? performance.now() / (u * 2 * Math.PI) % 1 : 0;
|
|
816
886
|
if (s) {
|
|
817
|
-
const
|
|
818
|
-
for (let
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
823
|
-
const
|
|
824
|
-
x: e.timeToBitmapXExact(
|
|
825
|
-
y: o.valueToBitmapYExact(this.effectiveValue(t,
|
|
826
|
-
} : this.stackedPositionAt(t,
|
|
827
|
-
|
|
887
|
+
const v = this.options.stacking, a = 4 * l.horizontalPixelRatio;
|
|
888
|
+
for (let g = 0; g < this.stores.length; g++) {
|
|
889
|
+
const n = this.getLayerAlpha(g);
|
|
890
|
+
if (n <= 0) continue;
|
|
891
|
+
const d = this.stores[g].findNearest(s.time, h);
|
|
892
|
+
if (!d || v === "off" && !o.isPlottable(d.value)) continue;
|
|
893
|
+
const M = this.resolveLayerColor(g, d.value), { x, y: w } = v === "off" ? {
|
|
894
|
+
x: e.timeToBitmapXExact(d.time),
|
|
895
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, g, d.time, d.value))
|
|
896
|
+
} : this.stackedPositionAt(t, g, d.time);
|
|
897
|
+
if (!Number.isFinite(w)) continue;
|
|
898
|
+
const R = n < 1;
|
|
899
|
+
R && (i.context.save(), i.context.globalAlpha *= n), i.context.save(), i.context.globalAlpha *= 0.25, i.context.beginPath(), i.context.arc(x, w, a + 3 * l.horizontalPixelRatio, 0, Math.PI * 2), i.context.fillStyle = M, i.context.fill(), i.context.restore(), i.context.beginPath(), i.context.arc(x, w, a, 0, Math.PI * 2), i.context.fillStyle = M, i.context.fill(), R && i.context.restore();
|
|
828
900
|
}
|
|
829
901
|
}
|
|
830
|
-
const
|
|
902
|
+
const f = this.introWave.active && this.introDirectives?.clip !== void 0;
|
|
831
903
|
let c = 1;
|
|
832
|
-
if (
|
|
833
|
-
const
|
|
834
|
-
for (let
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
837
|
-
const
|
|
838
|
-
if (
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (!
|
|
904
|
+
if (f && (c = Math.max(0, (this.introWave.linear() - (1 - K)) / K)), this.hasPulse && u > 0 && c > 0) {
|
|
905
|
+
const v = this.options.stacking;
|
|
906
|
+
for (let a = 0; a < this.stores.length; a++) {
|
|
907
|
+
const g = this.getLayerAlpha(a);
|
|
908
|
+
if (g <= 0) continue;
|
|
909
|
+
const n = this.lastFinitePoint(a);
|
|
910
|
+
if (!n) continue;
|
|
911
|
+
const d = this.resolveLayerColor(a, n.value);
|
|
912
|
+
if (v === "off") {
|
|
913
|
+
if (!o.isPlottable(n.value)) continue;
|
|
914
|
+
const w = n === this.stores[a].last() ? this.trailingEndpoint(t, a) : {
|
|
915
|
+
x: e.timeToBitmapXExact(n.time),
|
|
916
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, a, n.time, n.value))
|
|
917
|
+
};
|
|
918
|
+
if (!w) continue;
|
|
842
919
|
this.drawPulse({
|
|
843
920
|
ctx: i.context,
|
|
844
|
-
x:
|
|
845
|
-
y:
|
|
846
|
-
color:
|
|
847
|
-
pixelRatio:
|
|
848
|
-
phase:
|
|
849
|
-
alpha:
|
|
921
|
+
x: w.x,
|
|
922
|
+
y: w.y,
|
|
923
|
+
color: d,
|
|
924
|
+
pixelRatio: l.horizontalPixelRatio,
|
|
925
|
+
phase: r,
|
|
926
|
+
alpha: g * c
|
|
850
927
|
});
|
|
851
928
|
continue;
|
|
852
929
|
}
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
const { x: E, y: B } = this.stackedPositionAt(t, n, A.time);
|
|
856
|
-
this.drawPulse({
|
|
930
|
+
const { x: M, y: x } = this.stackedPositionAt(t, a, n.time);
|
|
931
|
+
Number.isFinite(x) && this.drawPulse({
|
|
857
932
|
ctx: i.context,
|
|
858
|
-
x:
|
|
859
|
-
y:
|
|
860
|
-
color:
|
|
861
|
-
pixelRatio:
|
|
862
|
-
phase:
|
|
863
|
-
alpha:
|
|
933
|
+
x: M,
|
|
934
|
+
y: x,
|
|
935
|
+
color: d,
|
|
936
|
+
pixelRatio: l.horizontalPixelRatio,
|
|
937
|
+
phase: r,
|
|
938
|
+
alpha: g * c
|
|
864
939
|
});
|
|
865
940
|
}
|
|
866
941
|
}
|
|
@@ -871,23 +946,38 @@ class Pt extends ut {
|
|
|
871
946
|
y: e,
|
|
872
947
|
color: o,
|
|
873
948
|
pixelRatio: s,
|
|
874
|
-
phase:
|
|
875
|
-
alpha:
|
|
949
|
+
phase: h,
|
|
950
|
+
alpha: l = 1
|
|
876
951
|
}) {
|
|
877
|
-
const
|
|
878
|
-
c && (t.save(), t.globalAlpha *=
|
|
952
|
+
const u = 3 * s, r = 0.4 + 0.6 * Math.abs(Math.sin(h * 2 * Math.PI)), f = u + 4 * s * r, c = l < 1;
|
|
953
|
+
c && (t.save(), t.globalAlpha *= l), t.beginPath(), t.arc(i, e, f, 0, Math.PI * 2), t.fillStyle = B(o, r * 0.3), t.fill(), t.beginPath(), t.arc(i, e, u, 0, Math.PI * 2), t.fillStyle = o, t.fill(), c && t.restore();
|
|
879
954
|
}
|
|
880
955
|
}
|
|
881
|
-
const
|
|
956
|
+
const It = {
|
|
882
957
|
type: "line",
|
|
883
958
|
xTypes: ["time", "numeric", "category"],
|
|
884
|
-
create: ({ theme:
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
959
|
+
create: ({ theme: S, layerCount: t, paletteIndex: i = 0 }, e) => new xt(
|
|
960
|
+
t,
|
|
961
|
+
{
|
|
962
|
+
colors: at({ theme: S, layerCount: t, paletteIndex: i }),
|
|
963
|
+
strokeWidth: S.line.width,
|
|
964
|
+
...e
|
|
965
|
+
},
|
|
966
|
+
i
|
|
967
|
+
)
|
|
889
968
|
};
|
|
969
|
+
function yt(S) {
|
|
970
|
+
const t = [];
|
|
971
|
+
let i = 0;
|
|
972
|
+
for (let e = 0; e <= S.length; e++)
|
|
973
|
+
(e === S.length || S[e]) && (e > i && t.push({ from: i, to: e }), i = e + 1);
|
|
974
|
+
return t;
|
|
975
|
+
}
|
|
976
|
+
function at(S) {
|
|
977
|
+
const { theme: t, layerCount: i, paletteIndex: e } = S, o = t.seriesColors;
|
|
978
|
+
return i === 1 && e === 0 || o.length === 0 ? [t.line.color] : Array.from({ length: i }, (s, h) => o[(e + h) % o.length]);
|
|
979
|
+
}
|
|
890
980
|
export {
|
|
891
|
-
|
|
892
|
-
|
|
981
|
+
xt as LineRenderer,
|
|
982
|
+
It as LineSeriesDef
|
|
893
983
|
};
|