velo-plot 3.1.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.
Files changed (116) hide show
  1. package/dist/{ChartCore-AnR_3Xkb.js → ChartCore-KYG2HTcK.js} +1349 -1213
  2. package/dist/ChartCore-KYG2HTcK.js.map +1 -0
  3. package/dist/{PluginRegistry-CzMHebYP.js → PluginRegistry-CDf_jcnp.js} +2 -2
  4. package/dist/{PluginRegistry-CzMHebYP.js.map → PluginRegistry-CDf_jcnp.js.map} +1 -1
  5. package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
  6. package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
  7. package/dist/angular-hooks.js +1 -1
  8. package/dist/angular.js +4 -4
  9. package/dist/{chartSyncBridge-D_rCtbFq.js → chartSyncBridge-C1uRy0ZS.js} +3 -3
  10. package/dist/{chartSyncBridge-D_rCtbFq.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
  11. package/dist/core/chart/ChartCore.d.ts +7 -3
  12. package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
  13. package/dist/core/chart/ChartRenderer.d.ts +9 -0
  14. package/dist/core/chart/ChartSetup.d.ts +1 -0
  15. package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
  16. package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
  17. package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
  18. package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
  19. package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
  20. package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
  21. package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
  22. package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
  23. package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
  24. package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
  25. package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
  26. package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
  27. package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
  28. package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
  29. package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
  30. package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
  31. package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
  32. package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
  33. package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
  34. package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
  35. package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
  36. package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
  37. package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
  38. package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
  39. package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
  40. package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
  41. package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
  42. package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
  43. package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
  44. package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
  45. package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
  46. package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
  47. package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
  48. package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
  49. package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
  50. package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
  51. package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
  52. package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
  53. package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
  54. package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
  55. package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
  56. package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
  57. package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
  58. package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
  59. package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
  60. package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
  61. package/dist/core/chart/mountSVGString.d.ts +5 -0
  62. package/dist/core/chart/types.d.ts +2 -2
  63. package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
  64. package/dist/core/stacked/index.d.ts +3 -2
  65. package/dist/core/stacked/types.d.ts +12 -4
  66. package/dist/createStackedChart-DjA3aJAu.js +2761 -0
  67. package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
  68. package/dist/{hooks-DH-3bewj.js → hooks-4wQH27r9.js} +3 -3
  69. package/dist/{hooks-DH-3bewj.js.map → hooks-4wQH27r9.js.map} +1 -1
  70. package/dist/index-Bj-xyXY6.js +582 -0
  71. package/dist/index-Bj-xyXY6.js.map +1 -0
  72. package/dist/plugins/PluginManager.d.ts +5 -0
  73. package/dist/plugins/annotations.js +8 -7
  74. package/dist/plugins/annotations.js.map +1 -1
  75. package/dist/plugins/broken-axis.js +198 -152
  76. package/dist/plugins/broken-axis.js.map +1 -1
  77. package/dist/plugins/forecasting.js +273 -258
  78. package/dist/plugins/forecasting.js.map +1 -1
  79. package/dist/plugins/ml-integration.js +107 -93
  80. package/dist/plugins/ml-integration.js.map +1 -1
  81. package/dist/plugins/radar/types.d.ts +11 -0
  82. package/dist/plugins/radar.js +64 -53
  83. package/dist/plugins/radar.js.map +1 -1
  84. package/dist/plugins/roi/index.d.ts +2 -0
  85. package/dist/plugins/roi.js +184 -145
  86. package/dist/plugins/roi.js.map +1 -1
  87. package/dist/plugins/snapshot.js +20 -15
  88. package/dist/plugins/snapshot.js.map +1 -1
  89. package/dist/plugins/types.d.ts +4 -0
  90. package/dist/react.js +2 -2
  91. package/dist/regression-HNdyk1Dm.js +28 -0
  92. package/dist/regression-HNdyk1Dm.js.map +1 -0
  93. package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
  94. package/dist/renderer/SVGChartRenderer.d.ts +15 -0
  95. package/dist/renderer/SankeyRenderer.d.ts +1 -0
  96. package/dist/renderer/registerSVG.d.ts +5 -0
  97. package/dist/renderer/sankeyLayout.d.ts +29 -0
  98. package/dist/scientific.js +2 -2
  99. package/dist/solid.js +2 -2
  100. package/dist/svelte.js +2 -2
  101. package/dist/tickUtils-B_X-ha13.js +41 -0
  102. package/dist/tickUtils-B_X-ha13.js.map +1 -0
  103. package/dist/trading.js +3 -3
  104. package/dist/types.d.ts +2 -1
  105. package/dist/velo-plot.full.js +1107 -1292
  106. package/dist/velo-plot.full.js.map +1 -1
  107. package/dist/velo-plot.js +2 -2
  108. package/dist/vue/VeloPlot.vue.d.ts +1 -1
  109. package/dist/vue/index.d.ts +33 -33
  110. package/dist/vue.js +2 -2
  111. package/package.json +6 -1
  112. package/dist/ChartCore-AnR_3Xkb.js.map +0 -1
  113. package/dist/createStackedChart-DqcLCFGS.js +0 -1338
  114. package/dist/createStackedChart-DqcLCFGS.js.map +0 -1
  115. package/dist/index-Cv6ZDLWf.js +0 -521
  116. package/dist/index-Cv6ZDLWf.js.map +0 -1
@@ -22,8 +22,8 @@ var z = (t) => [, , , K((t == null ? void 0 : t[q("metadata")]) ?? null)], B = [
22
22
  }, k = (t, r, n) => v(t, typeof r != "symbol" ? r + "" : r, n), I = (t, r, n) => r.has(t) || f("Cannot " + n), Q = (t, r) => Object(r) !== r ? f('Cannot use the "in" operator on this value') : t.has(r), O = (t, r, n) => (I(t, r, "read from private field"), n ? n.call(t) : r.get(t));
23
23
  var T = (t, r, n, o) => (I(t, r, "write to private field"), o ? o.call(t, n) : r.set(t, n), n), R = (t, r, n) => (I(t, r, "access private method"), n);
24
24
  import { Injectable as U } from "@angular/core";
25
- import { c as V } from "./createStackedChart-DqcLCFGS.js";
26
- import { c as W, a as X, b as Y } from "./chartSyncBridge-D_rCtbFq.js";
25
+ import { c as V } from "./createStackedChart-DjA3aJAu.js";
26
+ import { c as W, a as X, b as Y } from "./chartSyncBridge-C1uRy0ZS.js";
27
27
  var G, j;
28
28
  G = [U()];
29
29
  class g {
@@ -66,4 +66,4 @@ export {
66
66
  at as c,
67
67
  tt as u
68
68
  };
69
- //# sourceMappingURL=hooks-DH-3bewj.js.map
69
+ //# sourceMappingURL=hooks-4wQH27r9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks-DH-3bewj.js","sources":["../src/angular/hooks.ts"],"sourcesContent":["/**\n * Angular service-style hooks (usable in components).\n */\n\nimport { Injectable, OnDestroy } from \"@angular/core\";\nimport type { Chart } from \"../core/Chart\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport {\n createChartLifecycle,\n createChartSync,\n addIndicatorToHost,\n type ChartBindingOptions,\n type IndicatorHost,\n} from \"../bindings/shared\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { createStackedChart } from \"../core/stacked\";\n\n@Injectable()\nexport class VeloPlotHost implements OnDestroy {\n chart: Chart | null = null;\n private destroy: (() => void) | null = null;\n\n mount(container: HTMLDivElement, options: ChartBindingOptions = {}): void {\n this.destroy?.();\n const handle = createChartLifecycle(container, options);\n this.chart = handle.chart;\n this.destroy = handle.destroy;\n }\n\n ngOnDestroy(): void {\n this.destroy?.();\n this.chart = null;\n }\n}\n\nexport function useVeloPlotAngular() {\n return new VeloPlotHost();\n}\n\nexport function useStackedPlotAngular(\n container: HTMLDivElement,\n options: Omit<StackedChartOptions, \"container\">,\n): { stack: StackedChart; destroy: () => void } {\n const stack = createStackedChart({ ...options, container });\n return { stack, destroy: () => stack.destroy() };\n}\n\nexport async function useIndicatorAngular(\n host: IndicatorHost,\n preset: IndicatorPresetName,\n options?: AddIndicatorOptions,\n): Promise<AddIndicatorResult & { paneId?: string }> {\n return addIndicatorToHost(host, preset, options ?? {});\n}\n\nexport function useChartSyncAngular(\n charts: ChartLike[],\n options?: SyncOptions,\n): { group: ChartGroup | null; destroy: () => void } {\n if (charts.length < 2) return { group: null, destroy: () => {} };\n const handle = createChartSync(charts, options);\n return { group: handle.group, destroy: handle.destroy };\n}\n"],"names":["_VeloPlotHost_decorators","Injectable","VeloPlotHost","__publicField","container","options","_a","handle","createChartLifecycle","_init","__decoratorStart","__decorateElement","__runInitializers","useVeloPlotAngular","useStackedPlotAngular","stack","createStackedChart","useIndicatorAngular","host","preset","addIndicatorToHost","useChartSyncAngular","charts","createChartSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBAA,IAAA,CAACC,EAAA;AACM,MAAMC,EAAkC;AAAA,EAAxC;AACL,IAAAC,EAAA,eAAsB;AACd,IAAAA,EAAA,iBAA+B;AAAA;AAAA,EAEvC,MAAMC,GAA2BC,IAA+B,IAAU;;AACxE,KAAAC,IAAA,KAAK,YAAL,QAAAA,EAAA;AACA,UAAMC,IAASC,EAAqBJ,GAAWC,CAAO;AACtD,SAAK,QAAQE,EAAO,OACpB,KAAK,UAAUA,EAAO;AAAA,EACxB;AAAA,EAEA,cAAoB;;AAClB,KAAAD,IAAA,KAAK,YAAL,QAAAA,EAAA,YACA,KAAK,QAAQ;AAAA,EACf;AACF;AAfOG,IAAAC,EAAA,OAAMR,IAANS,EAAAF,GAAA,mBADPT,GACaE,IAANU,EAAAH,GAAA,GAAMP;AAiBN,SAASW,KAAqB;AACnC,SAAO,IAAIX,EAAA;AACb;AAEO,SAASY,GACdV,GACAC,GAC8C;AAC9C,QAAMU,IAAQC,EAAmB,EAAE,GAAGX,GAAS,WAAAD,GAAW;AAC1D,SAAO,EAAE,OAAAW,GAAO,SAAS,MAAMA,EAAM,UAAQ;AAC/C;AAEA,eAAsBE,GACpBC,GACAC,GACAd,GACmD;AACnD,SAAOe,EAAmBF,GAAMC,GAAQd,KAAW,CAAA,CAAE;AACvD;AAEO,SAASgB,GACdC,GACAjB,GACmD;AACnD,MAAIiB,EAAO,SAAS,EAAG,QAAO,EAAE,OAAO,MAAM,SAAS,MAAM;AAAA,EAAC,EAAA;AAC7D,QAAMf,IAASgB,EAAgBD,GAAQjB,CAAO;AAC9C,SAAO,EAAE,OAAOE,EAAO,OAAO,SAASA,EAAO,QAAA;AAChD;"}
1
+ {"version":3,"file":"hooks-4wQH27r9.js","sources":["../src/angular/hooks.ts"],"sourcesContent":["/**\n * Angular service-style hooks (usable in components).\n */\n\nimport { Injectable, OnDestroy } from \"@angular/core\";\nimport type { Chart } from \"../core/Chart\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport {\n createChartLifecycle,\n createChartSync,\n addIndicatorToHost,\n type ChartBindingOptions,\n type IndicatorHost,\n} from \"../bindings/shared\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { createStackedChart } from \"../core/stacked\";\n\n@Injectable()\nexport class VeloPlotHost implements OnDestroy {\n chart: Chart | null = null;\n private destroy: (() => void) | null = null;\n\n mount(container: HTMLDivElement, options: ChartBindingOptions = {}): void {\n this.destroy?.();\n const handle = createChartLifecycle(container, options);\n this.chart = handle.chart;\n this.destroy = handle.destroy;\n }\n\n ngOnDestroy(): void {\n this.destroy?.();\n this.chart = null;\n }\n}\n\nexport function useVeloPlotAngular() {\n return new VeloPlotHost();\n}\n\nexport function useStackedPlotAngular(\n container: HTMLDivElement,\n options: Omit<StackedChartOptions, \"container\">,\n): { stack: StackedChart; destroy: () => void } {\n const stack = createStackedChart({ ...options, container });\n return { stack, destroy: () => stack.destroy() };\n}\n\nexport async function useIndicatorAngular(\n host: IndicatorHost,\n preset: IndicatorPresetName,\n options?: AddIndicatorOptions,\n): Promise<AddIndicatorResult & { paneId?: string }> {\n return addIndicatorToHost(host, preset, options ?? {});\n}\n\nexport function useChartSyncAngular(\n charts: ChartLike[],\n options?: SyncOptions,\n): { group: ChartGroup | null; destroy: () => void } {\n if (charts.length < 2) return { group: null, destroy: () => {} };\n const handle = createChartSync(charts, options);\n return { group: handle.group, destroy: handle.destroy };\n}\n"],"names":["_VeloPlotHost_decorators","Injectable","VeloPlotHost","__publicField","container","options","_a","handle","createChartLifecycle","_init","__decoratorStart","__decorateElement","__runInitializers","useVeloPlotAngular","useStackedPlotAngular","stack","createStackedChart","useIndicatorAngular","host","preset","addIndicatorToHost","useChartSyncAngular","charts","createChartSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBAA,IAAA,CAACC,EAAA;AACM,MAAMC,EAAkC;AAAA,EAAxC;AACL,IAAAC,EAAA,eAAsB;AACd,IAAAA,EAAA,iBAA+B;AAAA;AAAA,EAEvC,MAAMC,GAA2BC,IAA+B,IAAU;;AACxE,KAAAC,IAAA,KAAK,YAAL,QAAAA,EAAA;AACA,UAAMC,IAASC,EAAqBJ,GAAWC,CAAO;AACtD,SAAK,QAAQE,EAAO,OACpB,KAAK,UAAUA,EAAO;AAAA,EACxB;AAAA,EAEA,cAAoB;;AAClB,KAAAD,IAAA,KAAK,YAAL,QAAAA,EAAA,YACA,KAAK,QAAQ;AAAA,EACf;AACF;AAfOG,IAAAC,EAAA,OAAMR,IAANS,EAAAF,GAAA,mBADPT,GACaE,IAANU,EAAAH,GAAA,GAAMP;AAiBN,SAASW,KAAqB;AACnC,SAAO,IAAIX,EAAA;AACb;AAEO,SAASY,GACdV,GACAC,GAC8C;AAC9C,QAAMU,IAAQC,EAAmB,EAAE,GAAGX,GAAS,WAAAD,GAAW;AAC1D,SAAO,EAAE,OAAAW,GAAO,SAAS,MAAMA,EAAM,UAAQ;AAC/C;AAEA,eAAsBE,GACpBC,GACAC,GACAd,GACmD;AACnD,SAAOe,EAAmBF,GAAMC,GAAQd,KAAW,CAAA,CAAE;AACvD;AAEO,SAASgB,GACdC,GACAjB,GACmD;AACnD,MAAIiB,EAAO,SAAS,EAAG,QAAO,EAAE,OAAO,MAAM,SAAS,MAAM;AAAA,EAAC,EAAA;AAC7D,QAAMf,IAASgB,EAAgBD,GAAQjB,CAAO;AAC9C,SAAO,EAAE,OAAOE,EAAO,OAAO,SAASA,EAAO,QAAA;AAChD;"}
@@ -0,0 +1,582 @@
1
+ import { f as u } from "./SVGDocumentBuilder-C-uLkcFW.js";
2
+ import { p as Z } from "./tickUtils-B_X-ha13.js";
3
+ function yt(r) {
4
+ const e = r.close.length, l = new Float32Array(e), n = new Float32Array(e), s = new Float32Array(e), h = new Float32Array(e);
5
+ for (let c = 0; c < e; c++) {
6
+ const p = r.open[c], f = r.high[c], x = r.low[c], b = r.close[c];
7
+ h[c] = (p + f + x + b) / 4, l[c] = c === 0 ? (p + b) / 2 : (l[c - 1] + h[c - 1]) / 2, n[c] = Math.max(f, l[c], h[c]), s[c] = Math.min(x, l[c], h[c]);
8
+ }
9
+ return { open: l, high: n, low: s, close: h };
10
+ }
11
+ function ut(r) {
12
+ const e = r.length, l = new Float64Array(e), n = new Float32Array(e), s = new Float32Array(e), h = new Float32Array(e), c = new Float32Array(e), p = new Float32Array(e);
13
+ for (let f = 0; f < e; f++) {
14
+ const x = r[f];
15
+ l[f] = x.time, n[f] = x.open, s[f] = x.high, h[f] = x.low, c[f] = x.close, p[f] = x.volume ?? 0;
16
+ }
17
+ return { x: l, open: n, high: s, low: h, close: c, volume: p };
18
+ }
19
+ function C(r) {
20
+ let e = r;
21
+ return () => (e = e * 16807 % 2147483647, (e - 1) / 2147483646);
22
+ }
23
+ function tt(r, e, l, n, s) {
24
+ const h = [];
25
+ let c = n;
26
+ for (let p = r; p <= e; p += l) {
27
+ const f = c, x = (s() - 0.48) * 2, b = Math.max(1, f + x), d = Math.max(f, b) + s() * 1.5, I = Math.min(f, b) - s() * 1.5;
28
+ h.push({
29
+ time: p,
30
+ open: f,
31
+ high: d,
32
+ low: I,
33
+ close: b,
34
+ volume: 1e3 + s() * 5e3
35
+ }), c = b;
36
+ }
37
+ return h;
38
+ }
39
+ function xt(r = {}) {
40
+ const e = r.barMs ?? 6e4, l = r.basePrice ?? 100, n = C(r.seed ?? 42), s = /* @__PURE__ */ new Map();
41
+ return {
42
+ async resolveSymbol(h) {
43
+ return {
44
+ symbol: h,
45
+ name: h,
46
+ description: `Mock symbol ${h}`,
47
+ timezone: "UTC",
48
+ session: "24x7",
49
+ pricescale: 100
50
+ };
51
+ },
52
+ async getBars(h) {
53
+ const c = `${h.symbol}:${h.from}:${h.to}`;
54
+ return s.has(c) || s.set(
55
+ c,
56
+ tt(h.from, h.to, e, l, n)
57
+ ), s.get(c);
58
+ },
59
+ subscribeBars(h) {
60
+ let c = l + n() * 5;
61
+ const p = setInterval(() => {
62
+ const f = c, x = Math.max(1, f + (n() - 0.5) * 2), b = Math.max(f, x) + n(), d = Math.min(f, x) - n();
63
+ h.onBar({
64
+ time: Date.now(),
65
+ open: f,
66
+ high: b,
67
+ low: d,
68
+ close: x,
69
+ volume: 1e3 + n() * 3e3
70
+ }), c = x;
71
+ }, e);
72
+ return () => clearInterval(p);
73
+ }
74
+ };
75
+ }
76
+ function et(r, e) {
77
+ if (r.length === 0) return -1;
78
+ let l = 0, n = Math.abs(r[0] - e);
79
+ for (let s = 1; s < r.length; s++) {
80
+ const h = Math.abs(r[s] - e);
81
+ h < n && (n = h, l = s);
82
+ }
83
+ return l;
84
+ }
85
+ function nt(r) {
86
+ if (r.barX.length === 0)
87
+ return { x: r.x, y: r.y };
88
+ const e = et(r.barX, r.x);
89
+ if (e < 0) return { x: r.x, y: r.y };
90
+ const l = r.barX[e], n = [
91
+ r.open[e],
92
+ r.high[e],
93
+ r.low[e],
94
+ r.close[e]
95
+ ], s = r.dataToPixelY(r.y), h = r.pixelThreshold ?? 12;
96
+ let c = r.y, p = 1 / 0;
97
+ for (const f of n) {
98
+ const x = r.dataToPixelY(f), b = Math.abs(x - s);
99
+ b < p && b <= h && (p = b, c = f);
100
+ }
101
+ return { x: l, y: c };
102
+ }
103
+ function L(r, e) {
104
+ const l = e.y - r.y, n = Math.abs(r.y), s = n > 0 ? l / n * 100 : 0, h = Math.round(Math.abs(e.x - r.x));
105
+ return { change: l, percent: s, bars: h, up: l >= 0 };
106
+ }
107
+ function Y(r) {
108
+ const e = r.change >= 0 ? "+" : "";
109
+ return `${e}${r.change.toFixed(2)} (${e}${r.percent.toFixed(2)}%) · ${r.bars} bars`;
110
+ }
111
+ function E(r) {
112
+ const e = Math.abs(r), l = e >= 1e3 ? 0 : e >= 1 ? 2 : 4;
113
+ return r.toLocaleString("en-US", {
114
+ minimumFractionDigits: l,
115
+ maximumFractionDigits: l
116
+ });
117
+ }
118
+ const U = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1], ot = 4, rt = "#26a69a", at = "#ef5350";
119
+ function z(r, e) {
120
+ return r.startsWith("#") && r.length === 7 ? r + e : r;
121
+ }
122
+ const st = {
123
+ name: "velo-plot-drawing-tools",
124
+ version: "1.0.0",
125
+ description: "Interactive trendline, horizontal, vertical, rectangle, and fibonacci drawing",
126
+ provides: ["drawing"],
127
+ tags: ["drawing", "annotations", "trading"]
128
+ };
129
+ function B(r) {
130
+ return r !== "none" && r !== "pan";
131
+ }
132
+ function it(r) {
133
+ for (const e of r.data.getAllSeries())
134
+ if (e.getType() === "candlestick") return e;
135
+ }
136
+ function dt(r = {}) {
137
+ let e = null;
138
+ const l = r.autoDeselect !== !1, n = {
139
+ mode: "none",
140
+ pending: null,
141
+ start: null,
142
+ dragging: !1,
143
+ dragMoved: !1,
144
+ dragStartPixel: null,
145
+ cursor: null,
146
+ magnet: r.magnet ?? !1,
147
+ undoStack: [],
148
+ redoStack: []
149
+ }, s = r.color ?? "#38bdf8", h = r.measureUpColor ?? rt, c = r.measureDownColor ?? at;
150
+ function p() {
151
+ var t, o;
152
+ return ((o = e == null ? void 0 : (t = e.chart).getAnnotations) == null ? void 0 : o.call(t)) ?? [];
153
+ }
154
+ function f() {
155
+ n.undoStack.push(p()), n.redoStack = [];
156
+ }
157
+ function x() {
158
+ n.pending = null, n.start = null, n.dragging = !1, n.dragMoved = !1, n.dragStartPixel = null;
159
+ }
160
+ function b(t) {
161
+ var o, a;
162
+ n.mode = t, x(), (o = r.onModeChange) == null || o.call(r, t), (a = e == null ? void 0 : e.requestRender) == null || a.call(e);
163
+ }
164
+ function d() {
165
+ var t;
166
+ x(), l ? b("none") : (t = e == null ? void 0 : e.requestRender) == null || t.call(e);
167
+ }
168
+ function I(t, o) {
169
+ if (!e || !n.magnet) return { x: t, y: o };
170
+ const a = it(e);
171
+ if (!a) return { x: t, y: o };
172
+ const i = a.getData();
173
+ return !i.open || !i.high || !i.low || !i.close ? { x: t, y: o } : nt({
174
+ x: t,
175
+ y: o,
176
+ barX: i.x,
177
+ open: i.open,
178
+ high: i.high,
179
+ low: i.low,
180
+ close: i.close,
181
+ dataToPixelX: e.coords.dataToPixelX,
182
+ dataToPixelY: (y) => e.coords.dataToPixelY(y),
183
+ enabled: !0
184
+ });
185
+ }
186
+ function A(t, o) {
187
+ return I(
188
+ t.coords.pixelToDataX(o.pixelX),
189
+ t.coords.pixelToDataY(o.pixelY)
190
+ );
191
+ }
192
+ function R(t) {
193
+ e && (f(), e.chart.addAnnotation({
194
+ type: "horizontal-line",
195
+ y: t,
196
+ color: s,
197
+ interactive: !0
198
+ }));
199
+ }
200
+ function O(t) {
201
+ e && (f(), e.chart.addAnnotation({
202
+ type: "vertical-line",
203
+ x: t,
204
+ color: s,
205
+ interactive: !0
206
+ }));
207
+ }
208
+ function V(t, o) {
209
+ if (!e) return;
210
+ f();
211
+ const a = L(t, o), i = a.up ? h : c, y = (t.x + o.x) / 2;
212
+ e.chart.addAnnotation({
213
+ type: "rectangle",
214
+ xMin: Math.min(t.x, o.x),
215
+ xMax: Math.max(t.x, o.x),
216
+ yMin: Math.min(t.y, o.y),
217
+ yMax: Math.max(t.y, o.y),
218
+ strokeColor: i,
219
+ fillColor: z(i, "33"),
220
+ interactive: !0
221
+ }), e.chart.addAnnotation({
222
+ type: "arrow",
223
+ x1: y,
224
+ y1: t.y,
225
+ x2: y,
226
+ y2: o.y,
227
+ color: i,
228
+ headStyle: "filled",
229
+ interactive: !0
230
+ }), e.chart.addAnnotation({
231
+ type: "text",
232
+ x: y,
233
+ y: o.y,
234
+ text: Y(a),
235
+ color: "#ffffff",
236
+ backgroundColor: i,
237
+ padding: 4,
238
+ fontWeight: "bold",
239
+ anchor: a.up ? "bottom-center" : "top-center",
240
+ interactive: !0
241
+ });
242
+ }
243
+ function W(t, o) {
244
+ if (e) {
245
+ if (n.mode === "measure") {
246
+ V(t, o);
247
+ return;
248
+ }
249
+ if (f(), n.mode === "trendline")
250
+ e.chart.addAnnotation({
251
+ type: "arrow",
252
+ x1: t.x,
253
+ y1: t.y,
254
+ x2: o.x,
255
+ y2: o.y,
256
+ color: s,
257
+ interactive: !0
258
+ });
259
+ else if (n.mode === "rectangle")
260
+ e.chart.addAnnotation({
261
+ type: "rectangle",
262
+ xMin: Math.min(t.x, o.x),
263
+ xMax: Math.max(t.x, o.x),
264
+ yMin: Math.min(t.y, o.y),
265
+ yMax: Math.max(t.y, o.y),
266
+ strokeColor: s,
267
+ fillColor: s + "22",
268
+ interactive: !0
269
+ });
270
+ else if (n.mode === "fibonacci") {
271
+ const a = Math.min(t.y, o.y), i = Math.max(t.y, o.y);
272
+ for (const y of U) {
273
+ const $ = i - (i - a) * y;
274
+ e.chart.addAnnotation({
275
+ type: "horizontal-line",
276
+ y: $,
277
+ color: s,
278
+ lineDash: y === 0 || y === 1 ? void 0 : [4, 4],
279
+ label: `${(y * 100).toFixed(1)}% ${E($)}`,
280
+ labelPosition: "right",
281
+ interactive: !0
282
+ });
283
+ }
284
+ }
285
+ }
286
+ }
287
+ function G(t, o, a) {
288
+ const i = n.mode;
289
+ if (!B(i) || !n.cursor) return;
290
+ const y = n.cursor, $ = n.pending ?? n.start;
291
+ t.save(), t.strokeStyle = s, t.lineWidth = 1.5, t.setLineDash([6, 4]), t.globalAlpha = 0.85;
292
+ const S = (M, w) => ({
293
+ px: a.dataToPixelX(M),
294
+ py: a.dataToPixelY(w)
295
+ });
296
+ if (i === "horizontal") {
297
+ const { py: M } = S(0, y.y);
298
+ t.beginPath(), t.moveTo(o.x, M), t.lineTo(o.x + o.width, M), t.stroke();
299
+ } else if (i === "vertical") {
300
+ const { px: M } = S(y.x, 0);
301
+ t.beginPath(), t.moveTo(M, o.y), t.lineTo(M, o.y + o.height), t.stroke();
302
+ } else if ($) {
303
+ const M = S($.x, $.y), w = S(y.x, y.y);
304
+ if (i === "trendline")
305
+ t.beginPath(), t.moveTo(M.px, M.py), t.lineTo(w.px, w.py), t.stroke();
306
+ else if (i === "rectangle") {
307
+ const m = Math.min(M.px, w.px), g = Math.min(M.py, w.py), v = Math.abs(w.px - M.px), k = Math.abs(w.py - M.py);
308
+ t.strokeRect(m, g, v, k), t.fillStyle = s + "22", t.fillRect(m, g, v, k);
309
+ } else if (i === "fibonacci") {
310
+ const m = Math.min($.y, y.y), g = Math.max($.y, y.y);
311
+ t.font = "11px sans-serif", t.textAlign = "left", t.textBaseline = "bottom";
312
+ for (const v of U) {
313
+ const k = g - (g - m) * v, { py: P } = S(0, k);
314
+ t.beginPath(), t.moveTo(o.x, P), t.lineTo(o.x + o.width, P), t.stroke(), t.save(), t.setLineDash([]), t.globalAlpha = 1, t.fillStyle = s, t.fillText(
315
+ `${(v * 100).toFixed(1)}% ${E(k)}`,
316
+ o.x + 4,
317
+ P - 2
318
+ ), t.restore();
319
+ }
320
+ } else i === "measure" && N(t, M, w, $, y);
321
+ }
322
+ t.restore();
323
+ }
324
+ function N(t, o, a, i, y) {
325
+ const $ = L(i, y), S = $.up ? h : c, M = Math.min(o.px, a.px), w = Math.min(o.py, a.py), m = Math.abs(a.px - o.px), g = Math.abs(a.py - o.py);
326
+ t.setLineDash([]), t.globalAlpha = 0.9, t.fillStyle = z(S, "33"), t.fillRect(M, w, m, g), t.strokeStyle = S, t.lineWidth = 1.5, t.strokeRect(M, w, m, g);
327
+ const v = (o.px + a.px) / 2;
328
+ t.beginPath(), t.moveTo(v, o.py), t.lineTo(v, a.py), t.stroke();
329
+ const k = 7, P = a.py >= o.py ? 1 : -1;
330
+ t.beginPath(), t.moveTo(v, a.py), t.lineTo(v - 4, a.py - P * k), t.lineTo(v + 4, a.py - P * k), t.closePath(), t.fillStyle = S, t.fill();
331
+ const T = Y($);
332
+ t.font = "12px sans-serif";
333
+ const F = t.measureText(T).width + 6 * 2, X = 20, Q = v - F / 2, H = $.up ? a.py - X - 8 : a.py + 8;
334
+ t.globalAlpha = 1, t.fillStyle = S, t.fillRect(Q, H, F, X), t.fillStyle = "#ffffff", t.textAlign = "center", t.textBaseline = "middle", t.fillText(T, v, H + X / 2);
335
+ }
336
+ function q(t) {
337
+ const o = n.mode;
338
+ if (!B(o) || !n.cursor) return [];
339
+ const a = Z(t.yScales) ?? [...t.yScales.values()][0];
340
+ if (!a) return [];
341
+ const i = t.plotArea, y = n.cursor, $ = n.pending ?? n.start, S = (m, g) => ({
342
+ px: t.xScale.transform(m),
343
+ py: a.transform(g)
344
+ }), M = 'stroke-dasharray="6,4"', w = [];
345
+ if (o === "horizontal") {
346
+ const { py: m } = S(0, y.y);
347
+ w.push(
348
+ `<line x1="${u(i.x)}" y1="${u(m)}" x2="${u(i.x + i.width)}" y2="${u(m)}" stroke="${s}" stroke-width="1.5" ${M}/>`
349
+ );
350
+ } else if (o === "vertical") {
351
+ const { px: m } = S(y.x, 0);
352
+ w.push(
353
+ `<line x1="${u(m)}" y1="${u(i.y)}" x2="${u(m)}" y2="${u(i.y + i.height)}" stroke="${s}" stroke-width="1.5" ${M}/>`
354
+ );
355
+ } else if ($) {
356
+ const m = S($.x, $.y), g = S(y.x, y.y);
357
+ if (o === "trendline")
358
+ w.push(
359
+ `<line x1="${u(m.px)}" y1="${u(m.py)}" x2="${u(g.px)}" y2="${u(g.py)}" stroke="${s}" stroke-width="1.5" ${M}/>`
360
+ );
361
+ else if (o === "rectangle") {
362
+ const v = Math.min(m.px, g.px), k = Math.min(m.py, g.py), P = Math.abs(g.px - m.px), T = Math.abs(g.py - m.py);
363
+ w.push(
364
+ `<rect x="${u(v)}" y="${u(k)}" width="${u(P)}" height="${u(T)}" fill="${s}22" stroke="${s}" stroke-width="1.5" ${M}/>`
365
+ );
366
+ } else if (o === "fibonacci") {
367
+ const v = Math.min($.y, y.y), k = Math.max($.y, y.y);
368
+ for (const P of U) {
369
+ const T = k - (k - v) * P, { py: D } = S(0, T);
370
+ w.push(
371
+ `<line x1="${u(i.x)}" y1="${u(D)}" x2="${u(i.x + i.width)}" y2="${u(D)}" stroke="${s}" stroke-width="1.5" ${M}/>`
372
+ ), w.push(
373
+ `<text x="${u(i.x + 4)}" y="${u(D - 2)}" fill="${s}" font-size="11" font-family="sans-serif">${(P * 100).toFixed(1)}% ${E(T)}</text>`
374
+ );
375
+ }
376
+ } else if (o === "measure") {
377
+ const v = L($, y), k = v.up ? h : c, P = Math.min(m.px, g.px), T = Math.min(m.py, g.py), D = Math.abs(g.px - m.px), _ = Math.abs(g.py - m.py), F = (m.px + g.px) / 2;
378
+ w.push(
379
+ `<rect x="${u(P)}" y="${u(T)}" width="${u(D)}" height="${u(_)}" fill="${z(k, "33")}" stroke="${k}" stroke-width="1.5"/>`
380
+ ), w.push(
381
+ `<line x1="${u(F)}" y1="${u(m.py)}" x2="${u(F)}" y2="${u(g.py)}" stroke="${k}" stroke-width="1.5"/>`
382
+ ), w.push(
383
+ `<text x="${u(F)}" y="${u(v.up ? g.py - 12 : g.py + 16)}" fill="${k}" font-size="12" font-family="sans-serif" text-anchor="middle">${Y(v)}</text>`
384
+ );
385
+ }
386
+ }
387
+ return w;
388
+ }
389
+ function j(t, o) {
390
+ var i;
391
+ if (!o.inPlotArea) return;
392
+ o.preventDefault();
393
+ const a = A(t, o);
394
+ if (n.mode === "horizontal") {
395
+ R(a.y), d();
396
+ return;
397
+ }
398
+ if (n.mode === "vertical") {
399
+ O(a.x), d();
400
+ return;
401
+ }
402
+ if (n.pending) {
403
+ W(n.pending, a), d();
404
+ return;
405
+ }
406
+ n.start = a, n.dragging = !0, n.dragMoved = !1, n.dragStartPixel = { x: o.pixelX, y: o.pixelY }, n.cursor = a, (i = t.requestRender) == null || i.call(t);
407
+ }
408
+ function J(t, o) {
409
+ var i;
410
+ const a = A(t, o);
411
+ if (n.cursor = a, n.dragging && n.dragStartPixel) {
412
+ const y = o.pixelX - n.dragStartPixel.x, $ = o.pixelY - n.dragStartPixel.y;
413
+ Math.hypot(y, $) >= ot && (n.dragMoved = !0);
414
+ }
415
+ o.preventDefault(), (i = t.requestRender) == null || i.call(t);
416
+ }
417
+ function K(t, o) {
418
+ var y;
419
+ if (!n.dragging || !n.start) return;
420
+ const a = A(t, o), i = n.start;
421
+ if (n.dragging = !1, n.dragStartPixel = null, n.dragMoved) {
422
+ W(i, a), d();
423
+ return;
424
+ }
425
+ n.pending = i, n.start = null, n.cursor = a, (y = t.requestRender) == null || y.call(t);
426
+ }
427
+ return {
428
+ manifest: st,
429
+ api: {
430
+ setMode(t) {
431
+ b(t);
432
+ },
433
+ getMode() {
434
+ return n.mode;
435
+ },
436
+ setMagnet(t) {
437
+ n.magnet = t;
438
+ },
439
+ isMagnet() {
440
+ return n.magnet;
441
+ },
442
+ undo() {
443
+ if (!e || n.undoStack.length === 0) return !1;
444
+ n.redoStack.push(p());
445
+ const t = n.undoStack.pop(), o = p();
446
+ for (const a of o) e.chart.removeAnnotation(a.id);
447
+ for (const a of t) e.chart.addAnnotation(a);
448
+ return !0;
449
+ },
450
+ redo() {
451
+ if (!e || n.redoStack.length === 0) return !1;
452
+ n.undoStack.push(p());
453
+ const t = n.redoStack.pop(), o = p();
454
+ for (const a of o) e.chart.removeAnnotation(a.id);
455
+ for (const a of t) e.chart.addAnnotation(a);
456
+ return !0;
457
+ },
458
+ clear() {
459
+ if (e) {
460
+ f();
461
+ for (const t of p()) e.chart.removeAnnotation(t.id);
462
+ }
463
+ }
464
+ },
465
+ onInit(t) {
466
+ e = t;
467
+ },
468
+ onDestroy() {
469
+ e = null;
470
+ },
471
+ onInteraction(t, o) {
472
+ if (B(n.mode)) {
473
+ if (o.type === "mousedown") {
474
+ j(t, o);
475
+ return;
476
+ }
477
+ if (o.type === "mousemove") {
478
+ J(t, o);
479
+ return;
480
+ }
481
+ o.type === "mouseup" && K(t, o);
482
+ }
483
+ },
484
+ onRenderOverlay(t) {
485
+ const o = t.render.ctx2d;
486
+ o && G(o, t.render.plotArea, t.coords);
487
+ },
488
+ onExportSVG(t) {
489
+ var o;
490
+ if (t.builder && ((o = t.exportContext) == null ? void 0 : o.options.includeOverlays) !== !1)
491
+ for (const a of q(t))
492
+ t.builder.push("plugins", a);
493
+ }
494
+ };
495
+ }
496
+ const lt = {
497
+ name: "velo-plot-replay",
498
+ version: "1.0.0",
499
+ description: "Bar-by-bar chart replay with speed control",
500
+ provides: ["replay"],
501
+ tags: ["replay", "trading"]
502
+ };
503
+ function mt(r) {
504
+ let e = null, l = null, n = 0, s = null, h = 1;
505
+ const c = r.frameMs ?? 250;
506
+ function p(x) {
507
+ const b = e, d = l, I = Math.min(x + 1, d.x.length), A = (R) => R ? R.subarray(0, I) : void 0;
508
+ b.chart.updateSeries(r.seriesId, {
509
+ x: A(d.x),
510
+ y: A(d.y),
511
+ open: A(d.open),
512
+ high: A(d.high),
513
+ low: A(d.low),
514
+ close: A(d.close)
515
+ });
516
+ }
517
+ const f = {
518
+ play(x = 1) {
519
+ l && (h = Math.max(0.1, x), s && clearInterval(s), s = setInterval(() => {
520
+ if (!e || !l) {
521
+ f.pause();
522
+ return;
523
+ }
524
+ if (n >= l.x.length - 1) {
525
+ f.pause();
526
+ return;
527
+ }
528
+ n++, p(n);
529
+ }, c / h));
530
+ },
531
+ pause() {
532
+ s && (clearInterval(s), s = null);
533
+ },
534
+ step(x = 1) {
535
+ l && (n = Math.min(l.x.length - 1, n + x), p(n));
536
+ },
537
+ seek(x) {
538
+ l && (n = Math.max(0, Math.min(l.x.length - 1, x)), p(n));
539
+ },
540
+ getIndex() {
541
+ return n;
542
+ },
543
+ getLength() {
544
+ return (l == null ? void 0 : l.x.length) ?? 0;
545
+ },
546
+ isPlaying() {
547
+ return s != null;
548
+ }
549
+ };
550
+ return {
551
+ manifest: lt,
552
+ api: f,
553
+ onInit(x) {
554
+ e = x;
555
+ const b = e.chart.getSeries(r.seriesId);
556
+ if (!b) {
557
+ console.warn(`[PluginReplay] Series "${r.seriesId}" not found`);
558
+ return;
559
+ }
560
+ const d = b.getData();
561
+ l = {
562
+ x: Float32Array.from(d.x),
563
+ y: d.y ? Float32Array.from(d.y) : void 0,
564
+ open: d.open ? Float32Array.from(d.open) : void 0,
565
+ high: d.high ? Float32Array.from(d.high) : void 0,
566
+ low: d.low ? Float32Array.from(d.low) : void 0,
567
+ close: d.close ? Float32Array.from(d.close) : void 0
568
+ }, n = Math.max(0, l.x.length - 1);
569
+ },
570
+ onDestroy() {
571
+ f.pause(), e = null, l = null;
572
+ }
573
+ };
574
+ }
575
+ export {
576
+ dt as P,
577
+ mt as a,
578
+ ut as b,
579
+ yt as c,
580
+ xt as d
581
+ };
582
+ //# sourceMappingURL=index-Bj-xyXY6.js.map