@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,281 @@
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{distinctUntilChanged as E}from"rxjs/operators";import{areBoundsChanged as B,CanvasElement as d}from"../../canvas/canvas-bounds-container";import{ChartBaseElement as A}from"../../model/chart-base-element";import{defaultValueFormatter as Y}from"../../model/data-series.model";import{SyncedByXScaleModel as w}from"../../model/scale.model";import{firstOf as D,flatMap as y,lastOf as P}from"../../utils/array.utils";import{cloneUnsafe as _}from"../../utils/object.utils";import{createCandlesOffsetProvider as S}from"../chart/data-series.high-low-provider";import{GridComponent as b}from"../grid/grid.component";import{NumericYAxisLabelsGenerator as U}from"../y_axis/numeric-y-axis-labels.generator";import{YAxisScaleHandler as M}from"../y_axis/y-axis-scale.handler";import{YAxisDrawer as H}from"../y_axis/y-axis.drawer";import{createDefaultYExtentHighLowProvider as I,YExtentComponent as N}from"./extent/y-extent-component";import{YAxisBaseLabelsModel as L}from"../y_axis/y-axis-base-labels.model";export class PaneComponent extends A{get scaleModel(){return this.mainYExtentComponent.scaleModel}get dataSeries(){return y(this.yExtentComponents,t=>Array.from(t.dataSeries))}constructor(t,e,n,u,m,a,r,i,l,o,h,c,v,s,p,C){super(),this.chartBaseModel=t,this.hitTestController=e,this.config=n,this.mainScaleModel=u,this.drawingManager=m,this.chartPanComponent=a,this.mainCanvasModel=r,this.canvasInputListener=i,this.userInputListenerComponents=l,this.canvasAnimation=o,this.cursorHandler=h,this.eventBus=c,this.canvasBoundsContainer=v,this.uuid=s,this.dataSeriesCanvasModel=p,this._paneOrder=0,this.yExtentComponents=[],this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(d.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(x,f)=>this.mainYExtentComponent.valueFormatter(x,f);const g=this.createExtentComponent(C);this.mainYExtentComponent=g,this.ht=this.canvasBoundsContainer.getBoundsHitTest(d.PANE_UUID(s),{extensionY:-this.config.components.paneResizer.dragZone})}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(d.PANE_UUID(this.uuid)).pipe(E(B)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scaleModel.recalculateZoomY()),this.dataSeriesCanvasModel.fireDraw()}))}createYAxisComponent(t,e,n,u,m){const a=_(this.config.components.yAxis),r=new U(m,void 0,n,u,()=>"regular",()=>1,a.labelHeight),i=d.PANE_UUID_Y_AXIS(t,e),l=new H(this.config,a,this.mainCanvasModel,()=>r.generateNumericLabels(),()=>this.canvasBoundsContainer.getBounds(i),()=>this.config.components.yAxis.visible,n.toY.bind(n));this.drawingManager.addDrawerAfter(l,i,"Y_AXIS"),a.type="regular";const o=new M(this.eventBus,a,this.chartPanComponent,n,this.canvasInputListener,this.canvasBoundsContainer,this.canvasBoundsContainer.getBoundsHitTest(i),c=>n.autoScale(c)),h=new L(n,r,this.canvasBoundsContainer);return h.activate(),this.userInputListenerComponents.push(o),{labelsGenerator:r,drawer:l,yAxisScaleHandler:o,state:this.config.components.yAxis,unsub:()=>{this.drawingManager.removeDrawerByName(i),h.disable()}}}createGridComponent(t,e,n){return new b(this.mainCanvasModel,e,this.config,`PANE_${t}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(d.PANE_UUID(t)),()=>this.canvasBoundsContainer.getBounds(d.PANE_UUID(t)),()=>[],()=>n.generateNumericLabels())}createYPanHandler(t,e){const n=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(d.PANE_UUID(t)));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(n),n.disable()},n]}addCursors(t){const e=d.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(e,this.config.components.yAxis.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(e)}createExtentComponent(t){var e,n,u,m,a,r;const i=this.yExtentComponents.length,l=()=>this.canvasBoundsContainer.getBounds(d.PANE_UUID(this.uuid)),o=(e=t==null?void 0:t.scaleModel)!==null&&e!==void 0?e:new w(this.mainScaleModel,this.config,l,this.canvasAnimation),h=!((n=t==null?void 0:t.useDefaultYAxis)!==null&&n!==void 0)||n?this.createYAxisComponent(this.uuid,i,o,(m=(u=t==null?void 0:t.paneFormatters)===null||u===void 0?void 0:u.regular)!==null&&m!==void 0?m:Y,(a=t==null?void 0:t.increment)!==null&&a!==void 0?a:null):void 0,[c,v]=this.createYPanHandler(this.uuid,o),s=new N(this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dataSeriesCanvasModel,o,h,v);if(s.addSubscription(c),s.addSubscription(this.addCursors(i)),t!=null&&t.paneFormatters&&s.setValueFormatters(t.paneFormatters),((r=t==null?void 0:t.useDefaultHighLow)!==null&&r!==void 0?r:!0)&&o.autoScaleModel.setHighLowProvider("default",S(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),I(s))),h){const C=this.createGridComponent(this.uuid,o,h.labelsGenerator);s.addChildEntity(C)}return s.activate(),this.yExtentComponents.push(s),this.canvasBoundsContainer.updateYAxisWidths(),s}removeExtentComponent(t){t.disable(),this.yExtentComponents.splice(t.idx,1),this.yExtentComponents.forEach((e,n)=>e.idx=n),this.canvasBoundsContainer.updateYAxisWidths()}updateView(){this.yExtentComponents.forEach(t=>{var e;t.scaleModel.doAutoScale(),(e=t.yAxisComponent)===null||e===void 0||e.labelsGenerator.generateNumericLabels()}),this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}mergeYExtents(){for(let t=1;t<this.yExtentComponents.length;t++){const e=this.yExtentComponents[t];e.dataSeries.forEach(n=>n.moveToExtent(this.mainYExtentComponent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainYExtentComponent]}getBounds(){return this.mainYExtentComponent.getBounds()}hide(){this._paneOrder=this.canvasBoundsContainer.panesOrder.indexOf(this.uuid),this.canvasBoundsContainer.removedPaneBounds(this.uuid),this.eventBus.fireDraw()}show(){this.canvasBoundsContainer.addPaneBounds(this.uuid,this._paneOrder),this.eventBus.fireDraw()}createDataSeries(){var t;return(t=this.mainYExtentComponent)===null||t===void 0?void 0:t.createDataSeries()}addDataSeries(t){this.mainYExtentComponent.addDataSeries(t),this.updateView()}removeDataSeries(t){this.mainYExtentComponent.removeDataSeries(t),this.updateView()}getAxisType(){return"regular"}moveUp(){this.canvasBoundsContainer.movePaneUp(this.uuid)}moveDown(){this.canvasBoundsContainer.movePaneDown(this.uuid)}canMoveUp(){const t=D(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}canMoveDown(){const t=P(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}get regularFormatter(){return this.mainYExtentComponent.formatters.regular}setPaneValueFormatters(t){this.mainYExtentComponent.setValueFormatters(t)}regularValueFromY(t){return this.mainYExtentComponent.regularValueFromY(t)}}
6
+ import { distinctUntilChanged } from 'rxjs/operators';
7
+ import { areBoundsChanged, CanvasElement, } from '../../canvas/canvas-bounds-container';
8
+ import { ChartBaseElement } from '../../model/chart-base-element';
9
+ import { SyncedByXScaleModel } from '../../model/scale.model';
10
+ import { firstOf, flatMap, lastOf } from '../../utils/array.utils';
11
+ import { createCandlesOffsetProvider } from '../chart/data-series.high-low-provider';
12
+ import { GridComponent } from '../grid/grid.component';
13
+ import { YAxisComponent } from '../y_axis/y-axis.component';
14
+ import { createDefaultYExtentHighLowProvider, YExtentComponent, } from './extent/y-extent-component';
15
+ export class PaneComponent extends ChartBaseElement {
16
+ get scale() {
17
+ return this.mainExtent.scale;
18
+ }
19
+ get yAxis() {
20
+ return this.mainExtent.yAxis;
21
+ }
22
+ get dataSeries() {
23
+ return flatMap(this.yExtentComponents, c => Array.from(c.dataSeries));
24
+ }
25
+ constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, options) {
26
+ super();
27
+ this.chartBaseModel = chartBaseModel;
28
+ this.mainCanvasModel = mainCanvasModel;
29
+ this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
30
+ this.dynamicObjectsCanvasModel = dynamicObjectsCanvasModel;
31
+ this.hitTestController = hitTestController;
32
+ this.config = config;
33
+ this.mainScale = mainScale;
34
+ this.drawingManager = drawingManager;
35
+ this.chartPanComponent = chartPanComponent;
36
+ this.canvasInputListener = canvasInputListener;
37
+ this.canvasAnimation = canvasAnimation;
38
+ this.cursorHandler = cursorHandler;
39
+ this.eventBus = eventBus;
40
+ this.canvasBoundsContainer = canvasBoundsContainer;
41
+ this.uuid = uuid;
42
+ this.seriesAddedSubject = seriesAddedSubject;
43
+ this.seriesRemovedSubject = seriesRemovedSubject;
44
+ this._paneOrder = 0;
45
+ this.yExtentComponents = [];
46
+ this.getYAxisBounds = () => {
47
+ return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.uuid));
48
+ };
49
+ this.valueFormatter = (value, dataSeries) => {
50
+ return this.mainExtent.valueFormatter(value, dataSeries);
51
+ };
52
+ const yExtentComponent = this.createExtentComponent(options);
53
+ this.mainExtent = yExtentComponent;
54
+ this.ht = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID(uuid), {
55
+ // this is needed to reduce cross event fire zone, so cross event won't be fired when hover resizer
56
+ // maybe we need to rework it, this isn't perfect - top and bottom panes will have small no-hover area
57
+ extensionY: -this.config.components.paneResizer.dragZone,
58
+ });
59
+ }
60
+ /**
61
+ * Method that activates the canvas bounds container and recalculates the zoom Y of the scale model.
62
+ * @protected
63
+ * @function
64
+ * @returns {void}
65
+ */
66
+ doActivate() {
67
+ super.doActivate();
68
+ this.addRxSubscription(this.canvasBoundsContainer
69
+ .observeBoundsChanged(CanvasElement.PANE_UUID(this.uuid))
70
+ .pipe(distinctUntilChanged(areBoundsChanged))
71
+ .subscribe(() => {
72
+ this.yExtentComponents.forEach(c => c.scale.recalculateZoomY());
73
+ this.dynamicObjectsCanvasModel.fireDraw();
74
+ }));
75
+ }
76
+ toY(price) {
77
+ var _a, _b;
78
+ return (_b = (_a = this.mainExtent.mainDataSeries) === null || _a === void 0 ? void 0 : _a.view.toY(price)) !== null && _b !== void 0 ? _b : this.scale.toY(price);
79
+ }
80
+ /**
81
+ * Creates a new GridComponent instance with the provided parameters.
82
+ * @param {string} uuid - The unique identifier of the pane.
83
+ * @param {ScaleModel} scaleModel - The scale model used to calculate the scale of the grid.
84
+ * @param {NumericYAxisLabelsGenerator} yAxisLabelsGenerator - The generator used to create the labels for the y-axis.
85
+ * @returns {GridComponent} - The newly created GridComponent instance.
86
+ */
87
+ createGridComponent(uuid, scale, yAxisLabelsGenerator, yAxisState) {
88
+ const gridComponent = new GridComponent(this.mainCanvasModel, scale, this.config, yAxisState, `PANE_${uuid}_grid_drawer`, this.drawingManager, () => this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(uuid)), () => this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(uuid)), () => [], () => yAxisLabelsGenerator.generateNumericLabels());
89
+ return gridComponent;
90
+ }
91
+ /**
92
+ * Creates a handler for Y-axis panning of the chart.
93
+ * @private
94
+ * @param {string} uuid - The unique identifier of the chart pane.
95
+ * @param {ScaleModel} scaleModel - The scale model of the chart.
96
+ * @returns {Unsubscriber}
97
+ */
98
+ createYPanHandler(uuid, scale) {
99
+ const dragNDropComponent = this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(scale, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID(uuid)));
100
+ return [
101
+ () => {
102
+ this.chartPanComponent.chartAreaPanHandler.removeChildEntity(dragNDropComponent);
103
+ dragNDropComponent.disable();
104
+ },
105
+ dragNDropComponent,
106
+ ];
107
+ }
108
+ addCursors(extentIdx, yAxisComponent) {
109
+ const paneYAxis = CanvasElement.PANE_UUID_Y_AXIS(this.uuid, extentIdx);
110
+ this.cursorHandler.setCursorForCanvasEl(paneYAxis, yAxisComponent.state.cursor);
111
+ return () => this.cursorHandler.removeCursorForCanvasEl(paneYAxis);
112
+ }
113
+ createExtentComponent(options) {
114
+ var _a, _b;
115
+ const extentIdx = this.yExtentComponents.length;
116
+ const getBounds = () => this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(this.uuid));
117
+ const scaleModel = (_a = options === null || options === void 0 ? void 0 : options.scale) !== null && _a !== void 0 ? _a : new SyncedByXScaleModel(this.mainScale, this.config, getBounds, this.canvasAnimation);
118
+ const [unsub, dragNDrop] = this.createYPanHandler(this.uuid, scaleModel);
119
+ // creating partially resolved constructor except formatter & dataSeriesProvider - bcs it's not possible to provide formatter
120
+ // before y-extent is created
121
+ const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx);
122
+ const yExtentComponent = new YExtentComponent(this.uuid, extentIdx, this, this.chartBaseModel, this.canvasBoundsContainer, this.hitTestController, this.dynamicObjectsCanvasModel, scaleModel, createYAxisComponent, dragNDrop);
123
+ yExtentComponent.addSubscription(unsub);
124
+ yExtentComponent.addSubscription(this.addCursors(extentIdx, yExtentComponent.yAxis));
125
+ (options === null || options === void 0 ? void 0 : options.paneFormatters) && yExtentComponent.setValueFormatters(options.paneFormatters);
126
+ const useDefaultHighLow = (_b = options === null || options === void 0 ? void 0 : options.useDefaultHighLow) !== null && _b !== void 0 ? _b : true;
127
+ if (useDefaultHighLow) {
128
+ scaleModel.autoScaleModel.setHighLowProvider('default', createCandlesOffsetProvider(() => ({ top: 10, bottom: 10, left: 0, right: 0, visible: true }), createDefaultYExtentHighLowProvider(yExtentComponent)));
129
+ }
130
+ const gridComponent = this.createGridComponent(this.uuid, scaleModel, yExtentComponent.yAxis.model.labelsGenerator, yExtentComponent.yAxis.state);
131
+ yExtentComponent.addChildEntity(gridComponent);
132
+ yExtentComponent.activate();
133
+ this.yExtentComponents.push(yExtentComponent);
134
+ this.canvasBoundsContainer.updateYAxisWidths();
135
+ return yExtentComponent;
136
+ }
137
+ removeExtentComponent(extentComponent) {
138
+ extentComponent.disable();
139
+ this.yExtentComponents.splice(extentComponent.idx, 1);
140
+ // re-index extents
141
+ this.yExtentComponents.forEach((c, idx) => (c.idx = idx));
142
+ this.canvasBoundsContainer.updateYAxisWidths();
143
+ }
144
+ /**
145
+ * This method updates the view by calling the doAutoScale method of the scaleModel and firing the Draw event using the eventBus.
146
+ * @private
147
+ */
148
+ updateView() {
149
+ this.yExtentComponents.forEach(c => {
150
+ c.scale.doAutoScale();
151
+ c.yAxis.model.labelsGenerator.generateNumericLabels();
152
+ });
153
+ this.canvasBoundsContainer.updateYAxisWidths();
154
+ this.eventBus.fireDraw();
155
+ }
156
+ /**
157
+ * Merges all the y-axis extents on the pane into one.
158
+ */
159
+ mergeYExtents() {
160
+ for (let i = 1; i < this.yExtentComponents.length; i++) {
161
+ const extent = this.yExtentComponents[i];
162
+ extent.dataSeries.forEach(s => s.moveToExtent(this.mainExtent));
163
+ extent.disable();
164
+ }
165
+ this.canvasBoundsContainer.updateYAxisWidths();
166
+ this.yExtentComponents = [this.mainExtent];
167
+ }
168
+ /**
169
+ * Returns the bounds of the pane component.
170
+ */
171
+ getBounds() {
172
+ return this.mainExtent.getBounds();
173
+ }
174
+ /**
175
+ * Hides the pane by removing its bounds from the canvasBoundsContainer and firing a draw event.
176
+ * @function
177
+ * @name hide
178
+ * @memberof PaneComponent
179
+ * @returns {void}
180
+ */
181
+ hide() {
182
+ this._paneOrder = this.canvasBoundsContainer.panesOrder.indexOf(this.uuid);
183
+ this.canvasBoundsContainer.removedPaneBounds(this.uuid);
184
+ this.eventBus.fireDraw();
185
+ }
186
+ /**
187
+ * Adds the bounds of the pane to the canvas bounds container and fires a draw event.
188
+ * @function
189
+ * @name show
190
+ * @memberof PaneComponent
191
+ * @returns {void}
192
+ */
193
+ show() {
194
+ this.canvasBoundsContainer.addPaneBounds(this.uuid, this._paneOrder);
195
+ this.eventBus.fireDraw();
196
+ }
197
+ /**
198
+ * Creates a new DataSeriesModel object.
199
+ * @returns {DataSeriesModel} - The newly created DataSeriesModel object.
200
+ */
201
+ createDataSeries() {
202
+ var _a;
203
+ return (_a = this.mainExtent) === null || _a === void 0 ? void 0 : _a.createDataSeries();
204
+ }
205
+ /**
206
+ * Adds a new data series to the chart.
207
+ * @param {DataSeriesModel} series - The data series to be added.
208
+ * @returns {void}
209
+ */
210
+ addDataSeries(series) {
211
+ this.mainExtent.addDataSeries(series);
212
+ this.updateView();
213
+ }
214
+ /**
215
+ * Removes a data series from the chart.
216
+ *
217
+ * @param {DataSeriesModel} series - The data series to be removed.
218
+ * @returns {void}
219
+ */
220
+ removeDataSeries(series) {
221
+ this.mainExtent.removeDataSeries(series);
222
+ this.updateView();
223
+ }
224
+ // TODO hack, remove when each pane will have separate y-axis component
225
+ /**
226
+ * Returns the type of the y-axis component for the current pane.
227
+ *
228
+ * @returns {PriceAxisType} The 'regular' type of the y-axis component for the current pane.
229
+ *
230
+ */
231
+ getAxisType() {
232
+ return 'regular';
233
+ }
234
+ /**
235
+ * Moves the canvas bounds container up by calling the movePaneUp method with the uuid of the current object.
236
+ * @returns {void}
237
+ */
238
+ moveUp() {
239
+ this.canvasBoundsContainer.movePaneUp(this.uuid);
240
+ }
241
+ /**
242
+ * Moves the canvas bounds container down by calling the movePaneDown method with the uuid of the current object.
243
+ * @returns {void}
244
+ */
245
+ moveDown() {
246
+ this.canvasBoundsContainer.movePaneDown(this.uuid);
247
+ }
248
+ /**
249
+ * Checks if the current pane can move up.
250
+ * @returns {boolean} - Returns true if the current pane can move up, otherwise false.
251
+ */
252
+ canMoveUp() {
253
+ const firstPane = firstOf(this.canvasBoundsContainer.panesOrder);
254
+ return this.uuid !== firstPane;
255
+ }
256
+ /**
257
+ * Checks if the current pane can move down.
258
+ *
259
+ * @returns {boolean} - Returns true if the current pane is not the last one in the canvasBoundsContainer, otherwise returns false.
260
+ */
261
+ canMoveDown() {
262
+ const lastPane = lastOf(this.canvasBoundsContainer.panesOrder);
263
+ return this.uuid !== lastPane;
264
+ }
265
+ get regularFormatter() {
266
+ return this.mainExtent.formatters.regular;
267
+ }
268
+ /**
269
+ * Sets the pane value formatters for the current instance.
270
+ * @param {YExtentFormatters} formatters - The pane value formatters to be set.
271
+ */
272
+ setPaneValueFormatters(formatters) {
273
+ this.mainExtent.setValueFormatters(formatters);
274
+ }
275
+ /**
276
+ * Returns the regular value from Y coordinate.
277
+ * @param {number} y - The Y coordinate.
278
+ * @returns {number} - The regular value.
279
+ */
280
+ regularValueFromY(y) {
281
+ return this.mainExtent.regularValueFromY(y);
282
+ }
283
+ }
@@ -3,4 +3,142 @@
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{distinctUntilChanged as f,skip as u,startWith as C}from"rxjs/operators";import{DynamicDrawerType as s}from"../../drawers/drawing-manager";import{ChartBaseElement as b}from"../../model/chart-base-element";import{DragNDropYComponent as D}from"../dran-n-drop_helper/drag-n-drop-y.component";import{BarResizerDrawer as A}from"./bar-resizer.drawer";export class BarResizerComponent extends b{constructor(t,i,n,a,o,e,r,h,d,c,m){super(),this.id=t,this.boundsProvider=i,this.hitTest=n,this.dragTickCb=a,this.chartPanComponent=o,this.canvasModel=e,this.drawingManager=r,this.canvasInputListener=h,this.canvasAnimation=d,this.config=c,this.canvasBoundsContainer=m,this.initialY=0,this.resizeEvent$=new v,this.onYDragStart=()=>{this.config.components.crossTool.type="none",this.initialY=this.boundsProvider().y},this.onYDragEnd=()=>{this.config.components.crossTool.type="cross-and-labels",this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio)},this.onYDragTick=g=>{const{delta:p,draggedPixels:l}=g;Math.abs(this.initialY-this.boundsProvider().y+l)>=0&&(this.dragTickCb(p),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const n=new D(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent);this.addChildEntity(n),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(C(!1),f(),u(1)).subscribe(a=>{a?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const i=new A(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(i,s.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(s.paneResizer(this.id)))}doDeactivate(){super.doDeactivate(),this.resizeEvent$.complete()}handleHoverAnimation(t){let i;this.config.animation.paneResizer.bgMode?(i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),(!i||!i.animationInProgress)&&this.canvasAnimation.startColorAlphaAnimation(this.animationId,[{color:this.config.colors.paneResizer.bgHoverColor,type:t}])):(i=this.canvasAnimation.getColorTransitionAnimation(this.animationId),(!i||!i.animationInProgress)&&this.canvasAnimation.startColorTransitionAnimation(this.animationId,[{startColor:this.config.colors.paneResizer.bgColor,endColor:this.config.colors.paneResizer.bgHoverColor,type:t}],this.config.animation.paneResizer.duration)),i&&i.animationInProgress&&i.revert()}}
6
+ import { Subject } from 'rxjs';
7
+ import { distinctUntilChanged, skip, startWith } from 'rxjs/operators';
8
+ import { DynamicDrawerType } from '../../drawers/drawing-manager';
9
+ import { ChartBaseElement } from '../../model/chart-base-element';
10
+ import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
11
+ import { BarResizerDrawer } from './bar-resizer.drawer';
12
+ /**
13
+ * Bar separator between panes.
14
+ * Used to resize the areas height or just draw a fixed line.
15
+ * Supports hover animation.
16
+ *
17
+ * @doc-tags chart-core,resizer
18
+ */
19
+ export class BarResizerComponent extends ChartBaseElement {
20
+ constructor(id, boundsProvider, hitTest, dragTickCb, chartPanComponent, canvasModel, drawingManager, canvasInputListener, canvasAnimation, config, canvasBoundsContainer) {
21
+ super();
22
+ this.id = id;
23
+ this.boundsProvider = boundsProvider;
24
+ this.hitTest = hitTest;
25
+ this.dragTickCb = dragTickCb;
26
+ this.chartPanComponent = chartPanComponent;
27
+ this.canvasModel = canvasModel;
28
+ this.drawingManager = drawingManager;
29
+ this.canvasInputListener = canvasInputListener;
30
+ this.canvasAnimation = canvasAnimation;
31
+ this.config = config;
32
+ this.canvasBoundsContainer = canvasBoundsContainer;
33
+ this.initialY = 0;
34
+ this.resizeEvent$ = new Subject();
35
+ this.onYDragStart = () => {
36
+ this.config.components.crossTool.type = 'none';
37
+ this.initialY = this.boundsProvider().y;
38
+ };
39
+ this.onYDragEnd = () => {
40
+ this.config.components.crossTool.type = 'cross-and-labels';
41
+ this.initialY = this.boundsProvider().y;
42
+ this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio);
43
+ };
44
+ this.onYDragTick = (dragInfo) => {
45
+ const { delta: yDelta, draggedPixels } = dragInfo;
46
+ // in case cursor moves outside the bar - do not generate "tick"
47
+ if (Math.abs(this.initialY - this.boundsProvider().y + draggedPixels) >= 0) {
48
+ this.dragTickCb(yDelta);
49
+ this.resizeEvent$.next();
50
+ }
51
+ };
52
+ this.animationId = `${this.id}_RESIZER`;
53
+ }
54
+ /**
55
+ * This method activates the pane resizer component.
56
+ * It calls the parent class's doActivate method and then checks if the fixedMode property is set to false in the config object.
57
+ * If it is false, it creates a new DragNDropYComponent and adds it to the component list.
58
+ * It also adds a subscription to the canvasInputListener to observe mouse enter events and
59
+ * handle hover animations if the animation is enabled in the config object.
60
+ * Finally, it creates a new BarResizerDrawer and adds it to the drawing manager as a DynamicDrawerType.paneResizer with the current id.
61
+ * It also adds a subscription to remove the drawer when the component is deactivated.
62
+ * @protected
63
+ * @returns {void}
64
+ */
65
+ doActivate() {
66
+ super.doActivate();
67
+ const fixedMode = this.config.components.paneResizer.fixedMode;
68
+ if (!fixedMode) {
69
+ const dragNDropYComponent = new DragNDropYComponent(this.hitTest, {
70
+ onDragTick: this.onYDragTick,
71
+ onDragStart: this.onYDragStart,
72
+ onDragEnd: this.onYDragEnd,
73
+ }, this.canvasInputListener, this.chartPanComponent);
74
+ this.addChildEntity(dragNDropYComponent);
75
+ if (this.config.animation.paneResizer.enabled) {
76
+ this.addRxSubscription(this.canvasInputListener
77
+ .observeMouseEnter(this.hitTest, true)
78
+ .pipe(
79
+ // set initial pipe state to false, so animation will play for the first time only for appearing
80
+ startWith(false), distinctUntilChanged(), skip(1))
81
+ .subscribe(enter => {
82
+ if (enter) {
83
+ this.handleHoverAnimation('appearing');
84
+ }
85
+ else {
86
+ this.handleHoverAnimation('fading');
87
+ }
88
+ }));
89
+ }
90
+ }
91
+ const barResizerDrawer = new BarResizerDrawer(this.config, this.boundsProvider, this.canvasModel, this.canvasAnimation, this.animationId);
92
+ this.drawingManager.addDrawer(barResizerDrawer, DynamicDrawerType.paneResizer(this.id));
93
+ this.addSubscription(() => this.drawingManager.removeDrawerByName(DynamicDrawerType.paneResizer(this.id)));
94
+ }
95
+ /**
96
+ * This method is called when the component is being deactivated.
97
+ * It calls the parent method doDeactivate() and then completes the resizeEvent$ observable.
98
+ * @protected
99
+ * @returns {void}
100
+ */
101
+ doDeactivate() {
102
+ super.doDeactivate();
103
+ this.resizeEvent$.complete();
104
+ }
105
+ /**
106
+ * This function handles the hover animation of a pane resizer. It takes a type parameter which can be either 'fading' or 'appearing'.
107
+ * If the background mode is enabled, it gets the color alpha animation from the canvasAnimation and starts the color alpha animation
108
+ * with the given animationId and the color and type provided in the parameter. If the background mode is not enabled, it gets the color transition
109
+ * animation from the canvasAnimation and starts the color transition animation with the given animationId, startColor, endColor and type
110
+ * provided in the parameter and the duration from the config. If there is an animation in progress, it reverts it.
111
+ *
112
+ * @param {string} type - The type of animation, can be either 'fading' or 'appearing'.
113
+ * @returns {void}
114
+ */
115
+ handleHoverAnimation(type) {
116
+ let animation;
117
+ if (this.config.animation.paneResizer.bgMode) {
118
+ animation = this.canvasAnimation.getColorAlphaAnimation(this.animationId);
119
+ if (!animation || !animation.animationInProgress) {
120
+ this.canvasAnimation.startColorAlphaAnimation(this.animationId, [
121
+ {
122
+ color: this.config.colors.paneResizer.bgHoverColor,
123
+ type,
124
+ },
125
+ ]);
126
+ }
127
+ }
128
+ else {
129
+ animation = this.canvasAnimation.getColorTransitionAnimation(this.animationId);
130
+ if (!animation || !animation.animationInProgress) {
131
+ this.canvasAnimation.startColorTransitionAnimation(this.animationId, [
132
+ {
133
+ startColor: this.config.colors.paneResizer.bgColor,
134
+ endColor: this.config.colors.paneResizer.bgHoverColor,
135
+ type,
136
+ },
137
+ ], this.config.animation.paneResizer.duration);
138
+ }
139
+ }
140
+ if (animation && animation.animationInProgress) {
141
+ animation.revert();
142
+ }
143
+ }
144
+ }
@@ -3,4 +3,49 @@
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
- export class BarResizerDrawer{constructor(o,i,e,n,t){this.config=o,this.boundsProvider=i,this.canvasModel=e,this.canvasAnimation=n,this.animationId=t}draw(){if(this.config.components.paneResizer.visible){const o=this.config.components.paneResizer.fixedMode,i=this.boundsProvider(),e=this.canvasModel.ctx,n=this.canvasAnimation.getColorAlphaAnimation(this.animationId),t=this.config.components.paneResizer.dragZone;!o&&n&&(e.fillStyle=n.getColor(0),e.fillRect(i.x,i.y-t,i.width,i.height+2*t)),e.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?e.fillRect(i.x,i.y,i.width,i.height):e.fillRect(i.x,i.y-t,i.width,i.height+2*t)}}getCanvasIds(){return[this.canvasModel.canvasId]}}
6
+ export class BarResizerDrawer {
7
+ constructor(config, boundsProvider, canvasModel, canvasAnimation, animationId) {
8
+ this.config = config;
9
+ this.boundsProvider = boundsProvider;
10
+ this.canvasModel = canvasModel;
11
+ this.canvasAnimation = canvasAnimation;
12
+ this.animationId = animationId;
13
+ }
14
+ /**
15
+ * Draws the pane resizer on the canvas if it is visible.
16
+ * The resizer is drawn with a fixed mode or with an animation.
17
+ * The resizer's position and size are determined by the bounds provider.
18
+ * The yAxisWidth is calculated based on the canvas bounds container.
19
+ * The resizerXOffset and resizerWidthOffset are calculated based on the yAxis alignment.
20
+ * The resizer is filled with a color based on the animation or the config colors.
21
+ * If the bgMode is true, the resizer is filled without the drag zone, otherwise it is filled with the drag zone.
22
+ */
23
+ draw() {
24
+ if (this.config.components.paneResizer.visible) {
25
+ const fixedMode = this.config.components.paneResizer.fixedMode;
26
+ const resizer = this.boundsProvider();
27
+ const ctx = this.canvasModel.ctx;
28
+ const animation = this.canvasAnimation.getColorAlphaAnimation(this.animationId);
29
+ const drag = this.config.components.paneResizer.dragZone;
30
+ if (!fixedMode && animation) {
31
+ ctx.fillStyle = animation.getColor(0);
32
+ ctx.fillRect(resizer.x, resizer.y - drag, resizer.width, resizer.height + 2 * drag);
33
+ }
34
+ ctx.fillStyle = this.config.colors.paneResizer.lineColor;
35
+ if (this.config.animation.paneResizer.bgMode) {
36
+ ctx.fillRect(resizer.x, resizer.y, resizer.width, resizer.height);
37
+ }
38
+ else {
39
+ ctx.fillRect(resizer.x, resizer.y - drag, resizer.width, resizer.height + 2 * drag);
40
+ }
41
+ }
42
+ }
43
+ /**
44
+ * Returns an array of canvas IDs.
45
+ *
46
+ * @returns {Array<string>} An array containing the ID of the canvas model.
47
+ */
48
+ getCanvasIds() {
49
+ return [this.canvasModel.canvasId];
50
+ }
51
+ }
@@ -3,4 +3,51 @@
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{ChartBaseElement as h}from"../../model/chart-base-element";export class SnapshotComponent extends h{constructor(n,a){super(),this.elements=n,this.canvasModel=a}doActivate(){super.doActivate()}createSnapshot(n){const a=this.canvasModel.canvas,e=this.canvasModel.ctx;if(e){e.clearRect(0,0,a.width,a.height);const t=a.width/window.devicePixelRatio,s=a.height/window.devicePixelRatio;return e.drawImage(this.elements.backgroundCanvas,0,0,t,s),e.drawImage(this.elements.mainCanvas,0,0,t,s),e.drawImage(this.elements.staticDrawingCanvas,0,0,t,s),e.drawImage(this.elements.dataSeriesCanvas,0,0,t,s),e.drawImage(this.elements.overDataSeriesCanvas,0,0,t,s),e.drawImage(this.elements.dynamicDrawingCanvas,0,0,t,s),e.drawImage(this.elements.crossToolCanvas,0,0,t,s),n&&n(e),new Promise((o,r)=>this.elements.snapshotCanvas.toBlob(i=>i?o(i):r("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}
6
+ import { ChartBaseElement } from '../../model/chart-base-element';
7
+ /**
8
+ * Snapshot Component.
9
+ * Allows to copy, download and share snapshot
10
+ */
11
+ export class SnapshotComponent extends ChartBaseElement {
12
+ constructor(elements, canvasModel) {
13
+ super();
14
+ this.elements = elements;
15
+ this.canvasModel = canvasModel;
16
+ }
17
+ /**
18
+ * Implements doActivate method.
19
+ * @protected
20
+ * @returns {void}
21
+ */
22
+ doActivate() {
23
+ super.doActivate();
24
+ }
25
+ /**
26
+ * Creates a snapshot of the canvas and returns it as a Promise of Blob object.
27
+ * @param {function} userDrawCallback - Optional callback function that takes a CanvasRenderingContext2D object
28
+ * as a parameter and allows the user to draw on the canvas before taking the snapshot.
29
+ * @returns {Promise<Blob>} - A Promise that resolves with a Blob object representing the snapshot of the canvas.
30
+ * @throws {Error} - If the snapshot isn't supported, an error is thrown.
31
+ */
32
+ createSnapshot(userDrawCallback) {
33
+ const snapshotCanvas = this.canvasModel.canvas;
34
+ const ctx = this.canvasModel.ctx;
35
+ if (ctx) {
36
+ ctx.clearRect(0, 0, snapshotCanvas.width, snapshotCanvas.height);
37
+ const width = snapshotCanvas.width / window.devicePixelRatio;
38
+ const height = snapshotCanvas.height / window.devicePixelRatio;
39
+ ctx.drawImage(this.elements.backgroundCanvas, 0, 0, width, height);
40
+ ctx.drawImage(this.elements.mainCanvas, 0, 0, width, height);
41
+ ctx.drawImage(this.elements.dynamicObjectsCanvas, 0, 0, width, height);
42
+ ctx.drawImage(this.elements.crossToolCanvas, 0, 0, width, height);
43
+ userDrawCallback && userDrawCallback(ctx);
44
+ return new Promise((resolve, fail) => this.elements.snapshotCanvas.toBlob(blob => {
45
+ return blob ? resolve(blob) : fail('Blob is null');
46
+ }));
47
+ }
48
+ else {
49
+ console.error("Snapshot isn't supported");
50
+ return Promise.reject();
51
+ }
52
+ }
53
+ }
@@ -3,27 +3,23 @@
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 { ChartBaseElement } from '../../model/chart-base-element';
7
- import { BarType, FullChartConfig } from '../../chart.config';
8
- import { CanvasModel } from '../../model/canvas.model';
6
+ import { FullChartConfig } from '../../chart.config';
9
7
  import { DrawingManager } from '../../drawers/drawing-manager';
10
- import { ScaleModel } from '../../model/scale.model';
8
+ import { ChartBaseElement } from '../../model/chart-base-element';
11
9
  import { Pixel, Unit } from '../../model/scaling/viewport.model';
12
10
  import { ChartComponent } from '../chart/chart.component';
13
11
  import { PaneManager } from '../pane/pane-manager.component';
14
- import { VolumeColorResolver } from './volumes.component';
12
+ import { PaneComponent } from '../pane/pane.component';
15
13
  import { VolumesModel } from './volumes.model';
16
14
  export declare class SeparateVolumesComponent extends ChartBaseElement {
17
- private canvasModel;
18
15
  private chartComponent;
19
16
  private drawingManager;
20
- private config;
17
+ config: FullChartConfig;
21
18
  private volumesModel;
22
- private readonly volumesColorByChartTypeMap;
23
19
  private paneManager;
24
20
  static UUID: string;
25
- scaleModel: ScaleModel | undefined;
26
- constructor(canvasModel: CanvasModel, chartComponent: ChartComponent, drawingManager: DrawingManager, config: FullChartConfig, volumesModel: VolumesModel, volumesColorByChartTypeMap: Partial<Record<BarType, VolumeColorResolver>>, paneManager: PaneManager);
21
+ pane: PaneComponent | undefined;
22
+ constructor(chartComponent: ChartComponent, drawingManager: DrawingManager, config: FullChartConfig, volumesModel: VolumesModel, paneManager: PaneManager);
27
23
  protected doActivate(): void;
28
24
  /**
29
25
  * Activates the separate volumes feature.
@@ -3,4 +3,66 @@
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{ChartBaseElement as n}from"../../model/chart-base-element";import{createCandlesOffsetProvider as d}from"../chart/data-series.high-low-provider";import{VolumesDrawer as h}from"./volumes.drawer";import{volumeFormatter as u}from"./volumes.formatter";class a extends n{constructor(o,e,t,s,r,i,l){super(),this.canvasModel=o,this.chartComponent=e,this.drawingManager=t,this.config=s,this.volumesModel=r,this.volumesColorByChartTypeMap=i,this.paneManager=l,s.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var o,e;return!(!((o=this.scaleModel)===null||o===void 0)&&o.isViewportValid())&&((e=this.scaleModel)===null||e===void 0?void 0:e.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var o;return(o=this.scaleModel)===null||o===void 0?void 0:o.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.paneComponents[a.UUID]===void 0){const o=this.paneManager.createPane(a.UUID,{paneFormatters:{regular:u},useDefaultHighLow:!1,increment:1}),{scaleModel:e}=o,t=d(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);e.autoScaleModel.setHighLowProvider("volumes",t),e.doAutoScale(!0),this.scaleModel=e;const s=new h(this.canvasModel,this.config,this.volumesModel,this.chartComponent.chartModel,e,this.volumesColorByChartTypeMap,()=>this.config.components.volumes.showSeparately);this.drawingManager.addDrawer(s,"UNDERLAY_VOLUMES_AREA")}}deactiveSeparateVolumes(){this.paneManager.removePane(a.UUID),delete this.scaleModel,this.drawingManager.removeDrawerByName("UNDERLAY_VOLUMES_AREA")}fromY(o){var e,t;return(t=(e=this.scaleModel)===null||e===void 0?void 0:e.fromY(o))!==null&&t!==void 0?t:0}}a.UUID="volumes";export{a as SeparateVolumesComponent};
6
+ import { ChartBaseElement } from '../../model/chart-base-element';
7
+ import { createCandlesOffsetProvider } from '../chart/data-series.high-low-provider';
8
+ import { volumeFormatter } from './volumes.formatter';
9
+ class SeparateVolumesComponent extends ChartBaseElement {
10
+ constructor(chartComponent, drawingManager, config, volumesModel, paneManager) {
11
+ super();
12
+ this.chartComponent = chartComponent;
13
+ this.drawingManager = drawingManager;
14
+ this.config = config;
15
+ this.volumesModel = volumesModel;
16
+ this.paneManager = paneManager;
17
+ if (config.components.volumes.showSeparately) {
18
+ this.activateSeparateVolumes();
19
+ }
20
+ }
21
+ doActivate() {
22
+ super.doActivate();
23
+ this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(() => { var _a, _b; return !((_a = this.pane) === null || _a === void 0 ? void 0 : _a.scale.isViewportValid()) && ((_b = this.pane) === null || _b === void 0 ? void 0 : _b.scale.doAutoScale(true)); }));
24
+ this.addRxSubscription(this.volumesModel.volumeMax.subscribe(() => { var _a; return (_a = this.pane) === null || _a === void 0 ? void 0 : _a.scale.doAutoScale(); }));
25
+ }
26
+ /**
27
+ * Activates the separate volumes feature.
28
+ * If the pane component for separate volumes does not exist, it creates a new pane with the specified UUID and options.
29
+ * It then sets the high-low provider for the volumes scale model and does an auto scale.
30
+ * A new VolumesDrawer is created and added to the drawing manager with the specified parameters.
31
+ */
32
+ activateSeparateVolumes() {
33
+ if (this.paneManager.panes[SeparateVolumesComponent.UUID] === undefined) {
34
+ const volumePane = this.paneManager.createPane(SeparateVolumesComponent.UUID, {
35
+ paneFormatters: {
36
+ regular: volumeFormatter,
37
+ },
38
+ useDefaultHighLow: false,
39
+ increment: 1,
40
+ });
41
+ this.pane = volumePane;
42
+ volumePane.mainExtent.yAxis.setAxisType('regular');
43
+ const { scale: scaleModel } = volumePane;
44
+ const volumesHighLowProvider = createCandlesOffsetProvider(() => ({ top: 10, bottom: 0, left: 0, right: 0, visible: true }), this.volumesModel.highLowProvider);
45
+ scaleModel.autoScaleModel.setHighLowProvider('volumes', volumesHighLowProvider);
46
+ scaleModel.doAutoScale(true);
47
+ }
48
+ }
49
+ /**
50
+ * Deactivates the separate volumes feature by removing the separate volumes pane, deleting the scale model, and removing the underlay volumes area drawer.
51
+ */
52
+ deactiveSeparateVolumes() {
53
+ this.paneManager.removePane(SeparateVolumesComponent.UUID);
54
+ delete this.pane;
55
+ this.drawingManager.removeDrawerByName('UNDERLAY_VOLUMES_AREA');
56
+ }
57
+ /**
58
+ * Converts a pixel value from the Y-axis of the scale model to the corresponding data value.
59
+ * @param {Pixel} y - The pixel value to convert.
60
+ * @returns {Unit} - The corresponding data value.
61
+ */
62
+ fromY(y) {
63
+ var _a, _b;
64
+ return (_b = (_a = this.pane) === null || _a === void 0 ? void 0 : _a.scale.fromY(y)) !== null && _b !== void 0 ? _b : 0;
65
+ }
66
+ }
67
+ SeparateVolumesComponent.UUID = 'volumes';
68
+ export { SeparateVolumesComponent };