velo-plot 3.0.0 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -15
- package/dist/ChartCore-KYG2HTcK.js +7474 -0
- package/dist/ChartCore-KYG2HTcK.js.map +1 -0
- package/dist/GpuChartRenderer-Dxc0hrQA.js +75 -0
- package/dist/GpuChartRenderer-Dxc0hrQA.js.map +1 -0
- package/dist/{index.core-BmZe2jRQ.js → PluginRegistry-CDf_jcnp.js} +19 -33
- package/dist/PluginRegistry-CDf_jcnp.js.map +1 -0
- package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
- package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
- package/dist/angular-hooks.js +1 -1
- package/dist/angular.js +8 -8
- package/dist/{axisFormat-CzumxpCL.js → axisFormat-Sz4WIJfQ.js} +2 -2
- package/dist/{axisFormat-CzumxpCL.js.map → axisFormat-Sz4WIJfQ.js.map} +1 -1
- package/dist/{chartSyncBridge-DbWrwtyP.js → chartSyncBridge-C1uRy0ZS.js} +12 -11
- package/dist/{chartSyncBridge-DbWrwtyP.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
- package/dist/core/ChartStatistics.d.ts +1 -1
- package/dist/core/chart/ChartCore.d.ts +19 -20
- package/dist/core/chart/ChartFeatureHooks.d.ts +7 -0
- package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
- package/dist/core/chart/ChartRenderer.d.ts +9 -0
- package/dist/core/chart/ChartSetup.d.ts +1 -0
- package/dist/core/chart/chartExportPatch.d.ts +2 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
- package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
- package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
- package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
- package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
- package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
- package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
- package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
- package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
- package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
- package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
- package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
- package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
- package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
- package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
- package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
- package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
- package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
- package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
- package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
- package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
- package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
- package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
- package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
- package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
- package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
- package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
- package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
- package/dist/core/chart/mountSVGString.d.ts +5 -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 +2 -2
- package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
- package/dist/core/stacked/index.d.ts +3 -2
- package/dist/core/stacked/types.d.ts +12 -4
- package/dist/createStackedChart-DjA3aJAu.js +2761 -0
- package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
- package/dist/{hooks-CYPCxoZx.js → hooks-4wQH27r9.js} +7 -7
- package/dist/{hooks-CYPCxoZx.js.map → hooks-4wQH27r9.js.map} +1 -1
- 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-Bj-xyXY6.js +582 -0
- package/dist/index-Bj-xyXY6.js.map +1 -0
- package/dist/index-qhscKTDy.js.map +1 -1
- package/dist/index.core.d.ts +8 -6
- package/dist/index.d.ts +1 -14
- package/dist/plugins/3d.js +3 -1
- package/dist/plugins/3d.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/annotations.js +8 -7
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/broken-axis.js +198 -152
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/createPlugin.d.ts +8 -0
- package/dist/plugins/debug.js +32 -32
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/forecasting.js +273 -258
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/gpu.js +2033 -209
- package/dist/plugins/gpu.js.map +1 -1
- package/dist/plugins/i18n.js +286 -23
- package/dist/plugins/i18n.js.map +1 -1
- package/dist/plugins/latex.js +766 -207
- package/dist/plugins/latex.js.map +1 -1
- package/dist/plugins/loading/index.d.ts +1 -2
- package/dist/plugins/loading.js +3 -4
- package/dist/plugins/ml-integration.js +107 -93
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/offscreen.js +11 -10
- package/dist/plugins/offscreen.js.map +1 -1
- package/dist/plugins/radar/types.d.ts +11 -0
- package/dist/plugins/radar.js +64 -53
- package/dist/plugins/radar.js.map +1 -1
- package/dist/plugins/regression.js +254 -256
- package/dist/plugins/regression.js.map +1 -1
- package/dist/plugins/roi/index.d.ts +2 -0
- package/dist/plugins/roi.js +184 -145
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot.js +20 -15
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/streaming.js +1 -1
- package/dist/plugins/tools.js +1 -1
- package/dist/plugins/types.d.ts +4 -0
- package/dist/react.js +55 -58
- package/dist/react.js.map +1 -1
- package/dist/regression-HNdyk1Dm.js +28 -0
- package/dist/regression-HNdyk1Dm.js.map +1 -0
- package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
- package/dist/renderer/NativeWebGLRenderer.d.ts +2 -1
- package/dist/renderer/SVGChartRenderer.d.ts +15 -0
- package/dist/renderer/SankeyRenderer.d.ts +1 -0
- 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/registerSVG.d.ts +5 -0
- package/dist/renderer/registerWebGPU.d.ts +2 -0
- package/dist/renderer/sankeyLayout.d.ts +29 -0
- package/dist/renderer/seriesBufferExtended.d.ts +4 -0
- package/dist/scientific/index.d.ts +1 -5
- package/dist/scientific/registerScientific.d.ts +1 -0
- package/dist/scientific.js +41 -41
- package/dist/solid.js +56 -59
- package/dist/solid.js.map +1 -1
- package/dist/svelte.js +26 -29
- package/dist/svelte.js.map +1 -1
- package/dist/tickUtils-B_X-ha13.js +41 -0
- package/dist/tickUtils-B_X-ha13.js.map +1 -0
- 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 +5 -4
- package/dist/velo-plot.full.js +1951 -1275
- 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/VeloPlot.vue.d.ts +1 -1
- package/dist/vue/index.d.ts +33 -33
- package/dist/vue.js +17 -20
- package/dist/vue.js.map +1 -1
- package/package.json +14 -1
- package/dist/ChartCore-BpzRvN4Y.js +0 -8467
- package/dist/ChartCore-BpzRvN4Y.js.map +0 -1
- package/dist/createStackedChart-Dm-YqUT7.js +0 -756
- package/dist/createStackedChart-Dm-YqUT7.js.map +0 -1
- package/dist/gpuRenderer-BpaMYz-k.js +0 -1848
- package/dist/gpuRenderer-BpaMYz-k.js.map +0 -1
- package/dist/index-BMiZoKmm.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-BmZe2jRQ.js.map +0 -1
- package/dist/mockDatafeed-DHIDPcpX.js +0 -515
- package/dist/mockDatafeed-DHIDPcpX.js.map +0 -1
- package/dist/symbols-DT0eLlpW.js +0 -568
- package/dist/symbols-DT0eLlpW.js.map +0 -1
package/dist/plugins/snapshot.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const k = {
|
|
2
2
|
name: "velo-plot-snapshot",
|
|
3
3
|
version: "1.0.0",
|
|
4
4
|
description: "High-resolution image export for velo-plot",
|
|
5
5
|
provides: ["export", "snapshot"],
|
|
6
6
|
tags: ["snapshot", "export", "publication", "image"]
|
|
7
|
-
},
|
|
7
|
+
}, b = {
|
|
8
8
|
format: "png",
|
|
9
9
|
quality: 0.9,
|
|
10
10
|
resolution: "standard",
|
|
@@ -15,7 +15,7 @@ const b = {
|
|
|
15
15
|
fileName: "velo-plot-snapshot-export",
|
|
16
16
|
download: !1
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function O(c) {
|
|
19
19
|
if (typeof c == "number") return c;
|
|
20
20
|
switch (c) {
|
|
21
21
|
case "8k":
|
|
@@ -30,23 +30,28 @@ function R(c) {
|
|
|
30
30
|
return 1;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function P(c = {}) {
|
|
34
34
|
let a = null;
|
|
35
35
|
async function p(t = {}) {
|
|
36
|
-
var
|
|
36
|
+
var f, h;
|
|
37
37
|
if (!a) throw new Error("Snapshot plugin not initialized");
|
|
38
|
-
const e = { ...
|
|
38
|
+
const e = { ...b, ...c.defaultOptions, ...t }, n = a.chart, s = O(e.resolution), i = n.getDPR();
|
|
39
39
|
try {
|
|
40
40
|
if (e.format === "svg") {
|
|
41
|
-
const o = n.exportSVG(
|
|
41
|
+
const o = n.exportSVG({
|
|
42
|
+
includeOverlays: e.includeOverlays,
|
|
43
|
+
includeAnnotations: e.includeOverlays,
|
|
44
|
+
includeLegend: !0,
|
|
45
|
+
watermarkText: e.watermarkText || void 0
|
|
46
|
+
});
|
|
42
47
|
if (e.download) {
|
|
43
|
-
const l = new Blob([o], { type: "image/svg+xml" }), w = URL.createObjectURL(l),
|
|
44
|
-
|
|
48
|
+
const l = new Blob([o], { type: "image/svg+xml" }), w = URL.createObjectURL(l), u = document.createElement("a");
|
|
49
|
+
u.download = `${e.fileName}.svg`, u.href = w, document.body.appendChild(u), u.click(), document.body.removeChild(u), URL.revokeObjectURL(w);
|
|
45
50
|
}
|
|
46
51
|
return o;
|
|
47
52
|
}
|
|
48
53
|
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 = (
|
|
54
|
+
const m = (f = a.render.gl) == null ? void 0 : f.canvas, g = (h = a.render.ctx2d) == null ? void 0 : h.canvas;
|
|
50
55
|
if (!m) throw new Error("WebGL canvas not found");
|
|
51
56
|
const r = document.createElement("canvas");
|
|
52
57
|
r.width = m.width, r.height = m.height;
|
|
@@ -64,11 +69,11 @@ function S(c = {}) {
|
|
|
64
69
|
}
|
|
65
70
|
function x(t, e, n, s, i) {
|
|
66
71
|
t.save();
|
|
67
|
-
const
|
|
68
|
-
t.font = `bold ${
|
|
72
|
+
const f = Math.max(16, 24 * (i / 2));
|
|
73
|
+
t.font = `bold ${f}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
74
|
}
|
|
70
75
|
return {
|
|
71
|
-
manifest:
|
|
76
|
+
manifest: k,
|
|
72
77
|
onInit(t) {
|
|
73
78
|
a = t, a.log.info("Snapshot plugin initialized");
|
|
74
79
|
},
|
|
@@ -84,7 +89,7 @@ function S(c = {}) {
|
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
export {
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
P as PluginSnapshot,
|
|
93
|
+
P as default
|
|
89
94
|
};
|
|
90
95
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
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,SAASC,EAAkBC,GAAiC;AAC1D,MAAI,OAAOA,KAAQ,SAAU,QAAOA;AACpC,UAAQA,GAAA;AAAA,IACN,KAAK;AAAM,aAAO;AAAA,IAClB,KAAK;AAAM,aAAO;AAAA,IAClB,KAAK;AAAM,aAAO;AAAA,IAClB,KAAK;AAAY,aAAO;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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 includeOverlays: opt.includeOverlays,\n includeAnnotations: opt.includeOverlays,\n includeLegend: true,\n watermarkText: opt.watermarkText || undefined,\n });\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,SAASC,EAAkBC,GAAiC;AAC1D,MAAI,OAAOA,KAAQ,SAAU,QAAOA;AACpC,UAAQA,GAAA;AAAA,IACN,KAAK;AAAM,aAAO;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AAQ,MACJ,OAAOD,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,4 +1,4 @@
|
|
|
1
|
-
import { B as r, C as s, P as t, a as c, e as n, b as o, d as u, c as g, P as m } from "../index-
|
|
1
|
+
import { B as r, C as s, P as t, a as c, e as n, b as o, d as u, c as g, P as m } from "../index-BgrvqltV.js";
|
|
2
2
|
export {
|
|
3
3
|
r as BackpressureManager,
|
|
4
4
|
s as CircularBuffer,
|
package/dist/plugins/tools.js
CHANGED
package/dist/plugins/types.d.ts
CHANGED
|
@@ -333,6 +333,10 @@ export interface ChartPlugin<TConfig = unknown> {
|
|
|
333
333
|
* Use for custom 2D canvas rendering
|
|
334
334
|
*/
|
|
335
335
|
onRenderOverlay?(ctx: PluginContext, event: AfterRenderEvent): void;
|
|
336
|
+
/**
|
|
337
|
+
* Called during SVG export to contribute vector overlay elements.
|
|
338
|
+
*/
|
|
339
|
+
onExportSVG?(ctx: import('../core/chart/exporter/svg/plugins/types').SVGExportPluginContext): void;
|
|
336
340
|
/**
|
|
337
341
|
* Called after all rendering is complete
|
|
338
342
|
*/
|
package/dist/react.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { jsx as O, jsxs as A } from "react/jsx-runtime";
|
|
2
2
|
import { useState as R, useRef as m, useEffect as b, useCallback as E, forwardRef as F, useImperativeHandle as K, useMemo as T } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "./ChartCore-BpzRvN4Y.js";
|
|
6
|
-
import "./index-x4stH3jD.js";
|
|
7
|
-
import "./symbols-DT0eLlpW.js";
|
|
3
|
+
import { p as B, o as j, s as G, d as H } from "./optionsSync-QUiN4Inw.js";
|
|
4
|
+
import { c as J, a as X, i as Y, r as Z, b as q } from "./chartSyncBridge-C1uRy0ZS.js";
|
|
8
5
|
import { a as D, u as L } from "./a11y-Bw6urYpr.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { s as P, b as z, a as Q } from "./stackedSync-tnrunZMt.js";
|
|
7
|
+
import { c as U } from "./createStackedChart-DjA3aJAu.js";
|
|
11
8
|
function I(a, t = {}) {
|
|
12
|
-
const [l, n] = R(null), [i, p] = R(!1), [S, C] = R(null), [y, d] = R(null),
|
|
9
|
+
const [l, n] = R(null), [i, p] = R(!1), [S, C] = R(null), [y, d] = R(null), c = m(null), o = m(null), v = m(t), x = m(B(t));
|
|
13
10
|
v.current = t, b(() => {
|
|
14
11
|
const r = a.current;
|
|
15
12
|
if (r) {
|
|
16
13
|
try {
|
|
17
|
-
const e =
|
|
14
|
+
const e = J(
|
|
18
15
|
r,
|
|
19
16
|
v.current,
|
|
20
17
|
{
|
|
@@ -22,35 +19,35 @@ function I(a, t = {}) {
|
|
|
22
19
|
onError: C
|
|
23
20
|
}
|
|
24
21
|
);
|
|
25
|
-
|
|
22
|
+
c.current = e.chart, o.current = e.destroy, n(e.chart), p(!0), d(e.getBounds()), C(null), x.current = B(v.current);
|
|
26
23
|
} catch (e) {
|
|
27
24
|
console.error("[useVeloPlot] Failed to initialize chart:", e), C(e instanceof Error ? e : new Error(String(e))), p(!1);
|
|
28
25
|
}
|
|
29
26
|
return () => {
|
|
30
27
|
var e;
|
|
31
|
-
(e =
|
|
28
|
+
(e = o.current) == null || e.call(o), o.current = null, c.current = null, n(null), p(!1);
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
31
|
}, [a]), b(() => {
|
|
35
|
-
const r =
|
|
32
|
+
const r = c.current;
|
|
36
33
|
if (!r || !i) return;
|
|
37
34
|
const e = B(t), k = x.current;
|
|
38
|
-
|
|
35
|
+
j(k, e) && (G(r, k, e), x.current = e);
|
|
39
36
|
});
|
|
40
37
|
const s = E((r) => {
|
|
41
|
-
const e =
|
|
38
|
+
const e = c.current;
|
|
42
39
|
e && (e.addSeries(r), d(e.getViewBounds()));
|
|
43
40
|
}, []), f = E((r, e) => {
|
|
44
41
|
var k;
|
|
45
|
-
(k =
|
|
42
|
+
(k = c.current) == null || k.updateSeries(r, e);
|
|
46
43
|
}, []), g = E((r) => {
|
|
47
44
|
var e;
|
|
48
|
-
(e =
|
|
45
|
+
(e = c.current) == null || e.removeSeries(r);
|
|
49
46
|
}, []), u = E((r) => {
|
|
50
47
|
var e;
|
|
51
|
-
(e =
|
|
48
|
+
(e = c.current) == null || e.zoom(r);
|
|
52
49
|
}, []), h = E(() => {
|
|
53
|
-
const r =
|
|
50
|
+
const r = c.current;
|
|
54
51
|
r && (r.resetZoom(), d(r.getViewBounds()));
|
|
55
52
|
}, []);
|
|
56
53
|
return {
|
|
@@ -76,8 +73,8 @@ const N = F(
|
|
|
76
73
|
className: C = "",
|
|
77
74
|
style: y = {},
|
|
78
75
|
debug: d = !1,
|
|
79
|
-
ariaLabel:
|
|
80
|
-
keyboardNav:
|
|
76
|
+
ariaLabel: c,
|
|
77
|
+
keyboardNav: o = !0,
|
|
81
78
|
...v
|
|
82
79
|
}, x) {
|
|
83
80
|
const s = m(null), f = m(/* @__PURE__ */ new Map()), g = m(null), {
|
|
@@ -98,7 +95,7 @@ const N = F(
|
|
|
98
95
|
}),
|
|
99
96
|
[u, $, r]
|
|
100
97
|
), b(() => {
|
|
101
|
-
!h || !u || (f.current =
|
|
98
|
+
!h || !u || (f.current = H(
|
|
102
99
|
{ addSeries: e, updateSeries: k, removeSeries: V, autoScale: () => u.autoScale() },
|
|
103
100
|
t,
|
|
104
101
|
f.current
|
|
@@ -122,22 +119,22 @@ const N = F(
|
|
|
122
119
|
const M = s.current;
|
|
123
120
|
if (!(!h || !u || !M))
|
|
124
121
|
return g.current = D(M, u, {
|
|
125
|
-
label:
|
|
122
|
+
label: c,
|
|
126
123
|
series: t,
|
|
127
124
|
bounds: r,
|
|
128
|
-
enableKeyboard:
|
|
125
|
+
enableKeyboard: o
|
|
129
126
|
}), () => {
|
|
130
127
|
var w;
|
|
131
128
|
(w = g.current) == null || w.cleanup(), g.current = null;
|
|
132
129
|
};
|
|
133
|
-
}, [h, u, c,
|
|
130
|
+
}, [h, u, o, c, r, t]), b(() => {
|
|
134
131
|
const M = s.current;
|
|
135
132
|
!M || !g.current || L(M, g.current.srTable, {
|
|
136
|
-
label:
|
|
133
|
+
label: c,
|
|
137
134
|
series: t,
|
|
138
135
|
bounds: r
|
|
139
136
|
});
|
|
140
|
-
}, [t, r,
|
|
137
|
+
}, [t, r, c]);
|
|
141
138
|
const _ = T(
|
|
142
139
|
() => ({
|
|
143
140
|
position: "relative",
|
|
@@ -196,39 +193,39 @@ const N = F(
|
|
|
196
193
|
}
|
|
197
194
|
);
|
|
198
195
|
function W(a) {
|
|
199
|
-
const t = m(null), l = m(null), n = m(null), [i, p] = R(null), [S, C] = R(!1), y = m(a), d = m(P(a.panes)),
|
|
196
|
+
const t = m(null), l = m(null), n = m(null), [i, p] = R(null), [S, C] = R(!1), y = m(a), d = m(P(a.panes)), c = m(/* @__PURE__ */ new Map());
|
|
200
197
|
y.current = a;
|
|
201
|
-
const
|
|
198
|
+
const o = E(() => {
|
|
202
199
|
var g;
|
|
203
200
|
const s = t.current;
|
|
204
201
|
if (!s) return;
|
|
205
202
|
(g = n.current) == null || g.call(n);
|
|
206
|
-
const f =
|
|
203
|
+
const f = U({
|
|
207
204
|
...y.current,
|
|
208
205
|
container: s
|
|
209
206
|
});
|
|
210
207
|
l.current = f, n.current = () => {
|
|
211
208
|
f.destroy(), l.current = null;
|
|
212
|
-
}, p(f), d.current = P(y.current.panes),
|
|
209
|
+
}, p(f), d.current = P(y.current.panes), c.current = z(
|
|
213
210
|
f,
|
|
214
211
|
y.current.panes,
|
|
215
212
|
/* @__PURE__ */ new Map()
|
|
216
213
|
), f.whenReady().then(() => C(!0));
|
|
217
214
|
}, []);
|
|
218
|
-
b(() => (
|
|
215
|
+
b(() => (o(), () => {
|
|
219
216
|
var s;
|
|
220
217
|
C(!1), (s = n.current) == null || s.call(n), n.current = null, p(null);
|
|
221
|
-
}), [
|
|
218
|
+
}), [o]), b(() => {
|
|
222
219
|
const s = l.current;
|
|
223
220
|
if (!s || !S) return;
|
|
224
221
|
if (P(a.panes) !== d.current) {
|
|
225
|
-
|
|
222
|
+
o();
|
|
226
223
|
return;
|
|
227
224
|
}
|
|
228
|
-
|
|
225
|
+
Q(s, a), c.current = z(
|
|
229
226
|
s,
|
|
230
227
|
a.panes,
|
|
231
|
-
|
|
228
|
+
c.current
|
|
232
229
|
);
|
|
233
230
|
});
|
|
234
231
|
const v = E((s) => {
|
|
@@ -240,7 +237,7 @@ function W(a) {
|
|
|
240
237
|
}, []);
|
|
241
238
|
return { containerRef: t, stack: i, isReady: S, fitAll: v, resetAll: x };
|
|
242
239
|
}
|
|
243
|
-
const
|
|
240
|
+
const ae = F(
|
|
244
241
|
function({
|
|
245
242
|
width: t = "100%",
|
|
246
243
|
height: l = 480,
|
|
@@ -251,14 +248,14 @@ const fe = F(
|
|
|
251
248
|
drawingTools: C,
|
|
252
249
|
ariaLabel: y,
|
|
253
250
|
panes: d,
|
|
254
|
-
...
|
|
255
|
-
},
|
|
251
|
+
...c
|
|
252
|
+
}, o) {
|
|
256
253
|
const { containerRef: v, stack: x, isReady: s, fitAll: f, resetAll: g } = W({
|
|
257
254
|
panes: d,
|
|
258
|
-
...
|
|
255
|
+
...c
|
|
259
256
|
});
|
|
260
257
|
K(
|
|
261
|
-
|
|
258
|
+
o,
|
|
262
259
|
() => ({
|
|
263
260
|
getStack: () => x,
|
|
264
261
|
fitAll: () => f(),
|
|
@@ -289,19 +286,19 @@ const fe = F(
|
|
|
289
286
|
);
|
|
290
287
|
}
|
|
291
288
|
);
|
|
292
|
-
function
|
|
289
|
+
function le(a, t, l = {}) {
|
|
293
290
|
const [n, i] = R(null), [p, S] = R(!1), [C, y] = R(null), d = m(n);
|
|
294
291
|
return d.current = n, b(() => {
|
|
295
292
|
if (!a) return;
|
|
296
|
-
let
|
|
297
|
-
return S(!0), y(null),
|
|
298
|
-
|
|
299
|
-
}).catch((
|
|
300
|
-
|
|
293
|
+
let c = !1;
|
|
294
|
+
return S(!0), y(null), X(a, t, l).then((o) => {
|
|
295
|
+
c || (i(o), S(!1));
|
|
296
|
+
}).catch((o) => {
|
|
297
|
+
c || (y(o instanceof Error ? o : new Error(String(o))), S(!1));
|
|
301
298
|
}), () => {
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
299
|
+
c = !0;
|
|
300
|
+
const o = d.current;
|
|
301
|
+
o && !Y(a) && Z(a, o.id);
|
|
305
302
|
};
|
|
306
303
|
}, [a, t, JSON.stringify(l)]), { result: n, isLoading: p, error: C };
|
|
307
304
|
}
|
|
@@ -312,23 +309,23 @@ function ee(a, t) {
|
|
|
312
309
|
n(null);
|
|
313
310
|
return;
|
|
314
311
|
}
|
|
315
|
-
const i =
|
|
312
|
+
const i = q(a, t);
|
|
316
313
|
return n(i.group), () => {
|
|
317
314
|
i.destroy(), n(null);
|
|
318
315
|
};
|
|
319
316
|
}, [a, JSON.stringify(t)]), { group: l };
|
|
320
317
|
}
|
|
321
|
-
const
|
|
318
|
+
const ie = ee, fe = N, de = N, pe = I, Se = I;
|
|
322
319
|
export {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
320
|
+
de as SciChart,
|
|
321
|
+
fe as SciPlot,
|
|
322
|
+
ae as StackedPlot,
|
|
326
323
|
N as VeloPlot,
|
|
327
|
-
|
|
324
|
+
ie as useChartGroup,
|
|
328
325
|
ee as useChartSync,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
326
|
+
le as useIndicator,
|
|
327
|
+
Se as useSciChart,
|
|
328
|
+
pe as useSciPlot,
|
|
332
329
|
W as useStackedPlot,
|
|
333
330
|
I as useVeloPlot
|
|
334
331
|
};
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sources":["../src/react/useVeloPlot.ts","../src/react/VeloPlot.tsx","../src/react/useStackedPlot.ts","../src/react/StackedPlot.tsx","../src/react/useIndicator.ts","../src/react/useChartSync.ts","../src/react/index.ts"],"sourcesContent":["/**\n * useVeloPlot - React hook for Velo Plot\n */\n\nimport {\n useEffect,\n useRef,\n useState,\n useCallback,\n type RefObject,\n} from \"react\";\nimport type { Chart } from \"../core/Chart\";\nimport type {\n SeriesOptions,\n SeriesUpdateData,\n ZoomOptions,\n Bounds,\n} from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport interface UseVeloPlotReturn {\n chart: Chart | null;\n isReady: boolean;\n error: Error | null;\n bounds: Bounds | null;\n addSeries: (options: SeriesOptions) => void;\n updateSeries: (id: string, data: SeriesUpdateData) => void;\n removeSeries: (id: string) => void;\n zoom: (options: ZoomOptions) => void;\n resetZoom: () => void;\n}\n\nexport function useVeloPlot(\n containerRef: RefObject<HTMLDivElement>,\n options: UseVeloPlotOptions = {},\n): UseVeloPlotReturn {\n const [chart, setChart] = useState<Chart | null>(null);\n const [isReady, setIsReady] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [bounds, setBounds] = useState<Bounds | null>(null);\n\n const chartRef = useRef<Chart | null>(null);\n const destroyRef = useRef<(() => void) | null>(null);\n const optionsRef = useRef(options);\n const prevSyncOptionsRef = useRef(pickSyncableOptions(options));\n optionsRef.current = options;\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n try {\n const handle = createChartLifecycle(\n container,\n optionsRef.current,\n {\n onBoundsChange: setBounds,\n onError: setError,\n },\n );\n chartRef.current = handle.chart;\n destroyRef.current = handle.destroy;\n setChart(handle.chart);\n setIsReady(true);\n setBounds(handle.getBounds());\n setError(null);\n prevSyncOptionsRef.current = pickSyncableOptions(optionsRef.current);\n } catch (err) {\n console.error(\"[useVeloPlot] Failed to initialize chart:\", err);\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsReady(false);\n }\n\n return () => {\n destroyRef.current?.();\n destroyRef.current = null;\n chartRef.current = null;\n setChart(null);\n setIsReady(false);\n };\n }, [containerRef]);\n\n useEffect(() => {\n const currentChart = chartRef.current;\n if (!currentChart || !isReady) return;\n\n const next = pickSyncableOptions(options);\n const prev = prevSyncOptionsRef.current;\n if (optionsChanged(prev, next)) {\n syncChartOptions(currentChart, prev, next);\n prevSyncOptionsRef.current = next;\n }\n });\n\n const addSeries = useCallback((seriesOptions: SeriesOptions) => {\n const c = chartRef.current;\n if (c) {\n c.addSeries(seriesOptions);\n setBounds(c.getViewBounds());\n }\n }, []);\n\n const updateSeries = useCallback((id: string, data: SeriesUpdateData) => {\n chartRef.current?.updateSeries(id, data);\n }, []);\n\n const removeSeries = useCallback((id: string) => {\n chartRef.current?.removeSeries(id);\n }, []);\n\n const zoom = useCallback((zoomOptions: ZoomOptions) => {\n chartRef.current?.zoom(zoomOptions);\n }, []);\n\n const resetZoom = useCallback(() => {\n const c = chartRef.current;\n if (c) {\n c.resetZoom();\n setBounds(c.getViewBounds());\n }\n }, []);\n\n return {\n chart,\n isReady,\n error,\n bounds,\n addSeries,\n updateSeries,\n removeSeries,\n zoom,\n resetZoom,\n };\n}\n","/**\n * VeloPlot - React Component for Scientific Charts\n */\n\nimport {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useMemo,\n type CSSProperties,\n} from \"react\";\nimport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nimport type { ZoomOptions, CursorOptions, Bounds } from \"../types\";\nimport type { Chart } from \"../core/Chart\";\nimport {\n diffSeries,\n applyChartA11y,\n updateA11y,\n type VeloPlotSeries,\n} from \"../bindings/shared\";\n\nexport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface VeloPlotProps extends UseVeloPlotOptions {\n series?: VeloPlotSeries[];\n zoom?: ZoomOptions;\n onZoomChange?: (bounds: Bounds) => void;\n cursor?: CursorOptions;\n width?: number | string;\n height?: number | string;\n className?: string;\n style?: CSSProperties;\n debug?: boolean;\n /** Custom aria-label for accessibility */\n ariaLabel?: string;\n /** Enable keyboard navigation (default: true) */\n keyboardNav?: boolean;\n}\n\nexport interface VeloPlotRef {\n getChart: () => Chart | null;\n resetZoom: () => void;\n getBounds: () => Bounds | null;\n}\n\nexport const VeloPlot = forwardRef<VeloPlotRef, VeloPlotProps>(\n function VeloPlot(\n {\n series = [],\n zoom: zoomProp,\n onZoomChange,\n cursor,\n width = \"100%\",\n height = 400,\n className = \"\",\n style = {},\n debug = false,\n ariaLabel,\n keyboardNav = true,\n ...chartOptions\n },\n ref,\n ) {\n const containerRef = useRef<HTMLDivElement>(null);\n const previousSeriesRef = useRef<Map<string, VeloPlotSeries>>(new Map());\n const a11yRef = useRef<ReturnType<typeof applyChartA11y> | null>(null);\n\n const {\n chart,\n isReady,\n bounds,\n addSeries,\n updateSeries,\n removeSeries,\n resetZoom,\n } = useVeloPlot(containerRef, chartOptions);\n\n useImperativeHandle(\n ref,\n () => ({\n getChart: () => chart,\n resetZoom,\n getBounds: () => bounds,\n }),\n [chart, resetZoom, bounds],\n );\n\n useEffect(() => {\n if (!isReady || !chart) return;\n previousSeriesRef.current = diffSeries(\n { addSeries, updateSeries, removeSeries, autoScale: () => chart.autoScale() },\n series,\n previousSeriesRef.current,\n );\n }, [series, isReady, chart, addSeries, updateSeries, removeSeries]);\n\n useEffect(() => {\n if (!isReady || !chart || !zoomProp) return;\n chart.zoom(zoomProp);\n }, [isReady, chart, zoomProp]);\n\n useEffect(() => {\n if (!isReady || !chart || !onZoomChange) return;\n const handler = (event: { x: [number, number]; y: [number, number] }) => {\n onZoomChange({\n xMin: event.x[0],\n xMax: event.x[1],\n yMin: event.y[0],\n yMax: event.y[1],\n });\n };\n chart.on(\"zoom\", handler);\n return () => chart.off(\"zoom\", handler);\n }, [isReady, chart, onZoomChange]);\n\n useEffect(() => {\n if (!isReady || !chart) return;\n if (cursor?.enabled) {\n chart.enableCursor(cursor);\n } else {\n chart.disableCursor();\n }\n }, [isReady, chart, cursor]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!isReady || !chart || !el) return;\n\n a11yRef.current = applyChartA11y(el, chart, {\n label: ariaLabel,\n series,\n bounds,\n enableKeyboard: keyboardNav,\n });\n\n return () => {\n a11yRef.current?.cleanup();\n a11yRef.current = null;\n };\n }, [isReady, chart, keyboardNav, ariaLabel]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !a11yRef.current) return;\n updateA11y(el, a11yRef.current.srTable, {\n label: ariaLabel,\n series,\n bounds,\n });\n }, [series, bounds, ariaLabel]);\n\n const containerStyle = useMemo<CSSProperties>(\n () => ({\n position: \"relative\",\n width: typeof width === \"number\" ? `${width}px` : width,\n height: typeof height === \"number\" ? `${height}px` : height,\n outline: \"none\",\n ...style,\n }),\n [width, height, style],\n );\n\n return (\n <div\n ref={containerRef}\n className={`velo-plot-container ${className}`}\n style={containerStyle}\n >\n {debug && bounds && (\n <div\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n background: \"rgba(0,0,0,0.7)\",\n color: \"#0f0\",\n padding: \"4px 8px\",\n borderRadius: 4,\n fontSize: 11,\n fontFamily: \"monospace\",\n pointerEvents: \"none\",\n }}\n >\n <div>\n X: [{bounds.xMin.toFixed(3)}, {bounds.xMax.toFixed(3)}]\n </div>\n <div>\n Y: [{bounds.yMin.toExponential(2)}, {bounds.yMax.toExponential(2)}]\n </div>\n <div>Series: {series.length}</div>\n </div>\n )}\n </div>\n );\n },\n);\n\nexport default VeloPlot;\n","/**\n * useStackedPlot - React hook for multi-pane stacked charts\n */\n\nimport {\n useEffect,\n useRef,\n useState,\n useCallback,\n type RefObject,\n} from \"react\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport {\n stackedStructureKey,\n syncStackedOptions,\n syncStackedPaneSeries,\n} from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface UseStackedPlotOptions\n extends Omit<StackedChartOptions, \"container\"> {}\n\nexport interface UseStackedPlotReturn {\n containerRef: RefObject<HTMLDivElement>;\n stack: StackedChart | null;\n isReady: boolean;\n fitAll: (options?: { x?: Range; padding?: number }) => void;\n resetAll: () => void;\n}\n\nexport function useStackedPlot(\n options: UseStackedPlotOptions,\n): UseStackedPlotReturn {\n const containerRef = useRef<HTMLDivElement>(null);\n const stackRef = useRef<StackedChart | null>(null);\n const destroyRef = useRef<(() => void) | null>(null);\n const [stack, setStack] = useState<StackedChart | null>(null);\n const [isReady, setIsReady] = useState(false);\n\n const optionsRef = useRef(options);\n const structureKeyRef = useRef(stackedStructureKey(options.panes));\n const paneSeriesRef = useRef(new Map<string, Map<string, VeloPlotSeries>>());\n optionsRef.current = options;\n\n const mountStack = useCallback(() => {\n const el = containerRef.current;\n if (!el) return;\n\n destroyRef.current?.();\n const created = createStackedChart({\n ...optionsRef.current,\n container: el,\n });\n stackRef.current = created;\n destroyRef.current = () => {\n created.destroy();\n stackRef.current = null;\n };\n setStack(created);\n structureKeyRef.current = stackedStructureKey(optionsRef.current.panes);\n paneSeriesRef.current = syncStackedPaneSeries(\n created,\n optionsRef.current.panes,\n new Map(),\n );\n\n created.whenReady().then(() => setIsReady(true));\n }, []);\n\n useEffect(() => {\n mountStack();\n return () => {\n setIsReady(false);\n destroyRef.current?.();\n destroyRef.current = null;\n setStack(null);\n };\n }, [mountStack]);\n\n useEffect(() => {\n const current = stackRef.current;\n if (!current || !isReady) return;\n\n const nextKey = stackedStructureKey(options.panes);\n if (nextKey !== structureKeyRef.current) {\n mountStack();\n return;\n }\n\n syncStackedOptions(current, options);\n paneSeriesRef.current = syncStackedPaneSeries(\n current,\n options.panes,\n paneSeriesRef.current,\n );\n });\n\n const fitAll = useCallback((opts?: { x?: Range; padding?: number }) => {\n stackRef.current?.fitAll(opts);\n }, []);\n\n const resetAll = useCallback(() => {\n stackRef.current?.resetAll();\n }, []);\n\n return { containerRef, stack, isReady, fitAll, resetAll };\n}\n","/**\n * StackedPlot - Declarative React component for multi-pane charts\n */\n\nimport {\n forwardRef,\n useImperativeHandle,\n useMemo,\n type CSSProperties,\n} from \"react\";\nimport { useStackedPlot, type UseStackedPlotOptions } from \"./useStackedPlot\";\nimport type { StackedChart } from \"../core/stacked\";\nimport type { Bounds } from \"../types\";\nimport type { AddIndicatorOptions } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\n\nexport interface StackedPlotIndicator extends AddIndicatorOptions {\n type: IndicatorPresetName;\n}\n\nexport interface StackedPlotProps extends UseStackedPlotOptions {\n width?: number | string;\n height?: number | string;\n className?: string;\n style?: CSSProperties;\n indicators?: StackedPlotIndicator[];\n onCrosshairMove?: (event: { price?: number; x: number }) => void;\n drawingTools?: string[];\n ariaLabel?: string;\n}\n\nexport interface StackedPlotRef {\n getStack: () => StackedChart | null;\n fitAll: () => void;\n resetAll: () => void;\n getBounds: () => Bounds | null;\n}\n\nexport const StackedPlot = forwardRef<StackedPlotRef, StackedPlotProps>(\n function StackedPlot(\n {\n width = \"100%\",\n height = 480,\n className = \"\",\n style = {},\n indicators: _indicators,\n onCrosshairMove: _onCrosshairMove,\n drawingTools: _drawingTools,\n ariaLabel,\n panes,\n ...stackOptions\n },\n ref,\n ) {\n const { containerRef, stack, isReady, fitAll, resetAll } = useStackedPlot({\n panes,\n ...stackOptions,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getStack: () => stack,\n fitAll: () => fitAll(),\n resetAll,\n getBounds: () => stack?.getMaster().getViewBounds() ?? null,\n }),\n [stack, fitAll, resetAll],\n );\n\n const containerStyle = useMemo<CSSProperties>(\n () => ({\n position: \"relative\",\n width: typeof width === \"number\" ? `${width}px` : width,\n height: typeof height === \"number\" ? `${height}px` : height,\n ...style,\n }),\n [width, height, style],\n );\n\n return (\n <div\n ref={containerRef as React.RefObject<HTMLDivElement>}\n className={`velo-plot-stacked ${className}`}\n style={containerStyle}\n role=\"img\"\n aria-label={ariaLabel ?? `Stacked chart with ${panes.length} panes`}\n data-ready={isReady ? \"true\" : \"false\"}\n />\n );\n },\n);\n\nexport default StackedPlot;\n","/**\n * useIndicator - React hook for trading indicators\n */\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Chart } from \"../core/chart/types\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport {\n addIndicatorToHost,\n isStackedChart,\n removeIndicatorFromChart,\n type IndicatorHost,\n} from \"../bindings/shared\";\n\nexport interface UseIndicatorReturn {\n result: (AddIndicatorResult & { paneId?: string }) | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport function useIndicator(\n host: IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n): UseIndicatorReturn {\n const [result, setResult] = useState<\n (AddIndicatorResult & { paneId?: string }) | null\n >(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const resultRef = useRef(result);\n resultRef.current = result;\n\n useEffect(() => {\n if (!host) return;\n\n let cancelled = false;\n setIsLoading(true);\n setError(null);\n\n addIndicatorToHost(host, preset, options)\n .then((res) => {\n if (!cancelled) {\n setResult(res);\n setIsLoading(false);\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n const res = resultRef.current;\n if (res && !isStackedChart(host)) {\n removeIndicatorFromChart(host as Chart, res.id);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [host, preset, JSON.stringify(options)]);\n\n return { result, isLoading, error };\n}\n","/**\n * useChartSync - React hook for synchronizing multiple charts\n */\n\nimport { useEffect, useState } from \"react\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport interface UseChartSyncReturn {\n group: ChartGroup | null;\n}\n\nexport function useChartSync(\n charts: ChartLike[],\n options?: SyncOptions,\n): UseChartSyncReturn {\n const [group, setGroup] = useState<ChartGroup | null>(null);\n\n useEffect(() => {\n if (charts.length < 2) {\n setGroup(null);\n return;\n }\n\n const handle = createChartSync(charts, options);\n setGroup(handle.group);\n\n return () => {\n handle.destroy();\n setGroup(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [charts, JSON.stringify(options)]);\n\n return { group };\n}\n\n/** Alias matching roadmap naming (`useChartGroup` ≡ `useChartSync`). */\nexport const useChartGroup = useChartSync;\n","/**\n * React bindings for Velo Plot\n */\n\nexport {\n VeloPlot,\n type VeloPlotProps,\n type VeloPlotRef,\n type VeloPlotSeries,\n} from \"./VeloPlot\";\nexport {\n StackedPlot,\n type StackedPlotProps,\n type StackedPlotRef,\n type StackedPlotIndicator,\n} from \"./StackedPlot\";\nexport {\n useVeloPlot,\n type UseVeloPlotOptions,\n type UseVeloPlotReturn,\n} from \"./useVeloPlot\";\nexport {\n useStackedPlot,\n type UseStackedPlotOptions,\n type UseStackedPlotReturn,\n} from \"./useStackedPlot\";\nexport {\n useIndicator,\n type UseIndicatorReturn,\n} from \"./useIndicator\";\nexport {\n useChartSync,\n useChartGroup,\n type UseChartSyncReturn,\n} from \"./useChartSync\";\n\n// ---------------------------------------------------------------------------\n// Backward-compatible aliases (SciPlot / SciChart branding → VeloPlot)\n// Removed in v4.0.\n// ---------------------------------------------------------------------------\nimport { VeloPlot as VeloPlotImpl } from \"./VeloPlot\";\nimport { useVeloPlot as useVeloPlotImpl } from \"./useVeloPlot\";\n\n/**\n * @deprecated Use `VeloPlot` instead. **Removed in v4.0.**\n */\nexport const SciPlot = VeloPlotImpl;\n/**\n * @deprecated Use `VeloPlot` instead. **Removed in v4.0.**\n */\nexport const SciChart = VeloPlotImpl;\n/**\n * @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**\n */\nexport const useSciPlot = useVeloPlotImpl;\n/**\n * @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**\n */\nexport const useSciChart = useVeloPlotImpl;\n\nexport type {\n VeloPlotProps as SciPlotProps,\n VeloPlotRef as SciPlotRef,\n VeloPlotSeries as SciPlotSeries,\n VeloPlotProps as SciChartProps,\n VeloPlotRef as SciChartRef,\n VeloPlotSeries as SciChartSeries,\n} from \"./VeloPlot\";\nexport type {\n UseVeloPlotOptions as UseSciPlotOptions,\n UseVeloPlotReturn as UseSciPlotReturn,\n UseVeloPlotOptions as UseSciChartOptions,\n UseVeloPlotReturn as UseSciChartReturn,\n} from \"./useVeloPlot\";\n"],"names":["useVeloPlot","containerRef","options","chart","setChart","useState","isReady","setIsReady","error","setError","bounds","setBounds","chartRef","useRef","destroyRef","optionsRef","prevSyncOptionsRef","pickSyncableOptions","useEffect","container","handle","createChartLifecycle","err","_a","currentChart","next","prev","optionsChanged","syncChartOptions","addSeries","useCallback","seriesOptions","c","updateSeries","id","data","removeSeries","zoom","zoomOptions","resetZoom","VeloPlot","forwardRef","series","zoomProp","onZoomChange","cursor","width","height","className","style","debug","ariaLabel","keyboardNav","chartOptions","ref","previousSeriesRef","a11yRef","useImperativeHandle","diffSeries","handler","event","el","applyChartA11y","updateA11y","containerStyle","useMemo","jsx","jsxs","useStackedPlot","stackRef","stack","setStack","structureKeyRef","stackedStructureKey","paneSeriesRef","mountStack","created","createStackedChart","syncStackedPaneSeries","current","syncStackedOptions","fitAll","opts","resetAll","StackedPlot","_indicators","_onCrosshairMove","_drawingTools","panes","stackOptions","useIndicator","host","preset","result","setResult","isLoading","setIsLoading","resultRef","cancelled","addIndicatorToHost","res","isStackedChart","removeIndicatorFromChart","useChartSync","charts","group","setGroup","createChartSync","useChartGroup","SciPlot","VeloPlotImpl","SciChart","useSciPlot","useVeloPlotImpl","useSciChart"],"mappings":";;;;;;;;;;AAwCO,SAASA,EACdC,GACAC,IAA8B,IACX;AACnB,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAuB,IAAI,GAC/C,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GACtC,CAACG,GAAOC,CAAQ,IAAIJ,EAAuB,IAAI,GAC/C,CAACK,GAAQC,CAAS,IAAIN,EAAwB,IAAI,GAElDO,IAAWC,EAAqB,IAAI,GACpCC,IAAaD,EAA4B,IAAI,GAC7CE,IAAaF,EAAOX,CAAO,GAC3Bc,IAAqBH,EAAOI,EAAoBf,CAAO,CAAC;AAC9D,EAAAa,EAAW,UAAUb,GAErBgB,EAAU,MAAM;AACd,UAAMC,IAAYlB,EAAa;AAC/B,QAAKkB,GAEL;AAAA,UAAI;AACF,cAAMC,IAASC;AAAA,UACbF;AAAA,UACAJ,EAAW;AAAA,UACX;AAAA,YACE,gBAAgBJ;AAAA,YAChB,SAASF;AAAA,UAAA;AAAA,QACX;AAEF,QAAAG,EAAS,UAAUQ,EAAO,OAC1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lot.tsx","../src/react/useStackedPlot.ts","../src/react/StackedPlot.tsx","../src/react/useIndicator.ts","../src/react/useChartSync.ts","../src/react/index.ts"],"sourcesContent":["/**\n * useVeloPlot - React hook for Velo Plot\n */\n\nimport {\n useEffect,\n useRef,\n useState,\n useCallback,\n type RefObject,\n} from \"react\";\nimport type { Chart } from \"../core/Chart\";\nimport type {\n SeriesOptions,\n SeriesUpdateData,\n ZoomOptions,\n Bounds,\n} from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport interface UseVeloPlotReturn {\n chart: Chart | null;\n isReady: boolean;\n error: Error | null;\n bounds: Bounds | null;\n addSeries: (options: SeriesOptions) => void;\n updateSeries: (id: string, data: SeriesUpdateData) => void;\n removeSeries: (id: string) => void;\n zoom: (options: ZoomOptions) => void;\n resetZoom: () => void;\n}\n\nexport function useVeloPlot(\n containerRef: RefObject<HTMLDivElement>,\n options: UseVeloPlotOptions = {},\n): UseVeloPlotReturn {\n const [chart, setChart] = useState<Chart | null>(null);\n const [isReady, setIsReady] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [bounds, setBounds] = useState<Bounds | null>(null);\n\n const chartRef = useRef<Chart | null>(null);\n const destroyRef = useRef<(() => void) | null>(null);\n const optionsRef = useRef(options);\n const prevSyncOptionsRef = useRef(pickSyncableOptions(options));\n optionsRef.current = options;\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n try {\n const handle = createChartLifecycle(\n container,\n optionsRef.current,\n {\n onBoundsChange: setBounds,\n onError: setError,\n },\n );\n chartRef.current = handle.chart;\n destroyRef.current = handle.destroy;\n setChart(handle.chart);\n setIsReady(true);\n setBounds(handle.getBounds());\n setError(null);\n prevSyncOptionsRef.current = pickSyncableOptions(optionsRef.current);\n } catch (err) {\n console.error(\"[useVeloPlot] Failed to initialize chart:\", err);\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsReady(false);\n }\n\n return () => {\n destroyRef.current?.();\n destroyRef.current = null;\n chartRef.current = null;\n setChart(null);\n setIsReady(false);\n };\n }, [containerRef]);\n\n useEffect(() => {\n const currentChart = chartRef.current;\n if (!currentChart || !isReady) return;\n\n const next = pickSyncableOptions(options);\n const prev = prevSyncOptionsRef.current;\n if (optionsChanged(prev, next)) {\n syncChartOptions(currentChart, prev, next);\n prevSyncOptionsRef.current = next;\n }\n });\n\n const addSeries = useCallback((seriesOptions: SeriesOptions) => {\n const c = chartRef.current;\n if (c) {\n c.addSeries(seriesOptions);\n setBounds(c.getViewBounds());\n }\n }, []);\n\n const updateSeries = useCallback((id: string, data: SeriesUpdateData) => {\n chartRef.current?.updateSeries(id, data);\n }, []);\n\n const removeSeries = useCallback((id: string) => {\n chartRef.current?.removeSeries(id);\n }, []);\n\n const zoom = useCallback((zoomOptions: ZoomOptions) => {\n chartRef.current?.zoom(zoomOptions);\n }, []);\n\n const resetZoom = useCallback(() => {\n const c = chartRef.current;\n if (c) {\n c.resetZoom();\n setBounds(c.getViewBounds());\n }\n }, []);\n\n return {\n chart,\n isReady,\n error,\n bounds,\n addSeries,\n updateSeries,\n removeSeries,\n zoom,\n resetZoom,\n };\n}\n","/**\n * VeloPlot - React Component for Scientific Charts\n */\n\nimport {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useMemo,\n type CSSProperties,\n} from \"react\";\nimport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nimport type { ZoomOptions, CursorOptions, Bounds } from \"../types\";\nimport type { Chart } from \"../core/Chart\";\nimport {\n diffSeries,\n applyChartA11y,\n updateA11y,\n type VeloPlotSeries,\n} from \"../bindings/shared\";\n\nexport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface VeloPlotProps extends UseVeloPlotOptions {\n series?: VeloPlotSeries[];\n zoom?: ZoomOptions;\n onZoomChange?: (bounds: Bounds) => void;\n cursor?: CursorOptions;\n width?: number | string;\n height?: number | string;\n className?: string;\n style?: CSSProperties;\n debug?: boolean;\n /** Custom aria-label for accessibility */\n ariaLabel?: string;\n /** Enable keyboard navigation (default: true) */\n keyboardNav?: boolean;\n}\n\nexport interface VeloPlotRef {\n getChart: () => Chart | null;\n resetZoom: () => void;\n getBounds: () => Bounds | null;\n}\n\nexport const VeloPlot = forwardRef<VeloPlotRef, VeloPlotProps>(\n function VeloPlot(\n {\n series = [],\n zoom: zoomProp,\n onZoomChange,\n cursor,\n width = \"100%\",\n height = 400,\n className = \"\",\n style = {},\n debug = false,\n ariaLabel,\n keyboardNav = true,\n ...chartOptions\n },\n ref,\n ) {\n const containerRef = useRef<HTMLDivElement>(null);\n const previousSeriesRef = useRef<Map<string, VeloPlotSeries>>(new Map());\n const a11yRef = useRef<ReturnType<typeof applyChartA11y> | null>(null);\n\n const {\n chart,\n isReady,\n bounds,\n addSeries,\n updateSeries,\n removeSeries,\n resetZoom,\n } = useVeloPlot(containerRef, chartOptions);\n\n useImperativeHandle(\n ref,\n () => ({\n getChart: () => chart,\n resetZoom,\n getBounds: () => bounds,\n }),\n [chart, resetZoom, bounds],\n );\n\n useEffect(() => {\n if (!isReady || !chart) return;\n previousSeriesRef.current = diffSeries(\n { addSeries, updateSeries, removeSeries, autoScale: () => chart.autoScale() },\n series,\n previousSeriesRef.current,\n );\n }, [series, isReady, chart, addSeries, updateSeries, removeSeries]);\n\n useEffect(() => {\n if (!isReady || !chart || !zoomProp) return;\n chart.zoom(zoomProp);\n }, [isReady, chart, zoomProp]);\n\n useEffect(() => {\n if (!isReady || !chart || !onZoomChange) return;\n const handler = (event: { x: [number, number]; y: [number, number] }) => {\n onZoomChange({\n xMin: event.x[0],\n xMax: event.x[1],\n yMin: event.y[0],\n yMax: event.y[1],\n });\n };\n chart.on(\"zoom\", handler);\n return () => chart.off(\"zoom\", handler);\n }, [isReady, chart, onZoomChange]);\n\n useEffect(() => {\n if (!isReady || !chart) return;\n if (cursor?.enabled) {\n chart.enableCursor(cursor);\n } else {\n chart.disableCursor();\n }\n }, [isReady, chart, cursor]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!isReady || !chart || !el) return;\n\n a11yRef.current = applyChartA11y(el, chart, {\n label: ariaLabel,\n series,\n bounds,\n enableKeyboard: keyboardNav,\n });\n\n return () => {\n a11yRef.current?.cleanup();\n a11yRef.current = null;\n };\n }, [isReady, chart, keyboardNav, ariaLabel, bounds, series]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !a11yRef.current) return;\n updateA11y(el, a11yRef.current.srTable, {\n label: ariaLabel,\n series,\n bounds,\n });\n }, [series, bounds, ariaLabel]);\n\n const containerStyle = useMemo<CSSProperties>(\n () => ({\n position: \"relative\",\n width: typeof width === \"number\" ? `${width}px` : width,\n height: typeof height === \"number\" ? `${height}px` : height,\n outline: \"none\",\n ...style,\n }),\n [width, height, style],\n );\n\n return (\n <div\n ref={containerRef}\n className={`velo-plot-container ${className}`}\n style={containerStyle}\n >\n {debug && bounds && (\n <div\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n background: \"rgba(0,0,0,0.7)\",\n color: \"#0f0\",\n padding: \"4px 8px\",\n borderRadius: 4,\n fontSize: 11,\n fontFamily: \"monospace\",\n pointerEvents: \"none\",\n }}\n >\n <div>\n X: [{bounds.xMin.toFixed(3)}, {bounds.xMax.toFixed(3)}]\n </div>\n <div>\n Y: [{bounds.yMin.toExponential(2)}, {bounds.yMax.toExponential(2)}]\n </div>\n <div>Series: {series.length}</div>\n </div>\n )}\n </div>\n );\n },\n);\n\nexport default VeloPlot;\n","/**\n * useStackedPlot - React hook for multi-pane stacked charts\n */\n\nimport {\n useEffect,\n useRef,\n useState,\n useCallback,\n type RefObject,\n} from \"react\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport {\n stackedStructureKey,\n syncStackedOptions,\n syncStackedPaneSeries,\n} from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface UseStackedPlotOptions\n extends Omit<StackedChartOptions, \"container\"> {}\n\nexport interface UseStackedPlotReturn {\n containerRef: RefObject<HTMLDivElement>;\n stack: StackedChart | null;\n isReady: boolean;\n fitAll: (options?: { x?: Range; padding?: number }) => void;\n resetAll: () => void;\n}\n\nexport function useStackedPlot(\n options: UseStackedPlotOptions,\n): UseStackedPlotReturn {\n const containerRef = useRef<HTMLDivElement>(null);\n const stackRef = useRef<StackedChart | null>(null);\n const destroyRef = useRef<(() => void) | null>(null);\n const [stack, setStack] = useState<StackedChart | null>(null);\n const [isReady, setIsReady] = useState(false);\n\n const optionsRef = useRef(options);\n const structureKeyRef = useRef(stackedStructureKey(options.panes));\n const paneSeriesRef = useRef(new Map<string, Map<string, VeloPlotSeries>>());\n optionsRef.current = options;\n\n const mountStack = useCallback(() => {\n const el = containerRef.current;\n if (!el) return;\n\n destroyRef.current?.();\n const created = createStackedChart({\n ...optionsRef.current,\n container: el,\n });\n stackRef.current = created;\n destroyRef.current = () => {\n created.destroy();\n stackRef.current = null;\n };\n setStack(created);\n structureKeyRef.current = stackedStructureKey(optionsRef.current.panes);\n paneSeriesRef.current = syncStackedPaneSeries(\n created,\n optionsRef.current.panes,\n new Map(),\n );\n\n created.whenReady().then(() => setIsReady(true));\n }, []);\n\n useEffect(() => {\n mountStack();\n return () => {\n setIsReady(false);\n destroyRef.current?.();\n destroyRef.current = null;\n setStack(null);\n };\n }, [mountStack]);\n\n useEffect(() => {\n const current = stackRef.current;\n if (!current || !isReady) return;\n\n const nextKey = stackedStructureKey(options.panes);\n if (nextKey !== structureKeyRef.current) {\n mountStack();\n return;\n }\n\n syncStackedOptions(current, options);\n paneSeriesRef.current = syncStackedPaneSeries(\n current,\n options.panes,\n paneSeriesRef.current,\n );\n });\n\n const fitAll = useCallback((opts?: { x?: Range; padding?: number }) => {\n stackRef.current?.fitAll(opts);\n }, []);\n\n const resetAll = useCallback(() => {\n stackRef.current?.resetAll();\n }, []);\n\n return { containerRef, stack, isReady, fitAll, resetAll };\n}\n","/**\n * StackedPlot - Declarative React component for multi-pane charts\n */\n\nimport {\n forwardRef,\n useImperativeHandle,\n useMemo,\n type CSSProperties,\n} from \"react\";\nimport { useStackedPlot, type UseStackedPlotOptions } from \"./useStackedPlot\";\nimport type { StackedChart } from \"../core/stacked\";\nimport type { Bounds } from \"../types\";\nimport type { AddIndicatorOptions } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\n\nexport interface StackedPlotIndicator extends AddIndicatorOptions {\n type: IndicatorPresetName;\n}\n\nexport interface StackedPlotProps extends UseStackedPlotOptions {\n width?: number | string;\n height?: number | string;\n className?: string;\n style?: CSSProperties;\n indicators?: StackedPlotIndicator[];\n onCrosshairMove?: (event: { price?: number; x: number }) => void;\n drawingTools?: string[];\n ariaLabel?: string;\n}\n\nexport interface StackedPlotRef {\n getStack: () => StackedChart | null;\n fitAll: () => void;\n resetAll: () => void;\n getBounds: () => Bounds | null;\n}\n\nexport const StackedPlot = forwardRef<StackedPlotRef, StackedPlotProps>(\n function StackedPlot(\n {\n width = \"100%\",\n height = 480,\n className = \"\",\n style = {},\n indicators: _indicators,\n onCrosshairMove: _onCrosshairMove,\n drawingTools: _drawingTools,\n ariaLabel,\n panes,\n ...stackOptions\n },\n ref,\n ) {\n const { containerRef, stack, isReady, fitAll, resetAll } = useStackedPlot({\n panes,\n ...stackOptions,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getStack: () => stack,\n fitAll: () => fitAll(),\n resetAll,\n getBounds: () => stack?.getMaster().getViewBounds() ?? null,\n }),\n [stack, fitAll, resetAll],\n );\n\n const containerStyle = useMemo<CSSProperties>(\n () => ({\n position: \"relative\",\n width: typeof width === \"number\" ? `${width}px` : width,\n height: typeof height === \"number\" ? `${height}px` : height,\n ...style,\n }),\n [width, height, style],\n );\n\n return (\n <div\n ref={containerRef as React.RefObject<HTMLDivElement>}\n className={`velo-plot-stacked ${className}`}\n style={containerStyle}\n role=\"img\"\n aria-label={ariaLabel ?? `Stacked chart with ${panes.length} panes`}\n data-ready={isReady ? \"true\" : \"false\"}\n />\n );\n },\n);\n\nexport default StackedPlot;\n","/**\n * useIndicator - React hook for trading indicators\n */\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Chart } from \"../core/chart/types\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport {\n addIndicatorToHost,\n isStackedChart,\n removeIndicatorFromChart,\n type IndicatorHost,\n} from \"../bindings/shared\";\n\nexport interface UseIndicatorReturn {\n result: (AddIndicatorResult & { paneId?: string }) | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport function useIndicator(\n host: IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n): UseIndicatorReturn {\n const [result, setResult] = useState<\n (AddIndicatorResult & { paneId?: string }) | null\n >(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const resultRef = useRef(result);\n resultRef.current = result;\n\n useEffect(() => {\n if (!host) return;\n\n let cancelled = false;\n setIsLoading(true);\n setError(null);\n\n addIndicatorToHost(host, preset, options)\n .then((res) => {\n if (!cancelled) {\n setResult(res);\n setIsLoading(false);\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n const res = resultRef.current;\n if (res && !isStackedChart(host)) {\n removeIndicatorFromChart(host as Chart, res.id);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [host, preset, JSON.stringify(options)]);\n\n return { result, isLoading, error };\n}\n","/**\n * useChartSync - React hook for synchronizing multiple charts\n */\n\nimport { useEffect, useState } from \"react\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport interface UseChartSyncReturn {\n group: ChartGroup | null;\n}\n\nexport function useChartSync(\n charts: ChartLike[],\n options?: SyncOptions,\n): UseChartSyncReturn {\n const [group, setGroup] = useState<ChartGroup | null>(null);\n\n useEffect(() => {\n if (charts.length < 2) {\n setGroup(null);\n return;\n }\n\n const handle = createChartSync(charts, options);\n setGroup(handle.group);\n\n return () => {\n handle.destroy();\n setGroup(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [charts, JSON.stringify(options)]);\n\n return { group };\n}\n\n/** Alias matching roadmap naming (`useChartGroup` ≡ `useChartSync`). */\nexport const useChartGroup = useChartSync;\n","/**\n * React bindings for Velo Plot\n */\n\nexport {\n VeloPlot,\n type VeloPlotProps,\n type VeloPlotRef,\n type VeloPlotSeries,\n} from \"./VeloPlot\";\nexport {\n StackedPlot,\n type StackedPlotProps,\n type StackedPlotRef,\n type StackedPlotIndicator,\n} from \"./StackedPlot\";\nexport {\n useVeloPlot,\n type UseVeloPlotOptions,\n type UseVeloPlotReturn,\n} from \"./useVeloPlot\";\nexport {\n useStackedPlot,\n type UseStackedPlotOptions,\n type UseStackedPlotReturn,\n} from \"./useStackedPlot\";\nexport {\n useIndicator,\n type UseIndicatorReturn,\n} from \"./useIndicator\";\nexport {\n useChartSync,\n useChartGroup,\n type UseChartSyncReturn,\n} from \"./useChartSync\";\n\n// ---------------------------------------------------------------------------\n// Backward-compatible aliases (SciPlot / SciChart branding → VeloPlot)\n// Removed in v4.0.\n// ---------------------------------------------------------------------------\nimport { VeloPlot as VeloPlotImpl } from \"./VeloPlot\";\nimport { useVeloPlot as useVeloPlotImpl } from \"./useVeloPlot\";\n\n/**\n * @deprecated Use `VeloPlot` instead. **Removed in v4.0.**\n */\nexport const SciPlot = VeloPlotImpl;\n/**\n * @deprecated Use `VeloPlot` instead. **Removed in v4.0.**\n */\nexport const SciChart = VeloPlotImpl;\n/**\n * @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**\n */\nexport const useSciPlot = useVeloPlotImpl;\n/**\n * @deprecated Use `useVeloPlot` instead. **Removed in v4.0.**\n */\nexport const useSciChart = useVeloPlotImpl;\n\nexport type {\n VeloPlotProps as SciPlotProps,\n VeloPlotRef as SciPlotRef,\n VeloPlotSeries as SciPlotSeries,\n VeloPlotProps as SciChartProps,\n VeloPlotRef as SciChartRef,\n VeloPlotSeries as SciChartSeries,\n} from \"./VeloPlot\";\nexport type {\n UseVeloPlotOptions as UseSciPlotOptions,\n UseVeloPlotReturn as UseSciPlotReturn,\n UseVeloPlotOptions as UseSciChartOptions,\n UseVeloPlotReturn as UseSciChartReturn,\n} from \"./useVeloPlot\";\n"],"names":["useVeloPlot","containerRef","options","chart","setChart","useState","isReady","setIsReady","error","setError","bounds","setBounds","chartRef","useRef","destroyRef","optionsRef","prevSyncOptionsRef","pickSyncableOptions","useEffect","container","handle","createChartLifecycle","err","_a","currentChart","next","prev","optionsChanged","syncChartOptions","addSeries","useCallback","seriesOptions","c","updateSeries","id","data","removeSeries","zoom","zoomOptions","resetZoom","VeloPlot","forwardRef","series","zoomProp","onZoomChange","cursor","width","height","className","style","debug","ariaLabel","keyboardNav","chartOptions","ref","previousSeriesRef","a11yRef","useImperativeHandle","diffSeries","handler","event","el","applyChartA11y","updateA11y","containerStyle","useMemo","jsx","jsxs","useStackedPlot","stackRef","stack","setStack","structureKeyRef","stackedStructureKey","paneSeriesRef","mountStack","created","createStackedChart","syncStackedPaneSeries","current","syncStackedOptions","fitAll","opts","resetAll","StackedPlot","_indicators","_onCrosshairMove","_drawingTools","panes","stackOptions","useIndicator","host","preset","result","setResult","isLoading","setIsLoading","resultRef","cancelled","addIndicatorToHost","res","isStackedChart","removeIndicatorFromChart","useChartSync","charts","group","setGroup","createChartSync","useChartGroup","SciPlot","VeloPlotImpl","SciChart","useSciPlot","useVeloPlotImpl","useSciChart"],"mappings":";;;;;;;AAwCO,SAASA,EACdC,GACAC,IAA8B,IACX;AACnB,Q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,OAAAvF,EAAA;AAC9B;ACrDO,SAAS+F,GACdC,GACAtG,GACoB;AACpB,QAAM,CAACuG,GAAOC,CAAQ,IAAIrG,EAA4B,IAAI;AAE1D,SAAAa,EAAU,MAAM;AACd,QAAIsF,EAAO,SAAS,GAAG;AACrB,MAAAE,EAAS,IAAI;AACb;AAAA,IACF;AAEA,UAAMtF,IAASuF,EAAgBH,GAAQtG,CAAO;AAC9C,WAAAwG,EAAStF,EAAO,KAAK,GAEd,MAAM;AACX,MAAAA,EAAO,QAAA,GACPsF,EAAS,IAAI;AAAA,IACf;AAAA,EAEF,GAAG,CAACF,GAAQ,KAAK,UAAUtG,CAAO,CAAC,CAAC,GAE7B,EAAE,OAAAuG,EAAA;AACX;AAGO,MAAMG,KAAgBL,ICOhBM,KAAUC,GAIVC,KAAWD,GAIXE,KAAaC,GAIbC,KAAcD;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { f as e } from "./SVGDocumentBuilder-C-uLkcFW.js";
|
|
2
|
+
import { p as a } from "./tickUtils-B_X-ha13.js";
|
|
3
|
+
function f(o, n) {
|
|
4
|
+
if (!o.builder || n.points.length < 2) return;
|
|
5
|
+
const r = a(o.yScales), p = n.color ?? "#3b82f6";
|
|
6
|
+
if (n.band) {
|
|
7
|
+
const s = [];
|
|
8
|
+
for (const t of n.band.upper)
|
|
9
|
+
s.push(`${e(o.xScale.transform(t.x))},${e(r.transform(t.y))}`);
|
|
10
|
+
for (let t = n.band.lower.length - 1; t >= 0; t--) {
|
|
11
|
+
const i = n.band.lower[t];
|
|
12
|
+
s.push(`${e(o.xScale.transform(i.x))},${e(r.transform(i.y))}`);
|
|
13
|
+
}
|
|
14
|
+
o.builder.push("plugins", `<polygon points="${s.join(" ")}" fill="${p}" fill-opacity="0.15" stroke="none"/>`);
|
|
15
|
+
}
|
|
16
|
+
const l = n.points.map((s) => `${e(o.xScale.transform(s.x))},${e(r.transform(s.y))}`).join(" ");
|
|
17
|
+
o.builder.push(
|
|
18
|
+
"plugins",
|
|
19
|
+
`<polyline points="${l}" fill="none" stroke="${p}" stroke-width="2" stroke-dasharray="6,4"/>`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function d(o, n, r, p = "#8b5cf6") {
|
|
23
|
+
f(o, { points: n, color: p, band: r ? { upper: r.upper, lower: r.lower } : void 0 });
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
d as e
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=regression-HNdyk1Dm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regression-HNdyk1Dm.js","sources":["../src/core/chart/exporter/svg/plugins/regression.ts"],"sourcesContent":["import type { SVGExportPluginContext } from \"./types\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { primaryYScale } from \"../tickUtils\";\n\nexport interface RegressionOverlay {\n points: Array<{ x: number; y: number }>;\n color?: string;\n band?: { upper: Array<{ x: number; y: number }>; lower: Array<{ x: number; y: number }> };\n}\n\nexport function exportRegressionOverlay(ctx: SVGExportPluginContext, overlay: RegressionOverlay): void {\n if (!ctx.builder || overlay.points.length < 2) return;\n const yScale = primaryYScale(ctx.yScales)!;\n const color = overlay.color ?? \"#3b82f6\";\n\n if (overlay.band) {\n const bandPts: string[] = [];\n for (const p of overlay.band.upper) {\n bandPts.push(`${fmt(ctx.xScale.transform(p.x))},${fmt(yScale.transform(p.y))}`);\n }\n for (let i = overlay.band.lower.length - 1; i >= 0; i--) {\n const p = overlay.band.lower[i];\n bandPts.push(`${fmt(ctx.xScale.transform(p.x))},${fmt(yScale.transform(p.y))}`);\n }\n ctx.builder.push(\"plugins\", `<polygon points=\"${bandPts.join(\" \")}\" fill=\"${color}\" fill-opacity=\"0.15\" stroke=\"none\"/>`);\n }\n\n const linePts = overlay.points\n .map((p) => `${fmt(ctx.xScale.transform(p.x))},${fmt(yScale.transform(p.y))}`)\n .join(\" \");\n ctx.builder.push(\n \"plugins\",\n `<polyline points=\"${linePts}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"2\" stroke-dasharray=\"6,4\"/>`,\n );\n}\n\nexport function exportForecastOverlay(\n ctx: SVGExportPluginContext,\n forecast: Array<{ x: number; y: number }>,\n ci?: { upper: Array<{ x: number; y: number }>; lower: Array<{ x: number; y: number }> },\n color = \"#8b5cf6\",\n): void {\n exportRegressionOverlay(ctx, { points: forecast, color, band: ci ? { upper: ci.upper, lower: ci.lower } : undefined });\n}\n"],"names":["exportRegressionOverlay","ctx","overlay","yScale","primaryYScale","color","bandPts","p","fmt","i","linePts","exportForecastOverlay","forecast","ci"],"mappings":";;AAUO,SAASA,EAAwBC,GAA6BC,GAAkC;AACrG,MAAI,CAACD,EAAI,WAAWC,EAAQ,OAAO,SAAS,EAAG;AAC/C,QAAMC,IAASC,EAAcH,EAAI,OAAO,GAClCI,IAAQH,EAAQ,SAAS;AAE/B,MAAIA,EAAQ,MAAM;AAChB,UAAMI,IAAoB,CAAA;AAC1B,eAAWC,KAAKL,EAAQ,KAAK;AAC3B,MAAAI,EAAQ,KAAK,GAAGE,EAAIP,EAAI,OAAO,UAAUM,EAAE,CAAC,CAAC,CAAC,IAAIC,EAAIL,EAAO,UAAUI,EAAE,CAAC,CAAC,CAAC,EAAE;AAEhF,aAASE,IAAIP,EAAQ,KAAK,MAAM,SAAS,GAAGO,KAAK,GAAGA,KAAK;AACvD,YAAMF,IAAIL,EAAQ,KAAK,MAAMO,CAAC;AAC9B,MAAAH,EAAQ,KAAK,GAAGE,EAAIP,EAAI,OAAO,UAAUM,EAAE,CAAC,CAAC,CAAC,IAAIC,EAAIL,EAAO,UAAUI,EAAE,CAAC,CAAC,CAAC,EAAE;AAAA,IAChF;AACA,IAAAN,EAAI,QAAQ,KAAK,WAAW,oBAAoBK,EAAQ,KAAK,GAAG,CAAC,WAAWD,CAAK,uCAAuC;AAAA,EAC1H;AAEA,QAAMK,IAAUR,EAAQ,OACrB,IAAI,CAACK,MAAM,GAAGC,EAAIP,EAAI,OAAO,UAAUM,EAAE,CAAC,CAAC,CAAC,IAAIC,EAAIL,EAAO,UAAUI,EAAE,CAAC,CAAC,CAAC,EAAE,EAC5E,KAAK,GAAG;AACX,EAAAN,EAAI,QAAQ;AAAA,IACV;AAAA,IACA,qBAAqBS,CAAO,yBAAyBL,CAAK;AAAA,EAAA;AAE9D;AAEO,SAASM,EACdV,GACAW,GACAC,GACAR,IAAQ,WACF;AACN,EAAAL,EAAwBC,GAAK,EAAE,QAAQW,GAAU,OAAAP,GAAO,MAAMQ,IAAK,EAAE,OAAOA,EAAG,OAAO,OAAOA,EAAG,MAAA,IAAU,QAAW;AACvH;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NativeWebGLRenderer } from './NativeWebGLRenderer';
|
|
2
2
|
import { GpuChartRenderer } from './GpuChartRenderer';
|
|
3
|
+
import { SVGChartRenderer } from './SVGChartRenderer';
|
|
3
4
|
|
|
4
|
-
export type ChartSeriesRenderer = NativeWebGLRenderer | GpuChartRenderer;
|
|
5
|
-
export type ChartRendererBackend = "webgl" | "webgpu";
|
|
5
|
+
export type ChartSeriesRenderer = NativeWebGLRenderer | GpuChartRenderer | SVGChartRenderer;
|
|
6
|
+
export type ChartRendererBackend = "webgl" | "webgpu" | "svg";
|
|
6
7
|
export declare function getRendererBackend(renderer: ChartSeriesRenderer): ChartRendererBackend;
|