velo-plot 2.20.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -12
- package/dist/ChartCore-AnR_3Xkb.js +7338 -0
- package/dist/ChartCore-AnR_3Xkb.js.map +1 -0
- package/dist/GpuChartRenderer-Dxc0hrQA.js +75 -0
- package/dist/GpuChartRenderer-Dxc0hrQA.js.map +1 -0
- package/dist/{index.core-COREBDNq.js → PluginRegistry-CzMHebYP.js} +24 -38
- package/dist/PluginRegistry-CzMHebYP.js.map +1 -0
- package/dist/a11y-Bw6urYpr.js +105 -0
- package/dist/a11y-Bw6urYpr.js.map +1 -0
- package/dist/angular/hooks-entry.d.ts +1 -0
- package/dist/angular/hooks.d.ts +26 -0
- package/dist/angular/index.d.ts +8 -0
- package/dist/angular/velo-plot.component.d.ts +46 -0
- package/dist/angular-hooks.d.ts +1 -0
- package/dist/angular-hooks.js +9 -0
- package/dist/angular-hooks.js.map +1 -0
- package/dist/angular.d.ts +1 -0
- package/dist/angular.js +166 -0
- package/dist/angular.js.map +1 -0
- package/dist/assets/indicator.worker-bv0zC4EX.js.map +1 -1
- package/dist/astro/StackedPlot.astro +19 -0
- package/dist/astro/VeloPlot.astro +23 -0
- package/dist/{axisFormat-CzumxpCL.js → axisFormat-Sz4WIJfQ.js} +2 -2
- package/dist/{axisFormat-CzumxpCL.js.map → axisFormat-Sz4WIJfQ.js.map} +1 -1
- package/dist/bindings/shared/a11y.d.ts +26 -0
- package/dist/bindings/shared/chartLifecycle.d.ts +16 -0
- package/dist/bindings/shared/chartSyncBridge.d.ts +8 -0
- package/dist/bindings/shared/dimensions.d.ts +1 -0
- package/dist/bindings/shared/index.d.ts +9 -0
- package/dist/bindings/shared/indicatorBridge.d.ts +11 -0
- package/dist/bindings/shared/optionsSync.d.ts +7 -0
- package/dist/bindings/shared/seriesDiff.d.ts +8 -0
- package/dist/bindings/shared/stackedSync.d.ts +9 -0
- package/dist/bindings/shared/types.d.ts +46 -0
- package/dist/bindings/test-utils/index.d.ts +35 -0
- package/dist/bindings/test-utils/mockLifecycle.d.ts +120 -0
- package/dist/bindings/test-utils/vitestSveltePlugin.d.ts +3 -0
- package/dist/chartSyncBridge-D_rCtbFq.js +58 -0
- package/dist/chartSyncBridge-D_rCtbFq.js.map +1 -0
- package/dist/core/Chart.d.ts +1 -1
- package/dist/core/ChartStatistics.d.ts +1 -1
- package/dist/core/InteractionManager.d.ts +7 -1
- package/dist/core/OverlayRenderer.d.ts +5 -0
- package/dist/core/annotations/types.d.ts +1 -1
- package/dist/core/chart/ChartCore.d.ts +14 -19
- package/dist/core/chart/ChartFeatureHooks.d.ts +7 -0
- package/dist/core/chart/chartExportPatch.d.ts +2 -0
- package/dist/core/chart/overlaySeriesRegistry.d.ts +7 -0
- package/dist/core/chart/series/SeriesActions.d.ts +1 -0
- package/dist/core/chart/series/SeriesBufferLite.d.ts +13 -0
- package/dist/core/chart/series/seriesOptionsRegistry.d.ts +8 -0
- package/dist/core/chart/series/seriesTypeRegistry.d.ts +5 -0
- package/dist/core/chart/types.d.ts +1 -1
- package/dist/core/clipboard/index.d.ts +1 -1
- package/dist/core/debug/index.d.ts +1 -1
- package/dist/core/keybindings/index.d.ts +1 -1
- package/dist/core/loading/index.d.ts +1 -1
- package/dist/core/locale/index.d.ts +1 -1
- package/dist/core/stacked/paneResize.d.ts +3 -0
- package/dist/core/stacked/types.d.ts +10 -0
- package/dist/core/theme-editor/index.d.ts +1 -1
- package/dist/createStackedChart-DqcLCFGS.js +1338 -0
- package/dist/createStackedChart-DqcLCFGS.js.map +1 -0
- package/dist/examples/PluginDemonstration.d.ts +1 -1
- package/dist/hooks-DH-3bewj.js +69 -0
- package/dist/hooks-DH-3bewj.js.map +1 -0
- package/dist/{index-BBpJwOct.js → index-0InEyj0q.js} +119 -121
- package/dist/index-0InEyj0q.js.map +1 -0
- package/dist/{index-qunX30Xu.js → index-B7PTX94B.js} +2133 -2133
- package/dist/index-B7PTX94B.js.map +1 -0
- package/dist/{index-BMiZoKmm.js → index-BgrvqltV.js} +67 -67
- package/dist/index-BgrvqltV.js.map +1 -0
- package/dist/{index-DoYxf1cV.js → index-CWxIHdwX.js} +38 -98
- package/dist/index-CWxIHdwX.js.map +1 -0
- package/dist/index-CaXWSOTk.js.map +1 -1
- package/dist/{mockDatafeed-927foCM4.js → index-Cv6ZDLWf.js} +227 -217
- package/dist/index-Cv6ZDLWf.js.map +1 -0
- package/dist/index-Dag88bW4.js.map +1 -1
- package/dist/index-qhscKTDy.js.map +1 -1
- package/dist/index.core.d.ts +9 -7
- package/dist/index.d.ts +2 -15
- package/dist/indicators--eJGmVox.js.map +1 -1
- package/dist/optionsSync-QUiN4Inw.js +119 -0
- package/dist/optionsSync-QUiN4Inw.js.map +1 -0
- package/dist/plugins/3d/index.d.ts +2 -2
- package/dist/plugins/3d.d.ts +2 -2
- package/dist/plugins/3d.js +3 -1
- package/dist/plugins/3d.js.map +1 -1
- package/dist/plugins/analysis/index.d.ts +1 -1
- package/dist/plugins/analysis/indicators.d.ts +1 -1
- package/dist/plugins/analysis.d.ts +2 -2
- package/dist/plugins/analysis.js +2 -2
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/annotations/index.d.ts +1 -1
- package/dist/plugins/annotations.d.ts +2 -2
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/anomaly-detection.js +1 -1
- package/dist/plugins/anomaly-detection.js.map +1 -1
- package/dist/plugins/broken-axis.d.ts +2 -2
- package/dist/plugins/builtins/crosshair/CrosshairPlugin.d.ts +1 -1
- package/dist/plugins/builtins/index.d.ts +1 -1
- package/dist/plugins/caching.d.ts +2 -2
- package/dist/plugins/clipboard/index.d.ts +2 -2
- package/dist/plugins/clipboard.d.ts +2 -2
- package/dist/plugins/clipboard.js.map +1 -1
- package/dist/plugins/context-menu/index.d.ts +1 -1
- package/dist/plugins/context-menu.d.ts +2 -2
- package/dist/plugins/context-menu.js +1 -1
- package/dist/plugins/context-menu.js.map +1 -1
- package/dist/plugins/createPlugin.d.ts +8 -0
- package/dist/plugins/data-export/index.d.ts +1 -1
- package/dist/plugins/data-export.d.ts +2 -2
- package/dist/plugins/data-export.js +2 -2
- package/dist/plugins/data-export.js.map +1 -1
- package/dist/plugins/data-transform.d.ts +2 -2
- package/dist/plugins/data-transform.js +19 -19
- package/dist/plugins/data-transform.js.map +1 -1
- package/dist/plugins/debug/index.d.ts +2 -2
- package/dist/plugins/debug.d.ts +2 -2
- package/dist/plugins/debug.js +33 -33
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/forecasting/index.d.ts +1 -1
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/gpu/index.d.ts +2 -2
- package/dist/plugins/gpu.d.ts +2 -2
- package/dist/plugins/gpu.js +2033 -209
- package/dist/plugins/gpu.js.map +1 -1
- package/dist/plugins/i18n/index.d.ts +2 -2
- package/dist/plugins/i18n.d.ts +2 -2
- package/dist/plugins/i18n.js +286 -23
- package/dist/plugins/i18n.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/keyboard.d.ts +2 -2
- package/dist/plugins/keyboard.js +65 -5
- package/dist/plugins/keyboard.js.map +1 -1
- package/dist/plugins/latex.js +766 -207
- package/dist/plugins/latex.js.map +1 -1
- package/dist/plugins/lazy-load.d.ts +2 -2
- package/dist/plugins/loading/index.d.ts +2 -3
- package/dist/plugins/loading.d.ts +2 -2
- package/dist/plugins/loading.js +3 -4
- package/dist/plugins/ml-integration.d.ts +2 -2
- package/dist/plugins/ml-integration.js +5 -5
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/offscreen.d.ts +2 -2
- package/dist/plugins/offscreen.js +11 -10
- package/dist/plugins/offscreen.js.map +1 -1
- package/dist/plugins/pattern-recognition.d.ts +2 -2
- package/dist/plugins/pattern-recognition.js +1 -1
- package/dist/plugins/pattern-recognition.js.map +1 -1
- package/dist/plugins/radar.d.ts +2 -2
- package/dist/plugins/regression.d.ts +2 -2
- package/dist/plugins/regression.js +255 -257
- package/dist/plugins/regression.js.map +1 -1
- package/dist/plugins/roi.js +9 -9
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot/index.d.ts +1 -1
- package/dist/plugins/snapshot/types.d.ts +1 -1
- package/dist/plugins/snapshot.d.ts +2 -2
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/streaming/index.d.ts +2 -2
- package/dist/plugins/streaming.d.ts +2 -2
- package/dist/plugins/streaming.js +1 -1
- package/dist/plugins/sync/index.d.ts +3 -2
- package/dist/plugins/sync.d.ts +2 -2
- package/dist/plugins/sync.js.map +1 -1
- package/dist/plugins/theme-editor/index.d.ts +1 -1
- package/dist/plugins/theme-editor.d.ts +2 -2
- package/dist/plugins/tools/index.d.ts +1 -1
- package/dist/plugins/tools/tooltip/index.d.ts +1 -1
- package/dist/plugins/tools.d.ts +2 -2
- package/dist/plugins/tools.js +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins/video-recorder.d.ts +2 -2
- package/dist/plugins/virtualization.d.ts +2 -2
- package/dist/plugins/virtualization.js +1 -1
- package/dist/pool-DZ8shSqv.js +109 -0
- package/dist/pool-DZ8shSqv.js.map +1 -0
- package/dist/react/StackedPlot.d.ts +31 -0
- package/dist/react/VeloPlot.d.ts +29 -0
- package/dist/react/index.d.ts +25 -3
- package/dist/react/useChartSync.d.ts +8 -0
- package/dist/react/useIndicator.d.ts +12 -0
- package/dist/react/useVeloPlot.d.ts +19 -0
- package/dist/react.js +325 -24
- package/dist/react.js.map +1 -1
- package/dist/renderer/NativeWebGLRenderer.d.ts +2 -1
- package/dist/renderer/native/NativeWebGLRenderer.d.ts +5 -1
- package/dist/renderer/native/draw.d.ts +2 -47
- package/dist/renderer/native/drawCore.d.ts +27 -0
- package/dist/renderer/native/drawExtended.d.ts +29 -0
- package/dist/renderer/native/frameRenderExtended.d.ts +1 -0
- package/dist/renderer/native/frameRenderRegistry.d.ts +27 -0
- package/dist/renderer/native/programFactoryCore.d.ts +6 -0
- package/dist/renderer/native/programFactoryExtended.d.ts +4 -0
- package/dist/renderer/native/utils.d.ts +3 -29
- package/dist/renderer/native/utilsCore.d.ts +14 -0
- package/dist/renderer/native/utilsExtended.d.ts +17 -0
- package/dist/renderer/overlaySeriesExtended.d.ts +1 -0
- package/dist/renderer/registerExtendedSeries.d.ts +1 -0
- package/dist/renderer/registerWebGPU.d.ts +2 -0
- package/dist/renderer/seriesBufferExtended.d.ts +4 -0
- package/dist/scientific/index.d.ts +44 -0
- package/dist/scientific/registerScientific.d.ts +1 -0
- package/dist/scientific.d.ts +1 -0
- package/dist/scientific.js +91 -0
- package/dist/scientific.js.map +1 -0
- package/dist/solid/VeloPlot.d.ts +16 -0
- package/dist/solid/index.d.ts +13 -0
- package/dist/solid/useChartSync.d.ts +6 -0
- package/dist/solid/useIndicator.d.ts +11 -0
- package/dist/solid/useStackedPlot.d.ts +14 -0
- package/dist/solid/useVeloPlot.d.ts +18 -0
- package/dist/solid.d.ts +1 -0
- package/dist/solid.js +169 -0
- package/dist/solid.js.map +1 -0
- package/dist/stackedSync-tnrunZMt.js +100 -0
- package/dist/stackedSync-tnrunZMt.js.map +1 -0
- package/dist/svelte/StackedPlot.svelte +29 -0
- package/dist/svelte/StackedPlot.test.ts +114 -0
- package/dist/svelte/VeloPlot.svelte +44 -0
- package/dist/svelte/VeloPlot.test.ts +105 -0
- package/dist/svelte/index.d.ts +11 -0
- package/dist/svelte/index.test.ts +20 -0
- package/dist/svelte/index.ts +15 -0
- package/dist/svelte/useChartSync.d.ts +8 -0
- package/dist/svelte/useChartSync.test.ts +49 -0
- package/dist/svelte/useChartSync.ts +29 -0
- package/dist/svelte/useIndicator.d.ts +13 -0
- package/dist/svelte/useIndicator.test.ts +67 -0
- package/dist/svelte/useIndicator.ts +43 -0
- package/dist/svelte/useStackedPlot.d.ts +16 -0
- package/dist/svelte/useStackedPlot.test.ts +76 -0
- package/dist/svelte/useStackedPlot.ts +54 -0
- package/dist/svelte/useVeloPlot.d.ts +21 -0
- package/dist/svelte/useVeloPlot.test.ts +100 -0
- package/dist/svelte/useVeloPlot.ts +81 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +140 -0
- package/dist/svelte.js.map +1 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/theme/index.d.ts +2 -1
- package/dist/trading/index.d.ts +1 -4
- package/dist/trading/registerTrading.d.ts +3 -0
- package/dist/trading.js +42 -42
- package/dist/types.d.ts +4 -4
- package/dist/{utils-BK5UUXxj.js → utils-Dx0h0bgQ.js} +9 -9
- package/dist/{utils-BK5UUXxj.js.map → utils-Dx0h0bgQ.js.map} +1 -1
- package/dist/velo-plot.full.js +2216 -1346
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +33 -28
- package/dist/velo-plot.js.map +1 -1
- package/dist/vue/StackedPlot.vue.d.ts +48 -0
- package/dist/vue/VeloPlot.vue.d.ts +64 -0
- package/dist/vue/index.d.ts +250 -0
- package/dist/vue/useChartSync.d.ts +52 -0
- package/dist/vue/useIndicator.d.ts +23 -0
- package/dist/vue/useStackedPlot.d.ts +15 -0
- package/dist/vue/useVeloPlot.d.ts +20 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +309 -0
- package/dist/vue.js.map +1 -0
- package/dist/workers/indicatorsAsync.d.ts +2 -0
- package/dist/workers/pool.d.ts +9 -0
- package/package.json +96 -10
- package/dist/ChartCore-ivzLqxVb.js +0 -8350
- package/dist/ChartCore-ivzLqxVb.js.map +0 -1
- package/dist/SciPlot-CEU4ApgD.js +0 -463
- package/dist/SciPlot-CEU4ApgD.js.map +0 -1
- package/dist/createStackedChart-DxNW0VkF.js +0 -705
- package/dist/createStackedChart-DxNW0VkF.js.map +0 -1
- package/dist/gpuRenderer-BpaMYz-k.js +0 -1848
- package/dist/gpuRenderer-BpaMYz-k.js.map +0 -1
- package/dist/index-BBpJwOct.js.map +0 -1
- package/dist/index-BMiZoKmm.js.map +0 -1
- package/dist/index-DoYxf1cV.js.map +0 -1
- package/dist/index-qunX30Xu.js.map +0 -1
- package/dist/index-x4stH3jD.js +0 -282
- package/dist/index-x4stH3jD.js.map +0 -1
- package/dist/index.core-COREBDNq.js.map +0 -1
- package/dist/mockDatafeed-927foCM4.js.map +0 -1
- package/dist/pool-15HMCNv8.js +0 -88
- package/dist/pool-15HMCNv8.js.map +0 -1
- package/dist/react/SciPlot.d.ts +0 -60
- package/dist/react/useSciPlot.d.ts +0 -56
- package/dist/symbols-DT0eLlpW.js +0 -568
- package/dist/symbols-DT0eLlpW.js.map +0 -1
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { n as H, W as Z } from "./pool-
|
|
2
|
-
function R(o,
|
|
1
|
+
import { n as H, W as Z } from "./pool-DZ8shSqv.js";
|
|
2
|
+
function R(o, n, r) {
|
|
3
3
|
const l = o.length;
|
|
4
|
-
if (
|
|
4
|
+
if (r >= l || r <= 2)
|
|
5
5
|
return {
|
|
6
6
|
x: new Float32Array(o),
|
|
7
|
-
y: new Float32Array(
|
|
7
|
+
y: new Float32Array(n),
|
|
8
8
|
indices: new Uint32Array(Array.from({ length: l }, (g, F) => F))
|
|
9
9
|
};
|
|
10
|
-
const u = new Float32Array(
|
|
11
|
-
u[0] = o[0], f[0] =
|
|
12
|
-
const c = (l - 2) / (
|
|
10
|
+
const u = new Float32Array(r), f = new Float32Array(r), s = new Uint32Array(r);
|
|
11
|
+
u[0] = o[0], f[0] = n[0], s[0] = 0;
|
|
12
|
+
const c = (l - 2) / (r - 2);
|
|
13
13
|
let h = 0, p = 1;
|
|
14
|
-
for (let g = 0; g <
|
|
14
|
+
for (let g = 0; g < r - 2; g++) {
|
|
15
15
|
const F = Math.floor((g + 1) * c) + 1, z = Math.floor((g + 2) * c) + 1, x = Math.min(z, l - 1), y = Math.min(
|
|
16
16
|
Math.floor((g + 3) * c) + 1,
|
|
17
17
|
l
|
|
18
18
|
);
|
|
19
19
|
let w = 0, V = 0, v = 0;
|
|
20
20
|
for (let D = x; D < y; D++)
|
|
21
|
-
w += o[D], V +=
|
|
21
|
+
w += o[D], V += n[D], v++;
|
|
22
22
|
v > 0 && (w /= v, V /= v);
|
|
23
23
|
let b = -1, M = F;
|
|
24
|
-
const S = o[h],
|
|
24
|
+
const S = o[h], B = n[h];
|
|
25
25
|
for (let D = F; D < z && D < l; D++) {
|
|
26
|
-
const
|
|
27
|
-
(S - w) * (
|
|
26
|
+
const L = Math.abs(
|
|
27
|
+
(S - w) * (n[D] - B) - (S - o[D]) * (V - B)
|
|
28
28
|
);
|
|
29
|
-
|
|
29
|
+
L > b && (b = L, M = D);
|
|
30
30
|
}
|
|
31
|
-
u[p] = o[M], f[p] =
|
|
31
|
+
u[p] = o[M], f[p] = n[M], s[p] = M, h = M, p++;
|
|
32
32
|
}
|
|
33
|
-
return u[
|
|
33
|
+
return u[r - 1] = o[l - 1], f[r - 1] = n[l - 1], s[r - 1] = l - 1, { x: u, y: f, indices: s };
|
|
34
34
|
}
|
|
35
|
-
function G(o,
|
|
35
|
+
function G(o, n, r) {
|
|
36
36
|
const l = o.length;
|
|
37
|
-
if (
|
|
37
|
+
if (r >= l / 2)
|
|
38
38
|
return {
|
|
39
39
|
x: new Float32Array(o),
|
|
40
|
-
y: new Float32Array(
|
|
40
|
+
y: new Float32Array(n),
|
|
41
41
|
indices: new Uint32Array(Array.from({ length: l }, (h, p) => p))
|
|
42
42
|
};
|
|
43
|
-
const u = l /
|
|
44
|
-
for (let h = 0; h <
|
|
43
|
+
const u = l / r, f = [], s = [], c = [];
|
|
44
|
+
for (let h = 0; h < r; h++) {
|
|
45
45
|
const p = Math.floor(h * u), g = Math.floor((h + 1) * u);
|
|
46
46
|
let F = 1 / 0, z = -1 / 0, x = p, y = p;
|
|
47
47
|
for (let w = p; w < g && w < l; w++)
|
|
48
|
-
|
|
49
|
-
x <= y ? (f.push(o[x], o[y]), s.push(
|
|
48
|
+
n[w] < F && (F = n[w], x = w), n[w] > z && (z = n[w], y = w);
|
|
49
|
+
x <= y ? (f.push(o[x], o[y]), s.push(n[x], n[y]), c.push(x, y)) : (f.push(o[y], o[x]), s.push(n[y], n[x]), c.push(y, x));
|
|
50
50
|
}
|
|
51
51
|
return {
|
|
52
52
|
x: new Float32Array(f),
|
|
@@ -54,17 +54,17 @@ function G(o, r, n) {
|
|
|
54
54
|
indices: new Uint32Array(c)
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function ee(o,
|
|
58
|
-
const l =
|
|
57
|
+
function ee(o, n, r = 2) {
|
|
58
|
+
const l = n * r;
|
|
59
59
|
return Math.min(o, l);
|
|
60
60
|
}
|
|
61
|
-
function q(o,
|
|
61
|
+
function q(o, n, r, l, u, f) {
|
|
62
62
|
const s = o.length;
|
|
63
63
|
if (f >= s || f <= 1 || s === 0)
|
|
64
64
|
return {
|
|
65
65
|
x: new Float32Array(o),
|
|
66
|
-
open: new Float32Array(
|
|
67
|
-
high: new Float32Array(
|
|
66
|
+
open: new Float32Array(n),
|
|
67
|
+
high: new Float32Array(r),
|
|
68
68
|
low: new Float32Array(l),
|
|
69
69
|
close: new Float32Array(u),
|
|
70
70
|
indices: new Uint32Array(Array.from({ length: s }, (y, w) => w))
|
|
@@ -75,8 +75,8 @@ function q(o, r, n, l, u, f) {
|
|
|
75
75
|
if (w >= V) continue;
|
|
76
76
|
let v = -1 / 0, b = 1 / 0, M = w;
|
|
77
77
|
for (let S = w; S < V; S++)
|
|
78
|
-
|
|
79
|
-
p.push(
|
|
78
|
+
r[S] > v && (v = r[S]), l[S] < b && (b = l[S]), M = S;
|
|
79
|
+
p.push(n[w]), g.push(v), F.push(b), z.push(u[M]), h.push(o[M]), x.push(M);
|
|
80
80
|
}
|
|
81
81
|
return {
|
|
82
82
|
x: new Float32Array(h),
|
|
@@ -87,27 +87,27 @@ function q(o, r, n, l, u, f) {
|
|
|
87
87
|
indices: new Uint32Array(x)
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
function te(o,
|
|
91
|
-
let
|
|
92
|
-
for (;
|
|
93
|
-
const u =
|
|
94
|
-
o[u] <
|
|
90
|
+
function te(o, n) {
|
|
91
|
+
let r = 0, l = o.length;
|
|
92
|
+
for (; r < l; ) {
|
|
93
|
+
const u = r + l >>> 1;
|
|
94
|
+
o[u] < n ? r = u + 1 : l = u;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return r;
|
|
97
97
|
}
|
|
98
|
-
function ne(o,
|
|
99
|
-
let
|
|
100
|
-
for (;
|
|
101
|
-
const u =
|
|
102
|
-
o[u] <=
|
|
98
|
+
function ne(o, n) {
|
|
99
|
+
let r = 0, l = o.length;
|
|
100
|
+
for (; r < l; ) {
|
|
101
|
+
const u = r + l >>> 1;
|
|
102
|
+
o[u] <= n ? r = u + 1 : l = u;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return r;
|
|
105
105
|
}
|
|
106
|
-
function re(o,
|
|
106
|
+
function re(o, n, r, l = 0.5) {
|
|
107
107
|
const u = o.x.length;
|
|
108
108
|
if (u === 0)
|
|
109
109
|
return { x: new Float32Array(0), start: 0, end: 0 };
|
|
110
|
-
const f = Math.max(
|
|
110
|
+
const f = Math.max(r - n, 1e-12), s = n - f * l, c = r + f * l;
|
|
111
111
|
let h = te(o.x, s), p = ne(o.x, c);
|
|
112
112
|
h = Math.max(0, h), p = Math.min(u, Math.max(p, h + 1));
|
|
113
113
|
const g = (F) => {
|
|
@@ -138,10 +138,10 @@ function J() {
|
|
|
138
138
|
syncFallback: !0,
|
|
139
139
|
syncHandler: (o) => {
|
|
140
140
|
if (o.type === "downsample") {
|
|
141
|
-
const
|
|
142
|
-
return { id: o.id, type: "downsample-result", x:
|
|
141
|
+
const r = o.algorithm === "minmax" ? G(o.x, o.y, Math.ceil(o.targetPoints / 2)) : R(o.x, o.y, o.targetPoints);
|
|
142
|
+
return { id: o.id, type: "downsample-result", x: r.x, y: r.y };
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const n = q(
|
|
145
145
|
o.x,
|
|
146
146
|
o.open,
|
|
147
147
|
o.high,
|
|
@@ -152,23 +152,23 @@ function J() {
|
|
|
152
152
|
return {
|
|
153
153
|
id: o.id,
|
|
154
154
|
type: "ohlc-downsample-result",
|
|
155
|
-
x:
|
|
156
|
-
open:
|
|
157
|
-
high:
|
|
158
|
-
low:
|
|
159
|
-
close:
|
|
155
|
+
x: n.x,
|
|
156
|
+
open: n.open,
|
|
157
|
+
high: n.high,
|
|
158
|
+
low: n.low,
|
|
159
|
+
close: n.close
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
), I);
|
|
164
164
|
}
|
|
165
|
-
async function oe(o,
|
|
165
|
+
async function oe(o, n, r, l = "lttb") {
|
|
166
166
|
const u = H("downsample"), f = await J().run({
|
|
167
167
|
id: u,
|
|
168
168
|
type: "downsample",
|
|
169
169
|
x: o,
|
|
170
|
-
y:
|
|
171
|
-
targetPoints:
|
|
170
|
+
y: n,
|
|
171
|
+
targetPoints: r,
|
|
172
172
|
algorithm: l
|
|
173
173
|
});
|
|
174
174
|
if (f.type !== "downsample-result")
|
|
@@ -179,13 +179,13 @@ async function oe(o, r, n, l = "lttb") {
|
|
|
179
179
|
indices: new Uint32Array(f.x.length)
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
async function ae(o,
|
|
182
|
+
async function ae(o, n, r, l, u, f) {
|
|
183
183
|
const s = H("ohlc-downsample"), c = await J().run({
|
|
184
184
|
id: s,
|
|
185
185
|
type: "ohlc-downsample",
|
|
186
186
|
x: o,
|
|
187
|
-
open:
|
|
188
|
-
high:
|
|
187
|
+
open: n,
|
|
188
|
+
high: r,
|
|
189
189
|
low: l,
|
|
190
190
|
close: u,
|
|
191
191
|
targetBars: f
|
|
@@ -231,17 +231,17 @@ const le = {
|
|
|
231
231
|
workerThreshold: 25e4
|
|
232
232
|
};
|
|
233
233
|
function de(o = {}) {
|
|
234
|
-
const
|
|
235
|
-
let
|
|
234
|
+
const n = { ...ie, ...o };
|
|
235
|
+
let r = null, l = !1;
|
|
236
236
|
const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
237
237
|
let s = null, c = null, h = 0;
|
|
238
238
|
const p = /* @__PURE__ */ new Map();
|
|
239
239
|
let g = "";
|
|
240
240
|
function F(e, ...t) {
|
|
241
|
-
|
|
241
|
+
n.debug && r && r.log.info(`[Virtualization] ${e}`, ...t);
|
|
242
242
|
}
|
|
243
243
|
function z(e) {
|
|
244
|
-
if (!
|
|
244
|
+
if (!n.enabled || n.precision === "full" || n.includeSeries.length > 0 && !n.includeSeries.includes(e.getId()) || n.excludeSeries.includes(e.getId())) return !1;
|
|
245
245
|
const t = e.getType();
|
|
246
246
|
return t === "line" || t === "scatter" || t === "line+scatter" || t === "step" || t === "step+scatter" || t === "candlestick" || t === "bar";
|
|
247
247
|
}
|
|
@@ -258,10 +258,9 @@ function de(o = {}) {
|
|
|
258
258
|
} : { x: e.x, y: e.y };
|
|
259
259
|
}
|
|
260
260
|
function w(e) {
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return ee(e, t, r.pointsPerPixel);
|
|
261
|
+
if (n.targetPoints !== "auto") return Math.max(2, n.targetPoints);
|
|
262
|
+
const t = r.render.canvasSize.width / r.render.pixelRatio;
|
|
263
|
+
return ee(e, t, n.pointsPerPixel);
|
|
265
264
|
}
|
|
266
265
|
function V(e, t, a, i) {
|
|
267
266
|
if (a >= e.length || e.length <= 2)
|
|
@@ -274,7 +273,7 @@ function de(o = {}) {
|
|
|
274
273
|
return { x: d.x, y: d.y };
|
|
275
274
|
}
|
|
276
275
|
function v(e, t) {
|
|
277
|
-
|
|
276
|
+
n.reuseOriginalData && u.set(e, { ...t });
|
|
278
277
|
}
|
|
279
278
|
function b(e) {
|
|
280
279
|
return u.get(e) ?? null;
|
|
@@ -309,19 +308,18 @@ function de(o = {}) {
|
|
|
309
308
|
const a = { x: t.x, y: t.y };
|
|
310
309
|
return v(e.getId(), a), a;
|
|
311
310
|
}
|
|
312
|
-
function
|
|
311
|
+
function B(e) {
|
|
313
312
|
return b(e.getId()) ?? S(e);
|
|
314
313
|
}
|
|
315
314
|
function D(e) {
|
|
316
315
|
var i, d;
|
|
317
|
-
|
|
318
|
-
const t = (d = (i = n.data).getViewBounds) == null ? void 0 : d.call(i);
|
|
316
|
+
const t = (d = (i = r.data).getViewBounds) == null ? void 0 : d.call(i);
|
|
319
317
|
if (!t) return e;
|
|
320
318
|
const a = re(
|
|
321
319
|
e,
|
|
322
320
|
t.xMin,
|
|
323
321
|
t.xMax,
|
|
324
|
-
|
|
322
|
+
n.viewportBuffer
|
|
325
323
|
);
|
|
326
324
|
return a.end - a.start >= e.x.length ? e : {
|
|
327
325
|
x: a.x,
|
|
@@ -332,12 +330,12 @@ function de(o = {}) {
|
|
|
332
330
|
close: a.close
|
|
333
331
|
};
|
|
334
332
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
333
|
+
function L(e, t) {
|
|
334
|
+
l = !0, s(e, t), l = !1;
|
|
337
335
|
}
|
|
338
336
|
async function K(e, t, a) {
|
|
339
337
|
const i = new Float32Array(e.x), d = new Float32Array(e.y);
|
|
340
|
-
if (
|
|
338
|
+
if (n.useWorker && i.length >= n.workerThreshold) {
|
|
341
339
|
const A = await oe(i, d, t, a === "minmax" ? "minmax" : "lttb");
|
|
342
340
|
return { x: A.x, y: A.y };
|
|
343
341
|
}
|
|
@@ -345,85 +343,85 @@ function de(o = {}) {
|
|
|
345
343
|
}
|
|
346
344
|
async function W(e) {
|
|
347
345
|
var E;
|
|
348
|
-
if (!
|
|
346
|
+
if (!r || !s) return;
|
|
349
347
|
const t = e.getId();
|
|
350
348
|
if (!z(e)) {
|
|
351
349
|
const O = b(t);
|
|
352
|
-
O &&
|
|
350
|
+
O && n.reuseOriginalData && L(t, y(O));
|
|
353
351
|
return;
|
|
354
352
|
}
|
|
355
|
-
const a =
|
|
353
|
+
const a = B(e);
|
|
356
354
|
if (!((E = a == null ? void 0 : a.x) != null && E.length)) return;
|
|
357
355
|
const i = D(a), d = (p.get(t) ?? 0) + 1;
|
|
358
356
|
if (p.set(t, d), x(e)) {
|
|
359
357
|
if (!i.open || !i.high || !i.low || !i.close)
|
|
360
358
|
return;
|
|
361
|
-
const O = w(i.x.length), T = new Float32Array(i.x), $ = new Float32Array(i.open), j = new Float32Array(i.high), C = new Float32Array(i.low), _ = new Float32Array(i.close),
|
|
359
|
+
const O = w(i.x.length), T = new Float32Array(i.x), $ = new Float32Array(i.open), j = new Float32Array(i.high), C = new Float32Array(i.low), _ = new Float32Array(i.close), P = n.useWorker && T.length >= n.workerThreshold ? await ae(T, $, j, C, _, O) : q(T, $, j, C, _, O);
|
|
362
360
|
if (p.get(t) !== d) return;
|
|
363
|
-
|
|
364
|
-
x:
|
|
365
|
-
open:
|
|
366
|
-
high:
|
|
367
|
-
low:
|
|
368
|
-
close:
|
|
369
|
-
}), M(t, a.x.length,
|
|
361
|
+
L(t, {
|
|
362
|
+
x: P.x,
|
|
363
|
+
open: P.open,
|
|
364
|
+
high: P.high,
|
|
365
|
+
low: P.low,
|
|
366
|
+
close: P.close
|
|
367
|
+
}), M(t, a.x.length, P.x.length, O, n.mode, "minmax");
|
|
370
368
|
return;
|
|
371
369
|
}
|
|
372
370
|
if (!i.y) return;
|
|
373
|
-
const m = w(i.x.length), A = e.getType() === "bar" ? "minmax" :
|
|
374
|
-
p.get(t) === d && (
|
|
371
|
+
const m = w(i.x.length), A = e.getType() === "bar" ? "minmax" : n.strategy, U = await K(i, m, A);
|
|
372
|
+
p.get(t) === d && (L(t, { x: U.x, y: U.y }), M(t, a.x.length, U.x.length, m, n.mode, A));
|
|
375
373
|
}
|
|
376
|
-
function
|
|
377
|
-
|
|
374
|
+
function k() {
|
|
375
|
+
r && r.data.getAllSeries().forEach((e) => {
|
|
378
376
|
W(e);
|
|
379
377
|
});
|
|
380
378
|
}
|
|
381
379
|
function X() {
|
|
382
380
|
var t, a;
|
|
383
|
-
if (!
|
|
384
|
-
const e = (a = (t =
|
|
381
|
+
if (!r) return;
|
|
382
|
+
const e = (a = (t = r.data).getViewBounds) == null ? void 0 : a.call(t);
|
|
385
383
|
if (e) {
|
|
386
|
-
const i = `${e.xMin}:${e.xMax}:${e.yMin}:${e.yMax}:${
|
|
384
|
+
const i = `${e.xMin}:${e.xMax}:${e.yMin}:${e.yMax}:${r.render.canvasSize.width}`;
|
|
387
385
|
if (i === g) return;
|
|
388
386
|
g = i;
|
|
389
387
|
}
|
|
390
388
|
h || (h = requestAnimationFrame(() => {
|
|
391
|
-
h = 0,
|
|
389
|
+
h = 0, k();
|
|
392
390
|
}));
|
|
393
391
|
}
|
|
394
392
|
function N(e, t) {
|
|
395
393
|
var m, A, U, E;
|
|
396
|
-
if (!
|
|
397
|
-
if (!
|
|
394
|
+
if (!r || !s) return;
|
|
395
|
+
if (!n.enabled || l) {
|
|
398
396
|
s(e, t);
|
|
399
397
|
return;
|
|
400
398
|
}
|
|
401
|
-
if (!((A = (m =
|
|
399
|
+
if (!((A = (m = r.chart).getSeries) == null ? void 0 : A.call(m, e))) {
|
|
402
400
|
s(e, t);
|
|
403
401
|
return;
|
|
404
402
|
}
|
|
405
403
|
const i = b(e);
|
|
406
|
-
i &&
|
|
407
|
-
const d = (E = (U =
|
|
404
|
+
i && n.reuseOriginalData && (l = !0, s(e, y(i)), l = !1), s(e, t);
|
|
405
|
+
const d = (E = (U = r.chart).getSeries) == null ? void 0 : E.call(U, e);
|
|
408
406
|
d && (u.delete(e), S(d), W(d));
|
|
409
407
|
}
|
|
410
408
|
function Q(e, t, a) {
|
|
411
409
|
var A, U, E, O;
|
|
412
|
-
if (!
|
|
413
|
-
if (!
|
|
410
|
+
if (!r || !c || !s) return;
|
|
411
|
+
if (!n.enabled || l) {
|
|
414
412
|
c(e, t, a);
|
|
415
413
|
return;
|
|
416
414
|
}
|
|
417
|
-
if (!((U = (A =
|
|
415
|
+
if (!((U = (A = r.chart).getSeries) == null ? void 0 : U.call(A, e))) {
|
|
418
416
|
c(e, t, a);
|
|
419
417
|
return;
|
|
420
418
|
}
|
|
421
419
|
const d = b(e);
|
|
422
|
-
d &&
|
|
423
|
-
const m = (O = (E =
|
|
420
|
+
d && n.reuseOriginalData && (l = !0, s(e, y(d)), l = !1), c(e, t, a);
|
|
421
|
+
const m = (O = (E = r.chart).getSeries) == null ? void 0 : O.call(E, e);
|
|
424
422
|
if (m) {
|
|
425
423
|
const T = b(e);
|
|
426
|
-
T != null && T.y &&
|
|
424
|
+
T != null && T.y && n.reuseOriginalData ? u.set(e, {
|
|
427
425
|
x: Y(T.x, t),
|
|
428
426
|
y: Y(T.y, a)
|
|
429
427
|
}) : (u.delete(e), S(m)), W(m);
|
|
@@ -437,42 +435,42 @@ function de(o = {}) {
|
|
|
437
435
|
manifest: le,
|
|
438
436
|
onInit(e) {
|
|
439
437
|
var a, i;
|
|
440
|
-
|
|
441
|
-
const t =
|
|
442
|
-
s = ((a = t.updateSeries) == null ? void 0 : a.bind(t)) ?? null, c = ((i = t.appendData) == null ? void 0 : i.bind(t)) ?? null, s && (t.updateSeries = (d, m) => N(d, m)), c && (t.appendData = (d, m, A) => Q(d, m, A)),
|
|
438
|
+
r = e;
|
|
439
|
+
const t = r.chart;
|
|
440
|
+
s = ((a = t.updateSeries) == null ? void 0 : a.bind(t)) ?? null, c = ((i = t.appendData) == null ? void 0 : i.bind(t)) ?? null, s && (t.updateSeries = (d, m) => N(d, m)), c && (t.appendData = (d, m, A) => Q(d, m, A)), r.events.on("zoom", () => X()), r.events.on("pan", () => X()), r.events.on("resize", () => {
|
|
443
441
|
g = "", X();
|
|
444
|
-
}),
|
|
442
|
+
}), k(), F("Initialized");
|
|
445
443
|
},
|
|
446
444
|
onDestroy(e) {
|
|
447
|
-
h && cancelAnimationFrame(h), h = 0, p.clear(), s && (e.chart.updateSeries = s), c && (e.chart.appendData = c),
|
|
445
|
+
h && cancelAnimationFrame(h), h = 0, p.clear(), s && (e.chart.updateSeries = s), c && (e.chart.appendData = c), r = null, u.clear(), f.clear();
|
|
448
446
|
},
|
|
449
447
|
api: {
|
|
450
448
|
enable() {
|
|
451
|
-
|
|
449
|
+
n.enabled = !0, k();
|
|
452
450
|
},
|
|
453
451
|
disable() {
|
|
454
|
-
if (
|
|
452
|
+
if (n.enabled = !1, !r || !s) return;
|
|
455
453
|
const e = s;
|
|
456
|
-
|
|
454
|
+
r.data.getAllSeries().forEach((t) => {
|
|
457
455
|
const a = b(t.getId());
|
|
458
456
|
a && (l = !0, e(t.getId(), y(a)), l = !1);
|
|
459
457
|
});
|
|
460
458
|
},
|
|
461
459
|
isEnabled() {
|
|
462
|
-
return
|
|
460
|
+
return n.enabled;
|
|
463
461
|
},
|
|
464
462
|
updateConfig(e) {
|
|
465
|
-
Object.assign(
|
|
463
|
+
Object.assign(n, e), k();
|
|
466
464
|
},
|
|
467
465
|
invalidate(e) {
|
|
468
466
|
var t, a;
|
|
469
|
-
if (
|
|
467
|
+
if (r) {
|
|
470
468
|
if (e) {
|
|
471
|
-
const i = (a = (t =
|
|
469
|
+
const i = (a = (t = r.chart).getSeries) == null ? void 0 : a.call(t, e);
|
|
472
470
|
i && W(i);
|
|
473
471
|
return;
|
|
474
472
|
}
|
|
475
|
-
|
|
473
|
+
k();
|
|
476
474
|
}
|
|
477
475
|
},
|
|
478
476
|
getStats(e) {
|
|
@@ -486,16 +484,16 @@ function de(o = {}) {
|
|
|
486
484
|
}
|
|
487
485
|
export {
|
|
488
486
|
de as P,
|
|
489
|
-
|
|
490
|
-
|
|
487
|
+
ce as a,
|
|
488
|
+
q as b,
|
|
491
489
|
ee as c,
|
|
492
490
|
oe as d,
|
|
493
|
-
|
|
491
|
+
te as e,
|
|
494
492
|
fe as g,
|
|
495
493
|
R as l,
|
|
496
494
|
G as m,
|
|
497
|
-
|
|
495
|
+
ae as o,
|
|
498
496
|
re as s,
|
|
499
497
|
ne as u
|
|
500
498
|
};
|
|
501
|
-
//# sourceMappingURL=index-
|
|
499
|
+
//# sourceMappingURL=index-0InEyj0q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-0InEyj0q.js","sources":["../src/workers/downsample.ts","../src/workers/downsampleAsync.ts","../src/plugins/virtualization/index.ts"],"sourcesContent":["/**\n * LTTB (Largest-Triangle-Three-Buckets) Downsampling Algorithm\n *\n * This algorithm downsamples time-series data while preserving visual features.\n * It's much better than naive sampling for preserving peaks and valleys.\n *\n * Reference: https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf\n */\n\nexport interface DownsampleResult {\n x: Float32Array;\n y: Float32Array;\n /** Original indices of selected points */\n indices: Uint32Array;\n}\n\n/**\n * Downsample data using LTTB algorithm\n *\n * @param x - X values (e.g., potential)\n * @param y - Y values (e.g., current)\n * @param targetPoints - Number of output points\n * @returns Downsampled data\n */\nexport function lttbDownsample(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n targetPoints: number\n): DownsampleResult {\n const length = x.length;\n\n // No need to downsample\n if (targetPoints >= length || targetPoints <= 2) {\n return {\n x: new Float32Array(x),\n y: new Float32Array(y),\n indices: new Uint32Array(Array.from({ length }, (_, i) => i)),\n };\n }\n\n const outX = new Float32Array(targetPoints);\n const outY = new Float32Array(targetPoints);\n const outIndices = new Uint32Array(targetPoints);\n\n // Always include first point\n outX[0] = x[0];\n outY[0] = y[0];\n outIndices[0] = 0;\n\n // Bucket size\n const bucketSize = (length - 2) / (targetPoints - 2);\n\n let a = 0; // Previous selected point index\n let outIdx = 1;\n\n for (let i = 0; i < targetPoints - 2; i++) {\n // Calculate bucket boundaries\n const bucketStart = Math.floor((i + 1) * bucketSize) + 1;\n const bucketEnd = Math.floor((i + 2) * bucketSize) + 1;\n\n // Calculate average point of next bucket\n const nextBucketStart = Math.min(bucketEnd, length - 1);\n const nextBucketEnd = Math.min(\n Math.floor((i + 3) * bucketSize) + 1,\n length\n );\n\n let avgX = 0;\n let avgY = 0;\n let avgCount = 0;\n\n for (let j = nextBucketStart; j < nextBucketEnd; j++) {\n avgX += x[j];\n avgY += y[j];\n avgCount++;\n }\n\n if (avgCount > 0) {\n avgX /= avgCount;\n avgY /= avgCount;\n }\n\n // Find point in current bucket with largest triangle area\n let maxArea = -1;\n let maxIndex = bucketStart;\n\n const aX = x[a];\n const aY = y[a];\n\n for (let j = bucketStart; j < bucketEnd && j < length; j++) {\n // Calculate triangle area (simplified: |x1(y2-y3) + x2(y3-y1) + x3(y1-y2)| / 2)\n const area = Math.abs(\n (aX - avgX) * (y[j] - aY) - (aX - x[j]) * (avgY - aY)\n );\n\n if (area > maxArea) {\n maxArea = area;\n maxIndex = j;\n }\n }\n\n // Store selected point\n outX[outIdx] = x[maxIndex];\n outY[outIdx] = y[maxIndex];\n outIndices[outIdx] = maxIndex;\n\n a = maxIndex;\n outIdx++;\n }\n\n // Always include last point\n outX[targetPoints - 1] = x[length - 1];\n outY[targetPoints - 1] = y[length - 1];\n outIndices[targetPoints - 1] = length - 1;\n\n return { x: outX, y: outY, indices: outIndices };\n}\n\n/**\n * Min-Max per bucket downsampling\n *\n * Simpler alternative to LTTB that preserves extremes in each bucket.\n * Uses 2 points per bucket (min and max), so output is ~2x target.\n */\nexport function minMaxDownsample(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n bucketCount: number\n): DownsampleResult {\n const length = x.length;\n\n if (bucketCount >= length / 2) {\n return {\n x: new Float32Array(x),\n y: new Float32Array(y),\n indices: new Uint32Array(Array.from({ length }, (_, i) => i)),\n };\n }\n\n const bucketSize = length / bucketCount;\n const outX: number[] = [];\n const outY: number[] = [];\n const outIndices: number[] = [];\n\n for (let b = 0; b < bucketCount; b++) {\n const start = Math.floor(b * bucketSize);\n const end = Math.floor((b + 1) * bucketSize);\n\n let minY = Infinity;\n let maxY = -Infinity;\n let minIdx = start;\n let maxIdx = start;\n\n for (let i = start; i < end && i < length; i++) {\n if (y[i] < minY) {\n minY = y[i];\n minIdx = i;\n }\n if (y[i] > maxY) {\n maxY = y[i];\n maxIdx = i;\n }\n }\n\n // Add points in order (min first if it comes before max)\n if (minIdx <= maxIdx) {\n outX.push(x[minIdx], x[maxIdx]);\n outY.push(y[minIdx], y[maxIdx]);\n outIndices.push(minIdx, maxIdx);\n } else {\n outX.push(x[maxIdx], x[minIdx]);\n outY.push(y[maxIdx], y[minIdx]);\n outIndices.push(maxIdx, minIdx);\n }\n }\n\n return {\n x: new Float32Array(outX),\n y: new Float32Array(outY),\n indices: new Uint32Array(outIndices),\n };\n}\n\n/**\n * Calculate optimal target points based on canvas width\n */\nexport function calculateTargetPoints(\n dataLength: number,\n canvasWidth: number,\n pointsPerPixel = 2\n): number {\n // Never draw more than pointsPerPixel per pixel\n const maxPoints = canvasWidth * pointsPerPixel;\n return Math.min(dataLength, maxPoints);\n}\n\nexport interface OhlcDownsampleResult {\n x: Float32Array;\n open: Float32Array;\n high: Float32Array;\n low: Float32Array;\n close: Float32Array;\n indices: Uint32Array;\n}\n\n/**\n * Aggregate OHLC bars into fewer buckets while preserving extremes.\n * Each bucket: open=first open, close=last close, high=max high, low=min low, x=last x.\n */\nexport function ohlcMinMaxDownsample(\n x: Float32Array | Float64Array,\n open: Float32Array | Float64Array,\n high: Float32Array | Float64Array,\n low: Float32Array | Float64Array,\n close: Float32Array | Float64Array,\n targetBars: number,\n): OhlcDownsampleResult {\n const length = x.length;\n if (targetBars >= length || targetBars <= 1 || length === 0) {\n return {\n x: new Float32Array(x),\n open: new Float32Array(open),\n high: new Float32Array(high),\n low: new Float32Array(low),\n close: new Float32Array(close),\n indices: new Uint32Array(Array.from({ length }, (_, i) => i)),\n };\n }\n\n const bucketSize = length / targetBars;\n const outX: number[] = [];\n const outOpen: number[] = [];\n const outHigh: number[] = [];\n const outLow: number[] = [];\n const outClose: number[] = [];\n const outIndices: number[] = [];\n\n for (let b = 0; b < targetBars; b++) {\n const start = Math.floor(b * bucketSize);\n const end = Math.min(length, Math.floor((b + 1) * bucketSize));\n if (start >= end) continue;\n\n let hi = -Infinity;\n let lo = Infinity;\n let lastIdx = start;\n\n for (let i = start; i < end; i++) {\n if (high[i] > hi) hi = high[i];\n if (low[i] < lo) lo = low[i];\n lastIdx = i;\n }\n\n outOpen.push(open[start]);\n outHigh.push(hi);\n outLow.push(lo);\n outClose.push(close[lastIdx]);\n outX.push(x[lastIdx]);\n outIndices.push(lastIdx);\n }\n\n return {\n x: new Float32Array(outX),\n open: new Float32Array(outOpen),\n high: new Float32Array(outHigh),\n low: new Float32Array(outLow),\n close: new Float32Array(outClose),\n indices: new Uint32Array(outIndices),\n };\n}\n\n/** Binary search lower bound: first index where x[i] >= value */\nexport function lowerBoundX(\n x: Float32Array | Float64Array,\n value: number,\n): number {\n let lo = 0;\n let hi = x.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (x[mid] < value) lo = mid + 1;\n else hi = mid;\n }\n return lo;\n}\n\n/** Binary search upper bound: first index where x[i] > value */\nexport function upperBoundX(\n x: Float32Array | Float64Array,\n value: number,\n): number {\n let lo = 0;\n let hi = x.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (x[mid] <= value) lo = mid + 1;\n else hi = mid;\n }\n return lo;\n}\n\nexport interface ViewportSlice {\n x: Float32Array;\n y?: Float32Array;\n open?: Float32Array;\n high?: Float32Array;\n low?: Float32Array;\n close?: Float32Array;\n start: number;\n end: number;\n}\n\n/**\n * Slice sorted x-series to visible range plus buffer (fraction of visible width).\n */\nexport function sliceSeriesToViewport(\n source: {\n x: Float32Array | Float64Array;\n y?: Float32Array | Float64Array;\n open?: Float32Array | Float64Array;\n high?: Float32Array | Float64Array;\n low?: Float32Array | Float64Array;\n close?: Float32Array | Float64Array;\n },\n xMin: number,\n xMax: number,\n bufferRatio = 0.5,\n): ViewportSlice {\n const length = source.x.length;\n if (length === 0) {\n return { x: new Float32Array(0), start: 0, end: 0 };\n }\n\n const range = Math.max(xMax - xMin, 1e-12);\n const paddedMin = xMin - range * bufferRatio;\n const paddedMax = xMax + range * bufferRatio;\n\n let start = lowerBoundX(source.x, paddedMin);\n let end = upperBoundX(source.x, paddedMax);\n start = Math.max(0, start);\n end = Math.min(length, Math.max(end, start + 1));\n\n const slice = <T extends Float32Array | Float64Array>(arr: T | undefined): Float32Array | undefined => {\n if (!arr) return undefined;\n return new Float32Array(arr.subarray(start, end));\n };\n\n return {\n x: new Float32Array(source.x.subarray(start, end)),\n y: slice(source.y),\n open: slice(source.open),\n high: slice(source.high),\n low: slice(source.low),\n close: slice(source.close),\n start,\n end,\n };\n}\n","/**\n * Async downsampling via shared worker pool (main-thread fallback in Node/tests).\n * @module workers/downsampleAsync\n */\n\nimport {\n lttbDownsample,\n minMaxDownsample,\n ohlcMinMaxDownsample,\n type OhlcDownsampleResult,\n type DownsampleResult,\n} from \"./downsample\";\nimport { WorkerPool, nextTaskId } from \"./pool\";\n\ntype DownsampleTask = {\n id: string;\n type: \"downsample\";\n x: Float32Array;\n y: Float32Array;\n targetPoints: number;\n algorithm: \"lttb\" | \"minmax\";\n};\n\ntype OhlcDownsampleTask = {\n id: string;\n type: \"ohlc-downsample\";\n x: Float32Array;\n open: Float32Array;\n high: Float32Array;\n low: Float32Array;\n close: Float32Array;\n targetBars: number;\n};\n\ntype DownsampleWorkerResult =\n | {\n id: string;\n type: \"downsample-result\";\n x: Float32Array;\n y: Float32Array;\n }\n | {\n id: string;\n type: \"ohlc-downsample-result\";\n x: Float32Array;\n open: Float32Array;\n high: Float32Array;\n low: Float32Array;\n close: Float32Array;\n }\n | { id: string; type: \"error\"; error: string };\n\nlet pool: WorkerPool<DownsampleTask | OhlcDownsampleTask, DownsampleWorkerResult> | null = null;\n\nfunction getPool() {\n if (pool) return pool;\n\n pool = new WorkerPool<DownsampleTask | OhlcDownsampleTask, DownsampleWorkerResult>(\n () => new Worker(new URL(\"./downsample.worker.ts\", import.meta.url), { type: \"module\" }),\n {\n poolSize: 2,\n syncFallback: true,\n syncHandler: (task) => {\n if (task.type === \"downsample\") {\n const result =\n task.algorithm === \"minmax\"\n ? minMaxDownsample(task.x, task.y, Math.ceil(task.targetPoints / 2))\n : lttbDownsample(task.x, task.y, task.targetPoints);\n return { id: task.id, type: \"downsample-result\", x: result.x, y: result.y };\n }\n\n const result = ohlcMinMaxDownsample(\n task.x,\n task.open,\n task.high,\n task.low,\n task.close,\n task.targetBars,\n );\n return {\n id: task.id,\n type: \"ohlc-downsample-result\",\n x: result.x,\n open: result.open,\n high: result.high,\n low: result.low,\n close: result.close,\n };\n },\n },\n );\n\n return pool;\n}\n\nexport async function downsampleAsync(\n x: Float32Array,\n y: Float32Array,\n targetPoints: number,\n algorithm: \"lttb\" | \"minmax\" = \"lttb\",\n): Promise<DownsampleResult> {\n const id = nextTaskId(\"downsample\");\n const result = await getPool().run({\n id,\n type: \"downsample\",\n x,\n y,\n targetPoints,\n algorithm,\n });\n\n // Worker/pool failures surface as a rejected run() promise (sync fallback or\n // reject), so a resolved value is always a success payload; we only guard the\n // shape here.\n if (result.type !== \"downsample-result\") {\n throw new Error(\"Unexpected downsample worker response\");\n }\n\n return {\n x: result.x,\n y: result.y,\n indices: new Uint32Array(result.x.length),\n };\n}\n\nexport async function ohlcDownsampleAsync(\n x: Float32Array,\n open: Float32Array,\n high: Float32Array,\n low: Float32Array,\n close: Float32Array,\n targetBars: number,\n): Promise<OhlcDownsampleResult> {\n const id = nextTaskId(\"ohlc-downsample\");\n const result = await getPool().run({\n id,\n type: \"ohlc-downsample\",\n x,\n open,\n high,\n low,\n close,\n targetBars,\n });\n\n if (result.type !== \"ohlc-downsample-result\") {\n throw new Error(\"Unexpected OHLC downsample worker response\");\n }\n\n return {\n x: result.x,\n open: result.open,\n high: result.high,\n low: result.low,\n close: result.close,\n indices: new Uint32Array(result.x.length),\n };\n}\n\nexport function destroyDownsamplePool(): void {\n pool?.destroy();\n pool = null;\n}\n\nexport function getDownsamplePoolSize(): number {\n return pool?.size() ?? 0;\n}\n","/**\n * @fileoverview Data virtualization plugin (LOD/min-max)\n * @module plugins/virtualization\n */\n\nimport type {\n PluginVirtualizationConfig,\n VirtualizationAPI,\n VirtualizationStats,\n VirtualizationMode,\n VirtualizationStrategy,\n} from \"./types\";\nimport type { ChartPlugin, PluginContext, PluginManifest } from \"../types\";\nimport type { Series } from \"../../core/Series\";\nimport type { SeriesUpdateData } from \"../../types\";\nimport {\n lttbDownsample,\n minMaxDownsample,\n ohlcMinMaxDownsample,\n calculateTargetPoints,\n sliceSeriesToViewport,\n} from \"../../workers/downsample\";\nimport { downsampleAsync, ohlcDownsampleAsync } from \"../../workers/downsampleAsync\";\n\nconst manifest: PluginManifest = {\n name: \"velo-plot-virtualization\",\n version: \"1.0.0\",\n description: \"Viewport-aware data virtualization with LOD strategies\",\n provides: [\"performance\", \"data-virtualization\"],\n tags: [\"performance\", \"lod\", \"virtualization\"],\n};\n\nconst DEFAULT_CONFIG: Required<PluginVirtualizationConfig> = {\n enabled: true,\n precision: \"lod\",\n mode: \"lod\",\n targetPoints: \"auto\",\n pointsPerPixel: 2,\n lodLevels: [1, 4, 8, 16],\n strategy: \"lttb\",\n reuseOriginalData: true,\n syncWithLazyLoad: true,\n includeSeries: [],\n excludeSeries: [],\n debug: false,\n viewportBuffer: 0.5,\n useWorker: true,\n workerThreshold: 250_000,\n};\n\ntype SeriesCache = {\n x: Float32Array | Float64Array;\n y?: Float32Array | Float64Array;\n open?: Float32Array | Float64Array;\n high?: Float32Array | Float64Array;\n low?: Float32Array | Float64Array;\n close?: Float32Array | Float64Array;\n};\n\nexport function PluginVirtualization(\n userConfig: Partial<PluginVirtualizationConfig> = {}\n): ChartPlugin<PluginVirtualizationConfig> {\n const config = { ...DEFAULT_CONFIG, ...userConfig };\n let ctx: PluginContext | null = null;\n let isInternalUpdate = false;\n\n const originalData = new Map<string, SeriesCache>();\n const stats = new Map<string, VirtualizationStats>();\n\n let originalUpdateSeries: ((id: string, data: SeriesUpdateData) => void) | null = null;\n let originalAppendData: ((id: string, x: number[] | Float32Array, y: number[] | Float32Array) => void) | null = null;\n let refreshRaf = 0;\n const applyGeneration = new Map<string, number>();\n let lastViewKey = \"\";\n\n function log(message: string, ...args: unknown[]) {\n if (config.debug && ctx) {\n ctx.log.info(`[Virtualization] ${message}`, ...args);\n }\n }\n\n function shouldVirtualize(series: Series): boolean {\n if (!config.enabled) return false;\n if (config.precision === \"full\") return false;\n if (config.includeSeries.length > 0 && !config.includeSeries.includes(series.getId())) return false;\n if (config.excludeSeries.includes(series.getId())) return false;\n\n const type = series.getType();\n return (\n type === \"line\" ||\n type === \"scatter\" ||\n type === \"line+scatter\" ||\n type === \"step\" ||\n type === \"step+scatter\" ||\n type === \"candlestick\" ||\n type === \"bar\"\n );\n }\n\n function isOhlcSeries(series: Series): boolean {\n return series.getType() === \"candlestick\";\n }\n\n function buildUpdatePayload(cache: SeriesCache): SeriesUpdateData {\n if (cache.open && cache.high && cache.low && cache.close) {\n return {\n x: cache.x,\n open: cache.open,\n high: cache.high,\n low: cache.low,\n close: cache.close,\n };\n }\n return { x: cache.x, y: cache.y! };\n }\n\n function getTargetPoints(dataLength: number): number {\n if (config.targetPoints !== \"auto\") return Math.max(2, config.targetPoints);\n const width = ctx!.render.canvasSize.width / ctx!.render.pixelRatio;\n return calculateTargetPoints(dataLength, width, config.pointsPerPixel);\n }\n\n function downsampleData(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n targetPoints: number,\n strategy: VirtualizationStrategy\n ): { x: Float32Array; y: Float32Array } {\n if (targetPoints >= x.length || x.length <= 2) {\n return { x: new Float32Array(x), y: new Float32Array(y) };\n }\n\n if (strategy === \"minmax\") {\n const bucketCount = Math.ceil(targetPoints / 2);\n const result = minMaxDownsample(x, y, bucketCount);\n return { x: result.x, y: result.y };\n }\n\n const result = lttbDownsample(x, y, targetPoints);\n return { x: result.x, y: result.y };\n }\n\n function cacheOriginal(seriesId: string, data: SeriesCache): void {\n if (!config.reuseOriginalData) return;\n originalData.set(seriesId, { ...data });\n }\n\n function restoreOriginal(seriesId: string): SeriesCache | null {\n return originalData.get(seriesId) ?? null;\n }\n\n function updateStats(\n seriesId: string,\n originalPoints: number,\n renderedPoints: number,\n targetPoints: number,\n mode: VirtualizationMode,\n strategy: VirtualizationStrategy,\n ): void {\n stats.set(seriesId, {\n seriesId,\n originalPoints,\n renderedPoints,\n targetPoints,\n lastUpdated: Date.now(),\n mode,\n strategy,\n });\n }\n\n function captureOriginalFromSeries(series: Series): SeriesCache | null {\n const live = series.getData();\n if (!live?.x?.length) return null;\n\n if (isOhlcSeries(series)) {\n if (!live.open || !live.high || !live.low || !live.close) return null;\n const cache: SeriesCache = {\n x: live.x,\n open: live.open,\n high: live.high,\n low: live.low,\n close: live.close,\n };\n cacheOriginal(series.getId(), cache);\n return cache;\n }\n\n if (!live.y) return null;\n const cache: SeriesCache = { x: live.x, y: live.y };\n cacheOriginal(series.getId(), cache);\n return cache;\n }\n\n function getSourceData(series: Series): SeriesCache | null {\n return restoreOriginal(series.getId()) ?? captureOriginalFromSeries(series);\n }\n\n function getViewportSource(source: SeriesCache): SeriesCache {\n const bounds = ctx!.data.getViewBounds?.();\n if (!bounds) return source;\n\n const sliced = sliceSeriesToViewport(\n source,\n bounds.xMin,\n bounds.xMax,\n config.viewportBuffer,\n );\n if (sliced.end - sliced.start >= source.x.length) return source;\n\n return {\n x: sliced.x,\n y: sliced.y,\n open: sliced.open,\n high: sliced.high,\n low: sliced.low,\n close: sliced.close,\n };\n }\n\n function commitDownsampled(seriesId: string, payload: SeriesUpdateData): void {\n isInternalUpdate = true;\n originalUpdateSeries!(seriesId, payload);\n isInternalUpdate = false;\n }\n\n async function runDownsample(\n source: SeriesCache,\n targetPoints: number,\n strategy: VirtualizationStrategy,\n ): Promise<{ x: Float32Array; y: Float32Array }> {\n const x = new Float32Array(source.x);\n const y = new Float32Array(source.y!);\n\n if (config.useWorker && x.length >= config.workerThreshold) {\n const algorithm = strategy === \"minmax\" ? \"minmax\" : \"lttb\";\n const result = await downsampleAsync(x, y, targetPoints, algorithm);\n return { x: result.x, y: result.y };\n }\n\n return downsampleData(x, y, targetPoints, strategy);\n }\n\n async function applyVirtualization(series: Series): Promise<void> {\n if (!ctx || !originalUpdateSeries) return;\n const seriesId = series.getId();\n\n if (!shouldVirtualize(series)) {\n const original = restoreOriginal(seriesId);\n if (original && config.reuseOriginalData) {\n commitDownsampled(seriesId, buildUpdatePayload(original));\n }\n return;\n }\n\n const source = getSourceData(series);\n if (!source?.x?.length) return;\n\n const viewportSource = getViewportSource(source);\n const gen = (applyGeneration.get(seriesId) ?? 0) + 1;\n applyGeneration.set(seriesId, gen);\n\n if (isOhlcSeries(series)) {\n if (!viewportSource.open || !viewportSource.high || !viewportSource.low || !viewportSource.close) {\n return;\n }\n\n const targetBars = getTargetPoints(viewportSource.x.length);\n const x = new Float32Array(viewportSource.x);\n const open = new Float32Array(viewportSource.open);\n const high = new Float32Array(viewportSource.high);\n const low = new Float32Array(viewportSource.low);\n const close = new Float32Array(viewportSource.close);\n\n const downsampled =\n config.useWorker && x.length >= config.workerThreshold\n ? await ohlcDownsampleAsync(x, open, high, low, close, targetBars)\n : ohlcMinMaxDownsample(x, open, high, low, close, targetBars);\n\n if (applyGeneration.get(seriesId) !== gen) return;\n\n commitDownsampled(seriesId, {\n x: downsampled.x,\n open: downsampled.open,\n high: downsampled.high,\n low: downsampled.low,\n close: downsampled.close,\n });\n\n updateStats(seriesId, source.x.length, downsampled.x.length, targetBars, config.mode, \"minmax\");\n return;\n }\n\n if (!viewportSource.y) return;\n\n const targetPoints = getTargetPoints(viewportSource.x.length);\n const strategy = series.getType() === \"bar\" ? \"minmax\" : config.strategy;\n const downsampled = await runDownsample(viewportSource, targetPoints, strategy);\n\n if (applyGeneration.get(seriesId) !== gen) return;\n\n commitDownsampled(seriesId, { x: downsampled.x, y: downsampled.y });\n updateStats(seriesId, source.x.length, downsampled.x.length, targetPoints, config.mode, strategy);\n }\n\n function refreshAll(): void {\n if (!ctx) return;\n ctx.data.getAllSeries().forEach((series) => {\n void applyVirtualization(series);\n });\n }\n\n function scheduleRefreshAll(): void {\n if (!ctx) return;\n const bounds = ctx.data.getViewBounds?.();\n if (bounds) {\n const key = `${bounds.xMin}:${bounds.xMax}:${bounds.yMin}:${bounds.yMax}:${ctx.render.canvasSize.width}`;\n if (key === lastViewKey) return;\n lastViewKey = key;\n }\n\n if (refreshRaf) return;\n refreshRaf = requestAnimationFrame(() => {\n refreshRaf = 0;\n refreshAll();\n });\n }\n\n function handleUpdateSeries(id: string, data: SeriesUpdateData): void {\n if (!ctx || !originalUpdateSeries) return;\n if (!config.enabled || isInternalUpdate) {\n originalUpdateSeries(id, data);\n return;\n }\n\n const series = ctx.chart.getSeries?.(id) as Series | undefined;\n if (!series) {\n originalUpdateSeries(id, data);\n return;\n }\n\n const original = restoreOriginal(id);\n if (original && config.reuseOriginalData) {\n isInternalUpdate = true;\n originalUpdateSeries(id, buildUpdatePayload(original));\n isInternalUpdate = false;\n }\n\n originalUpdateSeries(id, data);\n\n const updatedSeries = ctx.chart.getSeries?.(id) as Series | undefined;\n if (updatedSeries) {\n originalData.delete(id);\n captureOriginalFromSeries(updatedSeries);\n void applyVirtualization(updatedSeries);\n }\n }\n\n function handleAppendData(\n id: string,\n x: number[] | Float32Array,\n y: number[] | Float32Array\n ): void {\n if (!ctx || !originalAppendData || !originalUpdateSeries) return;\n\n if (!config.enabled || isInternalUpdate) {\n originalAppendData(id, x, y);\n return;\n }\n\n const series = ctx.chart.getSeries?.(id) as Series | undefined;\n if (!series) {\n originalAppendData(id, x, y);\n return;\n }\n\n const original = restoreOriginal(id);\n if (original && config.reuseOriginalData) {\n isInternalUpdate = true;\n originalUpdateSeries(id, buildUpdatePayload(original));\n isInternalUpdate = false;\n }\n\n originalAppendData(id, x, y);\n\n const updatedSeries = ctx.chart.getSeries?.(id) as Series | undefined;\n if (updatedSeries) {\n const cached = restoreOriginal(id);\n if (cached?.y && config.reuseOriginalData) {\n // Replace (not cacheOriginal, which no-ops on an existing entry) so the\n // full-resolution cache grows with the appended points.\n originalData.set(id, {\n x: appendTyped(cached.x, x),\n y: appendTyped(cached.y, y),\n });\n } else {\n originalData.delete(id);\n captureOriginalFromSeries(updatedSeries);\n }\n void applyVirtualization(updatedSeries);\n }\n }\n\n function appendTyped(\n existing: Float32Array | Float64Array,\n incoming: number[] | Float32Array,\n ): Float32Array {\n const next = incoming instanceof Float32Array ? incoming : Float32Array.from(incoming);\n const merged = new Float32Array(existing.length + next.length);\n merged.set(existing);\n merged.set(next, existing.length);\n return merged;\n }\n\n const api: VirtualizationAPI & Record<string, unknown> = {\n enable() {\n config.enabled = true;\n refreshAll();\n },\n disable() {\n config.enabled = false;\n if (!ctx || !originalUpdateSeries) return;\n const updater = originalUpdateSeries;\n ctx.data.getAllSeries().forEach((series) => {\n const original = restoreOriginal(series.getId());\n if (original) {\n isInternalUpdate = true;\n updater(series.getId(), buildUpdatePayload(original));\n isInternalUpdate = false;\n }\n });\n },\n isEnabled() {\n return config.enabled;\n },\n updateConfig(newConfig) {\n Object.assign(config, newConfig);\n refreshAll();\n },\n invalidate(seriesId) {\n if (!ctx) return;\n if (seriesId) {\n const series = ctx.chart.getSeries?.(seriesId) as Series | undefined;\n if (series) applyVirtualization(series);\n return;\n }\n refreshAll();\n },\n getStats(seriesId) {\n return stats.get(seriesId) ?? null;\n },\n getAllStats() {\n return Array.from(stats.values());\n },\n };\n\n return {\n manifest,\n onInit(pluginCtx: PluginContext) {\n ctx = pluginCtx;\n // API is exposed via plugin.api / chart.virtualization getter (ChartPluginBridge)\n\n const chart = ctx.chart as any;\n originalUpdateSeries = chart.updateSeries?.bind(chart) ?? null;\n originalAppendData = chart.appendData?.bind(chart) ?? null;\n\n if (originalUpdateSeries) {\n chart.updateSeries = (id: string, data: SeriesUpdateData) => handleUpdateSeries(id, data);\n }\n\n if (originalAppendData) {\n chart.appendData = (id: string, x: number[] | Float32Array, y: number[] | Float32Array) =>\n handleAppendData(id, x, y);\n }\n\n ctx.events.on(\"zoom\", () => scheduleRefreshAll());\n ctx.events.on(\"pan\", () => scheduleRefreshAll());\n ctx.events.on(\"resize\", () => {\n lastViewKey = \"\";\n scheduleRefreshAll();\n });\n\n refreshAll();\n log(\"Initialized\");\n },\n onDestroy(pluginCtx: PluginContext) {\n if (refreshRaf) cancelAnimationFrame(refreshRaf);\n refreshRaf = 0;\n applyGeneration.clear();\n if (originalUpdateSeries) {\n (pluginCtx.chart as any).updateSeries = originalUpdateSeries;\n }\n if (originalAppendData) {\n (pluginCtx.chart as any).appendData = originalAppendData;\n }\n ctx = null;\n originalData.clear();\n stats.clear();\n },\n api,\n };\n}\n\nexport default PluginVirtualization;\n\n// Type exports\nexport type {\n PluginVirtualizationConfig,\n VirtualizationAPI,\n VirtualizationStats,\n VirtualizationMode,\n VirtualizationStrategy,\n} from \"./types\";\n"],"names":["lttbDownsample","x","y","targetPoints","length","_","i","outX","outY","outIndices","bucketSize","a","outIdx","bucketStart","bucketEnd","nextBucketStart","nextBucketEnd","avgX","avgY","avgCount","j","maxArea","maxIndex","aX","aY","area","minMaxDownsample","bucketCount","b","start","end","minY","maxY","minIdx","maxIdx","calculateTargetPoints","dataLength","canvasWidth","pointsPerPixel","maxPoints","ohlcMinMaxDownsample","open","high","low","close","targetBars","outOpen","outHigh","outLow","outClose","hi","lo","lastIdx","lowerBoundX","value","mid","upperBoundX","sliceSeriesToViewport","source","xMin","xMax","bufferRatio","range","paddedMin","paddedMax","slice","arr","pool","getPool","WorkerPool","task","result","downsampleAsync","algorithm","id","nextTaskId","ohlcDownsampleAsync","destroyDownsamplePool","getDownsamplePoolSize","manifest","DEFAULT_CONFIG","PluginVirtualization","userConfig","config","ctx","isInternalUpdate","originalData","stats","originalUpdateSeries","originalAppendData","refreshRaf","applyGeneration","lastViewKey","log","message","args","shouldVirtualize","series","type","isOhlcSeries","buildUpdatePayload","cache","getTargetPoints","width","downsampleData","strategy","cacheOriginal","seriesId","data","restoreOriginal","updateStats","originalPoints","renderedPoints","mode","captureOriginalFromSeries","live","_a","getSourceData","getViewportSource","bounds","_b","sliced","commitDownsampled","payload","runDownsample","applyVirtualization","original","viewportSource","gen","downsampled","refreshAll","scheduleRefreshAll","key","handleUpdateSeries","updatedSeries","_d","_c","handleAppendData","cached","appendTyped","existing","incoming","next","merged","pluginCtx","chart","updater","newConfig"],"mappings":";AAwBO,SAASA,EACdC,GACAC,GACAC,GACkB;AAClB,QAAMC,IAASH,EAAE;AAGjB,MAAIE,KAAgBC,KAAUD,KAAgB;AAC5C,WAAO;AAAA,MACL,GAAG,IAAI,aAAaF,CAAC;AAAA,MACrB,GAAG,IAAI,aAAaC,CAAC;AAAA,MACrB,SAAS,IAAI,YAAY,MAAM,KAAK,EAAE,QAAAE,EAAA,GAAU,CAACC,GAAGC,MAAMA,CAAC,CAAC;AAAA,IAAA;AAIhE,QAAMC,IAAO,IAAI,aAAaJ,CAAY,GACpCK,IAAO,IAAI,aAAaL,CAAY,GACpCM,IAAa,IAAI,YAAYN,CAAY;AAG/C,EAAAI,EAAK,CAAC,IAAIN,EAAE,CAAC,GACbO,EAAK,CAAC,IAAIN,EAAE,CAAC,GACbO,EAAW,CAAC,IAAI;AAGhB,QAAMC,KAAcN,IAAS,MAAMD,IAAe;AAElD,MAAIQ,IAAI,GACJC,IAAS;AAEb,WAASN,IAAI,GAAGA,IAAIH,IAAe,GAAGG,KAAK;AAEzC,UAAMO,IAAc,KAAK,OAAOP,IAAI,KAAKI,CAAU,IAAI,GACjDI,IAAY,KAAK,OAAOR,IAAI,KAAKI,CAAU,IAAI,GAG/CK,IAAkB,KAAK,IAAID,GAAWV,IAAS,CAAC,GAChDY,IAAgB,KAAK;AAAA,MACzB,KAAK,OAAOV,IAAI,KAAKI,CAAU,IAAI;AAAA,MACnCN;AAAA,IAAA;AAGF,QAAIa,IAAO,GACPC,IAAO,GACPC,IAAW;AAEf,aAASC,IAAIL,GAAiBK,IAAIJ,GAAeI;AAC/C,MAAAH,KAAQhB,EAAEmB,CAAC,GACXF,KAAQhB,EAAEkB,CAAC,GACXD;AAGF,IAAIA,IAAW,MACbF,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