velo-plot 2.0.0 → 3.0.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 +15 -8
- package/dist/{ChartCore-BhQ4j7f5.js → ChartCore-BpzRvN4Y.js} +998 -855
- package/dist/ChartCore-BpzRvN4Y.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-SPX-CD5s.js → axisFormat-CzumxpCL.js} +3 -3
- package/dist/axisFormat-CzumxpCL.js.map +1 -0
- 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-DbWrwtyP.js +57 -0
- package/dist/chartSyncBridge-DbWrwtyP.js.map +1 -0
- package/dist/core/Chart.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/ChartAxisManager.d.ts +2 -0
- package/dist/core/chart/ChartCore.d.ts +17 -2
- package/dist/core/chart/ChartPluginBridge.d.ts +1 -0
- package/dist/core/chart/ChartRenderLoop.d.ts +2 -0
- package/dist/core/chart/ChartStateManager.d.ts +2 -0
- package/dist/core/chart/types.d.ts +6 -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/sync/index.d.ts +0 -1
- package/dist/core/theme-editor/index.d.ts +1 -1
- package/dist/createStackedChart-Dm-YqUT7.js +756 -0
- package/dist/createStackedChart-Dm-YqUT7.js.map +1 -0
- package/dist/examples/PluginDemonstration.d.ts +1 -1
- package/dist/gpuRenderer-BpaMYz-k.js.map +1 -1
- package/dist/hooks-CYPCxoZx.js +69 -0
- package/dist/hooks-CYPCxoZx.js.map +1 -0
- package/dist/{index-D7dTq6VB.js → index-0InEyj0q.js} +130 -134
- package/dist/index-0InEyj0q.js.map +1 -0
- package/dist/index-BMiZoKmm.js.map +1 -1
- package/dist/{index-DoYxf1cV.js → index-CWxIHdwX.js} +38 -98
- package/dist/index-CWxIHdwX.js.map +1 -0
- package/dist/{index-CUGS98p4.js → index-CaXWSOTk.js} +3 -6
- package/dist/index-CaXWSOTk.js.map +1 -0
- package/dist/index-Dag88bW4.js.map +1 -1
- package/dist/index-qhscKTDy.js.map +1 -1
- package/dist/{index-CWipqOLP.js → index-qunX30Xu.js} +2 -2
- package/dist/index-qunX30Xu.js.map +1 -0
- package/dist/index-x4stH3jD.js.map +1 -1
- package/dist/{index.core-fpZ1dYN0.js → index.core-BmZe2jRQ.js} +30 -29
- package/dist/index.core-BmZe2jRQ.js.map +1 -0
- package/dist/index.core.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/indicators--eJGmVox.js.map +1 -1
- package/dist/{mockDatafeed-Cdg5hKEo.js → mockDatafeed-DHIDPcpX.js} +150 -146
- package/dist/mockDatafeed-DHIDPcpX.js.map +1 -0
- 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.map +1 -1
- package/dist/plugins/analysis/contours.d.ts +31 -0
- 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 +495 -408
- 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/broken-axis.js +170 -181
- package/dist/plugins/broken-axis.js.map +1 -1
- 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/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 +2 -2
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/forecasting/algorithms.d.ts +7 -2
- package/dist/plugins/forecasting/index.d.ts +1 -1
- package/dist/plugins/forecasting/types.d.ts +13 -3
- package/dist/plugins/forecasting.js +355 -175
- 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.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.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/symbols.d.ts +50 -0
- package/dist/plugins/latex/types.d.ts +13 -1
- package/dist/plugins/latex.js +351 -331
- package/dist/plugins/latex.js.map +1 -1
- package/dist/plugins/lazy-load.d.ts +2 -2
- package/dist/plugins/loading/index.d.ts +1 -1
- package/dist/plugins/loading.d.ts +2 -2
- package/dist/plugins/ml-integration/native-algorithms.d.ts +24 -4
- package/dist/plugins/ml-integration/types.d.ts +19 -0
- package/dist/plugins/ml-integration.d.ts +2 -2
- package/dist/plugins/ml-integration.js +190 -139
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/offscreen.d.ts +2 -2
- package/dist/plugins/pattern-recognition/types.d.ts +28 -1
- package/dist/plugins/pattern-recognition.d.ts +2 -2
- package/dist/plugins/pattern-recognition.js +417 -344
- 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 +1 -1
- 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 +36 -36
- 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/sync/index.d.ts +3 -2
- package/dist/plugins/sync.d.ts +2 -2
- package/dist/plugins/sync.js +1 -1
- 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 +328 -24
- package/dist/react.js.map +1 -1
- package/dist/scientific/index.d.ts +48 -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 +172 -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 +143 -0
- package/dist/svelte.js.map +1 -0
- package/dist/symbols-DT0eLlpW.js +568 -0
- package/dist/symbols-DT0eLlpW.js.map +1 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/theme/index.d.ts +2 -1
- package/dist/trading.js +7 -7
- package/dist/types.d.ts +1 -1
- 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 +444 -433
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +15 -15
- 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 +312 -0
- package/dist/vue.js.map +1 -0
- package/dist/workers/indicatorsAsync.d.ts +26 -0
- package/dist/workers/pool.d.ts +9 -0
- package/package.json +88 -10
- package/dist/ChartCore-BhQ4j7f5.js.map +0 -1
- package/dist/SciPlot-GJvw7GJo.js +0 -463
- package/dist/SciPlot-GJvw7GJo.js.map +0 -1
- package/dist/axisFormat-SPX-CD5s.js.map +0 -1
- package/dist/createStackedChart-DJSmqerD.js +0 -706
- package/dist/createStackedChart-DJSmqerD.js.map +0 -1
- package/dist/index-CUGS98p4.js.map +0 -1
- package/dist/index-CWipqOLP.js.map +0 -1
- package/dist/index-D7dTq6VB.js.map +0 -1
- package/dist/index-DoYxf1cV.js.map +0 -1
- package/dist/index.core-fpZ1dYN0.js.map +0 -1
- package/dist/mockDatafeed-Cdg5hKEo.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/plugins/snapshot.js
CHANGED
|
@@ -15,7 +15,7 @@ const b = {
|
|
|
15
15
|
fileName: "velo-plot-snapshot-export",
|
|
16
16
|
download: !1
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function R(c) {
|
|
19
19
|
if (typeof c == "number") return c;
|
|
20
20
|
switch (c) {
|
|
21
21
|
case "8k":
|
|
@@ -30,61 +30,61 @@ function S(c) {
|
|
|
30
30
|
return 1;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
async function p(
|
|
36
|
-
var
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
33
|
+
function S(c = {}) {
|
|
34
|
+
let a = null;
|
|
35
|
+
async function p(t = {}) {
|
|
36
|
+
var u, h;
|
|
37
|
+
if (!a) throw new Error("Snapshot plugin not initialized");
|
|
38
|
+
const e = { ...k, ...c.defaultOptions, ...t }, n = a.chart, s = R(e.resolution), i = n.getDPR();
|
|
39
39
|
try {
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
40
|
+
if (e.format === "svg") {
|
|
41
|
+
const o = n.exportSVG();
|
|
42
|
+
if (e.download) {
|
|
43
|
+
const l = new Blob([o], { type: "image/svg+xml" }), w = URL.createObjectURL(l), f = document.createElement("a");
|
|
44
|
+
f.download = `${e.fileName}.svg`, f.href = w, document.body.appendChild(f), f.click(), document.body.removeChild(f), URL.revokeObjectURL(w);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return o;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
const m = (
|
|
48
|
+
s > 1 && (typeof n.setDevicePixelRatioOverride == "function" ? n.setDevicePixelRatioOverride(i * s) : n.setDPR(i * s), typeof n.render == "function" && n.render(), await new Promise((o) => requestAnimationFrame(o)), await new Promise((o) => requestAnimationFrame(o)), await new Promise((o) => setTimeout(o, 100)));
|
|
49
|
+
const m = (u = a.render.gl) == null ? void 0 : u.canvas, g = (h = a.render.ctx2d) == null ? void 0 : h.canvas;
|
|
50
50
|
if (!m) throw new Error("WebGL canvas not found");
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const d =
|
|
54
|
-
!
|
|
55
|
-
const y = `image/${
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
51
|
+
const r = document.createElement("canvas");
|
|
52
|
+
r.width = m.width, r.height = m.height;
|
|
53
|
+
const d = r.getContext("2d");
|
|
54
|
+
!e.transparent && e.includeBackground && (d.fillStyle = a.ui.theme.backgroundColor || "#ffffff", d.fillRect(0, 0, r.width, r.height)), d.drawImage(m, 0, 0), e.includeOverlays && g && d.drawImage(g, 0, 0), e.watermarkText && x(d, e.watermarkText, r.width, r.height, i * s);
|
|
55
|
+
const y = `image/${e.format}`, v = r.toDataURL(y, e.quality);
|
|
56
|
+
if (e.download) {
|
|
57
|
+
const o = e.format === "jpeg" ? "jpg" : e.format, l = document.createElement("a");
|
|
58
|
+
l.download = `${e.fileName}.${o}`, l.href = v, document.body.appendChild(l), l.click(), document.body.removeChild(l);
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return v;
|
|
61
61
|
} finally {
|
|
62
|
-
|
|
62
|
+
s > 1 && (typeof n.setDevicePixelRatioOverride == "function" ? n.setDevicePixelRatioOverride(null) : n.setDPR(i));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function x(e,
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
65
|
+
function x(t, e, n, s, i) {
|
|
66
|
+
t.save();
|
|
67
|
+
const u = Math.max(16, 24 * (i / 2));
|
|
68
|
+
t.font = `bold ${u}px Inter, system-ui, sans-serif`, t.fillStyle = "rgba(128, 128, 128, 0.4)", t.textAlign = "right", t.textBaseline = "bottom", t.fillText(e, n - 20 * i / 2, s - 20 * i / 2), t.restore();
|
|
69
69
|
}
|
|
70
70
|
return {
|
|
71
71
|
manifest: b,
|
|
72
|
-
onInit(
|
|
73
|
-
|
|
72
|
+
onInit(t) {
|
|
73
|
+
a = t, a.log.info("Snapshot plugin initialized");
|
|
74
74
|
},
|
|
75
75
|
onDestroy() {
|
|
76
|
-
|
|
76
|
+
a = null;
|
|
77
77
|
},
|
|
78
78
|
api: {
|
|
79
79
|
takeSnapshot: p,
|
|
80
|
-
downloadSnapshot: async (
|
|
81
|
-
await p({ ...
|
|
80
|
+
downloadSnapshot: async (t) => {
|
|
81
|
+
await p({ ...t, download: !0 });
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
export {
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
S as PluginSnapshot,
|
|
88
|
+
S as default
|
|
89
89
|
};
|
|
90
90
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sources":["../../src/plugins/snapshot/index.ts"],"sourcesContent":["/**\n * SciPlot - Snapshot Plugin\n * \n * Provides high-resolution image export capabilities.\n * Supports different formats (PNG, JPEG, WebP) and resolutions (Standard, 2K, 4K, 8K).\n * \n * @module plugins/snapshot\n */\n\nimport type { \n PluginManifest, \n ChartPlugin, \n PluginContext,\n} from '../types';\n\nimport type {\n PluginSnapshotConfig,\n SnapshotExportAPI,\n SnapshotExportOptions,\n SnapshotResolution,\n} from './types';\n\nconst manifestSnapshot: PluginManifest = {\n name: \"velo-plot-snapshot\",\n version: \"1.0.0\",\n description: \"High-resolution image export for velo-plot\",\n provides: [\"export\", \"snapshot\"],\n tags: [\"snapshot\", \"export\", \"publication\", \"image\"],\n};\n\nconst DEFAULT_OPTIONS: Required<SnapshotExportOptions> = {\n format: 'png',\n quality: 0.9,\n resolution: 'standard',\n includeBackground: true,\n includeOverlays: true,\n watermarkText: '',\n transparent: false,\n fileName: 'velo-plot-snapshot-export',\n download: false\n};\n\nfunction resolutionToScale(res: SnapshotResolution): number {\n if (typeof res === 'number') return res;\n switch (res) {\n case '8k': return 8;\n case '4k': return 4;\n case '2k': return 2;\n case 'standard': return 1;\n default: return 1;\n }\n}\n\n/**\n * SciPlot Snapshot Plugin\n * \n * Captures the current chart view with all layers (WebGL + Overlay).\n */\nexport function PluginSnapshot(\n config: PluginSnapshotConfig = {}\n): ChartPlugin<PluginSnapshotConfig> {\n let ctx: PluginContext | null = null;\n\n /**\n * Captures the chart as an image\n */\n async function takeSnapshot(options: SnapshotExportOptions = {}): Promise<string | Blob> {\n if (!ctx) throw new Error(\"Snapshot plugin not initialized\");\n \n const opt = { ...DEFAULT_OPTIONS, ...config.defaultOptions, ...options };\n const chart = ctx.chart;\n \n // 1. Determine target resolution scale\n const scale = resolutionToScale(opt.resolution);\n const originalDPR = chart.getDPR();\n \n try {\n if (opt.format === 'svg') {\n const svg = chart.exportSVG();\n if (opt.download) {\n const blob = new Blob([svg], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.download = `${opt.fileName}.svg`;\n link.href = url;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n }\n return svg;\n }\n\n // High-res re-render if scale > 1\n // We temporarily boost the device pixel ratio to force a higher resolution render\n if (scale > 1) {\n chart.setDPR(originalDPR * scale);\n // Wait for DOM and GL updates\n await new Promise(r => requestAnimationFrame(r));\n // Small delay to ensure all overlays (which might have their own throttles) are ready\n await new Promise(r => setTimeout(r, 100));\n }\n\n const webglCanvas = (ctx.render.gl?.canvas) as HTMLCanvasElement;\n const overlayCanvas = (ctx.render.ctx2d?.canvas) as HTMLCanvasElement;\n \n if (!webglCanvas) throw new Error(\"WebGL canvas not found\");\n\n // 3. Compose layers into a final canvas\n const compositionCanvas = document.createElement('canvas');\n compositionCanvas.width = webglCanvas.width;\n compositionCanvas.height = webglCanvas.height;\n const compCtx = compositionCanvas.getContext('2d')!;\n \n // Fill background if not transparent\n if (!opt.transparent && opt.includeBackground) {\n compCtx.fillStyle = ctx.ui.theme.backgroundColor || '#ffffff';\n compCtx.fillRect(0, 0, compositionCanvas.width, compositionCanvas.height);\n }\n \n // Draw WebGL layer (bottom)\n compCtx.drawImage(webglCanvas, 0, 0);\n \n // Draw Overlay layer (top) - contains annotations, tooltips, etc.\n if (opt.includeOverlays && overlayCanvas) {\n compCtx.drawImage(overlayCanvas, 0, 0);\n }\n \n // Apply Watermark\n if (opt.watermarkText) {\n drawWatermark(compCtx, opt.watermarkText, compositionCanvas.width, compositionCanvas.height, originalDPR * scale);\n }\n \n const mimeType = `image/${opt.format}`;\n const dataUrl = compositionCanvas.toDataURL(mimeType, opt.quality);\n \n // Automatic download if requested\n if (opt.download) {\n const extension = opt.format === 'jpeg' ? 'jpg' : opt.format;\n const link = document.createElement('a');\n link.download = `${opt.fileName}.${extension}`;\n link.href = dataUrl;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n \n return dataUrl;\n } finally {\n // 4. Restore original resolution\n if (scale > 1) {\n chart.setDPR(originalDPR);\n }\n }\n }\n\n /**\n * Helper to draw a watermark on the captured image\n */\n function drawWatermark(c: CanvasRenderingContext2D, text: string, w: number, h: number, dpr: number) {\n c.save();\n // Scale font size according to DPR\n const fontSize = Math.max(16, 24 * (dpr / 2));\n c.font = `bold ${fontSize}px Inter, system-ui, sans-serif`;\n c.fillStyle = 'rgba(128, 128, 128, 0.4)';\n c.textAlign = 'right';\n c.textBaseline = 'bottom';\n c.fillText(text, w - (20 * dpr/2), h - (20 * dpr/2));\n c.restore();\n }\n\n const api: SnapshotExportAPI & Record<string, unknown> = {\n takeSnapshot,\n downloadSnapshot: async (opt: SnapshotExportOptions) => {\n await takeSnapshot({ ...opt, download: true });\n }\n };\n\n return {\n manifest: manifestSnapshot,\n onInit(c) { \n ctx = c; \n ctx.log.info(\"Snapshot plugin initialized\");\n },\n onDestroy() {\n ctx = null;\n },\n api\n };\n}\n\nexport default PluginSnapshot;\n\nexport type {\n SnapshotFormat,\n SnapshotResolution,\n SnapshotExportOptions,\n SnapshotExportAPI,\n PluginSnapshotConfig\n} from './types';\n"],"names":["manifestSnapshot","DEFAULT_OPTIONS","resolutionToScale","res","PluginSnapshot","config","ctx","takeSnapshot","options","_a","_b","opt","chart","scale","originalDPR","svg","blob","url","link","r","webglCanvas","overlayCanvas","compositionCanvas","compCtx","drawWatermark","mimeType","dataUrl","extension","c","text","w","h","dpr","fontSize"],"mappings":"AAsBA,MAAMA,IAAmC;AAAA,EACvC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU,CAAC,UAAU,UAAU;AAAA,EAC/B,MA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A,aAAOQ;AAAA,IACX,UAAA;AAEI,MAAIb,IAAQ,KACRD,EAAM,OAAOE,CAAW;AAAA,IAEhC;AAAA,EACF;AAKA,WAASU,EAAcI,GAA6BC,GAAcC,GAAWC,GAAWC,GAAa;AACnG,IAAAJ,EAAE,KAAA;AAEF,UAAMK,IAAW,KAAK,IAAI,IAAI,MAAMD,IAAM,EAAE;AAC5C,IAAAJ,EAAE,OAAO,QAAQK,CAAQ,mCACzBL,EAAE,YAAY,4BACdA,EAAE,YAAY,SACdA,EAAE,eAAe,UACjBA,EAAE,SAASC,GAAMC,IAAK,KAAKE,IAAI,GAAID,IAAK,KAAKC,IAAI,CAAE,GACnDJ,EAAE,QAAA;AAAA,EACJ;AASA,SAAO;AAAA,IACL,UAAU5B;AAAA,IACV,OAAO4B,GAAG;AACN,MAAAtB,IAAMsB,GACNtB,EAAI,IAAI,KAAK,6BAA6B;AAAA,IAC9C;AAAA,IACA,YAAY;AACR,MAAAA,IAAM;AAAA,IACV;AAAA,IACA,KAhBuD;AAAA,MACvD,cAAAC;AAAA,MACA,kBAAkB,OAAOI,MAA+B;AACtD,cAAMJ,EAAa,EAAE,GAAGI,GAAK,UAAU,IAAM;AAAA,MAC/C;AAAA,IAAA;AAAA,EAYA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"snapshot.js","sources":["../../src/plugins/snapshot/index.ts"],"sourcesContent":["/**\n * VeloPlot - Snapshot Plugin\n * \n * Provides high-resolution image export capabilities.\n * Supports different formats (PNG, JPEG, WebP) and resolutions (Standard, 2K, 4K, 8K).\n * \n * @module plugins/snapshot\n */\n\nimport type { \n PluginManifest, \n ChartPlugin, \n PluginContext,\n} from '../types';\n\nimport type {\n PluginSnapshotConfig,\n SnapshotExportAPI,\n SnapshotExportOptions,\n SnapshotResolution,\n} from './types';\n\nconst manifestSnapshot: PluginManifest = {\n name: \"velo-plot-snapshot\",\n version: \"1.0.0\",\n description: \"High-resolution image export for velo-plot\",\n provides: [\"export\", \"snapshot\"],\n tags: [\"snapshot\", \"export\", \"publication\", \"image\"],\n};\n\nconst DEFAULT_OPTIONS: Required<SnapshotExportOptions> = {\n format: 'png',\n quality: 0.9,\n resolution: 'standard',\n includeBackground: true,\n includeOverlays: true,\n watermarkText: '',\n transparent: false,\n fileName: 'velo-plot-snapshot-export',\n download: false\n};\n\nfunction resolutionToScale(res: SnapshotResolution): number {\n if (typeof res === 'number') return res;\n switch (res) {\n case '8k': return 8;\n case '4k': return 4;\n case '2k': return 2;\n case 'standard': return 1;\n default: return 1;\n }\n}\n\n/**\n * VeloPlot Snapshot Plugin\n * \n * Captures the current chart view with all layers (WebGL + Overlay).\n */\nexport function PluginSnapshot(\n config: PluginSnapshotConfig = {}\n): ChartPlugin<PluginSnapshotConfig> {\n let ctx: PluginContext | null = null;\n\n /**\n * Captures the chart as an image\n */\n async function takeSnapshot(options: SnapshotExportOptions = {}): Promise<string | Blob> {\n if (!ctx) throw new Error(\"Snapshot plugin not initialized\");\n \n const opt = { ...DEFAULT_OPTIONS, ...config.defaultOptions, ...options };\n const chart = ctx.chart;\n \n // 1. Determine target resolution scale\n const scale = resolutionToScale(opt.resolution);\n const originalDPR = chart.getDPR();\n \n try {\n if (opt.format === 'svg') {\n const svg = chart.exportSVG();\n if (opt.download) {\n const blob = new Blob([svg], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.download = `${opt.fileName}.svg`;\n link.href = url;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n }\n return svg;\n }\n\n // High-res re-render if scale > 1.\n // We temporarily lock the device pixel ratio to force a higher-resolution\n // render. Using an explicit override (instead of setDPR) is essential:\n // a plain setDPR gets reverted by the very next resize() call, so the\n // backing stores would stay at screen resolution and every preset would\n // look identical / pixelated. The override survives resize().\n if (scale > 1) {\n if (typeof chart.setDevicePixelRatioOverride === 'function') {\n chart.setDevicePixelRatioOverride(originalDPR * scale);\n } else {\n chart.setDPR(originalDPR * scale);\n }\n // Force a synchronous full render at the boosted DPR before capture.\n if (typeof chart.render === 'function') {\n chart.render();\n }\n // Wait for DOM and GL updates\n await new Promise(r => requestAnimationFrame(r));\n // Second frame ensures the resized backing store has actually been painted.\n await new Promise(r => requestAnimationFrame(r));\n // Small delay to ensure all overlays (which might have their own throttles) are ready\n await new Promise(r => setTimeout(r, 100));\n }\n\n const webglCanvas = (ctx.render.gl?.canvas) as HTMLCanvasElement;\n const overlayCanvas = (ctx.render.ctx2d?.canvas) as HTMLCanvasElement;\n \n if (!webglCanvas) throw new Error(\"WebGL canvas not found\");\n\n // 3. Compose layers into a final canvas\n const compositionCanvas = document.createElement('canvas');\n compositionCanvas.width = webglCanvas.width;\n compositionCanvas.height = webglCanvas.height;\n const compCtx = compositionCanvas.getContext('2d')!;\n \n // Fill background if not transparent\n if (!opt.transparent && opt.includeBackground) {\n compCtx.fillStyle = ctx.ui.theme.backgroundColor || '#ffffff';\n compCtx.fillRect(0, 0, compositionCanvas.width, compositionCanvas.height);\n }\n \n // Draw WebGL layer (bottom)\n compCtx.drawImage(webglCanvas, 0, 0);\n \n // Draw Overlay layer (top) - contains annotations, tooltips, etc.\n if (opt.includeOverlays && overlayCanvas) {\n compCtx.drawImage(overlayCanvas, 0, 0);\n }\n \n // Apply Watermark\n if (opt.watermarkText) {\n drawWatermark(compCtx, opt.watermarkText, compositionCanvas.width, compositionCanvas.height, originalDPR * scale);\n }\n \n const mimeType = `image/${opt.format}`;\n const dataUrl = compositionCanvas.toDataURL(mimeType, opt.quality);\n \n // Automatic download if requested\n if (opt.download) {\n const extension = opt.format === 'jpeg' ? 'jpg' : opt.format;\n const link = document.createElement('a');\n link.download = `${opt.fileName}.${extension}`;\n link.href = dataUrl;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n \n return dataUrl;\n } finally {\n // 4. Restore original resolution\n if (scale > 1) {\n if (typeof chart.setDevicePixelRatioOverride === 'function') {\n chart.setDevicePixelRatioOverride(null);\n } else {\n chart.setDPR(originalDPR);\n }\n }\n }\n }\n\n /**\n * Helper to draw a watermark on the captured image\n */\n function drawWatermark(c: CanvasRenderingContext2D, text: string, w: number, h: number, dpr: number) {\n c.save();\n // Scale font size according to DPR\n const fontSize = Math.max(16, 24 * (dpr / 2));\n c.font = `bold ${fontSize}px Inter, system-ui, sans-serif`;\n c.fillStyle = 'rgba(128, 128, 128, 0.4)';\n c.textAlign = 'right';\n c.textBaseline = 'bottom';\n c.fillText(text, w - (20 * dpr/2), h - (20 * dpr/2));\n c.restore();\n }\n\n const api: SnapshotExportAPI & Record<string, unknown> = {\n takeSnapshot,\n downloadSnapshot: async (opt: SnapshotExportOptions) => {\n await takeSnapshot({ ...opt, download: true });\n }\n };\n\n return {\n manifest: manifestSnapshot,\n onInit(c) { \n ctx = c; \n ctx.log.info(\"Snapshot plugin initialized\");\n },\n onDestroy() {\n ctx = null;\n },\n api\n };\n}\n\nexport default PluginSnapshot;\n\nexport type {\n SnapshotFormat,\n SnapshotResolution,\n SnapshotExportOptions,\n SnapshotExportAPI,\n PluginSnapshotConfig\n} from './types';\n"],"names":["manifestSnapshot","DEFAULT_OPTIONS","resolutionToScale","res","PluginSnapshot","config","ctx","takeSnapshot","options","_a","_b","opt","chart","scale","originalDPR","svg","blob","url","link","r","webglCanvas","overlayCanvas","compositionCanvas","compCtx","drawWatermark","mimeType","dataUrl","extension","c","text","w","h","dpr","fontSize"],"mappings":"AAsBA,MAAMA,IAAmC;AAAA,EACvC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU,CAAC,UAAU,UAAU;AAAA,EAC/B,MAAM,CAAC,YAAY,UAAU,eAAe,OAAO;AACrD,GAEMC,IAAmD;AAAA,EACvD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,UAAU;AAAA,EACV,UAAU;AACZ;AAEA,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AOD,EAAM,+BAAgC,aAC7CA,EAAM,4BAA4B,IAAI,IAEtCA,EAAM,OAAOE,CAAW;AAAA,IAGpC;AAAA,EACF;AAKA,WAASU,EAAcI,GAA6BC,GAAcC,GAAWC,GAAWC,GAAa;AACnG,IAAAJ,EAAE,KAAA;AAEF,UAAMK,IAAW,KAAK,IAAI,IAAI,MAAMD,IAAM,EAAE;AAC5C,IAAAJ,EAAE,OAAO,QAAQK,CAAQ,mCACzBL,EAAE,YAAY,4BACdA,EAAE,YAAY,SACdA,EAAE,eAAe,UACjBA,EAAE,SAASC,GAAMC,IAAK,KAAKE,IAAI,GAAID,IAAK,KAAKC,IAAI,CAAE,GACnDJ,EAAE,QAAA;AAAA,EACJ;AASA,SAAO;AAAA,IACL,UAAU5B;AAAA,IACV,OAAO4B,GAAG;AACN,MAAAtB,IAAMsB,GACNtB,EAAI,IAAI,KAAK,6BAA6B;AAAA,IAC9C;AAAA,IACA,YAAY;AACR,MAAAA,IAAM;AAAA,IACV;AAAA,IACA,KAhBuD;AAAA,MACvD,cAAAC;AAAA,MACA,kBAAkB,OAAOI,MAA+B;AACtD,cAAMJ,EAAa,EAAE,GAAGI,GAAK,UAAU,IAAM;AAAA,MAC/C;AAAA,IAAA;AAAA,EAYA;AAEJ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartPlugin } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Velo Plot - Streaming Plugin
|
|
4
4
|
*
|
|
5
5
|
* Provides real-time data streaming capabilities including:
|
|
6
6
|
* - WebSocket connections
|
|
@@ -24,7 +24,7 @@ export interface PluginStreamingConfig {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* VeloPlot Streaming Plugin
|
|
28
28
|
*
|
|
29
29
|
* Enables seamless integration with real-time data sources.
|
|
30
30
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './streaming/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './streaming/index'
|
|
3
|
+
export default VeloPlot
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartPlugin } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* VeloPlot Engine - Chart Sync Plugin
|
|
4
4
|
*
|
|
5
5
|
* Provides synchronization between multiple chart instances.
|
|
6
6
|
*
|
|
@@ -14,10 +14,11 @@ export interface PluginSyncConfig {
|
|
|
14
14
|
syncAxes?: "x" | "y" | "both";
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* VeloPlot Sync Plugin
|
|
18
18
|
*
|
|
19
19
|
* @deprecated Use `ChartGroup` / `createChartGroup` from `velo-plot` (or `velo-plot/full`) instead.
|
|
20
20
|
* This plugin stub does not perform synchronization. Kept for backward-compatible imports only.
|
|
21
|
+
* **Removed in v4.0.**
|
|
21
22
|
*/
|
|
22
23
|
export declare function PluginSync(config?: PluginSyncConfig): ChartPlugin<PluginSyncConfig>;
|
|
23
24
|
export default PluginSync;
|
package/dist/plugins/sync.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './sync/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './sync/index'
|
|
3
|
+
export default VeloPlot
|
package/dist/plugins/sync.js
CHANGED
package/dist/plugins/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sources":["../../src/plugins/sync/index.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"sync.js","sources":["../../src/plugins/sync/index.ts"],"sourcesContent":["/**\n * VeloPlot Engine - Chart Sync Plugin\n * \n * Provides synchronization between multiple chart instances.\n * \n * @module plugins/sync\n */\n\nexport * from \"../../core/sync\";\n\nimport type { PluginManifest, ChartPlugin, PluginContext } from \"../types\";\n\nexport interface PluginSyncConfig {\n /** Group ID to join */\n groupId?: string;\n /** Sync axes: 'x' | 'y' | 'both' */\n syncAxes?: \"x\" | \"y\" | \"both\";\n}\n\nconst manifestSync: PluginManifest = {\n name: \"velo-plot-sync\",\n version: \"1.0.0\",\n description: \"Multi-chart synchronization for velo-plot\",\n provides: [\"interaction\"],\n tags: [\"sync\", \"multi-chart\", \"coordination\"],\n};\n\n/**\n * VeloPlot Sync Plugin\n *\n * @deprecated Use `ChartGroup` / `createChartGroup` from `velo-plot` (or `velo-plot/full`) instead.\n * This plugin stub does not perform synchronization. Kept for backward-compatible imports only.\n * **Removed in v4.0.**\n */\nexport function PluginSync(config: PluginSyncConfig = {}): ChartPlugin<PluginSyncConfig> {\n void config;\n return {\n manifest: manifestSync,\n\n onInit(_ctx: PluginContext) {\n console.warn(\n \"[PluginSync] Deprecated: use ChartGroup / createChartGroup from the core sync module instead.\",\n );\n },\n\n onDestroy(_ctx: PluginContext) {\n },\n };\n}\n\nexport default PluginSync;\n"],"names":["manifestSync","PluginSync","config","_ctx"],"mappings":";AAmBA,MAAMA,IAA+B;AAAA,EACjC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU,CAAC,aAAa;AAAA,EACxB,MAAM,CAAC,QAAQ,eAAe,cAAc;AAChD;AASO,SAASC,EAAWC,IAA2B,IAAmC;AAEvF,SAAO;AAAA,IACL,UAAUF;AAAA,IAEV,OAAOG,GAAqB;AAC1B,cAAQ;AAAA,QACN;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,UAAUA,GAAqB;AAAA,IAC/B;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './theme-editor/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './theme-editor/index'
|
|
3
|
+
export default VeloPlot
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tooltip System - High-performance, customizable tooltips for
|
|
2
|
+
* Tooltip System - High-performance, customizable tooltips for Velo Plot
|
|
3
3
|
*
|
|
4
4
|
* This module provides a comprehensive tooltip system with:
|
|
5
5
|
* - Multiple tooltip types (datapoint, crosshair, heatmap, etc.)
|
package/dist/plugins/tools.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './tools/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './tools/index'
|
|
3
|
+
export default VeloPlot
|
package/dist/plugins/tools.js
CHANGED
package/dist/plugins/types.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface PluginManifest {
|
|
|
36
36
|
dependencies?: string[];
|
|
37
37
|
/** Optional plugins that enhance this one if present */
|
|
38
38
|
optionalDependencies?: string[];
|
|
39
|
-
/** Minimum
|
|
39
|
+
/** Minimum Velo Plot version required */
|
|
40
40
|
engineVersion?: PluginVersion;
|
|
41
41
|
/** Plugin-specific configuration schema (JSON Schema format) */
|
|
42
42
|
configSchema?: Record<string, unknown>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './video-recorder/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './video-recorder/index'
|
|
3
|
+
export default VeloPlot
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './virtualization/index'
|
|
2
|
-
import
|
|
3
|
-
export default
|
|
2
|
+
import VeloPlot from './virtualization/index'
|
|
3
|
+
export default VeloPlot
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var l = (n, e, r) => e in n ? h(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
|
|
3
|
+
var i = (n, e, r) => l(n, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
class k {
|
|
5
|
+
constructor(e, r = {}) {
|
|
6
|
+
i(this, "workers", []);
|
|
7
|
+
i(this, "pending", /* @__PURE__ */ new Map());
|
|
8
|
+
i(this, "nextWorker", 0);
|
|
9
|
+
i(this, "poolSize");
|
|
10
|
+
i(this, "syncFallback");
|
|
11
|
+
i(this, "timeoutMs");
|
|
12
|
+
i(this, "workerFactory");
|
|
13
|
+
i(this, "syncHandler");
|
|
14
|
+
i(this, "destroyed", !1);
|
|
15
|
+
if (this.workerFactory = e, this.poolSize = r.poolSize ?? 2, this.syncFallback = r.syncFallback ?? !0, this.timeoutMs = r.timeoutMs ?? 250, this.syncHandler = r.syncHandler, typeof Worker < "u")
|
|
16
|
+
for (let t = 0; t < this.poolSize; t++)
|
|
17
|
+
this.spawnWorker();
|
|
18
|
+
}
|
|
19
|
+
removeWorker(e) {
|
|
20
|
+
const r = this.workers.indexOf(e);
|
|
21
|
+
r >= 0 && this.workers.splice(r, 1), e.terminate();
|
|
22
|
+
}
|
|
23
|
+
workerErrorMessage(e) {
|
|
24
|
+
const r = e;
|
|
25
|
+
return typeof r.message == "string" && r.message ? r.message : "Worker error";
|
|
26
|
+
}
|
|
27
|
+
rejectPendingWithSyncFallback(e, r) {
|
|
28
|
+
this.removeWorker(e);
|
|
29
|
+
const t = this.workerErrorMessage(r), s = [...this.pending.entries()];
|
|
30
|
+
this.pending.clear();
|
|
31
|
+
for (const [, o] of s) {
|
|
32
|
+
if (this.clearTaskTimer(o), this.syncFallback && this.syncHandler) {
|
|
33
|
+
Promise.resolve(this.syncHandler(o.task)).then(o.resolve).catch(o.reject);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
o.reject(new Error(t));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
clearTaskTimer(e) {
|
|
40
|
+
e.timer !== void 0 && clearTimeout(e.timer);
|
|
41
|
+
}
|
|
42
|
+
settleWithSync(e) {
|
|
43
|
+
if (this.syncFallback && this.syncHandler) {
|
|
44
|
+
Promise.resolve(this.syncHandler(e.task)).then(e.resolve).catch(e.reject);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
e.reject(new Error("Worker task timed out"));
|
|
48
|
+
}
|
|
49
|
+
spawnWorker() {
|
|
50
|
+
const e = this.workerFactory();
|
|
51
|
+
e.onmessage = (r) => {
|
|
52
|
+
const t = r.data;
|
|
53
|
+
if (!(t != null && t.id)) return;
|
|
54
|
+
const s = this.pending.get(t.id);
|
|
55
|
+
if (s) {
|
|
56
|
+
if (this.pending.delete(t.id), this.clearTaskTimer(s), t.type === "error" || t.error) {
|
|
57
|
+
this.syncFallback && this.syncHandler ? this.settleWithSync(s) : s.reject(new Error(t.error ?? "Worker task failed"));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
s.resolve(t);
|
|
61
|
+
}
|
|
62
|
+
}, e.onerror = (r) => {
|
|
63
|
+
this.rejectPendingWithSyncFallback(e, r);
|
|
64
|
+
}, this.workers.push(e);
|
|
65
|
+
}
|
|
66
|
+
/** Dispatch a task to the pool. Falls back to syncHandler when no workers exist. */
|
|
67
|
+
run(e) {
|
|
68
|
+
return this.destroyed ? Promise.reject(new Error("WorkerPool destroyed")) : this.workers.length === 0 ? this.syncFallback && this.syncHandler ? Promise.resolve(this.syncHandler(e)) : Promise.reject(new Error("No workers available and sync fallback disabled")) : new Promise((r, t) => {
|
|
69
|
+
const s = { resolve: r, reject: t, task: e };
|
|
70
|
+
this.timeoutMs > 0 && (s.timer = setTimeout(() => {
|
|
71
|
+
this.pending.has(e.id) && (this.pending.delete(e.id), this.settleWithSync(s));
|
|
72
|
+
}, this.timeoutMs)), this.pending.set(e.id, s);
|
|
73
|
+
const o = this.nextWorker;
|
|
74
|
+
this.nextWorker = (this.nextWorker + 1) % this.workers.length;
|
|
75
|
+
try {
|
|
76
|
+
this.workers[o].postMessage(e);
|
|
77
|
+
} catch (a) {
|
|
78
|
+
if (this.pending.delete(e.id), this.clearTaskTimer(s), this.syncFallback && this.syncHandler) {
|
|
79
|
+
Promise.resolve(this.syncHandler(e)).then(r).catch(t);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
t(a instanceof Error ? a : new Error(String(a)));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
size() {
|
|
87
|
+
return this.workers.length;
|
|
88
|
+
}
|
|
89
|
+
pendingCount() {
|
|
90
|
+
return this.pending.size;
|
|
91
|
+
}
|
|
92
|
+
destroy() {
|
|
93
|
+
this.destroyed = !0;
|
|
94
|
+
for (const e of this.pending.values())
|
|
95
|
+
this.clearTaskTimer(e);
|
|
96
|
+
for (const e of this.workers)
|
|
97
|
+
e.terminate();
|
|
98
|
+
this.workers = [], this.pending.clear();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let c = 0;
|
|
102
|
+
function y(n = "task") {
|
|
103
|
+
return c += 1, `${n}-${c}-${Date.now()}`;
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
k as W,
|
|
107
|
+
y as n
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=pool-DZ8shSqv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-DZ8shSqv.js","sources":["../src/workers/pool.ts"],"sourcesContent":["/**\n * Generic worker pool with round-robin dispatch and sync fallback.\n * @module workers/pool\n */\n\nexport interface WorkerPoolOptions {\n /** Number of workers (default: 2) */\n poolSize?: number;\n /** Run tasks on main thread when Worker is unavailable */\n syncFallback?: boolean;\n /**\n * If a worker never answers (common with broken Vite worker URLs in docs),\n * fall back to syncHandler after this many ms (default: 250).\n * Set 0 to disable.\n */\n timeoutMs?: number;\n}\n\nexport class WorkerPool<TMessage extends { id: string }, TResult = unknown> {\n private workers: Worker[] = [];\n private pending = new Map<\n string,\n {\n resolve: (value: TResult) => void;\n reject: (error: Error) => void;\n task: TMessage;\n timer?: ReturnType<typeof setTimeout>;\n }\n >();\n private nextWorker = 0;\n private readonly poolSize: number;\n private readonly syncFallback: boolean;\n private readonly timeoutMs: number;\n private readonly workerFactory: () => Worker;\n private readonly syncHandler?: (task: TMessage) => TResult | Promise<TResult>;\n private destroyed = false;\n\n constructor(\n workerFactory: () => Worker,\n options: WorkerPoolOptions & {\n syncHandler?: (task: TMessage) => TResult | Promise<TResult>;\n } = {},\n ) {\n this.workerFactory = workerFactory;\n this.poolSize = options.poolSize ?? 2;\n this.syncFallback = options.syncFallback ?? true;\n this.timeoutMs = options.timeoutMs ?? 250;\n this.syncHandler = options.syncHandler;\n\n if (typeof Worker !== \"undefined\") {\n for (let i = 0; i < this.poolSize; i++) {\n this.spawnWorker();\n }\n }\n }\n\n private removeWorker(worker: Worker): void {\n const index = this.workers.indexOf(worker);\n if (index >= 0) this.workers.splice(index, 1);\n worker.terminate();\n }\n\n private workerErrorMessage(event: Event): string {\n const maybe = event as { message?: string };\n if (typeof maybe.message === \"string\" && maybe.message) return maybe.message;\n return \"Worker error\";\n }\n\n private rejectPendingWithSyncFallback(failedWorker: Worker, event: Event): void {\n this.removeWorker(failedWorker);\n const message = this.workerErrorMessage(event);\n const entries = [...this.pending.entries()];\n this.pending.clear();\n\n for (const [, entry] of entries) {\n this.clearTaskTimer(entry);\n if (this.syncFallback && this.syncHandler) {\n Promise.resolve(this.syncHandler(entry.task)).then(entry.resolve).catch(entry.reject);\n continue;\n }\n entry.reject(new Error(message));\n }\n }\n\n private clearTaskTimer(entry: { timer?: ReturnType<typeof setTimeout> }): void {\n if (entry.timer !== undefined) clearTimeout(entry.timer);\n }\n\n private settleWithSync(entry: {\n resolve: (value: TResult) => void;\n reject: (error: Error) => void;\n task: TMessage;\n }): void {\n if (this.syncFallback && this.syncHandler) {\n Promise.resolve(this.syncHandler(entry.task)).then(entry.resolve).catch(entry.reject);\n return;\n }\n entry.reject(new Error(\"Worker task timed out\"));\n }\n\n private spawnWorker(): void {\n const worker = this.workerFactory();\n worker.onmessage = (event: MessageEvent) => {\n const data = event.data as { id?: string; type?: string; error?: string };\n if (!data?.id) return;\n\n const task = this.pending.get(data.id);\n if (!task) return;\n\n this.pending.delete(data.id);\n this.clearTaskTimer(task);\n\n if (data.type === \"error\" || data.error) {\n if (this.syncFallback && this.syncHandler) {\n this.settleWithSync(task);\n } else {\n task.reject(new Error(data.error ?? \"Worker task failed\"));\n }\n return;\n }\n\n task.resolve(data as TResult);\n };\n\n worker.onerror = (event) => {\n this.rejectPendingWithSyncFallback(worker, event);\n };\n\n this.workers.push(worker);\n }\n\n /** Dispatch a task to the pool. Falls back to syncHandler when no workers exist. */\n run(task: TMessage): Promise<TResult> {\n if (this.destroyed) {\n return Promise.reject(new Error(\"WorkerPool destroyed\"));\n }\n\n if (this.workers.length === 0) {\n if (this.syncFallback && this.syncHandler) {\n return Promise.resolve(this.syncHandler(task));\n }\n return Promise.reject(new Error(\"No workers available and sync fallback disabled\"));\n }\n\n return new Promise((resolve, reject) => {\n const entry: {\n resolve: (value: TResult) => void;\n reject: (error: Error) => void;\n task: TMessage;\n timer?: ReturnType<typeof setTimeout>;\n } = { resolve, reject, task };\n\n if (this.timeoutMs > 0) {\n entry.timer = setTimeout(() => {\n if (!this.pending.has(task.id)) return;\n this.pending.delete(task.id);\n // Silent worker (Vite docs often loads a broken worker URL that never\n // answers and never fires onerror) — fall back to main-thread calc.\n this.settleWithSync(entry);\n }, this.timeoutMs);\n }\n\n this.pending.set(task.id, entry);\n const workerIndex = this.nextWorker;\n this.nextWorker = (this.nextWorker + 1) % this.workers.length;\n try {\n this.workers[workerIndex].postMessage(task);\n } catch (err) {\n this.pending.delete(task.id);\n this.clearTaskTimer(entry);\n if (this.syncFallback && this.syncHandler) {\n Promise.resolve(this.syncHandler(task)).then(resolve).catch(reject);\n return;\n }\n reject(err instanceof Error ? err : new Error(String(err)));\n }\n });\n }\n\n size(): number {\n return this.workers.length;\n }\n\n pendingCount(): number {\n return this.pending.size;\n }\n\n destroy(): void {\n this.destroyed = true;\n for (const entry of this.pending.values()) {\n this.clearTaskTimer(entry);\n }\n for (const worker of this.workers) {\n worker.terminate();\n }\n this.workers = [];\n this.pending.clear();\n }\n}\n\nlet taskCounter = 0;\n\n/** Generate a unique task id */\nexport function nextTaskId(prefix = \"task\"): string {\n taskCounter += 1;\n return `${prefix}-${taskCounter}-${Date.now()}`;\n}\n"],"names":["WorkerPool","workerFactory","options","__publicField","i","worker","index","event","maybe","failedWorker","message","entries","entry","data","task","resolve","reject","workerIndex","err","taskCounter","nextTaskId","prefix"],"mappings":";;;AAkBO,MAAMA,EAA+D;AAAA,EAmB1E,YACEC,GACAC,IAEI,IACJ;AAvBM,IAAAC,EAAA,iBAAoB,CAAA;AACpB,IAAAA,EAAA,qCAAc,IAAA;AASd,IAAAA,EAAA,oBAAa;AACJ,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACT,IAAAA,EAAA,mBAAY;AAclB,QANA,KAAK,gBAAgBF,GACrB,KAAK,WAAWC,EAAQ,YAAY,GACpC,KAAK,eAAeA,EAAQ,gBAAgB,IAC5C,KAAK,YAAYA,EAAQ,aAAa,KACtC,KAAK,cAAcA,EAAQ,aAEvB,OAAO,SAAW;AACpB,eAASE,IAAI,GAAGA,IAAI,KAAK,UAAUA;AACjC,aAAK,YAAA;AAAA,EAGX;AAAA,EAEQ,aAAaC,GAAsB;AACzC,UAAMC,IAAQ,KAAK,QAAQ,QAAQD,CAAM;AACzC,IAAIC,KAAS,KAAG,KAAK,QAAQ,OAAOA,GAAO,CAAC,GAC5CD,EAAO,UAAA;AAAA,EACT;AAAA,EAEQ,mBAAmBE,GAAsB;AAC/C,UAAMC,IAAQD;AACd,WAAI,OAAOC,EAAM,WAAY,YAAYA,EAAM,UAAgBA,EAAM,UAC9D;AAAA,EACT;AAAA,EAEQ,8BAA8BC,GAAsBF,GAAoB;AAC9E,SAAK,aAAaE,CAAY;AAC9B,UAAMC,IAAU,KAAK,mBAAmBH,CAAK,GACvCI,IAAU,CAAC,GAAG,KAAK,QAAQ,SAAS;AAC1C,SAAK,QAAQ,MAAA;AAEb,eAAW,CAAA,EAAGC,CAAK,KAAKD,GAAS;AAE/B,UADA,KAAK,eAAeC,CAA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QAAQ,OAAA;AAC/B,WAAK,eAAeA,CAAK;AAE3B,eAAWP,KAAU,KAAK;AACxB,MAAAA,EAAO,UAAA;AAET,SAAK,UAAU,CAAA,GACf,KAAK,QAAQ,MAAA;AAAA,EACf;AACF;AAEA,IAAIc,IAAc;AAGX,SAASC,EAAWC,IAAS,QAAgB;AAClD,SAAAF,KAAe,GACR,GAAGE,CAAM,IAAIF,CAAW,IAAI,KAAK,KAAK;AAC/C;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { UseStackedPlotOptions } from './useStackedPlot';
|
|
3
|
+
import { StackedChart } from '../core/stacked';
|
|
4
|
+
import { Bounds } from '../types';
|
|
5
|
+
import { AddIndicatorOptions } from '../core/indicator/addIndicator';
|
|
6
|
+
import { IndicatorPresetName } from '../core/indicator/indicatorPresets';
|
|
7
|
+
|
|
8
|
+
export interface StackedPlotIndicator extends AddIndicatorOptions {
|
|
9
|
+
type: IndicatorPresetName;
|
|
10
|
+
}
|
|
11
|
+
export interface StackedPlotProps extends UseStackedPlotOptions {
|
|
12
|
+
width?: number | string;
|
|
13
|
+
height?: number | string;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
indicators?: StackedPlotIndicator[];
|
|
17
|
+
onCrosshairMove?: (event: {
|
|
18
|
+
price?: number;
|
|
19
|
+
x: number;
|
|
20
|
+
}) => void;
|
|
21
|
+
drawingTools?: string[];
|
|
22
|
+
ariaLabel?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface StackedPlotRef {
|
|
25
|
+
getStack: () => StackedChart | null;
|
|
26
|
+
fitAll: () => void;
|
|
27
|
+
resetAll: () => void;
|
|
28
|
+
getBounds: () => Bounds | null;
|
|
29
|
+
}
|
|
30
|
+
export declare const StackedPlot: import('react').ForwardRefExoticComponent<StackedPlotProps & import('react').RefAttributes<StackedPlotRef>>;
|
|
31
|
+
export default StackedPlot;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { UseVeloPlotOptions } from './useVeloPlot';
|
|
3
|
+
import { ZoomOptions, CursorOptions, Bounds } from '../types';
|
|
4
|
+
import { Chart } from '../core/Chart';
|
|
5
|
+
import { VeloPlotSeries } from '../bindings/shared';
|
|
6
|
+
|
|
7
|
+
export type { VeloPlotSeries } from '../bindings/shared';
|
|
8
|
+
export interface VeloPlotProps extends UseVeloPlotOptions {
|
|
9
|
+
series?: VeloPlotSeries[];
|
|
10
|
+
zoom?: ZoomOptions;
|
|
11
|
+
onZoomChange?: (bounds: Bounds) => void;
|
|
12
|
+
cursor?: CursorOptions;
|
|
13
|
+
width?: number | string;
|
|
14
|
+
height?: number | string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
/** Custom aria-label for accessibility */
|
|
19
|
+
ariaLabel?: string;
|
|
20
|
+
/** Enable keyboard navigation (default: true) */
|
|
21
|
+
keyboardNav?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface VeloPlotRef {
|
|
24
|
+
getChart: () => Chart | null;
|
|
25
|
+
resetZoom: () => void;
|
|
26
|
+
getBounds: () => Bounds | null;
|
|
27
|
+
}
|
|
28
|
+
export declare const VeloPlot: import('react').ForwardRefExoticComponent<VeloPlotProps & import('react').RefAttributes<VeloPlotRef>>;
|
|
29
|
+
export default VeloPlot;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
import { useVeloPlot as useVeloPlotImpl } from './useVeloPlot';
|
|
1
2
|
/**
|
|
2
3
|
* React bindings for Velo Plot
|
|
3
4
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { VeloPlot, type VeloPlotProps, type VeloPlotRef, type VeloPlotSeries, } from './VeloPlot';
|
|
6
|
+
export { StackedPlot, type StackedPlotProps, type StackedPlotRef, type StackedPlotIndicator, } from './StackedPlot';
|
|
7
|
+
export { useVeloPlot, type UseVeloPlotOptions, type UseVeloPlotReturn, } from './useVeloPlot';
|
|
8
|
+
export { useStackedPlot, type UseStackedPlotOptions, type UseStackedPlotReturn, } from './useStackedPlot';
|
|
9
|
+
export { useIndicator, type UseIndicatorReturn, } from './useIndicator';
|
|
10
|
+
export { useChartSync, useChartGroup, type UseChartSyncReturn, } from './useChartSync';
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `VeloPlot` instead. **Removed in v4.0.**
|
|
13
|
+
*/
|
|
14
|
+
export declare const SciPlot: import('react').ForwardRefExoticComponent<import('./VeloPlot').VeloPlotProps & import('react').RefAttributes<import('./VeloPlot').VeloPlotRef>>;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `VeloPlot` instead. **Removed in v4.0.**
|
|
17
|
+
*/
|
|
18
|
+
export declare const SciChart: import('react').ForwardRefExoticComponent<import('./VeloPlot').VeloPlotProps & import('react').RefAttributes<import('./VeloPlot').VeloPlotRef>>;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**
|
|
21
|
+
*/
|
|
22
|
+
export declare const useSciPlot: typeof useVeloPlotImpl;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**
|
|
25
|
+
*/
|
|
26
|
+
export declare const useSciChart: typeof useVeloPlotImpl;
|
|
27
|
+
export type { VeloPlotProps as SciPlotProps, VeloPlotRef as SciPlotRef, VeloPlotSeries as SciPlotSeries, VeloPlotProps as SciChartProps, VeloPlotRef as SciChartRef, VeloPlotSeries as SciChartSeries, } from './VeloPlot';
|
|
28
|
+
export type { UseVeloPlotOptions as UseSciPlotOptions, UseVeloPlotReturn as UseSciPlotReturn, UseVeloPlotOptions as UseSciChartOptions, UseVeloPlotReturn as UseSciChartReturn, } from './useVeloPlot';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartLike, SyncOptions, ChartGroup } from '../core/sync';
|
|
2
|
+
|
|
3
|
+
export interface UseChartSyncReturn {
|
|
4
|
+
group: ChartGroup | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function useChartSync(charts: ChartLike[], options?: SyncOptions): UseChartSyncReturn;
|
|
7
|
+
/** Alias matching roadmap naming (`useChartGroup` ≡ `useChartSync`). */
|
|
8
|
+
export declare const useChartGroup: typeof useChartSync;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AddIndicatorOptions, AddIndicatorResult } from '../core/indicator/addIndicator';
|
|
2
|
+
import { IndicatorPresetName } from '../core/indicator/indicatorPresets';
|
|
3
|
+
import { IndicatorHost } from '../bindings/shared';
|
|
4
|
+
|
|
5
|
+
export interface UseIndicatorReturn {
|
|
6
|
+
result: (AddIndicatorResult & {
|
|
7
|
+
paneId?: string;
|
|
8
|
+
}) | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function useIndicator(host: IndicatorHost, preset: IndicatorPresetName, options?: AddIndicatorOptions): UseIndicatorReturn;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Chart } from '../core/Chart';
|
|
3
|
+
import { SeriesOptions, SeriesUpdateData, ZoomOptions, Bounds } from '../types';
|
|
4
|
+
import { ChartBindingOptions } from '../bindings/shared';
|
|
5
|
+
|
|
6
|
+
export interface UseVeloPlotOptions extends ChartBindingOptions {
|
|
7
|
+
}
|
|
8
|
+
export interface UseVeloPlotReturn {
|
|
9
|
+
chart: Chart | null;
|
|
10
|
+
isReady: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
bounds: Bounds | null;
|
|
13
|
+
addSeries: (options: SeriesOptions) => void;
|
|
14
|
+
updateSeries: (id: string, data: SeriesUpdateData) => void;
|
|
15
|
+
removeSeries: (id: string) => void;
|
|
16
|
+
zoom: (options: ZoomOptions) => void;
|
|
17
|
+
resetZoom: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function useVeloPlot(containerRef: RefObject<HTMLDivElement>, options?: UseVeloPlotOptions): UseVeloPlotReturn;
|