@wick-charts/vue 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/BandSeries.vue.js +50 -0
- package/dist/BandSeries.vue2.js +4 -0
- package/dist/ChartContainer.vue.js +16 -16
- package/dist/LineSeries.vue.js +2 -2
- package/dist/core/dist/animation/config.js +92 -75
- package/dist/core/dist/chart/badge-animator.js +30 -22
- package/dist/core/dist/chart/edge-indicators.js +22 -21
- package/dist/core/dist/chart/last-value.js +33 -26
- package/dist/core/dist/chart.js +168 -167
- package/dist/core/dist/data/decimation.js +58 -39
- package/dist/core/dist/navigator/controller.js +10 -10
- package/dist/core/dist/perf/perf-hud.js +6 -6
- package/dist/core/dist/series/band.js +670 -0
- package/dist/core/dist/series/bar.js +14 -14
- package/dist/core/dist/series/candlestick.js +31 -31
- package/dist/core/dist/series/heatmap.js +5 -5
- package/dist/core/dist/series/line-intro.js +47 -37
- package/dist/core/dist/series/line.js +485 -445
- package/dist/core/dist/series/painters/builtins.js +4 -4
- package/dist/core/dist/series/painters/canvas-path.js +64 -52
- package/dist/core/dist/series/register-builtins.js +9 -8
- package/dist/core/dist/snapshots.js +36 -35
- package/dist/core/dist/utils/point.js +10 -0
- package/dist/index.d.ts +255 -97
- package/dist/index.js +195 -191
- package/dist/ui/InfoBar.vue.js +100 -81
- package/dist/ui/Tooltip.vue.js +118 -91
- package/dist/ui/YLabel.vue.js +62 -69
- package/package.json +2 -2
- package/src/BandSeries.vue +87 -0
- package/src/index.ts +8 -0
- package/src/ui/InfoBar.vue +20 -1
- package/src/ui/Tooltip.vue +36 -2
- package/src/ui/YLabel.vue +2 -13
package/dist/core/dist/chart.js
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
import { Animator as K } from "./animation/animator.js";
|
|
2
|
-
import { AnimationConfig as j, DEFAULT_LINE_PULSE as
|
|
2
|
+
import { AnimationConfig as j, DEFAULT_LINE_PULSE as J } from "./animation/config.js";
|
|
3
3
|
import { easeOutCubic as W } from "./animation/easing.js";
|
|
4
|
-
import { prefersReducedMotion as
|
|
5
|
-
import { createViewportEngine as
|
|
6
|
-
import { CanvasManager as
|
|
7
|
-
import { resolveEdgeAnchorValue as
|
|
8
|
-
import { computeFitToData as
|
|
9
|
-
import { getLastValue as
|
|
10
|
-
import { resolveFade as O, resolveMaxVisibleBars as
|
|
11
|
-
import { computePan as
|
|
12
|
-
import { warnUnplottableBounds as
|
|
13
|
-
import { StreamingCadence as
|
|
14
|
-
import { computeStreamingTarget as
|
|
4
|
+
import { prefersReducedMotion as Q } from "./animation/reduced-motion.js";
|
|
5
|
+
import { createViewportEngine as tt } from "./animation/viewport-engine.js";
|
|
6
|
+
import { CanvasManager as it } from "./canvas-manager.js";
|
|
7
|
+
import { resolveEdgeAnchorValue as et, drawEdgeIndicators as st, resolveEdgeBoundary as rt } from "./chart/edge-indicators.js";
|
|
8
|
+
import { computeFitToData as nt } from "./chart/fit-to-data.js";
|
|
9
|
+
import { getLastValue as at, getPreviousClose as ot, getStackedLastValue as ht } from "./chart/last-value.js";
|
|
10
|
+
import { resolveFade as O, resolveMaxVisibleBars as lt, resolvePadding as F, resolvePerfOptions as ct, isSameHorizontalPadding as $ } from "./chart/options.js";
|
|
11
|
+
import { computePan as dt, computeZoom as ut } from "./chart/pan-zoom-math.js";
|
|
12
|
+
import { warnUnplottableBounds as N, assertStackingFitsScale as M, warnUnplottableValues as mt } from "./chart/scale-guards.js";
|
|
13
|
+
import { StreamingCadence as ft } from "./chart/streaming-cadence.js";
|
|
14
|
+
import { computeStreamingTarget as gt } from "./chart/streaming-target.js";
|
|
15
15
|
import { resolvePaddingTime as B } from "./chart/viewport-padding.js";
|
|
16
|
-
import { fromScaleSpace as
|
|
17
|
-
import { renderCrosshair as
|
|
18
|
-
import { renderGrid as
|
|
19
|
-
import { renderMarker as
|
|
20
|
-
import { renderReferenceLine as
|
|
21
|
-
import { resolveTimeRegionColors as
|
|
22
|
-
import { EventEmitter as
|
|
16
|
+
import { fromScaleSpace as pt, computeTargetYRange as yt, resolveYTarget as vt } from "./chart/y-target.js";
|
|
17
|
+
import { renderCrosshair as bt } from "./components/crosshair.js";
|
|
18
|
+
import { renderGrid as E } from "./components/grid.js";
|
|
19
|
+
import { renderMarker as xt } from "./components/marker.js";
|
|
20
|
+
import { renderReferenceLine as St } from "./components/reference-line.js";
|
|
21
|
+
import { resolveTimeRegionColors as kt, renderTimeRegion as At } from "./components/time-region.js";
|
|
22
|
+
import { EventEmitter as wt } from "./events.js";
|
|
23
23
|
import { InteractionHandler as Tt } from "./interactions/handler.js";
|
|
24
24
|
import { RenderScheduler as Y } from "./render-scheduler.js";
|
|
25
|
-
import { XScale as
|
|
26
|
-
import { YScale as
|
|
25
|
+
import { XScale as Lt } from "./scales/x-scale.js";
|
|
26
|
+
import { YScale as Mt, isPlottableOn as Pt } from "./scales/y-scale.js";
|
|
27
27
|
import { resolveSeriesDefinition as Dt } from "./series/definition.js";
|
|
28
28
|
import { isTimeSeriesRenderer as b } from "./series/types.js";
|
|
29
|
-
import { catppuccin as
|
|
30
|
-
import { clamp as
|
|
31
|
-
import { crispLineWidth as
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
import { catppuccin as Rt } from "./theme/themes/catppuccin.js";
|
|
30
|
+
import { clamp as Ct } from "./utils/math.js";
|
|
31
|
+
import { crispLineWidth as It, crispCenterOffset as Ht } from "./utils/pixel-grid.js";
|
|
32
|
+
import { pointValue as X, isBandPoint as zt } from "./utils/point.js";
|
|
33
|
+
import { normalizeTime as x, detectInterval as Vt } from "./utils/time.js";
|
|
34
|
+
const Wt = 200, Ot = 1500, Ft = 48, Z = 12, P = 9, $t = ["left", "right"], Nt = ["left"], Bt = ["right"];
|
|
35
|
+
let Et = 0, Yt = 0, Xt = 0, Zt = 0;
|
|
36
|
+
function _(y, t) {
|
|
36
37
|
return y === t ? !0 : !y || !t || y.length !== t.length ? !1 : y.every((i, e) => i === t[e]);
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function _t(y, t) {
|
|
39
40
|
return y === t ? !0 : !y || !t || y.length !== t.length ? !1 : y.every((i, e) => i === t[e]);
|
|
40
41
|
}
|
|
41
|
-
class
|
|
42
|
+
class Li extends wt {
|
|
42
43
|
/** Canvas lifecycle and DPR-aware sizing. */
|
|
43
44
|
#a;
|
|
44
45
|
/** Schedules main-layer redraws (background, grid, series). */
|
|
@@ -50,7 +51,7 @@ class Ai extends At {
|
|
|
50
51
|
/** Maps price/value to vertical pixel coordinates. */
|
|
51
52
|
yScale;
|
|
52
53
|
/** Zoom, pan, crosshair — null when interactive=false. */
|
|
53
|
-
#
|
|
54
|
+
#P;
|
|
54
55
|
/** All registered series (candlestick, line, bar, pie). */
|
|
55
56
|
#t = [];
|
|
56
57
|
/** Point annotations (event markers) drawn on the overlay layer, kept out of the series model. */
|
|
@@ -99,28 +100,28 @@ class Ai extends At {
|
|
|
99
100
|
* `time`/`y`; `'time'` (programmatic {@link setCrosshair}) keeps
|
|
100
101
|
* `time`/`y` and re-projects the pixel position.
|
|
101
102
|
*/
|
|
102
|
-
#
|
|
103
|
+
#q = "pointer";
|
|
103
104
|
/** Whether the last overlay pass painted anything — gates the full-bitmap
|
|
104
105
|
* clear so an empty overlay isn't cleared again every main frame. */
|
|
105
106
|
#gt = !1;
|
|
106
107
|
/** User-specified Y-axis bounds (auto, fixed, percentage). */
|
|
107
108
|
#p = {};
|
|
108
109
|
/** Cached series ID list — invalidated on add/remove. */
|
|
109
|
-
#
|
|
110
|
+
#D = null;
|
|
110
111
|
/** Axis visibility and sizing configuration. */
|
|
111
|
-
#
|
|
112
|
+
#T = {};
|
|
112
113
|
/** Host-declared state per edge — drives the edge-indicator overlay. */
|
|
113
114
|
#S = { left: "idle", right: "idle" };
|
|
114
115
|
/** Wall-clock start of a `loading` exit fade per side — set when the host
|
|
115
116
|
* drops `loading` back to `idle`/`has-more`, so the indicator fades out
|
|
116
117
|
* over {@link EDGE_EXIT_FADE_MS} instead of vanishing the same frame the
|
|
117
118
|
* fetched data lands. `null` = no fade in flight. */
|
|
118
|
-
|
|
119
|
+
#$ = { left: null, right: null };
|
|
119
120
|
/** Cached boundary timestamps from the last `edgeReached` emission, by side. */
|
|
120
121
|
#pt = { left: null, right: null };
|
|
121
122
|
/** Latest placeholder shapes a `loading` indicator reported per side —
|
|
122
123
|
* the morph hand-off candidate consumed by {@link prependData}. */
|
|
123
|
-
#
|
|
124
|
+
#K = { left: null, right: null };
|
|
124
125
|
/** True after a prepend consumed a side's placeholder snapshot: the series'
|
|
125
126
|
* reveal owns those pixels now, so the still-`loading` indicator is hidden
|
|
126
127
|
* and the upcoming `loading → idle` transition skips its exit fade. Reset
|
|
@@ -133,7 +134,7 @@ class Ai extends At {
|
|
|
133
134
|
/** Nesting depth for batch updates. Suppresses recomputes while > 0. */
|
|
134
135
|
#L = 0;
|
|
135
136
|
/** True when batched operations include data changes (triggers full onDataChanged on end). */
|
|
136
|
-
#
|
|
137
|
+
#j = !1;
|
|
137
138
|
/** True when batched operations include visibility changes (triggers Y-range + redraw on end). */
|
|
138
139
|
#V = !1;
|
|
139
140
|
/** True when batched operations bumped overlay version (emits a single overlayChange on flush). */
|
|
@@ -150,12 +151,12 @@ class Ai extends At {
|
|
|
150
151
|
#bt = 0;
|
|
151
152
|
/** CSS px of the Y-axis column. The default collapses to `0` on a spatial-only chart. */
|
|
152
153
|
get yAxisWidth() {
|
|
153
|
-
const t = this.#
|
|
154
|
+
const t = this.#T.y;
|
|
154
155
|
return t?.visible === !1 ? 0 : t?.width !== void 0 ? t.width : this.#X() ? 0 : 55;
|
|
155
156
|
}
|
|
156
157
|
/** Side of the plot area the Y-axis column sits on. */
|
|
157
158
|
get yAxisPosition() {
|
|
158
|
-
return this.#
|
|
159
|
+
return this.#T.y?.position ?? "right";
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
161
162
|
* Left edge of the plot area in container CSS px — the Y-axis width when
|
|
@@ -172,7 +173,7 @@ class Ai extends At {
|
|
|
172
173
|
}
|
|
173
174
|
/** CSS px of the time-axis row. The default collapses to `0` on a spatial-only chart. */
|
|
174
175
|
get xAxisHeight() {
|
|
175
|
-
const t = this.#
|
|
176
|
+
const t = this.#T.x;
|
|
176
177
|
return t?.visible === !1 ? 0 : t?.height !== void 0 ? t.height : this.#X() ? 0 : 30;
|
|
177
178
|
}
|
|
178
179
|
/** Resolved animation config derived from `options.animations` at construction. */
|
|
@@ -203,7 +204,7 @@ class Ai extends At {
|
|
|
203
204
|
*/
|
|
204
205
|
#xt = !1;
|
|
205
206
|
/** Earliest data timestamp registered across all series, `null` before any data has arrived. */
|
|
206
|
-
#
|
|
207
|
+
#w = null;
|
|
207
208
|
/** Latest data timestamp registered across all series, `null` before any data has arrived. */
|
|
208
209
|
#e = null;
|
|
209
210
|
/**
|
|
@@ -212,7 +213,7 @@ class Ai extends At {
|
|
|
212
213
|
* left of the tail keeps that offset as new bars arrive, instead of
|
|
213
214
|
* snapping back to the natural-pin position every frame.
|
|
214
215
|
*/
|
|
215
|
-
#
|
|
216
|
+
#N = null;
|
|
216
217
|
/**
|
|
217
218
|
* Warm-up window flag — `setVisibleRange({ from, bars })` arms it and
|
|
218
219
|
* the streaming-target math suppresses pan ticks while the data hasn't
|
|
@@ -246,7 +247,7 @@ class Ai extends At {
|
|
|
246
247
|
#l;
|
|
247
248
|
/** Cached chart width — passed by interactions on every call; kept for the rare
|
|
248
249
|
* call that omits it (e.g. programmatic `chart.pan(...)` without explicit width). */
|
|
249
|
-
|
|
250
|
+
#E = 0;
|
|
250
251
|
/** Active performance monitor, or `null` when instrumentation is disabled (the default). */
|
|
251
252
|
#k;
|
|
252
253
|
/** When true, `destroy()` tears down the monitor; false for caller-supplied monitors we must not destroy. */
|
|
@@ -254,9 +255,9 @@ class Ai extends At {
|
|
|
254
255
|
/** Visible HUD overlay (mounted by the perf config); non-null only when the caller requested one. */
|
|
255
256
|
#tt = null;
|
|
256
257
|
constructor(t, i) {
|
|
257
|
-
super(), i?.axis && (this.#
|
|
258
|
+
super(), i?.axis && (this.#T = i.axis, this.#p = { min: i.axis.y?.min, max: i.axis.y?.max }), this.#n = i?.theme ?? Rt.theme, this.#F = i?.grid?.visible !== !1, this.#A = O(i?.fade), this.#d = j.resolve(i?.animations), this.#St = lt(i?.viewport?.maxVisibleBars), this.#l = F(i?.padding), this.#R = new ft();
|
|
258
259
|
const e = this.#d.axis.y, s = this.#d.axis.x;
|
|
259
|
-
this.#s =
|
|
260
|
+
this.#s = tt({
|
|
260
261
|
initial: { yRange: { min: 0, max: 0 }, xRange: { from: 0, to: 0 } },
|
|
261
262
|
y: {
|
|
262
263
|
curve: e.curve,
|
|
@@ -275,8 +276,8 @@ class Ai extends At {
|
|
|
275
276
|
computeYTarget: ({ xTarget: o }) => this.#ht(o),
|
|
276
277
|
onWake: () => this.#i?.markDirty()
|
|
277
278
|
}), this.#yt = i?.onEdgeReached, this.#_ = i?.viewport?.initialRange;
|
|
278
|
-
const r =
|
|
279
|
-
this.#k = r.monitor, this.#Q = r.ownsMonitor, this.#a = new
|
|
279
|
+
const r = ct(i?.perf);
|
|
280
|
+
this.#k = r.monitor, this.#Q = r.ownsMonitor, this.#a = new it(t, this.#k ?? void 0), this.timeScale = new Lt(), this.yScale = new Mt(), this.yScale.setTransform(this.#T.y?.scale ?? null), N({ y: this.#T.y, isPlottable: this.#Y }), this.timeScale.setLocale(i?.locale), this.timeScale.setTimeZone(i?.timeZone);
|
|
280
281
|
const n = this.#d.axis.ticksMs;
|
|
281
282
|
this.timeScale.tickTracker.setFadeMs(n), this.yScale.tickTracker.setFadeMs(n), this.#H = new K({
|
|
282
283
|
initial: 0,
|
|
@@ -286,14 +287,14 @@ class Ai extends At {
|
|
|
286
287
|
(o) => this.#ut("overlay", o, () => this.renderOverlay(o))
|
|
287
288
|
), this.#k && r.hud && (this.#tt = r.hud(t, this.#k));
|
|
288
289
|
const a = i?.interactive !== !1;
|
|
289
|
-
this.#
|
|
290
|
+
this.#P = a ? new Tt(this.#a.canvas, this, this.timeScale, this.yScale) : null, this.#a.on("resize", () => {
|
|
290
291
|
this.syncScales(), this.#dt(), this.emit("viewportChange");
|
|
291
|
-
}), this.syncScales(), this.#
|
|
292
|
-
this.#
|
|
293
|
-
}), this.#
|
|
294
|
-
this.emit("pointClick", { ...o, spatialHit: this.#
|
|
295
|
-
}), this.#
|
|
296
|
-
this.fitContent(), this.emit("pointDoubleClick", { ...o, spatialHit: this.#
|
|
292
|
+
}), this.syncScales(), this.#P?.on("crosshairMove", (o) => {
|
|
293
|
+
this.#q = "pointer", this.#c = o, this.#o.markDirty(), this.emit("crosshairMove", o), this.#rt(o);
|
|
294
|
+
}), this.#P?.on("click", (o) => {
|
|
295
|
+
this.emit("pointClick", { ...o, spatialHit: this.#Dt(o) });
|
|
296
|
+
}), this.#P?.on("dblclick", (o) => {
|
|
297
|
+
this.fitContent(), this.emit("pointDoubleClick", { ...o, spatialHit: this.#Dt(o) });
|
|
297
298
|
});
|
|
298
299
|
}
|
|
299
300
|
/**
|
|
@@ -331,7 +332,7 @@ class Ai extends At {
|
|
|
331
332
|
* otherwise generate a new auto ID. Auto-generated IDs never collide with each other
|
|
332
333
|
* or with user-provided IDs because they use a monotonically increasing counter.
|
|
333
334
|
*/
|
|
334
|
-
|
|
335
|
+
#Et(t) {
|
|
335
336
|
if (t && !this.#t.some((e) => e.id === t))
|
|
336
337
|
return t;
|
|
337
338
|
let i;
|
|
@@ -352,17 +353,17 @@ class Ai extends At {
|
|
|
352
353
|
...this.#d.defaults(e.type),
|
|
353
354
|
...o,
|
|
354
355
|
...this.#d.overrides(e.type)
|
|
355
|
-
}, d = e.create({ theme: this.#n, layerCount: l }, h), m = a ?? (typeof n == "string" ? [n] : void 0), c = this
|
|
356
|
+
}, d = e.create({ theme: this.#n, layerCount: l }, h), m = a ?? (typeof n == "string" ? [n] : void 0), c = this.#Et(r);
|
|
356
357
|
d.onDataChanged?.(() => this.onDataChanged());
|
|
357
358
|
const f = this.#Z();
|
|
358
|
-
return this.#t.push({ id: c, labels: m, renderer: d, visible: !0 }), this.#
|
|
359
|
+
return this.#t.push({ id: c, labels: m, renderer: d, visible: !0 }), this.#D = null, this.#st(), this.#et(f), this.emit("seriesChange"), this.#f(), c;
|
|
359
360
|
}
|
|
360
361
|
/** Remove a series by ID and clean up its resources. */
|
|
361
362
|
removeSeries(t) {
|
|
362
363
|
const i = this.#t.findIndex((e) => e.id === t);
|
|
363
364
|
if (i >= 0) {
|
|
364
365
|
const e = this.#Z();
|
|
365
|
-
this.#t[i].renderer.dispose(), this.#t.splice(i, 1), this.#
|
|
366
|
+
this.#t[i].renderer.dispose(), this.#t.splice(i, 1), this.#D = null, this.#st(), this.#et(e), this.#i.markDirty(), this.emit("seriesChange"), this.#f();
|
|
366
367
|
}
|
|
367
368
|
}
|
|
368
369
|
// --- Markers (point annotations) -----------------------------------------
|
|
@@ -376,7 +377,7 @@ class Ai extends At {
|
|
|
376
377
|
* appear in series queries.
|
|
377
378
|
*/
|
|
378
379
|
addMarker(t) {
|
|
379
|
-
const i = `marker_${++
|
|
380
|
+
const i = `marker_${++Yt}`;
|
|
380
381
|
return this.#u.push(this.#kt(i, t)), this.#o.markDirty(), i;
|
|
381
382
|
}
|
|
382
383
|
/** Replace a marker's config in place. No-op when the id is unknown. */
|
|
@@ -410,7 +411,7 @@ class Ai extends At {
|
|
|
410
411
|
if (t.value !== void 0 && Number.isFinite(t.value)) return t.value;
|
|
411
412
|
if (t.seriesId === void 0) return null;
|
|
412
413
|
const i = this.getDataAtTime(t.seriesId, t.time);
|
|
413
|
-
return i ?
|
|
414
|
+
return i ? X(i) : null;
|
|
414
415
|
}
|
|
415
416
|
/** Resolve a marker's color: explicit `color`, else the series color, else the theme line color. */
|
|
416
417
|
#Xt(t) {
|
|
@@ -423,14 +424,14 @@ class Ai extends At {
|
|
|
423
424
|
}
|
|
424
425
|
#Zt(t, i, e) {
|
|
425
426
|
if (this.#u.length === 0) return;
|
|
426
|
-
const s = performance.now() / (
|
|
427
|
+
const s = performance.now() / (J * 2 * Math.PI) % 1, r = this.#it();
|
|
427
428
|
for (const n of this.#u) {
|
|
428
429
|
const a = this.#Yt(n);
|
|
429
430
|
if (a === null) continue;
|
|
430
431
|
const o = this.#Lt(r, n.time);
|
|
431
432
|
if (o <= 0) continue;
|
|
432
433
|
const l = t.context.globalAlpha;
|
|
433
|
-
o < 1 && (t.context.globalAlpha = l * o),
|
|
434
|
+
o < 1 && (t.context.globalAlpha = l * o), xt({
|
|
434
435
|
scope: t,
|
|
435
436
|
timeScale: this.timeScale,
|
|
436
437
|
yScale: this.yScale,
|
|
@@ -462,7 +463,7 @@ class Ai extends At {
|
|
|
462
463
|
* legend.
|
|
463
464
|
*/
|
|
464
465
|
addRegion(t) {
|
|
465
|
-
const i = `region_${
|
|
466
|
+
const i = `region_${++Xt}`;
|
|
466
467
|
return this.#x.push(this.#At(i, t)), this.#i.markDirty(), i;
|
|
467
468
|
}
|
|
468
469
|
/** Replace a region's config in place. No-op when the id is unknown. */
|
|
@@ -493,8 +494,8 @@ class Ai extends At {
|
|
|
493
494
|
#_t(t, i, e) {
|
|
494
495
|
if (this.#x.length !== 0)
|
|
495
496
|
for (const s of this.#x) {
|
|
496
|
-
const { color: r, fill: n } =
|
|
497
|
-
|
|
497
|
+
const { color: r, fill: n } = kt(s, this.#n);
|
|
498
|
+
At({
|
|
498
499
|
scope: t,
|
|
499
500
|
timeScale: this.timeScale,
|
|
500
501
|
theme: this.#n,
|
|
@@ -516,13 +517,13 @@ class Ai extends At {
|
|
|
516
517
|
* legend.
|
|
517
518
|
*/
|
|
518
519
|
addLine(t) {
|
|
519
|
-
const i = `line_${++
|
|
520
|
-
return this.#y.push(this.#
|
|
520
|
+
const i = `line_${++Zt}`;
|
|
521
|
+
return this.#y.push(this.#wt(i, t)), this.#o.markDirty(), i;
|
|
521
522
|
}
|
|
522
523
|
/** Replace a reference line's config in place. No-op when the id is unknown. */
|
|
523
524
|
updateLine(t, i) {
|
|
524
525
|
const e = this.#y.findIndex((s) => s.id === t);
|
|
525
|
-
e !== -1 && (this.#y[e] = this.#
|
|
526
|
+
e !== -1 && (this.#y[e] = this.#wt(t, i), this.#o.markDirty());
|
|
526
527
|
}
|
|
527
528
|
/** Remove a reference line by id. No-op when the id is unknown. */
|
|
528
529
|
removeLine(t) {
|
|
@@ -533,7 +534,7 @@ class Ai extends At {
|
|
|
533
534
|
getLines() {
|
|
534
535
|
return this.#y;
|
|
535
536
|
}
|
|
536
|
-
#
|
|
537
|
+
#wt(t, i) {
|
|
537
538
|
const { time: e, value: s } = i, r = {
|
|
538
539
|
id: t,
|
|
539
540
|
color: i.color,
|
|
@@ -550,7 +551,7 @@ class Ai extends At {
|
|
|
550
551
|
const n = s >= 1 ? 1 : r.orientation === "vertical" ? this.#Lt(s, r.coord) : W(s);
|
|
551
552
|
if (n <= 0) continue;
|
|
552
553
|
const a = t.context.globalAlpha;
|
|
553
|
-
n < 1 && (t.context.globalAlpha = a * n),
|
|
554
|
+
n < 1 && (t.context.globalAlpha = a * n), St({
|
|
554
555
|
scope: t,
|
|
555
556
|
timeScale: this.timeScale,
|
|
556
557
|
yScale: this.yScale,
|
|
@@ -575,12 +576,12 @@ class Ai extends At {
|
|
|
575
576
|
* underlying animator mutates between frames.
|
|
576
577
|
*/
|
|
577
578
|
getAnimationState() {
|
|
578
|
-
return this.#
|
|
579
|
+
return this.#Tt(this.#s.getAnimationState());
|
|
579
580
|
}
|
|
580
581
|
/** The engine animates Y in scale space (`axis.y.scale`'s forward); readers outside it get values. */
|
|
581
|
-
#
|
|
582
|
+
#Tt(t) {
|
|
582
583
|
const i = this.yScale.getTransform();
|
|
583
|
-
return i === null ? t : { ...t, yRange:
|
|
584
|
+
return i === null ? t : { ...t, yRange: pt(t.yRange, i) };
|
|
584
585
|
}
|
|
585
586
|
/** `yScale.isPlottable`, bound once for the helpers that take a predicate. */
|
|
586
587
|
#Y = (t) => this.yScale.isPlottable(t);
|
|
@@ -624,7 +625,7 @@ class Ai extends At {
|
|
|
624
625
|
#Lt(t, i) {
|
|
625
626
|
if (t >= 1) return 1;
|
|
626
627
|
const { from: e, to: s } = this.timeScale.getRange(), r = s - e, n = r > 0 ? (i - e) / r : 0;
|
|
627
|
-
return
|
|
628
|
+
return Ct((t - n) / 0.12, 0, 1);
|
|
628
629
|
}
|
|
629
630
|
/**
|
|
630
631
|
* Replace all data for a series.
|
|
@@ -660,8 +661,8 @@ class Ai extends At {
|
|
|
660
661
|
prependData(t, i, e) {
|
|
661
662
|
const s = this.#t.find((n) => n.id === t);
|
|
662
663
|
if (s === void 0 || s.renderer.prependPoints === void 0) return;
|
|
663
|
-
const r = this.#
|
|
664
|
-
r !== null && s.renderer.setHistoryHandoff !== void 0 && performance.now() - r.at <
|
|
664
|
+
const r = this.#K.left;
|
|
665
|
+
r !== null && s.renderer.setHistoryHandoff !== void 0 && performance.now() - r.at < Ot && (s.renderer.setHistoryHandoff(r.bars), this.#z.left = !0, this.#$.left = null, this.#K.left = null, this.#o.markDirty()), s.renderer.prependPoints(i, e);
|
|
665
666
|
}
|
|
666
667
|
/** Update the last data point of a series in place (e.g. live candle update). */
|
|
667
668
|
updateData(t, i, e) {
|
|
@@ -690,7 +691,7 @@ class Ai extends At {
|
|
|
690
691
|
"stacking" in i && M({ seriesId: t, stacking: i.stacking, isPlottable: this.#Y });
|
|
691
692
|
const s = e.labels, r = e.renderer.getLayerColors().slice(), n = this.#d.overrides(e.renderer.kind);
|
|
692
693
|
e.renderer.updateOptions({ ...i, ...n }), "label" in i && typeof i.label == "string" && (e.labels = [i.label]), this.#i.markDirty();
|
|
693
|
-
const a = e.renderer.getLayerColors(), o = r.length !== a.length || r.some((h, d) => h !== a[d]), l = !
|
|
694
|
+
const a = e.renderer.getLayerColors(), o = r.length !== a.length || r.some((h, d) => h !== a[d]), l = !_(s, e.labels);
|
|
694
695
|
(o || l) && this.#f();
|
|
695
696
|
}
|
|
696
697
|
/**
|
|
@@ -703,12 +704,12 @@ class Ai extends At {
|
|
|
703
704
|
t();
|
|
704
705
|
} finally {
|
|
705
706
|
if (--this.#L <= 0) {
|
|
706
|
-
if (this.#L = 0, this.#
|
|
707
|
-
this.#
|
|
707
|
+
if (this.#L = 0, this.#j)
|
|
708
|
+
this.#j = !1, this.#V = !1, this.onDataChanged();
|
|
708
709
|
else if (this.#V) {
|
|
709
710
|
this.#V = !1, this.#g = !0;
|
|
710
711
|
const i = performance.now();
|
|
711
|
-
this.#s.
|
|
712
|
+
this.#s.onSeriesVisibilityChanged(i), this.#b(i), this.#i.markDirty();
|
|
712
713
|
}
|
|
713
714
|
this.#J && (this.#J = !1, this.emit("overlayChange"));
|
|
714
715
|
}
|
|
@@ -789,7 +790,7 @@ class Ai extends At {
|
|
|
789
790
|
* tracking and is cheaper than recomputing from series stores.
|
|
790
791
|
*/
|
|
791
792
|
getDataRange() {
|
|
792
|
-
return this.#
|
|
793
|
+
return this.#w === null || this.#e === null ? null : { from: this.#w, to: this.#e };
|
|
793
794
|
}
|
|
794
795
|
/**
|
|
795
796
|
* Imperatively set the visible time range. Three forms:
|
|
@@ -890,15 +891,15 @@ class Ai extends At {
|
|
|
890
891
|
let s;
|
|
891
892
|
if (t.y !== void 0 ? s = t.y : e !== null ? s = e.y : s = this.yScale.yToValue(this.yScale.getMediaHeight() / 2), !Number.isFinite(s) || e !== null && e.time === i && e.y === s) return;
|
|
892
893
|
const r = this.plotLeft + this.timeScale.timeToX(i), n = this.yScale.valueToY(s);
|
|
893
|
-
this.#
|
|
894
|
+
this.#q = "time", this.#c = { mediaX: r, mediaY: n, time: i, y: s }, this.#o.markDirty(), this.emit("crosshairMove", this.#c);
|
|
894
895
|
}
|
|
895
896
|
/** Get the last visible value and whether the absolute last point is on screen. */
|
|
896
897
|
getLastValue(t) {
|
|
897
|
-
return
|
|
898
|
+
return at(t, this.#t, this.#s.getAnimationState().xRange);
|
|
898
899
|
}
|
|
899
900
|
/** Get the second-to-last value, useful for computing change. */
|
|
900
901
|
getPreviousClose(t) {
|
|
901
|
-
return
|
|
902
|
+
return ot(t, this.#t);
|
|
902
903
|
}
|
|
903
904
|
getLastData(t) {
|
|
904
905
|
const i = this.#t.find((e) => e.id === t);
|
|
@@ -920,7 +921,7 @@ class Ai extends At {
|
|
|
920
921
|
return e?.visible ? e.renderer.getLayerSnapshots?.(i, this.#r) ?? null : null;
|
|
921
922
|
}
|
|
922
923
|
getSeriesIds() {
|
|
923
|
-
return this.#
|
|
924
|
+
return this.#D || (this.#D = this.#t.map((t) => t.id)), this.#D.slice();
|
|
924
925
|
}
|
|
925
926
|
/**
|
|
926
927
|
* True if any visible series has a time axis (line / bar / candlestick).
|
|
@@ -969,7 +970,7 @@ class Ai extends At {
|
|
|
969
970
|
* series visibility.
|
|
970
971
|
*/
|
|
971
972
|
#st() {
|
|
972
|
-
this.#
|
|
973
|
+
this.#P?.syncPanZoomMode();
|
|
973
974
|
}
|
|
974
975
|
/**
|
|
975
976
|
* Filter `getSeriesIds()` by renderer type. A concrete kind (`'pie'`,
|
|
@@ -1012,7 +1013,7 @@ class Ai extends At {
|
|
|
1012
1013
|
* Returns `null` for unknown ids or empty series.
|
|
1013
1014
|
*/
|
|
1014
1015
|
getStackedLastValue(t) {
|
|
1015
|
-
return
|
|
1016
|
+
return ht(t, this.#t, this.#s.getAnimationState().xRange);
|
|
1016
1017
|
}
|
|
1017
1018
|
/**
|
|
1018
1019
|
* Stacked value at an arbitrary `time` — the cumulative stack top at that
|
|
@@ -1027,7 +1028,7 @@ class Ai extends At {
|
|
|
1027
1028
|
const s = e.renderer.getStackedValueAtTime?.(i, this.#r);
|
|
1028
1029
|
if (s != null) return s;
|
|
1029
1030
|
const r = e.renderer.getDataAtTime?.(i, this.#r);
|
|
1030
|
-
return r
|
|
1031
|
+
return !r || zt(r) ? null : X(r);
|
|
1031
1032
|
}
|
|
1032
1033
|
/**
|
|
1033
1034
|
* Per-layer last snapshots with each layer's own `time`. Returns `null`
|
|
@@ -1069,7 +1070,7 @@ class Ai extends At {
|
|
|
1069
1070
|
*/
|
|
1070
1071
|
setSeriesLabels(t, i) {
|
|
1071
1072
|
const e = this.#t.find((s) => s.id === t);
|
|
1072
|
-
!e ||
|
|
1073
|
+
!e || _(e.labels, i) || (e.labels = i, this.#f());
|
|
1073
1074
|
}
|
|
1074
1075
|
/**
|
|
1075
1076
|
* Set the per-layer color overrides carried in `data` (sparse — `undefined`
|
|
@@ -1080,7 +1081,7 @@ class Ai extends At {
|
|
|
1080
1081
|
*/
|
|
1081
1082
|
setLayerColors(t, i) {
|
|
1082
1083
|
const e = this.#t.find((s) => s.id === t);
|
|
1083
|
-
!e ||
|
|
1084
|
+
!e || _t(e.colorOverrides, i) || (e.colorOverrides = i, e.renderer.setColorOverrides?.(i), this.#i.markDirty(), this.#f());
|
|
1084
1085
|
}
|
|
1085
1086
|
/** Get per-layer colors for a series. Returns null for single-layer non-bar/line series. */
|
|
1086
1087
|
getSeriesLayers(t) {
|
|
@@ -1126,11 +1127,11 @@ class Ai extends At {
|
|
|
1126
1127
|
}
|
|
1127
1128
|
/** Update axis configuration and re-render. */
|
|
1128
1129
|
setAxis(t) {
|
|
1129
|
-
const i = t.y?.scale ?? null, e = (a) =>
|
|
1130
|
+
const i = t.y?.scale ?? null, e = (a) => Pt(i, a);
|
|
1130
1131
|
for (const a of this.#t)
|
|
1131
1132
|
b(a.renderer) && M({ seriesId: a.id, stacking: a.renderer.stacking, isPlottable: e });
|
|
1132
1133
|
const s = this.#Z(), r = i !== this.yScale.getTransform();
|
|
1133
|
-
this.#
|
|
1134
|
+
this.#T = t, this.#p = { min: t.y?.min, max: t.y?.max }, N({ y: t.y, isPlottable: e });
|
|
1134
1135
|
const n = performance.now();
|
|
1135
1136
|
r && (this.yScale.setTransform(i), this.yScale.tickTracker.reset(), this.#ht() === null && this.#s.snap({ y: { min: 0, max: 0 } }, n)), this.#g = !0, this.#s.onAxisReconfig(n), this.#b(n), this.#et(s), this.#i.markDirty();
|
|
1136
1137
|
}
|
|
@@ -1176,7 +1177,7 @@ class Ai extends At {
|
|
|
1176
1177
|
setPadding(t) {
|
|
1177
1178
|
const i = this.#l;
|
|
1178
1179
|
this.#l = F(t);
|
|
1179
|
-
const e = this.#l, s =
|
|
1180
|
+
const e = this.#l, s = !$(i.left, e.left) || !$(i.right, e.right), r = i.top !== e.top || i.bottom !== e.bottom;
|
|
1180
1181
|
if (s) {
|
|
1181
1182
|
const { first: n, last: a } = this.getDataBounds();
|
|
1182
1183
|
if (n !== void 0 && a !== void 0) {
|
|
@@ -1224,7 +1225,7 @@ class Ai extends At {
|
|
|
1224
1225
|
setEdgeState(t, i) {
|
|
1225
1226
|
if (this.#S[t] === i) return;
|
|
1226
1227
|
const e = this.#S[t] === "loading", s = this.#z[t];
|
|
1227
|
-
this.#z[t] = !1, this
|
|
1228
|
+
this.#z[t] = !1, this.#$[t] = e && !s && (i === "idle" || i === "has-more") ? performance.now() : null, this.#S[t] = i, this.#o.markDirty();
|
|
1228
1229
|
}
|
|
1229
1230
|
/** Read the current host-declared state for a given edge. */
|
|
1230
1231
|
getEdgeState(t) {
|
|
@@ -1234,11 +1235,11 @@ class Ai extends At {
|
|
|
1234
1235
|
* Alpha for a side's `loading` exit fade, or `null` when none is in
|
|
1235
1236
|
* flight. Self-cleaning: an elapsed fade clears its start stamp.
|
|
1236
1237
|
*/
|
|
1237
|
-
#
|
|
1238
|
-
const i = this
|
|
1238
|
+
#Pt(t) {
|
|
1239
|
+
const i = this.#$[t];
|
|
1239
1240
|
if (i === null) return null;
|
|
1240
|
-
const e = (performance.now() - i) /
|
|
1241
|
-
return e >= 1 ? (this
|
|
1241
|
+
const e = (performance.now() - i) / Wt;
|
|
1242
|
+
return e >= 1 ? (this.#$[t] = null, null) : 1 - W(Math.max(0, e));
|
|
1242
1243
|
}
|
|
1243
1244
|
/**
|
|
1244
1245
|
* Swap the painter used for a side's `loading` spinner — the same
|
|
@@ -1264,7 +1265,7 @@ class Ai extends At {
|
|
|
1264
1265
|
if (!s) return null;
|
|
1265
1266
|
const r = this.#t.find((n) => n.id === e);
|
|
1266
1267
|
return r ? {
|
|
1267
|
-
valueY: this.yScale.valueToY(
|
|
1268
|
+
valueY: this.yScale.valueToY(et(t, s)),
|
|
1268
1269
|
seriesKind: r.renderer.kind
|
|
1269
1270
|
} : null;
|
|
1270
1271
|
}
|
|
@@ -1274,7 +1275,7 @@ class Ai extends At {
|
|
|
1274
1275
|
* placeholder shapes to match the real bars that will render once data
|
|
1275
1276
|
* lands. `null` when the viewport has no meaningful span yet.
|
|
1276
1277
|
*/
|
|
1277
|
-
#
|
|
1278
|
+
#qt() {
|
|
1278
1279
|
const t = this.timeScale.barWidthMedia(this.#r);
|
|
1279
1280
|
return Number.isFinite(t) && t > 0 ? t : null;
|
|
1280
1281
|
}
|
|
@@ -1317,7 +1318,7 @@ class Ai extends At {
|
|
|
1317
1318
|
* Returns the first spatial series (pie, heatmap, or a custom spatial kind)
|
|
1318
1319
|
* whose `hitTest` claims the position, or `null` if none does.
|
|
1319
1320
|
*/
|
|
1320
|
-
#
|
|
1321
|
+
#Dt(t) {
|
|
1321
1322
|
const i = this.#a.size, e = this.#l, s = {
|
|
1322
1323
|
top: e.top * i.verticalPixelRatio,
|
|
1323
1324
|
bottom: e.bottom * i.verticalPixelRatio
|
|
@@ -1349,12 +1350,12 @@ class Ai extends At {
|
|
|
1349
1350
|
* viewport didn't move, the re-derived values are bit-identical and the
|
|
1350
1351
|
* method exits without emitting.
|
|
1351
1352
|
*/
|
|
1352
|
-
#
|
|
1353
|
+
#Kt() {
|
|
1353
1354
|
const t = this.#c;
|
|
1354
1355
|
if (t === null) return;
|
|
1355
1356
|
const { from: i, to: e } = this.timeScale.getRange(), s = this.yScale.getRange(), r = Math.abs(e - i) * 1e-9, n = Math.abs(s.max - s.min) * 1e-9, a = 1e-6;
|
|
1356
1357
|
let o;
|
|
1357
|
-
if (this.#
|
|
1358
|
+
if (this.#q === "pointer") {
|
|
1358
1359
|
const l = this.timeScale.xToTime(t.mediaX - this.plotLeft), h = this.yScale.yToValue(t.mediaY);
|
|
1359
1360
|
if (!Number.isFinite(l) || !Number.isFinite(h) || Math.abs(l - t.time) <= r && Math.abs(h - t.y) <= n) return;
|
|
1360
1361
|
o = { mediaX: t.mediaX, mediaY: t.mediaY, time: l, y: h };
|
|
@@ -1372,7 +1373,7 @@ class Ai extends At {
|
|
|
1372
1373
|
/** Tear down the chart: cancel animations, remove listeners, and detach the canvas. */
|
|
1373
1374
|
destroy() {
|
|
1374
1375
|
for (const t of this.#t) t.renderer.dispose();
|
|
1375
|
-
this.#t = [], this.#u = [], this.#x = [], this.#y = [], this.#
|
|
1376
|
+
this.#t = [], this.#u = [], this.#x = [], this.#y = [], this.#D = null, this.#i.destroy(), this.#o.destroy(), this.#P?.destroy(), this.#a.destroy(), this.#tt?.destroy(), this.#tt = null, this.#Q && this.#k?.destroy(), this.#k = null, this.#Q = !1, this.removeAllListeners();
|
|
1376
1377
|
}
|
|
1377
1378
|
/** The attached performance monitor, or `null` when instrumentation is disabled. */
|
|
1378
1379
|
getPerfMonitor() {
|
|
@@ -1394,12 +1395,12 @@ class Ai extends At {
|
|
|
1394
1395
|
#nt = !1;
|
|
1395
1396
|
onDataChanged() {
|
|
1396
1397
|
if (this.#L > 0) {
|
|
1397
|
-
this.#
|
|
1398
|
+
this.#j = !0;
|
|
1398
1399
|
return;
|
|
1399
1400
|
}
|
|
1400
1401
|
this.updateDataInterval();
|
|
1401
1402
|
const { first: t, last: i } = this.getDataBounds();
|
|
1402
|
-
t !== void 0 && (this.#
|
|
1403
|
+
t !== void 0 && (this.#w = t), i !== void 0 && (this.#N = this.#e, this.#e = i);
|
|
1403
1404
|
const e = this.#nt;
|
|
1404
1405
|
this.#nt = !1;
|
|
1405
1406
|
const s = !this.#g && t !== void 0;
|
|
@@ -1412,7 +1413,7 @@ class Ai extends At {
|
|
|
1412
1413
|
if (!b(t.renderer)) continue;
|
|
1413
1414
|
const i = t.renderer.sampleTimes(20);
|
|
1414
1415
|
if (i.length >= 2) {
|
|
1415
|
-
this.#r =
|
|
1416
|
+
this.#r = Vt(i);
|
|
1416
1417
|
break;
|
|
1417
1418
|
}
|
|
1418
1419
|
}
|
|
@@ -1457,12 +1458,12 @@ class Ai extends At {
|
|
|
1457
1458
|
*/
|
|
1458
1459
|
#ht(t) {
|
|
1459
1460
|
const i = t ?? this.#h, e = this.#p.min !== void 0 && this.#p.min !== "auto" && typeof this.#p.min != "number" || this.#p.max !== void 0 && this.#p.max !== "auto" && typeof this.#p.max != "number" ? [] : null, s = this.yScale.getTransform(), r = s === null ? void 0 : this.#Y;
|
|
1460
|
-
r && this.#
|
|
1461
|
-
const n =
|
|
1462
|
-
return n === null ? (this.#g = !1, null) :
|
|
1461
|
+
r && this.#jt(i);
|
|
1462
|
+
const n = yt({ targetVisible: i, series: this.#t, allValues: e, plottable: r });
|
|
1463
|
+
return n === null ? (this.#g = !1, null) : vt({ raw: n, bounds: this.#p, allValues: e ?? [], transform: s });
|
|
1463
1464
|
}
|
|
1464
1465
|
/** Dev-only sweep behind {@link warnUnplottableValues}; stops once it has warned. */
|
|
1465
|
-
#
|
|
1466
|
+
#jt(t) {
|
|
1466
1467
|
if (!(this.#Rt || process.env.NODE_ENV === "production"))
|
|
1467
1468
|
for (const i of this.#t) {
|
|
1468
1469
|
if (!i.visible || !b(i.renderer)) continue;
|
|
@@ -1470,7 +1471,7 @@ class Ai extends At {
|
|
|
1470
1471
|
if (e === null) continue;
|
|
1471
1472
|
const s = (i.renderer.stacking === "normal" ? e.min < 0 && !this.yScale.isPlottable(e.min) : !this.yScale.isPlottable(e.min)) ? e.min : this.yScale.isPlottable(e.max) ? null : e.max;
|
|
1472
1473
|
if (s !== null) {
|
|
1473
|
-
this.#Rt = !0,
|
|
1474
|
+
this.#Rt = !0, mt({ seriesId: i.id, value: s });
|
|
1474
1475
|
return;
|
|
1475
1476
|
}
|
|
1476
1477
|
}
|
|
@@ -1494,10 +1495,10 @@ class Ai extends At {
|
|
|
1494
1495
|
* from the tail).
|
|
1495
1496
|
*/
|
|
1496
1497
|
#Jt() {
|
|
1497
|
-
if (this.#
|
|
1498
|
+
if (this.#w === null || this.#e === null) return null;
|
|
1498
1499
|
const { from: t, to: i } = this.#h, e = t === 0 && i === 0, s = this.#a.size.media.width - this.yAxisWidth;
|
|
1499
1500
|
if (e) {
|
|
1500
|
-
if (this.#O(this.#
|
|
1501
|
+
if (this.#O(this.#w, this.#e, s), this.#_ !== void 0 && (this.setVisibleRange(this.#_), this.#_ = void 0, !this.#m && this.#e !== null)) {
|
|
1501
1502
|
const { to: n } = this.#h;
|
|
1502
1503
|
this.#e >= n && this.#e - n <= this.#r * 1.5 && (this.#m = !0);
|
|
1503
1504
|
}
|
|
@@ -1505,17 +1506,17 @@ class Ai extends At {
|
|
|
1505
1506
|
}
|
|
1506
1507
|
if (!this.#m) return null;
|
|
1507
1508
|
if (this.#xt)
|
|
1508
|
-
return this.#O(this.#
|
|
1509
|
-
const r =
|
|
1509
|
+
return this.#O(this.#w, this.#e, s), this.#h;
|
|
1510
|
+
const r = gt({
|
|
1510
1511
|
currentLogical: this.#h,
|
|
1511
1512
|
lastTime: this.#e,
|
|
1512
|
-
prevDataEnd: this.#
|
|
1513
|
+
prevDataEnd: this.#N,
|
|
1513
1514
|
dataInterval: this.#r,
|
|
1514
1515
|
paddingRight: this.#l.right,
|
|
1515
1516
|
chartWidth: s,
|
|
1516
1517
|
holdUntilFilled: this.#M
|
|
1517
1518
|
});
|
|
1518
|
-
return r.releaseHold && (this.#M = !1), r.reengageAutoScroll && (this.#m = !0), r.newLogical === null ? null : (this.#R.observe(performance.now()), this.#s.setXSettleMs(this.#R.pickSettleMs(this.#d.axis.x.settleMs)), this.#C(r.newLogical, { emitChange: !1, skipValidation: !0 }), this.#
|
|
1519
|
+
return r.releaseHold && (this.#M = !1), r.reengageAutoScroll && (this.#m = !0), r.newLogical === null ? null : (this.#R.observe(performance.now()), this.#s.setXSettleMs(this.#R.pickSettleMs(this.#d.axis.x.settleMs)), this.#C(r.newLogical, { emitChange: !1, skipValidation: !0 }), this.#N = this.#e, r.newLogical);
|
|
1519
1520
|
}
|
|
1520
1521
|
/**
|
|
1521
1522
|
* Fit the viewport's logical X range around a data span. Mirrors the
|
|
@@ -1524,7 +1525,7 @@ class Ai extends At {
|
|
|
1524
1525
|
* commits the new range via `viewport.setRange` (which emits `change`).
|
|
1525
1526
|
*/
|
|
1526
1527
|
#O(t, i, e) {
|
|
1527
|
-
const s = this.#l, r =
|
|
1528
|
+
const s = this.#l, r = nt({
|
|
1528
1529
|
firstTime: t,
|
|
1529
1530
|
lastTime: i,
|
|
1530
1531
|
dataInterval: this.#r,
|
|
@@ -1652,15 +1653,15 @@ class Ai extends At {
|
|
|
1652
1653
|
* as a gesture for visual easing. Public so consumers can drive pan
|
|
1653
1654
|
* programmatically.
|
|
1654
1655
|
*/
|
|
1655
|
-
pan(t, i = this
|
|
1656
|
-
i > 0 && (this
|
|
1657
|
-
const e =
|
|
1656
|
+
pan(t, i = this.#E) {
|
|
1657
|
+
i > 0 && (this.#E = i), this.#M = !1;
|
|
1658
|
+
const e = dt({
|
|
1658
1659
|
currentLogical: this.#h,
|
|
1659
1660
|
timeDelta: t,
|
|
1660
1661
|
chartWidth: i,
|
|
1661
1662
|
dataInterval: this.#r,
|
|
1662
1663
|
padding: { left: this.#l.left, right: this.#l.right },
|
|
1663
|
-
dataStart: this.#
|
|
1664
|
+
dataStart: this.#w,
|
|
1664
1665
|
dataEnd: this.#e
|
|
1665
1666
|
});
|
|
1666
1667
|
e.newLogical !== null && (this.#m = !e.autoScrollOff, this.#C(e.newLogical, { emitChange: !0 }), e.edgeReached !== null && (this.#pt[e.edgeReached.side] = e.edgeReached.boundaryTime, this.#yt?.(e.edgeReached)), this.#R.pause(), this.#zt());
|
|
@@ -1680,23 +1681,23 @@ class Ai extends At {
|
|
|
1680
1681
|
* and produce a visible jump). Cursor-anchored zoom is intentionally
|
|
1681
1682
|
* sacrificed in follow-live mode — pan first to inspect history.
|
|
1682
1683
|
*/
|
|
1683
|
-
zoomAt(t, i, e = this
|
|
1684
|
-
e > 0 && (this
|
|
1685
|
-
const s =
|
|
1684
|
+
zoomAt(t, i, e = this.#E) {
|
|
1685
|
+
e > 0 && (this.#E = e), this.#M = !1;
|
|
1686
|
+
const s = ut({
|
|
1686
1687
|
currentLogical: this.#h,
|
|
1687
1688
|
centerTime: t,
|
|
1688
1689
|
factor: i,
|
|
1689
1690
|
chartWidth: e,
|
|
1690
1691
|
dataInterval: this.#r,
|
|
1691
1692
|
padding: { left: this.#l.left, right: this.#l.right },
|
|
1692
|
-
dataStart: this.#
|
|
1693
|
+
dataStart: this.#w,
|
|
1693
1694
|
dataEnd: this.#e
|
|
1694
1695
|
});
|
|
1695
1696
|
if (s.newLogical === null) return;
|
|
1696
1697
|
let r = s.newLogical;
|
|
1697
1698
|
if (this.#m && this.#e !== null) {
|
|
1698
1699
|
const n = r.to - r.from, a = B(this.#l.right, n, this.#r, e), o = this.#e + a;
|
|
1699
|
-
r = { from: o - n, to: o }, this.#
|
|
1700
|
+
r = { from: o - n, to: o }, this.#N = this.#e;
|
|
1700
1701
|
}
|
|
1701
1702
|
this.#C(r, { emitChange: !0 }), this.#R.pause(), this.#zt();
|
|
1702
1703
|
}
|
|
@@ -1758,7 +1759,7 @@ class Ai extends At {
|
|
|
1758
1759
|
const c = i.media.height - this.xAxisHeight;
|
|
1759
1760
|
this.#B = this.#It({ min: r, max: n, chartHeight: c }), this.#at = r, this.#ot = n;
|
|
1760
1761
|
}
|
|
1761
|
-
if (this.syncScales(), this.#
|
|
1762
|
+
if (this.syncScales(), this.#Kt(), this.#e !== null && !this.#m) {
|
|
1762
1763
|
const c = this.#s.lastXTarget ?? this.#h, f = c.to - c.from;
|
|
1763
1764
|
if (f > 0) {
|
|
1764
1765
|
const g = this.#a.size.media.width - this.yAxisWidth, u = B(this.#l.right, f, this.#r, g), p = this.#r * 0.5;
|
|
@@ -1772,46 +1773,46 @@ class Ai extends At {
|
|
|
1772
1773
|
f.clearRect(0, 0, g.width, g.height), f.save(), f.translate(S, 0), f.beginPath(), f.rect(0, 0, this.#Bt(c, u), p), f.clip(), this.yScale.tickTracker.setCurrentTicks(this.yScale.niceTickValues()), this.timeScale.tickTracker.setCurrentTicks(this.timeScale.niceTickValues(this.#r).ticks), this.yScale.tickTracker.tick(e), this.timeScale.tickTracker.tick(e);
|
|
1773
1774
|
const A = this.yScale.tickTracker.snapshot(), k = this.timeScale.tickTracker.snapshot();
|
|
1774
1775
|
o = A.isAnimating, l = k.isAnimating, (A.isAnimating || k.isAnimating || s.animating) && this.emit("tickFrame");
|
|
1775
|
-
const
|
|
1776
|
-
if ((
|
|
1777
|
-
const v =
|
|
1778
|
-
this.#H.setTarget(
|
|
1776
|
+
const T = this.#F ? 1 : 0;
|
|
1777
|
+
if ((T === 0 || A.entries.length > 0 || k.entries.length > 0) && T !== this.#H.target) {
|
|
1778
|
+
const v = Q() ? 0 : this.#d.axis.gridMs;
|
|
1779
|
+
this.#H.setTarget(T, { now: e, duration: v });
|
|
1779
1780
|
}
|
|
1780
1781
|
h = this.#H.tick(e);
|
|
1781
|
-
const
|
|
1782
|
+
const D = this.#H.current, R = {
|
|
1782
1783
|
scope: c,
|
|
1783
1784
|
timeScale: this.timeScale,
|
|
1784
1785
|
yScale: this.yScale,
|
|
1785
1786
|
theme: this.#n,
|
|
1786
1787
|
yTicks: A,
|
|
1787
1788
|
timeTicks: k,
|
|
1788
|
-
alpha:
|
|
1789
|
-
}, L = this
|
|
1790
|
-
L === 0 &&
|
|
1791
|
-
const C = this.#l,
|
|
1789
|
+
alpha: D
|
|
1790
|
+
}, L = this.#$t(c, u);
|
|
1791
|
+
L === 0 && E(R), this.#_t(c, u, p);
|
|
1792
|
+
const C = this.#l, G = { top: C.top, bottom: C.bottom }, U = this.#Tt(s), I = this.#k;
|
|
1792
1793
|
for (const v of this.#t) {
|
|
1793
|
-
const
|
|
1794
|
-
if (
|
|
1794
|
+
const w = v.renderer.getAlpha?.() ?? (v.visible ? 1 : 0);
|
|
1795
|
+
if (w <= 0) continue;
|
|
1795
1796
|
const z = {
|
|
1796
1797
|
scope: c,
|
|
1797
1798
|
timeScale: this.timeScale,
|
|
1798
1799
|
yScale: this.yScale,
|
|
1799
1800
|
theme: this.#n,
|
|
1800
1801
|
dataInterval: this.#r,
|
|
1801
|
-
padding:
|
|
1802
|
-
state:
|
|
1802
|
+
padding: G,
|
|
1803
|
+
state: U,
|
|
1803
1804
|
seriesId: v.id
|
|
1804
1805
|
}, V = f.globalAlpha;
|
|
1805
|
-
if (
|
|
1806
|
-
const
|
|
1807
|
-
v.renderer.render(z), I.recordSeries(v.id, performance.now() -
|
|
1806
|
+
if (w < 1 && (f.globalAlpha = V * w), I) {
|
|
1807
|
+
const q = performance.now();
|
|
1808
|
+
v.renderer.render(z), I.recordSeries(v.id, performance.now() - q, e);
|
|
1808
1809
|
} else
|
|
1809
1810
|
v.renderer.render(z);
|
|
1810
|
-
|
|
1811
|
+
w < 1 && (f.globalAlpha = V);
|
|
1811
1812
|
}
|
|
1812
1813
|
f.restore();
|
|
1813
1814
|
const H = { left: S, width: u, height: p };
|
|
1814
|
-
L === 0 ? (this.#Wt({ scope: c, pane: H, timeTicks: k, alpha:
|
|
1815
|
+
L === 0 ? (this.#Wt({ scope: c, pane: H, timeTicks: k, alpha: D }), this.#lt(c, u)) : (this.#lt(c, u), this.#si({ grid: R, pane: H, overhang: L })), this.#Ft(c, u), this.#Vt(c, p);
|
|
1815
1816
|
}), this.#it();
|
|
1816
1817
|
let d = !1;
|
|
1817
1818
|
for (const c of this.#t)
|
|
@@ -1847,11 +1848,11 @@ class Ai extends At {
|
|
|
1847
1848
|
#Wt(t) {
|
|
1848
1849
|
const { scope: i, pane: e, timeTicks: s, alpha: r } = t;
|
|
1849
1850
|
if (!this.#F && r <= 0.01 || this.xAxisHeight === 0) return;
|
|
1850
|
-
const { context: n, horizontalPixelRatio: a, verticalPixelRatio: o } = i, l = Math.round(e.height), h = Math.round(
|
|
1851
|
+
const { context: n, horizontalPixelRatio: a, verticalPixelRatio: o } = i, l = Math.round(e.height), h = Math.round(P * o);
|
|
1851
1852
|
if (h < 1) return;
|
|
1852
1853
|
const d = this.#n.grid;
|
|
1853
|
-
n.save(), n.strokeStyle = d.color, d.style === "dashed" ? n.setLineDash([4 * a, 4 * a]) : d.style === "dotted" && n.setLineDash([1 * a, 3 * a]), n.lineDashOffset = l, n.lineWidth =
|
|
1854
|
-
const m =
|
|
1854
|
+
n.save(), n.strokeStyle = d.color, d.style === "dashed" ? n.setLineDash([4 * a, 4 * a]) : d.style === "dotted" && n.setLineDash([1 * a, 3 * a]), n.lineDashOffset = l, n.lineWidth = It(a);
|
|
1855
|
+
const m = Ht(a), c = Math.round(e.width);
|
|
1855
1856
|
for (const { value: f, opacity: g } of s.entries) {
|
|
1856
1857
|
const u = g * r;
|
|
1857
1858
|
if (u <= 0.01) continue;
|
|
@@ -1870,7 +1871,7 @@ class Ai extends At {
|
|
|
1870
1871
|
*/
|
|
1871
1872
|
#Ot(t, i) {
|
|
1872
1873
|
if (this.xAxisHeight === 0) return;
|
|
1873
|
-
const e = Math.round(i), s = Math.round(
|
|
1874
|
+
const e = Math.round(i), s = Math.round(P * t.verticalPixelRatio);
|
|
1874
1875
|
if (s < 1) return;
|
|
1875
1876
|
const { context: r } = t;
|
|
1876
1877
|
r.save(), r.globalCompositeOperation = "destination-out", r.fillStyle = this.#oi({ context: r, start: e, height: s }), r.fillRect(0, e, t.bitmapSize.width, s), r.restore();
|
|
@@ -1888,15 +1889,15 @@ class Ai extends At {
|
|
|
1888
1889
|
#ii(t) {
|
|
1889
1890
|
const i = this.#c;
|
|
1890
1891
|
if (i === null) return;
|
|
1891
|
-
const { scope: e, chartBitmapWidth: s, chartBitmapHeight: r } = t, { context: n } = e, a = this.#I(e), o = this.#Bt(e, s), l = this
|
|
1892
|
-
n.save(), n.translate(a, 0), n.beginPath(), n.rect(-l, 0, o + l, r + h), n.clip(),
|
|
1892
|
+
const { scope: e, chartBitmapWidth: s, chartBitmapHeight: r } = t, { context: n } = e, a = this.#I(e), o = this.#Bt(e, s), l = this.#$t(e, s), h = this.xAxisHeight > 0 ? Math.round(P * e.verticalPixelRatio) : 0;
|
|
1893
|
+
n.save(), n.translate(a, 0), n.beginPath(), n.rect(-l, 0, o + l, r + h), n.clip(), bt({
|
|
1893
1894
|
scope: e,
|
|
1894
1895
|
bitmapX: i.mediaX * e.horizontalPixelRatio - a,
|
|
1895
1896
|
bitmapY: i.mediaY * e.verticalPixelRatio,
|
|
1896
1897
|
theme: this.#n,
|
|
1897
1898
|
pane: { width: s, height: r },
|
|
1898
1899
|
leftOverhang: l
|
|
1899
|
-
}), n.restore(), this.#Ot(e, r), l === 0 ? this.#lt(e, s) : this.#
|
|
1900
|
+
}), n.restore(), this.#Ot(e, r), l === 0 ? this.#lt(e, s) : this.#Nt(e, l), this.#Ft(e, s), this.#Vt(e, r);
|
|
1900
1901
|
}
|
|
1901
1902
|
/**
|
|
1902
1903
|
* Horizontal companion to {@link #applyTopFade}: dissolve content that
|
|
@@ -1924,21 +1925,21 @@ class Ai extends At {
|
|
|
1924
1925
|
}
|
|
1925
1926
|
/** Sides whose fade is a plain edge zone rather than the axis-column ramp. */
|
|
1926
1927
|
#ei() {
|
|
1927
|
-
return this.#X() ?
|
|
1928
|
+
return this.#X() ? $t : this.yAxisPosition === "left" ? Bt : Nt;
|
|
1928
1929
|
}
|
|
1929
1930
|
/** Bitmap px the gridlines and crosshair run under a left Y-axis column, where
|
|
1930
1931
|
* data can't follow (see {@link #axisFadeZone}). `0` on the right or with the fade off. */
|
|
1931
|
-
|
|
1932
|
-
return this.yAxisPosition !== "left" || this.#ct(t, i) === null ? 0 : Math.min(Math.round(
|
|
1932
|
+
#$t(t, i) {
|
|
1933
|
+
return this.yAxisPosition !== "left" || this.#ct(t, i) === null ? 0 : Math.min(Math.round(Z * t.horizontalPixelRatio), this.#I(t));
|
|
1933
1934
|
}
|
|
1934
1935
|
/** Left-axis grid pass, run after the axis fade: `destination-over` keeps the
|
|
1935
1936
|
* gridlines out of the data ramp, then they taper out under the column. */
|
|
1936
1937
|
#si(t) {
|
|
1937
1938
|
const { grid: i, pane: e, overhang: s } = t, { scope: r } = i, { context: n } = r;
|
|
1938
|
-
n.save(), n.globalCompositeOperation = "destination-over", n.save(), n.translate(e.left, 0), n.beginPath(), n.rect(-s, 0, e.width + s, e.height), n.clip(),
|
|
1939
|
+
n.save(), n.globalCompositeOperation = "destination-over", n.save(), n.translate(e.left, 0), n.beginPath(), n.rect(-s, 0, e.width + s, e.height), n.clip(), E({ ...i, leftOverhang: s }), n.restore(), this.#Wt({ scope: r, pane: e, timeTicks: i.timeTicks, alpha: i.alpha ?? 1 }), n.restore(), this.#Nt(r, s);
|
|
1939
1940
|
}
|
|
1940
1941
|
/** Erase the {@link #gridOverhang} strip: none at the pane edge, total at its outer end. */
|
|
1941
|
-
#
|
|
1942
|
+
#Nt(t, i) {
|
|
1942
1943
|
const e = this.#I(t), s = e - i, { context: r } = t;
|
|
1943
1944
|
r.save(), r.globalCompositeOperation = "destination-out", r.fillStyle = this.#hi({ context: r, start: s, end: e }), r.fillRect(s, 0, i, t.bitmapSize.height), r.restore();
|
|
1944
1945
|
}
|
|
@@ -1969,7 +1970,7 @@ class Ai extends At {
|
|
|
1969
1970
|
if (this.#X()) return null;
|
|
1970
1971
|
const e = this.yAxisPosition === "left", s = t.bitmapSize.width, r = e ? this.#I(t) : Math.max(0, Math.round(s - i));
|
|
1971
1972
|
if (r === 0) return null;
|
|
1972
|
-
const n = t.horizontalPixelRatio, a = Math.round(
|
|
1973
|
+
const n = t.horizontalPixelRatio, a = Math.round(Z * n), o = Math.round(Ft * n), l = e ? 0 : Math.min(a, r), h = e ? a + o : l + o, d = e ? this.#A.left : this.#A.right, m = d === null ? h : Math.round(d * n);
|
|
1973
1974
|
if (m < 1) return null;
|
|
1974
1975
|
if (e) {
|
|
1975
1976
|
const g = r, u = Math.min(m, s - g);
|
|
@@ -2096,8 +2097,8 @@ class Ai extends At {
|
|
|
2096
2097
|
left: this.#z.left && this.#S.left === "loading" ? "idle" : this.#S.left,
|
|
2097
2098
|
right: this.#z.right && this.#S.right === "loading" ? "idle" : this.#S.right
|
|
2098
2099
|
}, r = {
|
|
2099
|
-
left: this.#
|
|
2100
|
-
right: this.#
|
|
2100
|
+
left: this.#Pt("left"),
|
|
2101
|
+
right: this.#Pt("right")
|
|
2101
2102
|
}, n = r.left !== null || r.right !== null, a = s.left === "loading" || s.right === "loading" || n, o = s.left !== "idle" || s.right !== "idle" || n, l = !!this.#c || e || o || this.#u.length > 0 || this.#y.length > 0;
|
|
2102
2103
|
if (!(!l && !this.#gt)) {
|
|
2103
2104
|
if (this.#gt = l, this.#a.useOverlayLayer((h) => {
|
|
@@ -2117,7 +2118,7 @@ class Ai extends At {
|
|
|
2117
2118
|
state: g,
|
|
2118
2119
|
seriesId: u.id
|
|
2119
2120
|
});
|
|
2120
|
-
this.#Gt(h, d, m), this.#Zt(h, d, m), o &&
|
|
2121
|
+
this.#Gt(h, d, m), this.#Zt(h, d, m), o && st({
|
|
2121
2122
|
scope: h,
|
|
2122
2123
|
chartMediaWidth: i.media.width - this.yAxisWidth,
|
|
2123
2124
|
chartMediaHeight: i.media.height - this.xAxisHeight,
|
|
@@ -2126,11 +2127,11 @@ class Ai extends At {
|
|
|
2126
2127
|
edgeStates: s,
|
|
2127
2128
|
edgeExitFades: r,
|
|
2128
2129
|
edgeIndicatorFns: this.#vt,
|
|
2129
|
-
resolveBoundary: (u) =>
|
|
2130
|
+
resolveBoundary: (u) => rt(u, this.#pt[u], this.getDataBounds()),
|
|
2130
2131
|
resolveEdgeAnchor: (u, p) => this.#Ut(u, p),
|
|
2131
|
-
resolveEdgeBarSpacing: () => this.#
|
|
2132
|
+
resolveEdgeBarSpacing: () => this.#qt(),
|
|
2132
2133
|
reportPlaceholders: (u, p) => {
|
|
2133
|
-
this.#
|
|
2134
|
+
this.#K[u] = { bars: p, at: performance.now() };
|
|
2134
2135
|
}
|
|
2135
2136
|
}), h.context.restore();
|
|
2136
2137
|
}), e) {
|
|
@@ -2155,5 +2156,5 @@ class Ai extends At {
|
|
|
2155
2156
|
}
|
|
2156
2157
|
}
|
|
2157
2158
|
export {
|
|
2158
|
-
|
|
2159
|
+
Li as ChartInstance
|
|
2159
2160
|
};
|