@devexperts/dxcharts-lite 1.0.2 → 2.0.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 (258) hide show
  1. package/README.md +2 -2
  2. package/dist/chart/animation/canvas-animation.js +134 -1
  3. package/dist/chart/animation/types/animation.js +43 -1
  4. package/dist/chart/animation/types/color-alpha-animation.d.ts +1 -1
  5. package/dist/chart/animation/types/color-alpha-animation.js +60 -1
  6. package/dist/chart/animation/types/color-transition-animation.d.ts +1 -1
  7. package/dist/chart/animation/types/color-transition-animation.js +86 -1
  8. package/dist/chart/animation/types/viewport-movement-animation.js +63 -1
  9. package/dist/chart/animation/viewport-model-animation.js +20 -1
  10. package/dist/chart/bootstrap.d.ts +51 -48
  11. package/dist/chart/bootstrap.js +449 -1
  12. package/dist/chart/canvas/canvas-bounds-container.d.ts +0 -5
  13. package/dist/chart/canvas/canvas-bounds-container.js +815 -1
  14. package/dist/chart/canvas/canvas-chart-html.js +16 -18
  15. package/dist/chart/canvas/chart-elements.d.ts +1 -4
  16. package/dist/chart/canvas/chart-elements.js +22 -1
  17. package/dist/chart/canvas/cursor.handler.js +122 -1
  18. package/dist/chart/canvas/layout-creator.js +34 -1
  19. package/dist/chart/canvas/y-axis-bounds.container.d.ts +2 -2
  20. package/dist/chart/canvas/y-axis-bounds.container.js +67 -1
  21. package/dist/chart/chart-container.js +1 -1
  22. package/dist/chart/chart.config.d.ts +4 -5
  23. package/dist/chart/chart.config.js +645 -1
  24. package/dist/chart/chart.d.ts +62 -0
  25. package/dist/chart/chart.js +106 -0
  26. package/dist/chart/components/chart/basic-scale.d.ts +2 -2
  27. package/dist/chart/components/chart/basic-scale.js +31 -1
  28. package/dist/chart/components/chart/candle-transformer.functions.js +15 -1
  29. package/dist/chart/components/chart/candle-width-calculator.functions.js +2 -1
  30. package/dist/chart/components/chart/candle.functions.js +44 -1
  31. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +3 -3
  32. package/dist/chart/components/chart/chart-area-pan.handler.js +197 -1
  33. package/dist/chart/components/chart/chart-base.model.js +66 -1
  34. package/dist/chart/components/chart/chart.component.d.ts +7 -3
  35. package/dist/chart/components/chart/chart.component.js +408 -1
  36. package/dist/chart/components/chart/chart.model.d.ts +4 -11
  37. package/dist/chart/components/chart/chart.model.js +954 -1
  38. package/dist/chart/components/chart/data-series.high-low-provider.js +34 -1
  39. package/dist/chart/components/chart/fake-candles.js +97 -1
  40. package/dist/chart/components/chart/price.formatter.js +35 -1
  41. package/dist/chart/components/chart/secondary-chart-colors-pool.js +68 -1
  42. package/dist/chart/components/cross_tool/cross-tool.component.js +85 -1
  43. package/dist/chart/components/cross_tool/cross-tool.drawer.js +32 -1
  44. package/dist/chart/components/cross_tool/cross-tool.model.js +107 -1
  45. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +137 -1
  46. package/dist/chart/components/cross_tool/types/none.drawer.js +3 -1
  47. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +28 -1
  48. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +24 -1
  49. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +53 -1
  50. package/dist/chart/components/dynamic-objects/dynamic-objects.component.d.ts +13 -0
  51. package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +20 -0
  52. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.d.ts +18 -0
  53. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.js +23 -0
  54. package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +63 -0
  55. package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +136 -0
  56. package/dist/chart/components/events/events-hit-test.drawer.js +63 -1
  57. package/dist/chart/components/events/events.component.js +61 -1
  58. package/dist/chart/components/events/events.drawer.js +195 -1
  59. package/dist/chart/components/events/events.model.js +69 -1
  60. package/dist/chart/components/grid/grid.component.d.ts +2 -2
  61. package/dist/chart/components/grid/grid.component.js +31 -1
  62. package/dist/chart/components/grid/grid.drawer.d.ts +4 -3
  63. package/dist/chart/components/grid/grid.drawer.js +106 -1
  64. package/dist/chart/components/high_low/high-low.component.js +12 -1
  65. package/dist/chart/components/high_low/high-low.drawer.js +126 -1
  66. package/dist/chart/components/highlights/highlights.component.js +46 -1
  67. package/dist/chart/components/highlights/highlights.drawer.js +154 -1
  68. package/dist/chart/components/highlights/highlights.model.js +75 -1
  69. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +1 -1
  70. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +199 -1
  71. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +2 -2
  72. package/dist/chart/components/navigation_map/navigation-map-move.handler.js +108 -1
  73. package/dist/chart/components/navigation_map/navigation-map.component.js +112 -1
  74. package/dist/chart/components/navigation_map/navigation-map.drawer.js +244 -1
  75. package/dist/chart/components/navigation_map/navigation-map.model.js +33 -2
  76. package/dist/chart/components/pan/chart-pan.component.d.ts +2 -2
  77. package/dist/chart/components/pan/chart-pan.component.js +51 -1
  78. package/dist/chart/components/pane/extent/y-extent-component.d.ts +12 -18
  79. package/dist/chart/components/pane/extent/y-extent-component.js +120 -1
  80. package/dist/chart/components/pane/pane-hit-test.controller.d.ts +2 -2
  81. package/dist/chart/components/pane/pane-hit-test.controller.js +55 -1
  82. package/dist/chart/components/pane/pane-manager.component.d.ts +12 -6
  83. package/dist/chart/components/pane/pane-manager.component.js +149 -1
  84. package/dist/chart/components/pane/pane.component.d.ts +16 -32
  85. package/dist/chart/components/pane/pane.component.js +278 -1
  86. package/dist/chart/components/resizer/bar-resizer.component.js +139 -1
  87. package/dist/chart/components/resizer/bar-resizer.drawer.js +46 -1
  88. package/dist/chart/components/snapshot/snapshot.component.js +48 -1
  89. package/dist/chart/components/volumes/separate-volumes.component.d.ts +6 -10
  90. package/dist/chart/components/volumes/separate-volumes.component.js +63 -1
  91. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +18 -1
  92. package/dist/chart/components/volumes/volumes.component.d.ts +6 -7
  93. package/dist/chart/components/volumes/volumes.component.js +94 -1
  94. package/dist/chart/components/volumes/volumes.drawer.d.ts +5 -12
  95. package/dist/chart/components/volumes/volumes.drawer.js +140 -1
  96. package/dist/chart/components/volumes/volumes.formatter.js +31 -1
  97. package/dist/chart/components/volumes/volumes.model.d.ts +2 -2
  98. package/dist/chart/components/volumes/volumes.model.js +43 -1
  99. package/dist/chart/components/watermark/water-mark.component.js +103 -1
  100. package/dist/chart/components/watermark/water-mark.drawer.js +187 -1
  101. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +27 -1
  102. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +187 -1
  103. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +76 -1
  104. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +79 -1
  105. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +14 -1
  106. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +1 -1
  107. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +143 -1
  108. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +73 -1
  109. package/dist/chart/components/x_axis/x-axis-draw.functions.js +49 -1
  110. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +70 -1
  111. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
  112. package/dist/chart/components/x_axis/x-axis-labels.generator.js +332 -1
  113. package/dist/chart/components/x_axis/x-axis-labels.model.js +35 -1
  114. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +2 -2
  115. package/dist/chart/components/x_axis/x-axis-scale.handler.js +60 -1
  116. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +82 -1
  117. package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -2
  118. package/dist/chart/components/x_axis/x-axis.component.js +119 -1
  119. package/dist/chart/components/y_axis/label-color.functions.js +53 -1
  120. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +4 -4
  121. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +33 -1
  122. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +3 -3
  123. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +67 -1
  124. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +56 -1
  125. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +4 -3
  126. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +96 -1
  127. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +2 -2
  128. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +119 -1
  129. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +9 -8
  130. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +201 -1
  131. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +6 -7
  132. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +58 -1
  133. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +6 -4
  134. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +47 -1
  135. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +4 -4
  136. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +161 -1
  137. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +2 -2
  138. package/dist/chart/components/y_axis/y-axis-scale.handler.js +72 -1
  139. package/dist/chart/components/y_axis/y-axis.component.d.ts +32 -41
  140. package/dist/chart/components/y_axis/y-axis.component.js +220 -1
  141. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +9 -12
  142. package/dist/chart/components/y_axis/y-axis.drawer.js +96 -1
  143. package/dist/chart/components/y_axis/y-axis.model.d.ts +10 -17
  144. package/dist/chart/components/y_axis/y-axis.model.js +34 -1
  145. package/dist/chart/drawers/chart-background.drawer.js +69 -1
  146. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +69 -1
  147. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +57 -1
  148. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +84 -1
  149. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +162 -1
  150. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +57 -1
  151. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +38 -1
  152. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +19 -1
  153. package/dist/chart/drawers/clear-canvas.drawer.js +14 -1
  154. package/dist/chart/drawers/composite.drawer.js +67 -1
  155. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +50 -1
  156. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +35 -1
  157. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +16 -1
  158. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +106 -1
  159. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +23 -1
  160. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +19 -1
  161. package/dist/chart/drawers/data-series-drawers/points.drawer.js +19 -1
  162. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +7 -1
  163. package/dist/chart/drawers/data-series-drawers/text.drawer.js +25 -1
  164. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +35 -1
  165. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +22 -1
  166. package/dist/chart/drawers/data-series.drawer.d.ts +5 -7
  167. package/dist/chart/drawers/data-series.drawer.js +56 -1
  168. package/dist/chart/drawers/drawing-manager.d.ts +1 -1
  169. package/dist/chart/drawers/drawing-manager.js +177 -1
  170. package/dist/chart/drawers/ht-data-series.drawer.js +37 -1
  171. package/dist/chart/events/event-bus.js +73 -1
  172. package/dist/chart/events/events.js +3 -1
  173. package/dist/chart/inputhandlers/candle-tap.handler.js +46 -1
  174. package/dist/chart/inputhandlers/chart-resize.handler.js +98 -1
  175. package/dist/chart/inputhandlers/cross-event-producer.component.js +67 -1
  176. package/dist/chart/inputhandlers/hover-producer.component.d.ts +2 -2
  177. package/dist/chart/inputhandlers/hover-producer.component.js +228 -1
  178. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +2 -2
  179. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +80 -1
  180. package/dist/chart/inputlisteners/canvas-input-listener.component.js +629 -1
  181. package/dist/chart/model/baseline.model.js +88 -1
  182. package/dist/chart/model/bounds.model.js +1 -1
  183. package/dist/chart/model/candle-hover.js +70 -1
  184. package/dist/chart/model/candle-series-high-low.provider.js +45 -1
  185. package/dist/chart/model/candle-series.model.d.ts +3 -3
  186. package/dist/chart/model/candle-series.model.js +245 -1
  187. package/dist/chart/model/candle.model.js +69 -1
  188. package/dist/chart/model/canvas.model.js +228 -1
  189. package/dist/chart/model/chart-base-element.js +129 -1
  190. package/dist/chart/model/compare-series-hover.js +25 -1
  191. package/dist/chart/model/data-series-view.d.ts +5 -5
  192. package/dist/chart/model/data-series-view.js +111 -1
  193. package/dist/chart/model/data-series.config.js +14 -1
  194. package/dist/chart/model/data-series.model.d.ts +4 -4
  195. package/dist/chart/model/data-series.model.js +281 -1
  196. package/dist/chart/model/date-time.formatter.js +151 -1
  197. package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
  198. package/dist/chart/model/hit-test-canvas.model.js +256 -1
  199. package/dist/chart/model/main-candle-series.model.d.ts +1 -1
  200. package/dist/chart/model/main-candle-series.model.js +29 -1
  201. package/dist/chart/model/scale.model.d.ts +3 -2
  202. package/dist/chart/model/scale.model.js +316 -1
  203. package/dist/chart/model/scaling/auto-scale.model.d.ts +2 -4
  204. package/dist/chart/model/scaling/auto-scale.model.js +91 -1
  205. package/dist/chart/model/scaling/constrait.functions.js +61 -1
  206. package/dist/chart/model/scaling/lock-ratio.model.js +17 -1
  207. package/dist/chart/model/scaling/move-chart.functions.js +22 -1
  208. package/dist/chart/model/scaling/viewport.model.d.ts +2 -2
  209. package/dist/chart/model/scaling/viewport.model.js +279 -1
  210. package/dist/chart/model/scaling/x-zooming.functions.js +35 -1
  211. package/dist/chart/model/time-zone.model.js +109 -1
  212. package/dist/chart/model/visual-candle.js +134 -1
  213. package/dist/chart/utils/__tests__/array.utils.test.js +135 -1
  214. package/dist/chart/utils/__tests__/math.utils.test.js +14 -1
  215. package/dist/chart/utils/__tests__/object.utils.test.js +11 -1
  216. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +29 -1
  217. package/dist/chart/utils/array.utils.d.ts +1 -1
  218. package/dist/chart/utils/array.utils.js +269 -1
  219. package/dist/chart/utils/auto-period-detector.utils.js +39 -1
  220. package/dist/chart/utils/candles-generator-ts.utils.js +20 -1
  221. package/dist/chart/utils/candles-generator.utils.js +161 -1
  222. package/dist/chart/utils/candles.utils.js +42 -1
  223. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +144 -1
  224. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +51 -1
  225. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +156 -1
  226. package/dist/chart/utils/color.utils.js +31 -1
  227. package/dist/chart/utils/device/browser.utils.js +10 -1
  228. package/dist/chart/utils/device/device-detector.utils.js +24 -1
  229. package/dist/chart/utils/device/device-pixel-ratio.utils.js +21 -1
  230. package/dist/chart/utils/device/touchpad.utils.js +91 -1
  231. package/dist/chart/utils/dom.utils.js +15 -1
  232. package/dist/chart/utils/function.utils.js +16 -1
  233. package/dist/chart/utils/linkedList.utils.d.ts +28 -0
  234. package/dist/chart/utils/linkedList.utils.js +138 -0
  235. package/dist/chart/utils/math.utils.js +115 -1
  236. package/dist/chart/utils/merge.utils.js +56 -1
  237. package/dist/chart/utils/object.utils.js +43 -1
  238. package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
  239. package/dist/chart/utils/{perfomance → performance}/debounce.utils.js +7 -1
  240. package/dist/chart/utils/performance/memoize.utils.js +74 -0
  241. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
  242. package/dist/chart/utils/performance/throttle.utils.js +26 -0
  243. package/dist/chart/utils/price-increments.utils.d.ts +1 -0
  244. package/dist/chart/utils/price-increments.utils.js +127 -1
  245. package/dist/chart/utils/uuid.utils.js +4 -1
  246. package/dist/dxchart.min.js +9 -12
  247. package/dist/index.d.ts +3 -3
  248. package/dist/index.js +20 -1
  249. package/package.json +4 -4
  250. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
  251. package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
  252. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
  253. package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
  254. /package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +0 -0
  255. /package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +0 -0
  256. /package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +0 -0
  257. /package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +0 -0
  258. /package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +0 -0
@@ -3,4 +3,123 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- import{CanvasElement as d}from"../../../canvas/canvas-bounds-container";import{ChartBaseElement as f}from"../../../model/chart-base-element";import{DataSeriesModel as S,VisualSeriesPoint as w,defaultValueFormatter as x}from"../../../model/data-series.model";import{mergeHighLow as A}from"../../../model/scaling/auto-scale.model";import{createYExtentFormatters as B}from"../../chart/price.formatter";export class YExtentComponent extends f{constructor(t,i,e,u,l,m,c,h,a,g,v=new Set,p={regular:x}){if(super(),this.paneUuid=t,this.idx=i,this.paneComponent=e,this.chartBaseModel=u,this.canvasBoundsContainer=l,this.hitTestController=m,this.dataSeriesCanvasModel=c,this.scaleModel=h,this.yAxisComponent=a,this.dragNDrop=g,this.dataSeries=v,this.formatters=p,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(d.PANE_UUID_Y_AXIS(this.paneUuid,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(d.PANE_UUID_Y_AXIS(this.paneUuid,this.idx)),this.toVisualPoints=s=>s.map(r=>new w(this.chartBaseModel.dataFromTimestamp(r.timestamp).centerUnit,r.close)),this.valueFormatter=(s,r)=>{var o;return((o=this.formatters[this.getAxisType()])!==null&&o!==void 0?o:this.formatters.regular)(s,r)},this.addChildEntity(h),a!==void 0){this.addChildEntity(a.yAxisScaleHandler),this.addSubscription(a.unsub);const s={getLargestLabel:()=>{var r;return(r=a.labelsGenerator.getLargestLabel())!==null&&r!==void 0?r:""},getYAxisIndex:()=>i,getYAxisAlign:()=>a.state.align,getPaneUUID:()=>e.uuid};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(s),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(s))}this.setValueFormatters(B(this))}doDeactivate(){super.doDeactivate(),this.dataSeries.forEach(t=>t.deactivate())}getBounds(){return this.scaleModel.getBounds()}createDataSeries(){const t=new S(this,this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){this.dataSeries.add(t),this.dataSeries.size===1&&(this.mainDataSeries=t),this.paneComponent.updateView()}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView()}getAxisType(){return"regular"}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var i,e;return(e=(i=this.mainDataSeries)===null||i===void 0?void 0:i.view.priceFromY(t))!==null&&e!==void 0?e:this.scaleModel.fromY(t)}}export const createDefaultYExtentHighLowProvider=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const i=Array.from(n.dataSeries).filter(e=>e.highLowProvider.isHighLowActive()).map(e=>e.highLowProvider.calculateHighLow(t));return A(i)}});
6
+ import { CanvasElement } from '../../../canvas/canvas-bounds-container';
7
+ import { ChartBaseElement } from '../../../model/chart-base-element';
8
+ import { DataSeriesModel, VisualSeriesPoint, defaultValueFormatter, } from '../../../model/data-series.model';
9
+ import { mergeHighLow } from '../../../model/scaling/auto-scale.model';
10
+ import { createYExtentFormatters } from '../../chart/price.formatter';
11
+ export class YExtentComponent extends ChartBaseElement {
12
+ constructor(paneUUID, idx, paneComponent, chartBaseModel, canvasBoundsContainer, hitTestController, dynamicObjectsCanvasModel, scale, createYAxisComponent, dragNDrop, dataSeries = new Set(), formatters = {
13
+ regular: defaultValueFormatter,
14
+ }) {
15
+ super();
16
+ this.paneUUID = paneUUID;
17
+ this.idx = idx;
18
+ this.paneComponent = paneComponent;
19
+ this.chartBaseModel = chartBaseModel;
20
+ this.canvasBoundsContainer = canvasBoundsContainer;
21
+ this.hitTestController = hitTestController;
22
+ this.dynamicObjectsCanvasModel = dynamicObjectsCanvasModel;
23
+ this.scale = scale;
24
+ this.dragNDrop = dragNDrop;
25
+ this.dataSeries = dataSeries;
26
+ this.formatters = formatters;
27
+ this.getYAxisBounds = () => {
28
+ return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.paneUUID, this.idx));
29
+ };
30
+ this.yAxisHT = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(this.paneUUID, this.idx));
31
+ this.toVisualPoints = (points) => points.map(p => new VisualSeriesPoint(this.chartBaseModel.dataFromTimestamp(p.timestamp).centerUnit, p.close));
32
+ this.toY = (value) => {
33
+ var _a, _b;
34
+ return (_b = (_a = this.mainDataSeries) === null || _a === void 0 ? void 0 : _a.view.toY(value)) !== null && _b !== void 0 ? _b : 1;
35
+ };
36
+ this.valueFormatter = (value, dataSeries) => {
37
+ var _a;
38
+ const formatter = (_a = this.formatters[this.yAxis.getAxisType()]) !== null && _a !== void 0 ? _a : this.formatters.regular;
39
+ return formatter(value, dataSeries);
40
+ };
41
+ this.addChildEntity(scale);
42
+ this.setValueFormatters(createYExtentFormatters(this));
43
+ this.yAxis = createYAxisComponent(this.valueFormatter.bind(this), () => this.mainDataSeries);
44
+ this.addChildEntity(this.yAxis);
45
+ }
46
+ doDeactivate() {
47
+ super.doDeactivate();
48
+ this.dataSeries.forEach(ds => {
49
+ this.paneComponent.seriesRemovedSubject.next(ds);
50
+ ds.deactivate();
51
+ });
52
+ }
53
+ /**
54
+ * Returns the bounds of the scale model.
55
+ * @returns {Bounds} The bounds of the scale model.
56
+ */
57
+ getBounds() {
58
+ return this.scale.getBounds();
59
+ }
60
+ getBaseline() {
61
+ var _a, _b;
62
+ return (_b = (_a = this.mainDataSeries) === null || _a === void 0 ? void 0 : _a.getBaseline()) !== null && _b !== void 0 ? _b : 1;
63
+ }
64
+ /**
65
+ * Creates a new DataSeriesModel object.
66
+ * @returns {DataSeriesModel} - The newly created DataSeriesModel object.
67
+ */
68
+ createDataSeries() {
69
+ const series = new DataSeriesModel(this, this.hitTestController.getNewDataSeriesHitTestId());
70
+ series.toVisualPoints = this.toVisualPoints;
71
+ return series;
72
+ }
73
+ /**
74
+ * Adds a new data series to the chart.
75
+ * @param {DataSeriesModel} series - The data series to be added.
76
+ * @returns {void}
77
+ */
78
+ addDataSeries(series) {
79
+ this.dataSeries.add(series);
80
+ if (this.dataSeries.size === 1) {
81
+ this.mainDataSeries = series;
82
+ }
83
+ this.paneComponent.updateView();
84
+ this.paneComponent.seriesAddedSubject.next(series);
85
+ }
86
+ /**
87
+ * Removes a data series from the chart.
88
+ *
89
+ * @param {DataSeriesModel} series - The data series to be removed.
90
+ * @returns {void}
91
+ */
92
+ removeDataSeries(series) {
93
+ this.dataSeries.delete(series);
94
+ this.paneComponent.updateView();
95
+ this.paneComponent.seriesRemovedSubject.next(series);
96
+ }
97
+ get regularFormatter() {
98
+ return this.formatters.regular;
99
+ }
100
+ /**
101
+ * Sets the pane value formatters for the current instance.
102
+ * @param {YExtentFormatters} formatters - The pane value formatters to be set.
103
+ */
104
+ setValueFormatters(formatters) {
105
+ this.formatters = formatters;
106
+ }
107
+ /**
108
+ * Returns the regular value from Y coordinate.
109
+ * @param {number} y - The Y coordinate.
110
+ * @returns {number} - The regular value.
111
+ */
112
+ regularValueFromY(y) {
113
+ var _a, _b;
114
+ return (_b = (_a = this.mainDataSeries) === null || _a === void 0 ? void 0 : _a.view.priceFromY(y)) !== null && _b !== void 0 ? _b : this.scale.fromY(y);
115
+ }
116
+ }
117
+ export const createDefaultYExtentHighLowProvider = (extent) => ({
118
+ isHighLowActive: () => true,
119
+ calculateHighLow: state => {
120
+ const highLows = Array.from(extent.dataSeries)
121
+ .filter(ds => ds.highLowProvider.isHighLowActive())
122
+ .map(ds => ds.highLowProvider.calculateHighLow(state));
123
+ return mergeHighLow(highLows);
124
+ },
125
+ });
@@ -8,10 +8,10 @@ import { DataSeriesModel, DataSeriesPoint, VisualSeriesPoint } from '../../model
8
8
  import { HitTestSubscriber } from '../../model/hit-test-canvas.model';
9
9
  import { PaneComponent } from './pane.component';
10
10
  export declare class PaneHitTestController implements HitTestSubscriber<DataSeriesModel> {
11
- private readonly paneComponents;
11
+ private readonly panes;
12
12
  private canvasModel;
13
13
  private dataSeriesIdCounter;
14
- constructor(paneComponents: Record<string, PaneComponent>, canvasModel: CanvasModel);
14
+ constructor(panes: Record<string, PaneComponent>, canvasModel: CanvasModel);
15
15
  getNewDataSeriesHitTestId: () => number;
16
16
  /**
17
17
  * Returns an array with two numbers representing the range of IDs for data series.
@@ -3,4 +3,58 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- import{HIT_TEST_ID_RANGE as n}from"../../model/hit-test-canvas.model";import{flatMap as r}from"../../utils/array.utils";export class PaneHitTestController{constructor(t,e){this.paneComponents=t,this.canvasModel=e,this.dataSeriesIdCounter=n.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return n.DATA_SERIES}get allDataSeries(){return r(r(Object.values(this.paneComponents),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(a=>a.id===t)}onHover(t){this.allDataSeries.forEach(e=>e.hovered=e.id===(t==null?void 0:t.id)),this.canvasModel.fireDraw()}onMouseDown(t){t&&this.handleYExtentDragStart(t)}onMouseUp(){this.handleYExtentDragEnd()}handleYExtentDragStart(t){Object.values(this.paneComponents).forEach(e=>e.yExtentComponents.forEach(a=>a.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.paneComponents).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}
6
+ import { HIT_TEST_ID_RANGE } from '../../model/hit-test-canvas.model';
7
+ import { flatMap } from '../../utils/array.utils';
8
+ export class PaneHitTestController {
9
+ constructor(panes, canvasModel) {
10
+ this.panes = panes;
11
+ this.canvasModel = canvasModel;
12
+ // used in hit test for creating series
13
+ this.dataSeriesIdCounter = HIT_TEST_ID_RANGE.DATA_SERIES[0];
14
+ this.getNewDataSeriesHitTestId = () => {
15
+ return this.dataSeriesIdCounter++;
16
+ };
17
+ }
18
+ /**
19
+ * Returns an array with two numbers representing the range of IDs for data series.
20
+ * @returns {Array<number>} An array with two numbers representing the range of IDs for data series.
21
+ */
22
+ getIdRange() {
23
+ return HIT_TEST_ID_RANGE.DATA_SERIES;
24
+ }
25
+ get allDataSeries() {
26
+ return flatMap(flatMap(Object.values(this.panes), c => c.yExtentComponents), p => Array.from(p.dataSeries));
27
+ }
28
+ /**
29
+ * Looks up a data series by its ID.
30
+ *
31
+ * @param {number} id - The ID of the data series to look up.
32
+ * @returns {DataSeriesModel | undefined} - The data series with the given ID, or undefined if it does not exist.
33
+ */
34
+ lookup(id) {
35
+ const result = this.allDataSeries.find(d => d.id === id);
36
+ return result;
37
+ }
38
+ /**
39
+ * Changes the hovered property of all data series to true if their id matches the id of the provided model.
40
+ * @param {DataSeriesModel | null} model - The model to compare the id with.
41
+ * @returns {void}
42
+ */
43
+ onHover(model) {
44
+ this.allDataSeries.forEach(d => (d.hovered = d.id === (model === null || model === void 0 ? void 0 : model.id)));
45
+ this.canvasModel.fireDraw();
46
+ }
47
+ onMouseDown(model) {
48
+ model && this.handleYExtentDragStart(model);
49
+ }
50
+ onMouseUp() {
51
+ this.handleYExtentDragEnd();
52
+ }
53
+ handleYExtentDragStart(model) {
54
+ Object.values(this.panes).forEach(p => p.yExtentComponents.forEach(y => y.dragNDrop.deactivate()));
55
+ model.extentComponent.dragNDrop.activate();
56
+ }
57
+ handleYExtentDragEnd() {
58
+ Object.values(this.panes).forEach(p => p.yExtentComponents.forEach(y => y.dragNDrop.activate()));
59
+ }
60
+ }
@@ -18,32 +18,37 @@ import { ScaleModel } from '../../model/scale.model';
18
18
  import { AtLeastOne } from '../../utils/object.utils';
19
19
  import { ChartBaseModel } from '../chart/chart-base.model';
20
20
  import { ChartPanComponent } from '../pan/chart-pan.component';
21
- import { YExtentCreationOptions } from './extent/y-extent-component';
21
+ import { YExtentComponent, YExtentCreationOptions } from './extent/y-extent-component';
22
22
  import { PaneHitTestController } from './pane-hit-test.controller';
23
23
  import { PaneComponent } from './pane.component';
24
+ import { DataSeriesModel } from '../../model/data-series.model';
24
25
  export declare class PaneManager extends ChartBaseElement {
25
26
  private chartBaseModel;
27
+ private dynamicObjectsCanvasModel;
26
28
  private userInputListenerComponents;
27
29
  private eventBus;
28
- private mainScaleModel;
30
+ private mainScale;
29
31
  private canvasBoundsContainer;
30
32
  private config;
31
33
  private canvasAnimation;
32
34
  private canvasInputListener;
33
35
  private drawingManager;
34
- private dataSeriesCanvasModel;
35
36
  private cursorHandler;
36
37
  private crossEventProducer;
37
38
  chartPanComponent: ChartPanComponent;
38
39
  private mainCanvasModel;
39
- paneComponents: Record<string, PaneComponent>;
40
- panesChangedSubject: Subject<Record<string, PaneComponent>>;
40
+ private yAxisLabelsCanvasModel;
41
+ panes: Record<string, PaneComponent>;
42
+ paneRemovedSubject: Subject<PaneComponent>;
43
+ paneAddedSubject: Subject<Record<string, PaneComponent>>;
41
44
  hitTestController: PaneHitTestController;
45
+ dataSeriesAddedSubject: Subject<DataSeriesModel>;
46
+ dataSeriesRemovedSubject: Subject<DataSeriesModel>;
42
47
  /**
43
48
  * Returns order of panes in the chart from top to bottom.
44
49
  */
45
50
  get panesOrder(): string[];
46
- constructor(chartBaseModel: ChartBaseModel<'candle'>, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScaleModel: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, dataSeriesCanvasModel: CanvasModel, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel);
51
+ constructor(chartBaseModel: ChartBaseModel<'candle'>, dynamicObjectsCanvasModel: CanvasModel, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel);
47
52
  private addBounds;
48
53
  /**
49
54
  * Adds a resizer to the canvas bounds container for the given uuid.
@@ -51,6 +56,7 @@ export declare class PaneManager extends ChartBaseElement {
51
56
  * @returns {BarResizerComponent} - The BarResizerComponent instance that was added to the userInputListenerComponents array.
52
57
  */
53
58
  private addResizer;
59
+ get yExtents(): YExtentComponent[];
54
60
  /**
55
61
  * Returns the pane component that contains the given point.
56
62
  * @param {Point} point - The point to check.
@@ -3,4 +3,152 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- import{Subject as v}from"rxjs";import{CHART_UUID as f,CanvasElement as a}from"../../canvas/canvas-bounds-container";import{ChartBaseElement as g}from"../../model/chart-base-element";import{uuid as E}from"../../utils/uuid.utils";import{createHighLowOffsetCalculator as P}from"../chart/data-series.high-low-provider";import{BarResizerComponent as B}from"../resizer/bar-resizer.component";import{createDefaultYExtentHighLowProvider as M}from"./extent/y-extent-component";import{PaneHitTestController as S}from"./pane-hit-test.controller";import{PaneComponent as I}from"./pane.component";export class PaneManager extends g{get panesOrder(){return this.canvasBoundsContainer.panesOrder}constructor(e,s,n,t,o,r,c,h,d,p,l,m,u,C){super(),this.chartBaseModel=e,this.userInputListenerComponents=s,this.eventBus=n,this.mainScaleModel=t,this.canvasBoundsContainer=o,this.config=r,this.canvasAnimation=c,this.canvasInputListener=h,this.drawingManager=d,this.dataSeriesCanvasModel=p,this.cursorHandler=l,this.crossEventProducer=m,this.chartPanComponent=u,this.mainCanvasModel=C,this.paneComponents={},this.panesChangedSubject=new v,this.hitTestController=new S(this.paneComponents,this.dataSeriesCanvasModel);const i=this.createPane(f,{useDefaultHighLow:!1,scaleModel:this.mainScaleModel,useDefaultYAxis:!1});i.mainYExtentComponent.scaleModel.autoScaleModel.setHighLowProvider("series",M(i.mainYExtentComponent)),t.autoScaleModel.setHighLowPostProcessor("offsets",P(()=>this.mainScaleModel.getOffsets()))}addBounds(e,s){return this.canvasBoundsContainer.addPaneBounds(e,s),()=>this.canvasBoundsContainer.removedPaneBounds(e)}addResizer(e){const s=this.canvasBoundsContainer.getBoundsHitTest(a.PANE_UUID_RESIZER(e),{extensionY:this.config.components.paneResizer.dragZone}),n=()=>{this.canvasBoundsContainer.resizePaneVertically(e,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"overDataSeriesCanvas"])},t=a.PANE_UUID_RESIZER(e),o=new B(t,()=>this.canvasBoundsContainer.getBounds(t),s,n,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer);return this.userInputListenerComponents.push(o),o}getPaneIfHit(e){return Object.values(this.paneComponents).find(n=>this.canvasBoundsContainer.getBoundsHitTest(a.PANE_UUID(n.uuid))(e.x,e.y))}createPane(e=E(),s){if(this.paneComponents[e]!==void 0)return this.paneComponents[e];const n=new I(this.chartBaseModel,this.hitTestController,this.config,this.mainScaleModel,this.drawingManager,this.chartPanComponent,this.mainCanvasModel,this.canvasInputListener,this.userInputListenerComponents,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,e,this.dataSeriesCanvasModel,s);return this.config.components.paneResizer.visible&&n.addChildEntity(this.addResizer(e)),n.addSubscription(this.addBounds(e,s==null?void 0:s.order)),n.addSubscription(this.addCursors(e)),n.addSubscription(this.crossEventProducer.subscribeMouseOverHT(e,n.ht)),this.paneComponents[e]=n,n.activate(),this.recalculateState(),n.mainYExtentComponent.scaleModel.autoScale(!0),this.panesChangedSubject.next(this.paneComponents),n}removePane(e){const s=this.paneComponents[e];s!==void 0&&(s.disable(),s.yExtentComponents.forEach(n=>n.disable()),delete this.paneComponents[e],this.recalculateState(),this.panesChangedSubject.next(this.paneComponents))}addCursors(e,s=this.config.components.chart.cursor){const n=a.PANE_UUID(e),t=a.PANE_UUID_RESIZER(e);return this.cursorHandler.setCursorForCanvasEl(n,s),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(t,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone),()=>{this.cursorHandler.removeCursorForCanvasEl(n),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(t)}}recalculateState(){Object.values(this.paneComponents).forEach(e=>e.scaleModel.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"overDataSeriesCanvas"])}}
6
+ import { Subject } from 'rxjs';
7
+ import { CHART_UUID, CanvasElement } from '../../canvas/canvas-bounds-container';
8
+ import { ChartBaseElement } from '../../model/chart-base-element';
9
+ import { uuid as generateUuid } from '../../utils/uuid.utils';
10
+ import { createHighLowOffsetCalculator } from '../chart/data-series.high-low-provider';
11
+ import { BarResizerComponent } from '../resizer/bar-resizer.component';
12
+ import { createDefaultYExtentHighLowProvider, } from './extent/y-extent-component';
13
+ import { PaneHitTestController } from './pane-hit-test.controller';
14
+ import { PaneComponent } from './pane.component';
15
+ import { flatMap } from '../../utils/array.utils';
16
+ export class PaneManager extends ChartBaseElement {
17
+ /**
18
+ * Returns order of panes in the chart from top to bottom.
19
+ */
20
+ get panesOrder() {
21
+ return this.canvasBoundsContainer.panesOrder;
22
+ }
23
+ constructor(chartBaseModel, dynamicObjectsCanvasModel, userInputListenerComponents, eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, cursorHandler, crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel) {
24
+ super();
25
+ this.chartBaseModel = chartBaseModel;
26
+ this.dynamicObjectsCanvasModel = dynamicObjectsCanvasModel;
27
+ this.userInputListenerComponents = userInputListenerComponents;
28
+ this.eventBus = eventBus;
29
+ this.mainScale = mainScale;
30
+ this.canvasBoundsContainer = canvasBoundsContainer;
31
+ this.config = config;
32
+ this.canvasAnimation = canvasAnimation;
33
+ this.canvasInputListener = canvasInputListener;
34
+ this.drawingManager = drawingManager;
35
+ this.cursorHandler = cursorHandler;
36
+ this.crossEventProducer = crossEventProducer;
37
+ this.chartPanComponent = chartPanComponent;
38
+ this.mainCanvasModel = mainCanvasModel;
39
+ this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
40
+ this.panes = {};
41
+ this.paneRemovedSubject = new Subject();
42
+ this.paneAddedSubject = new Subject();
43
+ this.dataSeriesAddedSubject = new Subject();
44
+ this.dataSeriesRemovedSubject = new Subject();
45
+ this.hitTestController = new PaneHitTestController(this.panes, this.dynamicObjectsCanvasModel);
46
+ const mainPane = this.createPane(CHART_UUID, {
47
+ useDefaultHighLow: false,
48
+ scale: this.mainScale,
49
+ });
50
+ mainPane.mainExtent.scale.autoScaleModel.setHighLowProvider('series', createDefaultYExtentHighLowProvider(mainPane.mainExtent));
51
+ mainScale.autoScaleModel.setHighLowPostProcessor('offsets', createHighLowOffsetCalculator(() => this.mainScale.getOffsets()));
52
+ }
53
+ addBounds(uuid, order) {
54
+ this.canvasBoundsContainer.addPaneBounds(uuid, order);
55
+ return () => this.canvasBoundsContainer.removedPaneBounds(uuid);
56
+ }
57
+ /**
58
+ * Adds a resizer to the canvas bounds container for the given uuid.
59
+ * @param {string} uuid - The uuid of the pane to which the resizer is to be added.
60
+ * @returns {BarResizerComponent} - The BarResizerComponent instance that was added to the userInputListenerComponents array.
61
+ */
62
+ addResizer(uuid) {
63
+ const resizerHT = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_RESIZER(uuid), {
64
+ extensionY: this.config.components.paneResizer.dragZone,
65
+ });
66
+ const dragTick = () => {
67
+ this.canvasBoundsContainer.resizePaneVertically(uuid, this.canvasInputListener.getCurrentPoint().y);
68
+ this.eventBus.fireDraw([this.mainCanvasModel.canvasId, 'dynamicObjectsCanvas']);
69
+ };
70
+ const resizerId = CanvasElement.PANE_UUID_RESIZER(uuid);
71
+ const barResizerComponent = new BarResizerComponent(resizerId, () => this.canvasBoundsContainer.getBounds(resizerId), resizerHT, dragTick, this.chartPanComponent, this.mainCanvasModel, this.drawingManager, this.canvasInputListener, this.canvasAnimation, this.config, this.canvasBoundsContainer);
72
+ this.userInputListenerComponents.push(barResizerComponent);
73
+ return barResizerComponent;
74
+ }
75
+ get yExtents() {
76
+ return flatMap(Object.values(this.panes), c => c.yExtentComponents);
77
+ }
78
+ /**
79
+ * Returns the pane component that contains the given point.
80
+ * @param {Point} point - The point to check.
81
+ * @returns {PaneComponent | undefined} - The pane component that contains the point or undefined if no pane contains it.
82
+ */
83
+ getPaneIfHit(point) {
84
+ const panes = Object.values(this.panes);
85
+ return panes.find(p => this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID(p.uuid))(point.x, point.y));
86
+ }
87
+ /**
88
+ * Creates sub-plot on the chart with y-axis
89
+ * @param uuid
90
+ * @returns
91
+ */
92
+ createPane(uuid = generateUuid(), options) {
93
+ if (this.panes[uuid] !== undefined) {
94
+ return this.panes[uuid];
95
+ }
96
+ const paneComponent = new PaneComponent(this.chartBaseModel, this.mainCanvasModel, this.yAxisLabelsCanvasModel, this.dynamicObjectsCanvasModel, this.hitTestController, this.config, this.mainScale, this.drawingManager, this.chartPanComponent, this.canvasInputListener, this.canvasAnimation, this.cursorHandler, this.eventBus, this.canvasBoundsContainer, uuid, this.dataSeriesAddedSubject, this.dataSeriesRemovedSubject, options);
97
+ // TODO: is resizer should be added always?
98
+ if (this.config.components.paneResizer.visible) {
99
+ paneComponent.addChildEntity(this.addResizer(uuid));
100
+ }
101
+ paneComponent.addSubscription(this.addBounds(uuid, options === null || options === void 0 ? void 0 : options.order));
102
+ paneComponent.addSubscription(this.addCursors(uuid));
103
+ paneComponent.addSubscription(this.crossEventProducer.subscribeMouseOverHT(uuid, paneComponent.ht));
104
+ this.panes[uuid] = paneComponent;
105
+ paneComponent.activate();
106
+ this.recalculateState();
107
+ paneComponent.mainExtent.scale.autoScale(true);
108
+ this.paneAddedSubject.next(this.panes);
109
+ return paneComponent;
110
+ }
111
+ /**
112
+ * Removes pane from the chart and all related components
113
+ * @param uuid
114
+ */
115
+ removePane(uuid) {
116
+ const pane = this.panes[uuid];
117
+ if (pane !== undefined) {
118
+ this.paneRemovedSubject.next(pane);
119
+ pane.disable();
120
+ pane.yExtentComponents.forEach(yExtentComponent => yExtentComponent.disable());
121
+ delete this.panes[uuid];
122
+ this.recalculateState();
123
+ }
124
+ }
125
+ /**
126
+ * Adds cursors to the chart elements based on the provided uuid and cursor type.
127
+ * @private
128
+ * @param {string} uuid - The unique identifier for the chart element.
129
+ * @param {string} [cursor=this.config.components.chart.cursor] - The type of cursor to be added to the chart element.
130
+ * @returns {void}
131
+ */
132
+ addCursors(uuid, cursor = this.config.components.chart.cursor) {
133
+ const pane = CanvasElement.PANE_UUID(uuid);
134
+ const paneResizer = CanvasElement.PANE_UUID_RESIZER(uuid);
135
+ this.cursorHandler.setCursorForCanvasEl(pane, cursor);
136
+ this.config.components.paneResizer.visible &&
137
+ this.cursorHandler.setCursorForCanvasEl(paneResizer, this.config.components.paneResizer.cursor, this.config.components.paneResizer.dragZone);
138
+ return () => {
139
+ this.cursorHandler.removeCursorForCanvasEl(pane);
140
+ this.config.components.paneResizer.visible && this.cursorHandler.removeCursorForCanvasEl(paneResizer);
141
+ };
142
+ }
143
+ /**
144
+ * Recalculates the zoom Y of all pane components and fires a draw event on the event bus.
145
+ * @function
146
+ * @name recalculateState
147
+ * @memberof PaneManager
148
+ * @returns {void}
149
+ */
150
+ recalculateState() {
151
+ Object.values(this.panes).forEach(state => state.scale.recalculateZoomY());
152
+ this.eventBus.fireDraw([this.mainCanvasModel.canvasId, 'dynamicObjectsCanvas']);
153
+ }
154
+ }
@@ -3,62 +3,56 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
+ import { Subject } from 'rxjs';
6
7
  import { CanvasAnimation } from '../../animation/canvas-animation';
7
8
  import { CanvasBoundsContainer, HitBoundsTest } from '../../canvas/canvas-bounds-container';
8
9
  import { CursorHandler } from '../../canvas/cursor.handler';
9
- import { ChartConfigComponentsYAxis, FullChartConfig } from '../../chart.config';
10
+ import { FullChartConfig } from '../../chart.config';
10
11
  import { DrawingManager } from '../../drawers/drawing-manager';
11
12
  import EventBus from '../../events/event-bus';
12
13
  import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component';
13
14
  import { Bounds } from '../../model/bounds.model';
14
15
  import { CanvasModel } from '../../model/canvas.model';
15
- import { ChartBaseElement, ChartEntity } from '../../model/chart-base-element';
16
+ import { ChartBaseElement } from '../../model/chart-base-element';
16
17
  import { DataSeriesModel } from '../../model/data-series.model';
17
18
  import { ScaleModel } from '../../model/scale.model';
18
- import { Unit } from '../../model/scaling/viewport.model';
19
- import { Unsubscriber } from '../../utils/function.utils';
19
+ import { Pixel, Price, Unit } from '../../model/scaling/viewport.model';
20
20
  import { AtLeastOne } from '../../utils/object.utils';
21
21
  import { ChartBaseModel } from '../chart/chart-base.model';
22
22
  import { PriceAxisType } from '../labels_generator/numeric-axis-labels.generator';
23
23
  import { ChartPanComponent } from '../pan/chart-pan.component';
24
- import { NumericYAxisLabelsGenerator } from '../y_axis/numeric-y-axis-labels.generator';
25
- import { YAxisScaleHandler } from '../y_axis/y-axis-scale.handler';
26
- import { YAxisDrawer } from '../y_axis/y-axis.drawer';
24
+ import { YAxisComponent } from '../y_axis/y-axis.component';
27
25
  import { YExtentComponent, YExtentCreationOptions } from './extent/y-extent-component';
28
26
  import { PaneHitTestController } from './pane-hit-test.controller';
29
- export interface ExtentYAxis {
30
- labelsGenerator: NumericYAxisLabelsGenerator;
31
- drawer: YAxisDrawer;
32
- yAxisScaleHandler: YAxisScaleHandler;
33
- state: ChartConfigComponentsYAxis;
34
- unsub: Unsubscriber;
35
- }
36
27
  export declare class PaneComponent extends ChartBaseElement {
37
28
  chartBaseModel: ChartBaseModel<'candle'>;
29
+ private mainCanvasModel;
30
+ private yAxisLabelsCanvasModel;
31
+ readonly dynamicObjectsCanvasModel: CanvasModel;
38
32
  private hitTestController;
39
33
  private config;
40
- private mainScaleModel;
34
+ private mainScale;
41
35
  private drawingManager;
42
36
  private chartPanComponent;
43
- private mainCanvasModel;
44
37
  private canvasInputListener;
45
- private userInputListenerComponents;
46
38
  private canvasAnimation;
47
39
  private cursorHandler;
48
40
  eventBus: EventBus;
49
41
  private canvasBoundsContainer;
50
42
  readonly uuid: string;
51
- readonly dataSeriesCanvasModel: CanvasModel;
43
+ seriesAddedSubject: Subject<DataSeriesModel>;
44
+ seriesRemovedSubject: Subject<DataSeriesModel>;
52
45
  private _paneOrder;
53
46
  /**
54
47
  * Pane hit test (without Y-Axis and resizer)
55
48
  */
56
49
  ht: HitBoundsTest;
57
50
  yExtentComponents: YExtentComponent[];
58
- get scaleModel(): ScaleModel;
51
+ get scale(): ScaleModel;
52
+ get yAxis(): YAxisComponent;
59
53
  get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
60
- mainYExtentComponent: YExtentComponent;
61
- constructor(chartBaseModel: ChartBaseModel<'candle'>, hitTestController: PaneHitTestController, config: FullChartConfig, mainScaleModel: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, canvasInputListener: CanvasInputListenerComponent, userInputListenerComponents: ChartEntity[], canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, dataSeriesCanvasModel: CanvasModel, options?: AtLeastOne<YExtentCreationOptions>);
54
+ mainExtent: YExtentComponent;
55
+ constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, options?: AtLeastOne<YExtentCreationOptions>);
62
56
  /**
63
57
  * Method that activates the canvas bounds container and recalculates the zoom Y of the scale model.
64
58
  * @protected
@@ -66,17 +60,7 @@ export declare class PaneComponent extends ChartBaseElement {
66
60
  * @returns {void}
67
61
  */
68
62
  protected doActivate(): void;
69
- /**
70
- * Creates a Y-axis component for the chart.
71
- * @private
72
- * @param {string} uuid - The unique identifier of the chart pane.
73
- * @param {ScaleModel} scaleModel - The scale model for the chart.
74
- * @param {(value: number) => string} formatter - The function to format the Y-axis labels.
75
- * @param {Unsubscriber[]} subs - The array of unsubscriber functions.
76
- * @param {number | null} increment - The increment value for the Y-axis labels.
77
- * @returns {[NumericYAxisLabelsGenerator, YAxisDrawer, YAxisScaleHandler]} - An array containing the Y-axis labels generator, Y-axis drawer, and Y-axis scale handler.
78
- */
79
- private createYAxisComponent;
63
+ toY(price: Price): Pixel;
80
64
  /**
81
65
  * Creates a new GridComponent instance with the provided parameters.
82
66
  * @param {string} uuid - The unique identifier of the pane.