@wick-charts/vue 0.8.0 → 0.8.1
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 +40 -30
- package/dist/BarSeries.vue.js +39 -29
- package/dist/CandlestickSeries.vue.js +2 -2
- package/dist/ChartContainer.vue.js +1 -1
- package/dist/LineSeries.vue.js +40 -30
- package/dist/core/dist/chart/badge-animator.js +38 -28
- package/dist/core/dist/chart.js +801 -694
- package/dist/core/dist/data/sync.js +77 -50
- package/dist/core/dist/navigator/controller.js +11 -11
- 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 +82 -82
- package/dist/core/dist/series/bar.js +1 -1
- package/dist/core/dist/series/base-multi-layer.js +182 -152
- package/dist/core/dist/series/candlestick.js +96 -96
- package/dist/core/dist/series/line.js +297 -292
- package/dist/core/dist/snapshots.js +39 -35
- package/dist/core/dist/utils/point.js +4 -0
- package/dist/core/dist/utils/time.js +42 -26
- package/dist/index.d.ts +45 -24
- package/dist/ui/InfoBar.vue.js +13 -13
- package/dist/ui/Tooltip.vue.js +11 -11
- package/dist/ui/YLabel.vue.js +47 -47
- package/package.json +2 -2
- package/src/BandSeries.vue +16 -3
- package/src/BarSeries.vue +16 -3
- package/src/ChartContainer.vue +14 -8
- package/src/LineSeries.vue +16 -3
- package/src/ui/YLabel.vue +28 -27
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DEFAULT_HISTORY_REVEAL as nt, DEFAULT_LINE_INTRO as lt, DEFAULT_LINE_PULSE as at, DEFAULT_LINE_SMOOTH as rt, DEFAULT_LINE_ENTRY as ht } from "../animation/config.js";
|
|
2
|
-
import { easeOutCubic as
|
|
2
|
+
import { easeOutCubic as U } from "../animation/easing.js";
|
|
3
3
|
import { decimateLineData as q } from "../data/decimation.js";
|
|
4
|
-
import { hexToRgba as
|
|
5
|
-
import { lerp as
|
|
4
|
+
import { hexToRgba as C } from "../utils/color.js";
|
|
5
|
+
import { lerp as z } from "../utils/math.js";
|
|
6
6
|
import { BaseMultiLayerSeries as ut } from "./base-multi-layer.js";
|
|
7
|
-
import { unfoldIntro as
|
|
7
|
+
import { unfoldIntro as mt, scaleMean as pt, backfillSweepIntro as ft } from "./line-intro.js";
|
|
8
8
|
import { buildCurveSegments as tt, replaySegmentsForward as et, replaySegmentsReversed as gt } from "./painters/canvas-path.js";
|
|
9
9
|
import { resolveLinePainter as dt } from "./painters/resolve.js";
|
|
10
10
|
import { ScaleStack as it } from "./scale-stack.js";
|
|
@@ -36,22 +36,24 @@ function ot(y) {
|
|
|
36
36
|
function st(y) {
|
|
37
37
|
return y.map(([t, i]) => ({ x: t, y: i }));
|
|
38
38
|
}
|
|
39
|
-
const J = 0.15, xt =
|
|
39
|
+
const J = 0.15, xt = ft();
|
|
40
40
|
function j(y, t, i) {
|
|
41
|
-
const { resolve: e, lerp: o =
|
|
41
|
+
const { resolve: e, lerp: o = z } = i;
|
|
42
42
|
if (y.length === 0) return null;
|
|
43
43
|
if (t <= y[0].time) return Number.isFinite(y[0].value) ? e(y[0]) : null;
|
|
44
44
|
const s = y[y.length - 1];
|
|
45
45
|
if (t >= s.time) return Number.isFinite(s.value) ? e(s) : null;
|
|
46
|
-
let
|
|
47
|
-
for (; r -
|
|
48
|
-
const c =
|
|
49
|
-
y[c].time <= t ?
|
|
50
|
-
}
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
|
|
46
|
+
let a = 0, r = y.length - 1;
|
|
47
|
+
for (; r - a > 1; ) {
|
|
48
|
+
const c = a + r >> 1;
|
|
49
|
+
y[c].time <= t ? a = c : r = c;
|
|
50
|
+
}
|
|
51
|
+
const m = y[a];
|
|
52
|
+
if (m.time === t) return Number.isFinite(m.value) ? e(m) : null;
|
|
53
|
+
const h = y[r];
|
|
54
|
+
if (!Number.isFinite(m.value) || !Number.isFinite(h.value)) return null;
|
|
55
|
+
const p = h.time - m.time;
|
|
56
|
+
return p <= 0 ? e(m) : o(e(m), e(h), (t - m.time) / p);
|
|
55
57
|
}
|
|
56
58
|
function yt(y, t) {
|
|
57
59
|
let i = 0, e = y.length - 1;
|
|
@@ -106,8 +108,8 @@ class Pt extends ut {
|
|
|
106
108
|
}
|
|
107
109
|
const o = this.historyDirectives, s = o?.ghostAlpha ?? 0;
|
|
108
110
|
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)),
|
|
111
|
+
const a = this.applyHistoryClip(t, o, e);
|
|
112
|
+
this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)), a && i.restore(), o?.heads !== void 0 && o.heads.length > 0 && this.drawIntroHeads(t, o.heads, this.historyWave.linear());
|
|
111
113
|
}
|
|
112
114
|
/**
|
|
113
115
|
* Initial-load intro pass: the resolved LineIntroFn describes this frame
|
|
@@ -117,14 +119,14 @@ class Pt extends ut {
|
|
|
117
119
|
renderWithIntro(t) {
|
|
118
120
|
const i = this.resolveIntro()(this.buildIntroFrame(t));
|
|
119
121
|
this.introDirectives = i;
|
|
120
|
-
const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize,
|
|
121
|
-
|
|
122
|
-
const r = i.clip,
|
|
123
|
-
if (
|
|
124
|
-
const h = r.fromX ?? 0,
|
|
125
|
-
e.save(), e.beginPath(), e.rect(h, 0, Math.max(0,
|
|
122
|
+
const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize, a = i.ghostAlpha ?? 0;
|
|
123
|
+
a > 0 && (e.save(), e.globalAlpha *= a, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, e.restore());
|
|
124
|
+
const r = i.clip, m = r !== void 0 && (r.fromX !== void 0 || r.toX !== void 0);
|
|
125
|
+
if (m) {
|
|
126
|
+
const h = r.fromX ?? 0, p = r.toX ?? o;
|
|
127
|
+
e.save(), e.beginPath(), e.rect(h, 0, Math.max(0, p - h), s), e.clip();
|
|
126
128
|
}
|
|
127
|
-
this.renderBody(t),
|
|
129
|
+
this.renderBody(t), m && e.restore(), i.heads !== void 0 && i.heads.length > 0 && this.drawIntroHeads(t, i.heads, this.introWave.linear());
|
|
128
130
|
}
|
|
129
131
|
/**
|
|
130
132
|
* Apply the history reveal's clip directive, mapped from reveal space
|
|
@@ -135,8 +137,8 @@ class Pt extends ut {
|
|
|
135
137
|
applyHistoryClip(t, i, e) {
|
|
136
138
|
const o = i?.clip;
|
|
137
139
|
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(
|
|
140
|
+
const { context: s } = t.scope, { width: a, height: r } = t.scope.bitmapSize, m = t.timeScale.timeToBitmapXExact(e.to), h = Math.abs(m - t.timeScale.timeToBitmapXExact(e.from)), p = Math.max(2, (this.options.strokeWidth ?? 1) * t.scope.horizontalPixelRatio), c = o.fromX ?? 0, x = o.toX ?? h;
|
|
141
|
+
return s.save(), s.beginPath(), s.rect(m - x - p, 0, Math.max(0, x - c + p), r), s.rect(m, 0, Math.max(0, a - m), r), s.clip(), !0;
|
|
140
142
|
}
|
|
141
143
|
renderBody(t) {
|
|
142
144
|
this.options.stacking === "off" ? (this.stackedEdges = null, this.renderOff(t)) : this.renderStacked(t, this.options.stacking === "percent");
|
|
@@ -166,7 +168,7 @@ class Pt extends ut {
|
|
|
166
168
|
defaultIntro = null;
|
|
167
169
|
resolveIntro() {
|
|
168
170
|
const t = this.options.introAnimation;
|
|
169
|
-
return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro =
|
|
171
|
+
return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro = mt()), this.defaultIntro);
|
|
170
172
|
}
|
|
171
173
|
/**
|
|
172
174
|
* Frame context handed to the intro fn — progress plus memoized data
|
|
@@ -198,39 +200,39 @@ class Pt extends ut {
|
|
|
198
200
|
});
|
|
199
201
|
}
|
|
200
202
|
buildFrame(t, i) {
|
|
201
|
-
const { timeScale: e, yScale: o, scope: s } = t, { progress:
|
|
203
|
+
const { timeScale: e, yScale: o, scope: s } = t, { progress: a, range: r, width: m } = i, h = this.options.stacking === "percent", p = new Array(this.stores.length), c = new Array(this.stores.length);
|
|
202
204
|
let x, n;
|
|
203
|
-
const
|
|
204
|
-
let g =
|
|
205
|
-
return g === void 0 && (g = this.stores[
|
|
205
|
+
const f = (l) => {
|
|
206
|
+
let g = p[l];
|
|
207
|
+
return g === void 0 && (g = this.stores[l]?.getVisibleData(r.from, r.to) ?? [], p[l] = g), g;
|
|
206
208
|
};
|
|
207
209
|
return {
|
|
208
|
-
progress:
|
|
210
|
+
progress: a,
|
|
209
211
|
range: r,
|
|
210
|
-
width:
|
|
212
|
+
width: m,
|
|
211
213
|
height: o.getMediaHeight() * s.verticalPixelRatio,
|
|
212
214
|
stacking: this.options.stacking,
|
|
213
|
-
timeToX: (
|
|
214
|
-
xToTime: (
|
|
215
|
-
valueToY: (
|
|
216
|
-
lerpValue: (
|
|
215
|
+
timeToX: (l) => e.timeToBitmapXExact(l),
|
|
216
|
+
xToTime: (l) => e.xToTime(l / s.horizontalPixelRatio),
|
|
217
|
+
valueToY: (l) => o.valueToBitmapYExact(l),
|
|
218
|
+
lerpValue: (l, g, b) => o.lerpValue(l, g, b),
|
|
217
219
|
layerCount: this.stores.length,
|
|
218
|
-
layerData:
|
|
219
|
-
layerMean: (
|
|
220
|
-
let g = c[
|
|
221
|
-
return g === void 0 && (h ? (x ??= this.meanShares(
|
|
220
|
+
layerData: f,
|
|
221
|
+
layerMean: (l) => {
|
|
222
|
+
let g = c[l];
|
|
223
|
+
return g === void 0 && (h ? (x ??= this.meanShares(f, o), g = x[l]) : g = pt(f(l), o), c[l] = g), g;
|
|
222
224
|
},
|
|
223
225
|
primaryPath: () => {
|
|
224
226
|
if (n === void 0) {
|
|
225
227
|
n = null;
|
|
226
|
-
for (let
|
|
227
|
-
if (this.getLayerAlpha(
|
|
228
|
-
const g =
|
|
228
|
+
for (let l = 0; l < this.stores.length; l++) {
|
|
229
|
+
if (this.getLayerAlpha(l) <= 0 || !this.stores[l].isVisible()) continue;
|
|
230
|
+
const g = f(l).filter((b) => o.isPlottable(b.value));
|
|
229
231
|
if (!(g.length < 2)) {
|
|
230
|
-
n = g.map((
|
|
231
|
-
x: e.timeToBitmapXExact(
|
|
232
|
-
y: o.valueToBitmapYExact(
|
|
233
|
-
time:
|
|
232
|
+
n = g.map((b) => ({
|
|
233
|
+
x: e.timeToBitmapXExact(b.time),
|
|
234
|
+
y: o.valueToBitmapYExact(b.value),
|
|
235
|
+
time: b.time
|
|
234
236
|
}));
|
|
235
237
|
break;
|
|
236
238
|
}
|
|
@@ -252,9 +254,9 @@ class Pt extends ut {
|
|
|
252
254
|
}
|
|
253
255
|
/** Layer's share of its column in percent, passed through the intro value transform. */
|
|
254
256
|
introShare(t, i) {
|
|
255
|
-
const { layerIndex: e, time: o, value: s, total:
|
|
256
|
-
if (
|
|
257
|
-
const r = s /
|
|
257
|
+
const { layerIndex: e, time: o, value: s, total: a } = i;
|
|
258
|
+
if (a <= 0) return s;
|
|
259
|
+
const r = s / a * 100;
|
|
258
260
|
return Math.max(0, this.introValue(t, { layerIndex: e, time: o, value: r }));
|
|
259
261
|
}
|
|
260
262
|
/**
|
|
@@ -265,40 +267,40 @@ class Pt extends ut {
|
|
|
265
267
|
meanShares(t, i) {
|
|
266
268
|
const e = this.stores.length, o = /* @__PURE__ */ new Set();
|
|
267
269
|
for (let h = 0; h < e; h++)
|
|
268
|
-
for (const
|
|
269
|
-
o.add(
|
|
270
|
-
const s = new Array(e).fill(0),
|
|
271
|
-
let
|
|
270
|
+
for (const p of t(h))
|
|
271
|
+
o.add(p.time);
|
|
272
|
+
const s = new Array(e).fill(0), a = new Array(e).fill(!1), r = new Array(e);
|
|
273
|
+
let m = 0;
|
|
272
274
|
for (const h of o) {
|
|
273
|
-
let
|
|
275
|
+
let p = 0;
|
|
274
276
|
for (let c = 0; c < e; c++) {
|
|
275
277
|
r[c] = null;
|
|
276
278
|
const x = this.getLayerAlpha(c), n = t(c);
|
|
277
279
|
if (x <= 0 || n.length === 0 || h < n[0].time) continue;
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
+
const f = j(n, h, { resolve: (l) => l.value });
|
|
281
|
+
f === null || !i.isPlottable(f) || (r[c] = f * x, p += f * x);
|
|
280
282
|
}
|
|
281
|
-
if (!(
|
|
282
|
-
|
|
283
|
+
if (!(p <= 0)) {
|
|
284
|
+
m++;
|
|
283
285
|
for (let c = 0; c < e; c++) {
|
|
284
286
|
const x = r[c];
|
|
285
|
-
x !== null && (s[c] += x /
|
|
287
|
+
x !== null && (s[c] += x / p * 100, a[c] = !0);
|
|
286
288
|
}
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
|
-
return s.map((h,
|
|
291
|
+
return s.map((h, p) => a[p] ? h / m : null);
|
|
290
292
|
}
|
|
291
293
|
/** The active history-reveal or intro value transform applied to one value. */
|
|
292
294
|
introValue(t, i) {
|
|
293
|
-
const { layerIndex: e, time: o, value: s } = i,
|
|
294
|
-
if (
|
|
295
|
+
const { layerIndex: e, time: o, value: s } = i, a = this.historyWave.active ? this.historyDirectives?.value : void 0, r = this.historyRange;
|
|
296
|
+
if (a !== void 0 && r !== null && o < r.to) {
|
|
295
297
|
const x = r.to - r.from, n = x > 0 ? Math.min(1, Math.max(0, (r.to - o) / x)) : 0;
|
|
296
|
-
return
|
|
298
|
+
return a({ layerIndex: e, time: o, value: s, position: n });
|
|
297
299
|
}
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
300
|
-
const h = t.timeScale.getRange(),
|
|
301
|
-
return
|
|
300
|
+
const m = this.introWave.active ? this.introDirectives?.value : void 0;
|
|
301
|
+
if (m === void 0) return s;
|
|
302
|
+
const h = t.timeScale.getRange(), p = h.to - h.from, c = p > 0 ? Math.min(1, Math.max(0, (o - h.from) / p)) : 0;
|
|
303
|
+
return m({ layerIndex: e, time: o, value: s, position: c });
|
|
302
304
|
}
|
|
303
305
|
/**
|
|
304
306
|
* Extends the base last-value query with the 'grow' entrance's value-space
|
|
@@ -322,22 +324,22 @@ class Pt extends ut {
|
|
|
322
324
|
if (e.length === 0) return null;
|
|
323
325
|
const o = this.stores[t].getAll(), s = o.length - 1 - e.length;
|
|
324
326
|
if (s < 0) return null;
|
|
325
|
-
const
|
|
326
|
-
if (!Number.isFinite(
|
|
327
|
-
let r = i(
|
|
328
|
-
const
|
|
327
|
+
const a = o[s];
|
|
328
|
+
if (!Number.isFinite(a.value)) return null;
|
|
329
|
+
let r = i(a.time, a.value);
|
|
330
|
+
const m = /* @__PURE__ */ new Map();
|
|
329
331
|
for (let h = 0; h < e.length; h++) {
|
|
330
|
-
const
|
|
331
|
-
if (!Number.isFinite(
|
|
332
|
-
const c =
|
|
333
|
-
|
|
332
|
+
const p = o[s + 1 + h];
|
|
333
|
+
if (!Number.isFinite(p.value)) return null;
|
|
334
|
+
const c = U(e[h].progress), x = i(p.time, p.value), n = this.axisLerp(r, x, c);
|
|
335
|
+
m.set(p.time, n), r = n;
|
|
334
336
|
}
|
|
335
|
-
return
|
|
337
|
+
return m;
|
|
336
338
|
}
|
|
337
339
|
/** `lerp` along the last rendered Y axis — plain before the first render. */
|
|
338
340
|
axisLerp(t, i, e) {
|
|
339
341
|
const o = this.lastYScale;
|
|
340
|
-
return o === null ?
|
|
342
|
+
return o === null ? z(t, i, e) : o.lerpValue(t, i, e);
|
|
341
343
|
}
|
|
342
344
|
/**
|
|
343
345
|
* Glowing pulse dots riding the intro's head anchors — the line reads as
|
|
@@ -347,14 +349,14 @@ class Pt extends ut {
|
|
|
347
349
|
*/
|
|
348
350
|
drawIntroHeads(t, i, e) {
|
|
349
351
|
if (this.options.stacking !== "off") return;
|
|
350
|
-
const o = Math.min(1, e / J), s = Math.min(1, (1 - e) / J),
|
|
351
|
-
if (
|
|
352
|
+
const o = Math.min(1, e / J), s = Math.min(1, (1 - e) / J), a = Math.max(0, Math.min(o, s));
|
|
353
|
+
if (a <= 0) return;
|
|
352
354
|
const { scope: r } = t;
|
|
353
|
-
for (const
|
|
355
|
+
for (const m of i)
|
|
354
356
|
for (let h = 0; h < this.stores.length; h++) {
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
const c = this.introHeadAnchor(t, h,
|
|
357
|
+
const p = this.getLayerAlpha(h);
|
|
358
|
+
if (p <= 0 || !this.stores[h].isVisible()) continue;
|
|
359
|
+
const c = this.introHeadAnchor(t, h, m);
|
|
358
360
|
c !== null && this.drawPulse({
|
|
359
361
|
ctx: r.context,
|
|
360
362
|
x: c.x,
|
|
@@ -362,7 +364,7 @@ class Pt extends ut {
|
|
|
362
364
|
color: this.resolveLayerColor(h, c.value),
|
|
363
365
|
pixelRatio: r.horizontalPixelRatio,
|
|
364
366
|
phase: e * 2,
|
|
365
|
-
alpha:
|
|
367
|
+
alpha: a * p
|
|
366
368
|
});
|
|
367
369
|
}
|
|
368
370
|
}
|
|
@@ -378,13 +380,13 @@ class Pt extends ut {
|
|
|
378
380
|
* visible range, not the data span) and jumps back on settle.
|
|
379
381
|
*/
|
|
380
382
|
introHeadAnchor(t, i, e) {
|
|
381
|
-
const { timeScale: o, yScale: s } = t,
|
|
383
|
+
const { timeScale: o, yScale: s } = t, a = o.getRange(), r = this.stores[i].getVisibleData(a.from, a.to);
|
|
382
384
|
if (r.length === 0) return null;
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (!s.isPlottable(
|
|
385
|
+
const m = this.stores[i].last();
|
|
386
|
+
if (m !== void 0 && e.time >= m.time) {
|
|
387
|
+
if (!s.isPlottable(m.value)) return null;
|
|
386
388
|
const c = this.trailingEndpoint(t, i);
|
|
387
|
-
return c === null ? null : { x: c.x, y: c.y, value:
|
|
389
|
+
return c === null ? null : { x: c.x, y: c.y, value: m.value };
|
|
388
390
|
}
|
|
389
391
|
const h = r[0];
|
|
390
392
|
if (e.time <= h.time) {
|
|
@@ -396,12 +398,12 @@ class Pt extends ut {
|
|
|
396
398
|
value: h.value
|
|
397
399
|
};
|
|
398
400
|
}
|
|
399
|
-
const
|
|
401
|
+
const p = j(r, e.time, {
|
|
400
402
|
resolve: (c) => this.effectiveValue(t, i, c.time, c.value),
|
|
401
403
|
// Along the axis, so the dot stays on the straight segment the stroke draws.
|
|
402
404
|
lerp: (c, x, n) => !s.isPlottable(c) || !s.isPlottable(x) ? Number.NaN : s.lerpValue(c, x, n)
|
|
403
405
|
});
|
|
404
|
-
return
|
|
406
|
+
return p === null || !s.isPlottable(p) ? null : { x: e.x, y: s.valueToBitmapYExact(p), value: p };
|
|
405
407
|
}
|
|
406
408
|
/**
|
|
407
409
|
* Rendered positions of the layer's still-unsettled trailing points, keyed
|
|
@@ -426,49 +428,49 @@ class Pt extends ut {
|
|
|
426
428
|
* it (see `renderStacked`'s `valueMaps` comment for the full rationale).
|
|
427
429
|
*/
|
|
428
430
|
stackedValueAt(t, i, e) {
|
|
429
|
-
const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow",
|
|
431
|
+
const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow", a = new Array(this.stores.length), r = (n) => {
|
|
430
432
|
if (!s) return null;
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
return
|
|
435
|
-
},
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
return j(
|
|
440
|
-
resolve: (g) =>
|
|
433
|
+
const f = a[n];
|
|
434
|
+
if (f !== void 0) return f;
|
|
435
|
+
const l = this.chainedTailValues(n, (g, b) => this.effectiveValue(t, n, g, b));
|
|
436
|
+
return a[n] = l, l;
|
|
437
|
+
}, m = (n) => {
|
|
438
|
+
const f = this.stores[n].getAll();
|
|
439
|
+
if (f.length === 0 || e < f[0].time) return null;
|
|
440
|
+
const l = r(n);
|
|
441
|
+
return j(f, e, {
|
|
442
|
+
resolve: (g) => l?.get(g.time) ?? this.effectiveValue(t, n, g.time, g.value)
|
|
441
443
|
});
|
|
442
444
|
}, { yScale: h } = t;
|
|
443
445
|
if (h.getTransform() !== null && !o) {
|
|
444
446
|
const n = new it(h);
|
|
445
|
-
for (let
|
|
446
|
-
const
|
|
447
|
-
g !== null && h.isPlottable(g) && n.push(g,
|
|
447
|
+
for (let f = 0; f <= i; f++) {
|
|
448
|
+
const l = this.getLayerAlpha(f), g = l > 0 ? m(f) : null;
|
|
449
|
+
g !== null && h.isPlottable(g) && n.push(g, l);
|
|
448
450
|
}
|
|
449
451
|
return n.edge;
|
|
450
452
|
}
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
const
|
|
455
|
-
if (o &&
|
|
456
|
-
const g =
|
|
457
|
-
return g === null ? null : g *
|
|
453
|
+
const p = (n) => {
|
|
454
|
+
const f = this.getLayerAlpha(n);
|
|
455
|
+
if (f <= 0) return null;
|
|
456
|
+
const l = this.stores[n].getAll();
|
|
457
|
+
if (o && l.length > 0 && e < l[0].time) return 0;
|
|
458
|
+
const g = m(n);
|
|
459
|
+
return g === null ? null : g * f;
|
|
458
460
|
};
|
|
459
461
|
let c = 0;
|
|
460
462
|
if (o)
|
|
461
463
|
for (let n = 0; n < this.stores.length; n++)
|
|
462
|
-
c +=
|
|
464
|
+
c += p(n) ?? 0;
|
|
463
465
|
let x = 0;
|
|
464
466
|
for (let n = 0; n <= i; n++) {
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
+
const f = p(n);
|
|
468
|
+
if (f !== null)
|
|
467
469
|
if (o) {
|
|
468
|
-
const
|
|
469
|
-
x = Math.min(100, x +
|
|
470
|
+
const l = this.introShare(t, { layerIndex: n, time: e, value: f, total: c });
|
|
471
|
+
x = Math.min(100, x + l);
|
|
470
472
|
} else
|
|
471
|
-
x +=
|
|
473
|
+
x += f;
|
|
472
474
|
}
|
|
473
475
|
return x;
|
|
474
476
|
}
|
|
@@ -486,11 +488,11 @@ class Pt extends ut {
|
|
|
486
488
|
stackedPositionAt(t, i, e) {
|
|
487
489
|
const o = this.paintedStackVertex(t, i, e);
|
|
488
490
|
if (o !== null) return o;
|
|
489
|
-
const { timeScale: s, yScale:
|
|
490
|
-
if ((this.options.entryAnimation ?? "grow") !== "grow" || e !==
|
|
491
|
-
let x = s.timeToBitmapXExact(
|
|
491
|
+
const { timeScale: s, yScale: a } = t, r = a.valueToBitmapYExact(this.stackedValueAt(t, i, e)), m = s.timeToBitmapXExact(e), h = this.unsettledTail(i), p = this.stores[i].getAll(), c = p.length - 1 - h.length;
|
|
492
|
+
if ((this.options.entryAnimation ?? "grow") !== "grow" || e !== p[p.length - 1]?.time || h.length === 0 || c < 0) return { x: m, y: r };
|
|
493
|
+
let x = s.timeToBitmapXExact(p[c].time);
|
|
492
494
|
for (let n = 0; n < h.length; n++)
|
|
493
|
-
x =
|
|
495
|
+
x = z(x, s.timeToBitmapXExact(p[c + 1 + n].time), U(h[n].progress));
|
|
494
496
|
return { x, y: r };
|
|
495
497
|
}
|
|
496
498
|
/** Upper-edge vertex of layer `li` at column `t`, replayed from the last
|
|
@@ -498,29 +500,29 @@ class Pt extends ut {
|
|
|
498
500
|
paintedStackVertex(t, i, e) {
|
|
499
501
|
const o = this.stackedEdges, s = o?.cumulative[i];
|
|
500
502
|
if (o === null || s === void 0) return null;
|
|
501
|
-
const { times:
|
|
503
|
+
const { times: a, growChain: r, collapse: m } = o, h = yt(a, e);
|
|
502
504
|
if (h < 0) return null;
|
|
503
|
-
const { timeScale:
|
|
504
|
-
if (h < g) return { x:
|
|
505
|
-
let
|
|
505
|
+
const { timeScale: p, yScale: c } = t, x = t.scope.bitmapSize.height, n = m[i] ?? 1, f = c.valueToBitmapYExact(s[h]), l = n >= 1 ? f : x + (f - x) * n, g = a.length - r.length;
|
|
506
|
+
if (h < g) return { x: p.timeToBitmapXExact(e), y: l };
|
|
507
|
+
let b = p.timeToBitmapXExact(a[g - 1]);
|
|
506
508
|
for (let E = 0; E <= h - g; E++)
|
|
507
|
-
|
|
508
|
-
return { x:
|
|
509
|
+
b = z(b, p.timeToBitmapXExact(a[g + E]), r[E]);
|
|
510
|
+
return { x: b, y: l };
|
|
509
511
|
}
|
|
510
512
|
chainedTailPositions(t, i) {
|
|
511
513
|
const e = this.unsettledTail(i);
|
|
512
514
|
if (e.length === 0) return null;
|
|
513
515
|
const o = this.stores[i].getAll(), s = o.length - 1 - e.length;
|
|
514
516
|
if (s < 0) return null;
|
|
515
|
-
const { timeScale:
|
|
516
|
-
if (!r.isPlottable(
|
|
517
|
-
let h =
|
|
517
|
+
const { timeScale: a, yScale: r } = t, m = o[s];
|
|
518
|
+
if (!r.isPlottable(m.value)) return null;
|
|
519
|
+
let h = a.timeToBitmapXExact(m.time), p = r.valueToBitmapYExact(this.effectiveValue(t, i, m.time, m.value));
|
|
518
520
|
const c = /* @__PURE__ */ new Map();
|
|
519
521
|
for (let x = 0; x < e.length; x++) {
|
|
520
522
|
const n = o[s + 1 + x];
|
|
521
523
|
if (!r.isPlottable(n.value)) return null;
|
|
522
|
-
const
|
|
523
|
-
c.set(n.time, { x:
|
|
524
|
+
const f = U(e[x].progress), l = a.timeToBitmapXExact(n.time), g = r.valueToBitmapYExact(this.effectiveValue(t, i, n.time, n.value)), b = z(h, l, f), E = z(p, g, f);
|
|
525
|
+
c.set(n.time, { x: b, y: E }), h = b, p = E;
|
|
524
526
|
}
|
|
525
527
|
return c;
|
|
526
528
|
}
|
|
@@ -537,8 +539,8 @@ class Pt extends ut {
|
|
|
537
539
|
trailingEndpoint(t, i) {
|
|
538
540
|
const e = this.stores[i].last();
|
|
539
541
|
if (!e) return null;
|
|
540
|
-
const { timeScale: o, yScale: s } = t,
|
|
541
|
-
return (this.options.entryAnimation ?? "grow") !== "grow" ? { x:
|
|
542
|
+
const { timeScale: o, yScale: s } = t, a = o.timeToBitmapXExact(e.time), r = s.valueToBitmapYExact(this.effectiveValue(t, i, e.time, e.value));
|
|
543
|
+
return (this.options.entryAnimation ?? "grow") !== "grow" ? { x: a, y: r } : this.chainedTailPositions(t, i)?.get(e.time) ?? { x: a, y: r };
|
|
542
544
|
}
|
|
543
545
|
/**
|
|
544
546
|
* Vertical stroke + area gradients for `options.threshold`, pinned to the
|
|
@@ -552,10 +554,10 @@ class Pt extends ut {
|
|
|
552
554
|
buildThresholdPaint(t, i) {
|
|
553
555
|
const e = this.options.threshold;
|
|
554
556
|
if (!e) return null;
|
|
555
|
-
const { scope: o, yScale: s } = t, { context:
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
return
|
|
557
|
+
const { scope: o, yScale: s } = t, { context: a } = o, r = o.bitmapSize.height, m = e.above, h = e.below ?? i, p = Math.min(1, Math.max(0, s.valueToBitmapYExact(e.value) / r)), c = Math.min(6 * o.verticalPixelRatio, r * 0.02) / r, x = Math.max(0, p - c), n = Math.min(1, p + c), f = a.createLinearGradient(0, 0, 0, r);
|
|
558
|
+
f.addColorStop(0, m), f.addColorStop(x, m), f.addColorStop(n, h), f.addColorStop(1, h);
|
|
559
|
+
const l = a.createLinearGradient(0, 0, 0, r);
|
|
560
|
+
return l.addColorStop(0, C(m, 0.26)), l.addColorStop(x, C(m, 0.14)), l.addColorStop(n, C(h, 0.1)), l.addColorStop(1, C(h, 0.01)), { stroke: f, area: l };
|
|
559
561
|
}
|
|
560
562
|
/**
|
|
561
563
|
* Dot markers at each data point (`options.points`). Callers pass the same
|
|
@@ -568,61 +570,61 @@ class Pt extends ut {
|
|
|
568
570
|
drawPointMarkers(t) {
|
|
569
571
|
const i = this.options.points;
|
|
570
572
|
if (!i?.visible) return;
|
|
571
|
-
const { context: e, points: o, pixelRatio: s, color:
|
|
573
|
+
const { context: e, points: o, pixelRatio: s, color: a } = t;
|
|
572
574
|
if (o.length === 0) return;
|
|
573
575
|
const r = Math.max(1, (i.radius ?? 3) * s);
|
|
574
576
|
if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) < r * 3)) {
|
|
575
577
|
e.beginPath();
|
|
576
|
-
for (const
|
|
577
|
-
e.moveTo(
|
|
578
|
-
e.fillStyle = i.color ??
|
|
578
|
+
for (const m of o)
|
|
579
|
+
e.moveTo(m.x + r, m.y), e.arc(m.x, m.y, r, 0, Math.PI * 2);
|
|
580
|
+
e.fillStyle = i.color ?? a, e.fill();
|
|
579
581
|
}
|
|
580
582
|
}
|
|
581
583
|
/** Each layer drawn independently */
|
|
582
584
|
renderOff(t) {
|
|
583
|
-
const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i,
|
|
585
|
+
const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i, a = e.getRange(), { verticalPixelRatio: r } = i, m = this.options.strokeWidth > 0, h = Math.max(1, Math.round(this.options.strokeWidth * r)), p = this.options.entryAnimation ?? "grow", c = dt(this.options.linePainter ?? this.options.curve ?? "straight"), x = {
|
|
584
586
|
ctx: s,
|
|
585
587
|
theme: t.theme,
|
|
586
588
|
horizontalPixelRatio: i.horizontalPixelRatio,
|
|
587
589
|
verticalPixelRatio: r
|
|
588
590
|
};
|
|
589
591
|
for (let n = 0; n < this.stores.length; n++) {
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
let
|
|
592
|
+
const f = this.getLayerAlpha(n);
|
|
593
|
+
if (f <= 0) continue;
|
|
594
|
+
let l = this.stores[n].getVisibleData(a.from, a.to);
|
|
593
595
|
const g = i.mediaSize.width;
|
|
594
|
-
if (
|
|
595
|
-
const
|
|
596
|
-
x: e.timeToBitmapXExact(
|
|
597
|
-
y: o.valueToBitmapYExact(this.effectiveValue(t, n,
|
|
598
|
-
},
|
|
599
|
-
(G || I) && (s.save(), G && (s.globalAlpha *=
|
|
600
|
-
const
|
|
596
|
+
if (l.length > g * 2 && (l = q(l, Math.round(g * 1.5))), l.length < 2) continue;
|
|
597
|
+
const b = this.lastFinitePoint(n)?.value ?? l[l.length - 1].value, E = this.resolveLayerColor(n, b), B = this.buildThresholdPaint(t, E), V = l[l.length - 1], Y = this.stores[n].last(), D = Y !== void 0 && V.time === Y.time, N = D ? this.entranceProgress(n, V.time) : 1, I = D && p === "fade" && N < 1, H = (D ? this.trailingEndpoint(t, n) : null) ?? {
|
|
598
|
+
x: e.timeToBitmapXExact(V.time),
|
|
599
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, n, V.time, V.value))
|
|
600
|
+
}, F = H.x, X = H.y, $ = D && p === "grow" ? this.chainedTailPositions(t, n) : null, G = f < 1;
|
|
601
|
+
(G || I) && (s.save(), G && (s.globalAlpha *= f), I && (s.globalAlpha *= N));
|
|
602
|
+
const _ = l.length - 1, u = [];
|
|
601
603
|
let v = null;
|
|
602
|
-
for (let d = 0; d <
|
|
603
|
-
const S =
|
|
604
|
+
for (let d = 0; d < _; d++) {
|
|
605
|
+
const S = l[d].value;
|
|
604
606
|
if (!o.isPlottable(S)) {
|
|
605
607
|
v = null;
|
|
606
608
|
continue;
|
|
607
609
|
}
|
|
608
610
|
v || (v = [], u.push(v));
|
|
609
|
-
const w =
|
|
611
|
+
const w = $?.get(l[d].time);
|
|
610
612
|
if (w)
|
|
611
613
|
v.push({ x: w.x, y: w.y });
|
|
612
614
|
else {
|
|
613
|
-
const
|
|
614
|
-
v.push({ x: e.timeToBitmapXExact(
|
|
615
|
+
const W = o.valueToBitmapYExact(this.effectiveValue(t, n, l[d].time, S));
|
|
616
|
+
v.push({ x: e.timeToBitmapXExact(l[d].time), y: W });
|
|
615
617
|
}
|
|
616
618
|
}
|
|
617
|
-
const
|
|
618
|
-
let
|
|
619
|
-
if (
|
|
619
|
+
const T = l[_]?.value, A = Number.isFinite(F) && Number.isFinite(X) && o.isPlottable(T), P = p === "grow" && N < 1;
|
|
620
|
+
let M = null;
|
|
621
|
+
if (A && (v ? (v.push({ x: F, y: X }), M = v) : u.push([{ x: F, y: X }])), m && u.some((d) => d.length >= 2)) {
|
|
620
622
|
s.beginPath();
|
|
621
623
|
for (const d of u)
|
|
622
|
-
d.length < 2 || c(x, { points: d, color: E, lineWidth: h, closing: !1, grew: P && d ===
|
|
624
|
+
d.length < 2 || c(x, { points: d, color: E, lineWidth: h, closing: !1, grew: P && d === M });
|
|
623
625
|
s.strokeStyle = B ? B.stroke : E, s.lineWidth = h, s.lineJoin = "round", s.lineCap = "round", s.stroke();
|
|
624
626
|
}
|
|
625
|
-
if (
|
|
627
|
+
if (m) {
|
|
626
628
|
const d = Math.max(1, h / 2);
|
|
627
629
|
let S = !1;
|
|
628
630
|
for (const w of u)
|
|
@@ -635,12 +637,12 @@ class Pt extends ut {
|
|
|
635
637
|
if (B)
|
|
636
638
|
S = B.area;
|
|
637
639
|
else {
|
|
638
|
-
const w = String(n),
|
|
639
|
-
|
|
640
|
+
const w = String(n), W = this.areaGradientCache.get(w);
|
|
641
|
+
W && W.bottomY === d && W.color === E ? S = W.gradient : (S = s.createLinearGradient(0, 0, 0, d), S.addColorStop(0, C(E, 0.12)), S.addColorStop(1, C(E, 0.01)), this.areaGradientCache.set(w, { gradient: S, bottomY: d, color: E }));
|
|
640
642
|
}
|
|
641
643
|
s.fillStyle = S;
|
|
642
644
|
for (const w of u)
|
|
643
|
-
w.length < 2 || (s.beginPath(), c(x, { points: w, color: E, lineWidth: h, closing: !0, grew: P && w ===
|
|
645
|
+
w.length < 2 || (s.beginPath(), c(x, { points: w, color: E, lineWidth: h, closing: !0, grew: P && w === M }), s.lineTo(w[w.length - 1].x, d), s.lineTo(w[0].x, d), s.closePath(), s.fill());
|
|
644
646
|
}
|
|
645
647
|
if (this.options.points?.visible) {
|
|
646
648
|
const d = [];
|
|
@@ -653,158 +655,158 @@ class Pt extends ut {
|
|
|
653
655
|
}
|
|
654
656
|
/** Stacked area rendering */
|
|
655
657
|
renderStacked(t, i) {
|
|
656
|
-
const { scope: e, timeScale: o, yScale: s } = t, { context:
|
|
658
|
+
const { scope: e, timeScale: o, yScale: s } = t, { context: a } = e, r = o.getRange(), { verticalPixelRatio: m } = e, h = this.options.strokeWidth > 0, p = Math.max(1, Math.round(this.options.strokeWidth * m)), c = this.options.curve ?? "straight", x = e.mediaSize.width, n = this.stores.map((u, v) => {
|
|
657
659
|
if (this.getLayerAlpha(v) <= 0) return [];
|
|
658
|
-
let
|
|
659
|
-
return
|
|
660
|
-
}),
|
|
660
|
+
let T = u.getVisibleData(r.from, r.to);
|
|
661
|
+
return T.length > x * 2 && (T = q(T, Math.round(x * 1.5))), T;
|
|
662
|
+
}), f = /* @__PURE__ */ new Set();
|
|
661
663
|
for (const u of n)
|
|
662
|
-
for (const v of u)
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
664
|
+
for (const v of u) f.add(v.time);
|
|
665
|
+
const l = Array.from(f).sort((u, v) => u - v);
|
|
666
|
+
if (l.length < 2) {
|
|
665
667
|
this.stackedEdges = null;
|
|
666
668
|
return;
|
|
667
669
|
}
|
|
668
|
-
const g = this.options.entryAnimation ?? "grow",
|
|
669
|
-
const
|
|
670
|
-
if (u.length === 0) return
|
|
671
|
-
const
|
|
672
|
-
for (const d of
|
|
673
|
-
if (d <
|
|
674
|
-
const S = j(u, d, { resolve:
|
|
675
|
-
S !== null &&
|
|
670
|
+
const g = this.options.entryAnimation ?? "grow", b = n.map((u, v) => {
|
|
671
|
+
const T = /* @__PURE__ */ new Map();
|
|
672
|
+
if (u.length === 0) return T;
|
|
673
|
+
const A = u[0].time, P = g === "grow" ? this.chainedTailValues(v, (d, S) => this.effectiveValue(t, v, d, S)) : null, M = (d) => P?.get(d.time) ?? this.effectiveValue(t, v, d.time, d.value);
|
|
674
|
+
for (const d of l) {
|
|
675
|
+
if (d < A) continue;
|
|
676
|
+
const S = j(u, d, { resolve: M });
|
|
677
|
+
S !== null && T.set(d, S);
|
|
676
678
|
}
|
|
677
|
-
return
|
|
679
|
+
return T;
|
|
678
680
|
}), E = this.stores.map((u, v) => this.getLayerAlpha(v)), B = (u, v) => {
|
|
679
|
-
const
|
|
680
|
-
return
|
|
681
|
-
},
|
|
682
|
-
for (let u = 0; u <
|
|
683
|
-
const v =
|
|
684
|
-
if (
|
|
681
|
+
const T = b[u].get(v);
|
|
682
|
+
return T === void 0 ? void 0 : T * E[u];
|
|
683
|
+
}, V = s.getTransform() !== null && !i, Y = Array.from({ length: this.stores.length }, () => new Array(l.length).fill(0));
|
|
684
|
+
for (let u = 0; u < l.length; u++) {
|
|
685
|
+
const v = l[u];
|
|
686
|
+
if (V) {
|
|
685
687
|
const P = new it(s);
|
|
686
|
-
for (let
|
|
687
|
-
const d =
|
|
688
|
-
d !== void 0 && s.isPlottable(d) && P.push(d, E[
|
|
688
|
+
for (let M = 0; M < this.stores.length; M++) {
|
|
689
|
+
const d = b[M].get(v);
|
|
690
|
+
d !== void 0 && s.isPlottable(d) && P.push(d, E[M]), Y[M][u] = P.edge;
|
|
689
691
|
}
|
|
690
692
|
continue;
|
|
691
693
|
}
|
|
692
|
-
let
|
|
694
|
+
let T = 0;
|
|
693
695
|
if (i)
|
|
694
696
|
for (let P = 0; P < this.stores.length; P++) {
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
+
const M = B(P, v);
|
|
698
|
+
M !== void 0 && s.isPlottable(M) && (T += M);
|
|
697
699
|
}
|
|
698
|
-
let
|
|
700
|
+
let A = 0;
|
|
699
701
|
for (let P = 0; P < this.stores.length; P++) {
|
|
700
|
-
const
|
|
701
|
-
let d =
|
|
702
|
+
const M = B(P, v);
|
|
703
|
+
let d = M !== void 0 && s.isPlottable(M) ? M : null;
|
|
702
704
|
const S = n[P];
|
|
703
705
|
if (i && S.length > 0 && v < S[0].time && (d = 0), d !== null)
|
|
704
706
|
if (i) {
|
|
705
|
-
const w = this.introShare(t, { layerIndex: P, time: v, value: d, total:
|
|
706
|
-
|
|
707
|
+
const w = this.introShare(t, { layerIndex: P, time: v, value: d, total: T });
|
|
708
|
+
A = Math.min(100, A + w);
|
|
707
709
|
} else
|
|
708
|
-
|
|
709
|
-
|
|
710
|
+
A += d;
|
|
711
|
+
Y[P][u] = A;
|
|
710
712
|
}
|
|
711
713
|
}
|
|
712
|
-
const
|
|
713
|
-
for (let u = 0; u <
|
|
714
|
-
const
|
|
714
|
+
const D = /* @__PURE__ */ new Map();
|
|
715
|
+
for (let u = 0; u < l.length; u++) D.set(l[u], u);
|
|
716
|
+
const N = new Array(this.stores.length).fill(1);
|
|
715
717
|
for (let u = 0; u < this.stores.length; u++) {
|
|
716
718
|
if (this.getLayerAlpha(u) <= 0) continue;
|
|
717
|
-
const v = this.unsettledTail(u),
|
|
718
|
-
if (
|
|
719
|
-
let
|
|
720
|
-
for (let P = 0; P <
|
|
721
|
-
if (
|
|
722
|
-
|
|
719
|
+
const v = this.unsettledTail(u), T = v.length;
|
|
720
|
+
if (T === 0) continue;
|
|
721
|
+
let A = !0;
|
|
722
|
+
for (let P = 0; P < T; P++)
|
|
723
|
+
if (D.get(v[P].time) !== l.length - T + P) {
|
|
724
|
+
A = !1;
|
|
723
725
|
break;
|
|
724
726
|
}
|
|
725
|
-
|
|
727
|
+
A && (N[u] = v[T - 1].progress);
|
|
726
728
|
}
|
|
727
729
|
const I = [];
|
|
728
730
|
if (g === "grow") {
|
|
729
731
|
const u = n.map((v) => v.length - 1);
|
|
730
|
-
for (let v =
|
|
731
|
-
const
|
|
732
|
-
let
|
|
733
|
-
for (let
|
|
734
|
-
if (this.getLayerAlpha(
|
|
735
|
-
const d = n[
|
|
736
|
-
for (; u[
|
|
737
|
-
if (u[
|
|
738
|
-
const S = this.entranceProgress(
|
|
739
|
-
(!P || S >
|
|
732
|
+
for (let v = l.length - 1; v >= 1; v--) {
|
|
733
|
+
const T = l[v];
|
|
734
|
+
let A = 1, P = !1;
|
|
735
|
+
for (let M = 0; M < n.length; M++) {
|
|
736
|
+
if (this.getLayerAlpha(M) <= 0) continue;
|
|
737
|
+
const d = n[M];
|
|
738
|
+
for (; u[M] >= 0 && d[u[M]].time > T; ) u[M]--;
|
|
739
|
+
if (u[M] < 0 || d[u[M]].time !== T) continue;
|
|
740
|
+
const S = this.entranceProgress(M, T);
|
|
741
|
+
(!P || S > A) && (A = S), P = !0;
|
|
740
742
|
}
|
|
741
|
-
if (!P ||
|
|
742
|
-
I.unshift(
|
|
743
|
+
if (!P || A >= 1) break;
|
|
744
|
+
I.unshift(U(A));
|
|
743
745
|
}
|
|
744
746
|
}
|
|
745
747
|
const H = (u, v) => {
|
|
746
|
-
const
|
|
747
|
-
if (!(
|
|
748
|
-
for (let
|
|
749
|
-
const P = u.length -
|
|
750
|
-
u[P][0] =
|
|
748
|
+
const T = v.length;
|
|
749
|
+
if (!(T === 0 || u.length < T + 1))
|
|
750
|
+
for (let A = 0; A < T; A++) {
|
|
751
|
+
const P = u.length - T + A;
|
|
752
|
+
u[P][0] = z(u[P - 1][0], u[P][0], v[A]);
|
|
751
753
|
}
|
|
752
|
-
},
|
|
753
|
-
let
|
|
754
|
+
}, F = e.bitmapSize.height;
|
|
755
|
+
let X = -1, $ = -1;
|
|
754
756
|
for (let u = 0; u < this.stores.length; u++)
|
|
755
757
|
if (!(this.getLayerAlpha(u) <= 0))
|
|
756
|
-
if (
|
|
757
|
-
|
|
758
|
+
if (X < 0)
|
|
759
|
+
X = u;
|
|
758
760
|
else {
|
|
759
|
-
|
|
761
|
+
$ = u;
|
|
760
762
|
break;
|
|
761
763
|
}
|
|
762
|
-
const G =
|
|
764
|
+
const G = X >= 0 ? this.getLayerAlpha(X) : 1, _ = n.map((u, v) => v === X ? Math.min(1, this.getLayerAlpha(v)) : 1);
|
|
763
765
|
for (let u = this.stores.length - 1; u >= 0; u--) {
|
|
764
766
|
const v = this.getLayerAlpha(u);
|
|
765
767
|
if (v <= 0) continue;
|
|
766
|
-
const
|
|
767
|
-
for (let R = 0; R <
|
|
768
|
-
const
|
|
769
|
-
let O =
|
|
770
|
-
P ? O =
|
|
768
|
+
const T = this.lastFinitePoint(u)?.value ?? 0, A = this.resolveLayerColor(u, T), P = u === X, M = $ >= 0 && u === $ && G < 1, d = [];
|
|
769
|
+
for (let R = 0; R < l.length; R++) {
|
|
770
|
+
const L = u > 0 ? s.valueToBitmapYExact(Y[u - 1][R]) : F;
|
|
771
|
+
let O = L;
|
|
772
|
+
P ? O = F : M && (O = L + (F - L) * (1 - G)), d.push([o.timeToBitmapXExact(l[R]), O]);
|
|
771
773
|
}
|
|
772
774
|
g === "grow" && H(d, I);
|
|
773
775
|
const S = [];
|
|
774
|
-
for (let R = 0; R <
|
|
775
|
-
let
|
|
776
|
-
P && v < 1 && (
|
|
776
|
+
for (let R = 0; R < l.length; R++) {
|
|
777
|
+
let L = s.valueToBitmapYExact(Y[u][R]);
|
|
778
|
+
P && v < 1 && (L = F + (L - F) * v), S.push([o.timeToBitmapXExact(l[R]), L]);
|
|
777
779
|
}
|
|
778
780
|
g === "grow" && H(S, I);
|
|
779
|
-
const w = st(S),
|
|
780
|
-
if (K && (
|
|
781
|
-
let R = S[0][1],
|
|
781
|
+
const w = st(S), W = tt(w, c, g === "grow" && I.length > 0), K = g === "fade" && N[u] < 1;
|
|
782
|
+
if (K && (a.save(), a.globalAlpha *= N[u]), this.options.area.visible && !this.introGhostPass) {
|
|
783
|
+
let R = S[0][1], L = d[0][1];
|
|
782
784
|
for (let k = 1; k < S.length; k++)
|
|
783
785
|
S[k][1] < R && (R = S[k][1]);
|
|
784
786
|
for (let k = 1; k < d.length; k++)
|
|
785
|
-
d[k][1] >
|
|
786
|
-
let O =
|
|
787
|
-
if (
|
|
788
|
-
const k =
|
|
789
|
-
k.addColorStop(0,
|
|
787
|
+
d[k][1] > L && (L = d[k][1]);
|
|
788
|
+
let O = C(A, 0.25);
|
|
789
|
+
if (L > R + 0.5) {
|
|
790
|
+
const k = a.createLinearGradient(0, R, 0, L);
|
|
791
|
+
k.addColorStop(0, C(A, 0.25)), k.addColorStop(1, C(A, 0.05)), O = k;
|
|
790
792
|
}
|
|
791
|
-
if (
|
|
793
|
+
if (a.beginPath(), a.moveTo(w[0].x, w[0].y), et(a, W), P)
|
|
792
794
|
for (let k = d.length - 1; k >= 0; k--)
|
|
793
|
-
|
|
795
|
+
a.lineTo(d[k][0], d[k][1]);
|
|
794
796
|
else {
|
|
795
797
|
const k = st(d), ct = tt(k, c, g === "grow" && I.length > 0), Z = k[k.length - 1];
|
|
796
|
-
|
|
798
|
+
a.lineTo(Z.x, Z.y), gt(a, k, ct);
|
|
797
799
|
}
|
|
798
|
-
|
|
800
|
+
a.closePath(), a.fillStyle = O, a.fill();
|
|
799
801
|
}
|
|
800
802
|
const Q = h && v < 1;
|
|
801
|
-
if (Q && (
|
|
803
|
+
if (Q && (a.save(), a.globalAlpha *= v), h && (a.beginPath(), a.moveTo(w[0].x, w[0].y), et(a, W), a.strokeStyle = A, a.lineWidth = p, a.lineJoin = "round", a.lineCap = "round", a.stroke()), Q && a.restore(), this.options.points?.visible) {
|
|
802
804
|
const R = v < 1;
|
|
803
|
-
R && (
|
|
805
|
+
R && (a.save(), a.globalAlpha *= v), this.drawPointMarkers({ context: a, points: w, pixelRatio: e.horizontalPixelRatio, color: A }), R && a.restore();
|
|
804
806
|
}
|
|
805
|
-
K &&
|
|
807
|
+
K && a.restore();
|
|
806
808
|
}
|
|
807
|
-
this.stackedEdges = { times:
|
|
809
|
+
this.stackedEdges = { times: l, cumulative: Y, growChain: I, collapse: _ };
|
|
808
810
|
}
|
|
809
811
|
/**
|
|
810
812
|
* Overlay hook: draws crosshair nearest-point dots and last-point pulse dots.
|
|
@@ -812,55 +814,58 @@ class Pt extends ut {
|
|
|
812
814
|
*/
|
|
813
815
|
drawOverlay(t) {
|
|
814
816
|
this.tickAnimations(performance.now());
|
|
815
|
-
const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval:
|
|
817
|
+
const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval: a } = t, r = i, m = this.options.pulseMs, h = m > 0 ? performance.now() / (m * 2 * Math.PI) % 1 : 0;
|
|
816
818
|
if (s) {
|
|
817
819
|
const x = this.options.stacking, n = 4 * r.horizontalPixelRatio;
|
|
818
|
-
for (let
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
821
|
-
const g = this.stores[
|
|
820
|
+
for (let f = 0; f < this.stores.length; f++) {
|
|
821
|
+
const l = this.getLayerAlpha(f);
|
|
822
|
+
if (l <= 0) continue;
|
|
823
|
+
const g = this.stores[f].findNearest(s.time, a);
|
|
822
824
|
if (!g || x === "off" && !o.isPlottable(g.value)) continue;
|
|
823
|
-
const
|
|
825
|
+
const b = this.resolveLayerColor(f, g.value), { x: E, y: B } = x === "off" ? {
|
|
824
826
|
x: e.timeToBitmapXExact(g.time),
|
|
825
|
-
y: o.valueToBitmapYExact(this.effectiveValue(t,
|
|
826
|
-
} : this.stackedPositionAt(t,
|
|
827
|
-
|
|
827
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, f, g.time, g.value))
|
|
828
|
+
} : this.stackedPositionAt(t, f, g.time), V = l < 1;
|
|
829
|
+
V && (i.context.save(), i.context.globalAlpha *= l), i.context.save(), i.context.globalAlpha *= 0.25, i.context.beginPath(), i.context.arc(E, B, n + 3 * r.horizontalPixelRatio, 0, Math.PI * 2), i.context.fillStyle = b, i.context.fill(), i.context.restore(), i.context.beginPath(), i.context.arc(E, B, n, 0, Math.PI * 2), i.context.fillStyle = b, i.context.fill(), V && i.context.restore();
|
|
828
830
|
}
|
|
829
831
|
}
|
|
830
|
-
const
|
|
832
|
+
const p = this.introWave.active && this.introDirectives?.clip !== void 0;
|
|
831
833
|
let c = 1;
|
|
832
|
-
if (
|
|
834
|
+
if (p && (c = Math.max(0, (this.introWave.linear() - (1 - J)) / J)), this.hasPulse && m > 0 && c > 0) {
|
|
833
835
|
const x = this.options.stacking;
|
|
834
836
|
for (let n = 0; n < this.stores.length; n++) {
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
837
|
-
const
|
|
837
|
+
const f = this.getLayerAlpha(n);
|
|
838
|
+
if (f <= 0) continue;
|
|
839
|
+
const l = this.lastFinitePoint(n);
|
|
840
|
+
if (!l) continue;
|
|
841
|
+
const g = this.resolveLayerColor(n, l.value);
|
|
838
842
|
if (x === "off") {
|
|
839
|
-
if (!o.isPlottable(
|
|
840
|
-
const
|
|
841
|
-
|
|
843
|
+
if (!o.isPlottable(l.value)) continue;
|
|
844
|
+
const B = l === this.stores[n].last() ? this.trailingEndpoint(t, n) : {
|
|
845
|
+
x: e.timeToBitmapXExact(l.time),
|
|
846
|
+
y: o.valueToBitmapYExact(this.effectiveValue(t, n, l.time, l.value))
|
|
847
|
+
};
|
|
848
|
+
if (!B) continue;
|
|
842
849
|
this.drawPulse({
|
|
843
850
|
ctx: i.context,
|
|
844
|
-
x:
|
|
845
|
-
y:
|
|
851
|
+
x: B.x,
|
|
852
|
+
y: B.y,
|
|
846
853
|
color: g,
|
|
847
854
|
pixelRatio: r.horizontalPixelRatio,
|
|
848
855
|
phase: h,
|
|
849
|
-
alpha:
|
|
856
|
+
alpha: f * c
|
|
850
857
|
});
|
|
851
858
|
continue;
|
|
852
859
|
}
|
|
853
|
-
const
|
|
854
|
-
if (!A) continue;
|
|
855
|
-
const { x: E, y: B } = this.stackedPositionAt(t, n, A.time);
|
|
860
|
+
const { x: b, y: E } = this.stackedPositionAt(t, n, l.time);
|
|
856
861
|
this.drawPulse({
|
|
857
862
|
ctx: i.context,
|
|
858
|
-
x:
|
|
859
|
-
y:
|
|
863
|
+
x: b,
|
|
864
|
+
y: E,
|
|
860
865
|
color: g,
|
|
861
866
|
pixelRatio: r.horizontalPixelRatio,
|
|
862
867
|
phase: h,
|
|
863
|
-
alpha:
|
|
868
|
+
alpha: f * c
|
|
864
869
|
});
|
|
865
870
|
}
|
|
866
871
|
}
|
|
@@ -871,14 +876,14 @@ class Pt extends ut {
|
|
|
871
876
|
y: e,
|
|
872
877
|
color: o,
|
|
873
878
|
pixelRatio: s,
|
|
874
|
-
phase:
|
|
879
|
+
phase: a,
|
|
875
880
|
alpha: r = 1
|
|
876
881
|
}) {
|
|
877
|
-
const
|
|
878
|
-
c && (t.save(), t.globalAlpha *= r), t.beginPath(), t.arc(i, e,
|
|
882
|
+
const m = 3 * s, h = 0.4 + 0.6 * Math.abs(Math.sin(a * 2 * Math.PI)), p = m + 4 * s * h, c = r < 1;
|
|
883
|
+
c && (t.save(), t.globalAlpha *= r), t.beginPath(), t.arc(i, e, p, 0, Math.PI * 2), t.fillStyle = C(o, h * 0.3), t.fill(), t.beginPath(), t.arc(i, e, m, 0, Math.PI * 2), t.fillStyle = o, t.fill(), c && t.restore();
|
|
879
884
|
}
|
|
880
885
|
}
|
|
881
|
-
const
|
|
886
|
+
const Lt = {
|
|
882
887
|
type: "line",
|
|
883
888
|
xTypes: ["time", "numeric", "category"],
|
|
884
889
|
create: ({ theme: y, layerCount: t }, i) => new Pt(t, {
|
|
@@ -889,5 +894,5 @@ const Bt = {
|
|
|
889
894
|
};
|
|
890
895
|
export {
|
|
891
896
|
Pt as LineRenderer,
|
|
892
|
-
|
|
897
|
+
Lt as LineSeriesDef
|
|
893
898
|
};
|