@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,115 @@
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{merge as C}from"rxjs";import{filter as _,pairwise as N}from"rxjs/operators";import{ChartBaseElement as f}from"../../model/chart-base-element";import{CanvasElement as n}from"../../canvas/canvas-bounds-container";import{EVENT_RESIZED as g}from"../../events/events";import{NavigationMapDrawer as I}from"./navigation-map.drawer";import{NavigationMapMoveHandler as E}from"./navigation-map-move.handler";import{floor as A}from"../../utils/math.utils";export class NavigationMapComponent extends f{constructor(a,t,c,s,i,m,o,h,l,e){super(),this.eventBus=a,this.chartModel=t,this.canvasModel=c,this.config=s,this.canvasInputListeners=i,this.canvasBoundsContainer=m,this.chartPanComponent=l,this.visualCandles=[];const d=new I(s,t,c,m,h,()=>this.visualCandles);o.addDrawer(d,n.N_MAP_CHART),this.navigationMapMoveHandler=new E(this.eventBus,this.chartModel,this.chartModel.scaleModel,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),e.setCursorForCanvasEl(n.N_MAP_CHART,s.components.navigationMap.cursors.chart),e.setCursorForCanvasEl(n.N_MAP_BTN_L,s.components.navigationMap.cursors.buttonLeft),e.setCursorForCanvasEl(n.N_MAP_BTN_R,s.components.navigationMap.cursors.buttonRight),e.setCursorForCanvasEl(n.N_MAP_KNOT_L,s.components.navigationMap.cursors.leftResizer),e.setCursorForCanvasEl(n.N_MAP_KNOT_R,s.components.navigationMap.cursors.rightResizer),e.setCursorForCanvasEl(n.N_MAP_SLIDER_WINDOW,s.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(C(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(n.N_MAP),this.chartModel.scaleModel.xChanged.pipe(N(),_(([a,t])=>{const s=a.start<0||a.end>0,i=t.start<0||t.end>0;return s&&!i||i}))).subscribe(()=>{this.config.components.navigationMap.visible&&(this.visualCandles=this.makeVisualCandles(),this.canvasModel.fireDraw())}))}makeVisualCandles(){var a;const t=this.chartModel.getCandles();if(!t.length)return[];const c=this.chartModel.mainCandleSeries.dataIdxStart,s=this.chartModel.mainCandleSeries.dataIdxEnd,i=Math.round(Math.max(-c,0)),m=Math.max(this.chartModel.getCandlesCountWithRightOffset(),s)+i;let o=Number.NEGATIVE_INFINITY,h=Number.POSITIVE_INFINITY;const l=this.canvasBoundsContainer.getBounds(n.N_MAP_CHART),e=l.width,d=[];let v=0,r,p;for(r=0;r<e;r++)p=A(r*m/e)-i,p in t?(d[r]=t[p].close,v=(a=d[r])!==null&&a!==void 0?a:0,o=Math.max(o,v),h=Math.min(h,v)):d[r]=0;return o-=h,d.map((u,M)=>[M+l.x,(o+h-u)*l.height/o+l.y])}setVisible(a=!0){var t;!((t=this.config.components)===null||t===void 0)&&t.navigationMap&&(this.config.components.navigationMap.visible=a,this.eventBus.fire(g),this.canvasModel.fireDraw())}}
6
+ import { merge } from 'rxjs';
7
+ import { filter, pairwise } from 'rxjs/operators';
8
+ import { ChartBaseElement } from '../../model/chart-base-element';
9
+ import { CanvasElement } from '../../canvas/canvas-bounds-container';
10
+ import { EVENT_RESIZED } from '../../events/events';
11
+ import { NavigationMapDrawer } from './navigation-map.drawer';
12
+ import { NavigationMapMoveHandler } from './navigation-map-move.handler';
13
+ import { floor } from '../../utils/math.utils';
14
+ /**
15
+ * Navigation map component for chart.
16
+ * Controls navigation map in the bottom.
17
+ */
18
+ export class NavigationMapComponent extends ChartBaseElement {
19
+ constructor(eventBus, chartModel, canvasModel, config, canvasInputListeners, canvasBoundsContainer, drawingManager, formatterFactory, chartPanComponent, cursorHandler) {
20
+ super();
21
+ this.eventBus = eventBus;
22
+ this.chartModel = chartModel;
23
+ this.canvasModel = canvasModel;
24
+ this.config = config;
25
+ this.canvasInputListeners = canvasInputListeners;
26
+ this.canvasBoundsContainer = canvasBoundsContainer;
27
+ this.chartPanComponent = chartPanComponent;
28
+ this.visualCandles = [];
29
+ const navigationMapDrawer = new NavigationMapDrawer(config, chartModel, canvasModel, canvasBoundsContainer, formatterFactory, () => this.visualCandles);
30
+ drawingManager.addDrawer(navigationMapDrawer, CanvasElement.N_MAP_CHART);
31
+ this.navigationMapMoveHandler = new NavigationMapMoveHandler(this.eventBus, this.chartModel, this.chartModel.scale, this.canvasInputListeners, this.canvasBoundsContainer, this.chartPanComponent);
32
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_CHART, config.components.navigationMap.cursors.chart);
33
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_BTN_L, config.components.navigationMap.cursors.buttonLeft);
34
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_BTN_R, config.components.navigationMap.cursors.buttonRight);
35
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_KNOT_L, config.components.navigationMap.cursors.leftResizer);
36
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_KNOT_R, config.components.navigationMap.cursors.rightResizer);
37
+ cursorHandler.setCursorForCanvasEl(CanvasElement.N_MAP_SLIDER_WINDOW, config.components.navigationMap.cursors.slider);
38
+ }
39
+ /**
40
+ * Method to activate the chart. It subscribes to the observables of the chartModel and canvasBoundsContainer.
41
+ * It also subscribes to the xChanged observable of the chartModel's scaleModel and filters the values to check
42
+ * if the previous viewport had no-candles area and current viewport contains only candles or if the current viewport
43
+ * has no-candles area. If the navigationMap component is visible, it makes visual candles and fires the draw event
44
+ * of the canvasModel.
45
+ */
46
+ doActivate() {
47
+ super.doActivate();
48
+ this.addRxSubscription(merge(this.chartModel.observeCandlesChanged(), this.canvasBoundsContainer.observeBoundsChanged(CanvasElement.N_MAP), this.chartModel.scale.xChanged.pipe(pairwise(), filter(([prevScale, curScale]) => {
49
+ // TODO rework
50
+ const itemsCount = 0; //this.chartModel.scale.getItemsCount();
51
+ const prev = prevScale.start < 0 || prevScale.end > itemsCount;
52
+ const cur = curScale.start < 0 || curScale.end > itemsCount;
53
+ // trigger recalculation visual candles for nav map if previous viewport had
54
+ // no-candles area and current viewport contains only candles.
55
+ // OR if current viewport has no-candles area.
56
+ return (prev && !cur) || cur;
57
+ }))).subscribe(() => {
58
+ if (this.config.components.navigationMap.visible) {
59
+ this.visualCandles = this.makeVisualCandles();
60
+ this.canvasModel.fireDraw();
61
+ }
62
+ }));
63
+ }
64
+ /**
65
+ * This function generates an array of visual candles based on the data provided by the chartModel.
66
+ * It calculates the maximum and minimum values of the candles and maps them to the canvas bounds.
67
+ * @returns {Array<[number, number]>} An array of tuples containing the x and y coordinates of each visual candle.
68
+ */
69
+ makeVisualCandles() {
70
+ var _a;
71
+ const candles = this.chartModel.getCandles();
72
+ if (!candles.length) {
73
+ return [];
74
+ }
75
+ const firstId = this.chartModel.mainCandleSeries.dataIdxStart;
76
+ const lastId = this.chartModel.mainCandleSeries.dataIdxEnd;
77
+ const leftSideOffsetVisible = Math.round(Math.max(-firstId, 0));
78
+ // take into account left offset and a new rule using which we can scroll to right, so only two candles on left are visible
79
+ const len = Math.max(this.chartModel.getCandlesCountWithRightOffset(), lastId) + leftSideOffsetVisible;
80
+ let max = Number.NEGATIVE_INFINITY;
81
+ let min = Number.POSITIVE_INFINITY;
82
+ const nMapChart = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_CHART);
83
+ const width = nMapChart.width;
84
+ const res = [];
85
+ let candleClose = 0;
86
+ let x;
87
+ let idx;
88
+ for (x = 0; x < width; x++) {
89
+ idx = floor((x * len) / width) - leftSideOffsetVisible;
90
+ if (idx in candles) {
91
+ res[x] = candles[idx].close;
92
+ candleClose = (_a = res[x]) !== null && _a !== void 0 ? _a : 0;
93
+ max = Math.max(max, candleClose);
94
+ min = Math.min(min, candleClose);
95
+ }
96
+ else {
97
+ res[x] = 0;
98
+ }
99
+ }
100
+ max -= min;
101
+ return res.map((y, x) => {
102
+ return [x + nMapChart.x, ((max + min - y) * nMapChart.height) / max + nMapChart.y];
103
+ });
104
+ }
105
+ /**
106
+ * Sets the visibility of the navigation map component.
107
+ * @param {boolean} visible - Whether the navigation map component should be visible or not. Default is true.
108
+ */
109
+ setVisible(visible = true) {
110
+ var _a;
111
+ if ((_a = this.config.components) === null || _a === void 0 ? void 0 : _a.navigationMap) {
112
+ this.config.components.navigationMap.visible = visible;
113
+ this.eventBus.fire(EVENT_RESIZED);
114
+ this.canvasModel.fireDraw();
115
+ }
116
+ }
117
+ }
@@ -3,4 +3,247 @@
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 h}from"../../canvas/canvas-bounds-container";import{getTextLines as m,drawText as f,getTextLineHeight as v,prepareTextForFill as w}from"../../utils/canvas/canvas-text-functions.utils";import{getFormattedTimeLabel as M}from"./navigation-map.model";import{flat as T}from"../../utils/array.utils";const g=4;export class NavigationMapDrawer{constructor(i,t,o,e,a,l){this.config=i,this.chartModel=t,this.canvasModel=o,this.canvasBoundsContainer=e,this.formatterFactory=a,this.visualCandlesProvider=l}draw(){if(this.config.components.navigationMap.visible){const i=this.visualCandlesProvider();if(i.length){const t=this.canvasBoundsContainer.getBounds(h.N_MAP),o=this.canvasBoundsContainer.getBounds(h.N_MAP_BTN_L),e=this.canvasBoundsContainer.getBounds(h.N_MAP_BTN_R),a=this.canvasBoundsContainer.getBounds(h.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBounds(h.N_MAP_KNOT_R),d=this.canvasBoundsContainer.getBounds(h.N_MAP_SLIDER_WINDOW),r=this.canvasBoundsContainer.getBounds(h.N_MAP_CHART),n=this.canvasModel.ctx;n.fillStyle=this.config.colors.navigationMap.backgroundColor,n.fillRect(t.x,t.y,t.width,t.height),n.strokeStyle=this.config.colors.paneResizer.lineColor,n.lineWidth=1,n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(t.x+t.width,t.y),n.closePath(),n.stroke(),o.width!==0&&this.drawLeftArrowButton(n,o,this.config),e.width!==0&&this.drawRightArrowButton(n,e,this.config),n.fillStyle=this.config.colors.navigationMap.mapFillColor,n.beginPath(),n.moveTo(r.x,r.y+r.height);for(const s of i)n.lineTo(s[0],s[1]);if(n.lineTo(r.x+r.width,r.y+r.height),n.lineTo(r.x,r.y+r.height),n.closePath(),this.config.colors.navigationMap.mapGradientTopColor&&this.config.colors.navigationMap.mapGradientBottomColor){const s=n.createLinearGradient(r.x,r.y,r.x,r.y+r.height);s.addColorStop(0,this.config.colors.navigationMap.mapGradientTopColor),s.addColorStop(1,this.config.colors.navigationMap.mapGradientBottomColor),n.fillStyle=s}n.fill(),this.config.colors.navigationMap.mapColor&&(n.strokeStyle=this.config.colors.navigationMap.mapColor,n.stroke()),this.drawSlider(n,a,l,o,d),this.drawTimeLabels(n)}}}blockDrawSliderOnLeftArrow(i,t,o,e){i.x<=o.x+o.width&&(i.x=o.x+o.width,e.x=i.x+i.width,t.x=e.x+e.width)}drawSlider(i,t,o,e,a){this.blockDrawSliderOnLeftArrow(t,o,e,a),this.drawKnotButton(i,t,this.config,!0),this.drawKnotButton(i,o,this.config,!1),i.fillStyle=this.config.colors.navigationMap.sliderColor,i.fillRect(a.x,a.y,a.width,a.height)}drawLeftArrowButton(i,t,o){i.fillStyle=o.colors.navigationMap.buttonColor,i.fillRect(t.x,t.y,t.width,t.height),i.beginPath();const e=Math.round(t.x+t.width/2-g/2),a=Math.round(t.y+t.height/2);i.moveTo(e,a),i.lineTo(e+g,a+g),i.lineTo(e+g,a-g),i.fillStyle=o.colors.navigationMap.buttonArrowColor,i.fill()}drawRightArrowButton(i,t,o){i.fillStyle=o.colors.navigationMap.buttonColor,i.fillRect(t.x,t.y,t.width,t.height),i.beginPath();const e=Math.round(t.x+t.width/2-g/2),a=Math.round(t.y+t.height/2);i.moveTo(e,a-g),i.lineTo(e,a+g),i.lineTo(e+g,a),i.fillStyle=o.colors.navigationMap.buttonArrowColor,i.fill()}drawKnotButton(i,t,o,e){const a=o.components.navigationMap.knots.border;i.fillStyle=o.colors.navigationMap.knotColor;const l=e?t.x-a:t.x+a;i.fillRect(l,t.y,t.width,t.height),i.lineWidth=o.components.navigationMap.knots.lineWidth,a>0&&(i.beginPath(),i.moveTo(l,t.y),i.lineTo(l,t.y+t.height),i.lineTo(l+t.width,t.y+t.height),i.lineTo(l+t.width,t.y),i.lineTo(l,t.y),i.lineWidth=a,i.strokeStyle=o.colors.navigationMap.knotBorderColor,i.stroke()),i.beginPath(),i.moveTo(l+t.width/2,t.y+t.height/4),i.lineTo(l+t.width/2,t.y+3*t.height/4),i.strokeStyle=o.colors.navigationMap.knotLineColor,i.stroke()}drawTimeLabels(i){const t=T(this.chartModel.mainCandleSeries.getSeriesInViewport()),o=this.config.components.navigationMap.timeLabels,e=o.visible;if(t.length&&e){const a=t[0].candle.timestamp,l=t[t.length-1].candle.timestamp,d=this.canvasBoundsContainer.getBounds(h.N_MAP_LABEL_L),r=this.canvasBoundsContainer.getBounds(h.N_MAP_LABEL_R),s={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:o.fontFamily,textSize:`${o.fontSize}px`},c={dateFormat:o.dateFormat,padding:o.padding,textProperties:Object.assign(Object.assign({},s),{textAlign:"left"})},p={dateFormat:o.dateFormat,padding:o.padding,textProperties:Object.assign(Object.assign({},s),{textAlign:"right"})};this.drawTimeLabel(i,d,a,c),this.drawTimeLabel(i,r,l,p)}}drawTimeLabel(i,t,o,e){const a=e.padding,l=M(o,e.dateFormat,this.formatterFactory);w(i,e.textProperties);const d=v(i),r=m(l);f(i,r,t.x+a.x,t.y+d+a.y,e.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}
6
+ import { CanvasElement } from '../../canvas/canvas-bounds-container';
7
+ import { getTextLines, drawText, getTextLineHeight, prepareTextForFill, } from '../../utils/canvas/canvas-text-functions.utils';
8
+ import { getFormattedTimeLabel } from './navigation-map.model';
9
+ import { flat } from '../../utils/array.utils';
10
+ const BTN_ARROW_WIDTH = 4;
11
+ export class NavigationMapDrawer {
12
+ constructor(config, chartModel, canvasModel, canvasBoundsContainer, formatterFactory, visualCandlesProvider) {
13
+ this.config = config;
14
+ this.chartModel = chartModel;
15
+ this.canvasModel = canvasModel;
16
+ this.canvasBoundsContainer = canvasBoundsContainer;
17
+ this.formatterFactory = formatterFactory;
18
+ this.visualCandlesProvider = visualCandlesProvider;
19
+ }
20
+ /**
21
+ * Draws the navigation map on the canvas if it is visible in the configuration.
22
+ * It first gets the bounds of all the necessary elements on the canvas.
23
+ * Then it fills the background of the navigation map with the configured color.
24
+ * Draws a line at the top of the navigation map with the configured color.
25
+ * Draws the left and right arrow buttons if their width is not zero.
26
+ * Draws the chart with the configured colors and fills it with a gradient if the gradient colors are configured.
27
+ * Draws the slider with the left and right knots and the slider window.
28
+ * Draws the time labels.
29
+ * @returns {void}
30
+ */
31
+ draw() {
32
+ if (this.config.components.navigationMap.visible) {
33
+ const candles = this.visualCandlesProvider();
34
+ if (candles.length) {
35
+ const nMap = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP);
36
+ const btnL = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_BTN_L);
37
+ const btnR = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_BTN_R);
38
+ const knotL = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_KNOT_L);
39
+ const knotR = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_KNOT_R);
40
+ const slider = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_SLIDER_WINDOW);
41
+ const chart = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_CHART);
42
+ const ctx = this.canvasModel.ctx;
43
+ ctx.fillStyle = this.config.colors.navigationMap.backgroundColor;
44
+ ctx.fillRect(nMap.x, nMap.y, nMap.width, nMap.height);
45
+ // bar resizer at the very top
46
+ ctx.strokeStyle = this.config.colors.paneResizer.lineColor;
47
+ ctx.lineWidth = 1;
48
+ ctx.beginPath();
49
+ ctx.moveTo(nMap.x, nMap.y);
50
+ ctx.lineTo(nMap.x + nMap.width, nMap.y);
51
+ ctx.closePath();
52
+ ctx.stroke();
53
+ // btn left and right
54
+ if (btnL.width !== 0) {
55
+ this.drawLeftArrowButton(ctx, btnL, this.config);
56
+ }
57
+ if (btnR.width !== 0) {
58
+ this.drawRightArrowButton(ctx, btnR, this.config);
59
+ }
60
+ // chart
61
+ ctx.fillStyle = this.config.colors.navigationMap.mapFillColor;
62
+ ctx.beginPath();
63
+ ctx.moveTo(chart.x, chart.y + chart.height);
64
+ for (const candle of candles) {
65
+ ctx.lineTo(candle[0], candle[1]);
66
+ }
67
+ ctx.lineTo(chart.x + chart.width, chart.y + chart.height);
68
+ ctx.lineTo(chart.x, chart.y + chart.height);
69
+ ctx.closePath();
70
+ if (this.config.colors.navigationMap.mapGradientTopColor &&
71
+ this.config.colors.navigationMap.mapGradientBottomColor) {
72
+ const grd = ctx.createLinearGradient(chart.x, chart.y, chart.x, chart.y + chart.height);
73
+ grd.addColorStop(0, this.config.colors.navigationMap.mapGradientTopColor);
74
+ grd.addColorStop(1, this.config.colors.navigationMap.mapGradientBottomColor);
75
+ ctx.fillStyle = grd;
76
+ }
77
+ ctx.fill();
78
+ if (this.config.colors.navigationMap.mapColor) {
79
+ ctx.strokeStyle = this.config.colors.navigationMap.mapColor;
80
+ ctx.stroke();
81
+ }
82
+ // slider
83
+ this.drawSlider(ctx, knotL, knotR, btnL, slider);
84
+ // time labels
85
+ this.drawTimeLabels(ctx);
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * Moves the left knot and the slider to the right of the left arrow button if the left knot is to the left of the button.
91
+ * @param {Bounds} knotL - The bounds of the left knot.
92
+ * @param {Bounds} knotR - The bounds of the right knot.
93
+ * @param {Bounds} btnL - The bounds of the left arrow button.
94
+ * @param {Bounds} slider - The bounds of the slider.
95
+ */
96
+ blockDrawSliderOnLeftArrow(knotL, knotR, btnL, slider) {
97
+ if (knotL.x <= btnL.x + btnL.width) {
98
+ knotL.x = btnL.x + btnL.width;
99
+ slider.x = knotL.x + knotL.width;
100
+ knotR.x = slider.x + slider.width;
101
+ }
102
+ }
103
+ /**
104
+ * Draws a slider on a canvas context with given bounds for knots, button and slider.
105
+ * @param {CanvasRenderingContext2D} ctx - The canvas context to draw on.
106
+ * @param {Bounds} knotL - The bounds for the left knot.
107
+ * @param {Bounds} knotR - The bounds for the right knot.
108
+ * @param {Bounds} btnL - The bounds for the left button.
109
+ * @param {Bounds} slider - The bounds for the slider.
110
+ * @returns {void}
111
+ */
112
+ drawSlider(ctx, knotL, knotR, btnL, slider) {
113
+ //Slider can't move above the left arrow
114
+ this.blockDrawSliderOnLeftArrow(knotL, knotR, btnL, slider);
115
+ // knots
116
+ this.drawKnotButton(ctx, knotL, this.config, true);
117
+ this.drawKnotButton(ctx, knotR, this.config, false);
118
+ // slider
119
+ ctx.fillStyle = this.config.colors.navigationMap.sliderColor;
120
+ ctx.fillRect(slider.x, slider.y, slider.width, slider.height);
121
+ }
122
+ /**
123
+ * Draws a left arrow button on a canvas context with the provided bounds and configuration
124
+ * @param {CanvasRenderingContext2D} ctx - The canvas context to draw on
125
+ * @param {Bounds} bounds - The bounds of the button to be drawn
126
+ * @param {FullChartConfig} config - The configuration object containing the colors to be used for the button and arrow
127
+ * @returns {void}
128
+ */
129
+ drawLeftArrowButton(ctx, bounds, config) {
130
+ ctx.fillStyle = config.colors.navigationMap.buttonColor;
131
+ ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
132
+ ctx.beginPath();
133
+ const leftX = Math.round(bounds.x + bounds.width / 2 - BTN_ARROW_WIDTH / 2);
134
+ const midY = Math.round(bounds.y + bounds.height / 2);
135
+ ctx.moveTo(leftX, midY);
136
+ ctx.lineTo(leftX + BTN_ARROW_WIDTH, midY + BTN_ARROW_WIDTH);
137
+ ctx.lineTo(leftX + BTN_ARROW_WIDTH, midY - BTN_ARROW_WIDTH);
138
+ ctx.fillStyle = config.colors.navigationMap.buttonArrowColor;
139
+ ctx.fill();
140
+ }
141
+ /**
142
+ * Draws a right arrow button on a canvas context with the provided bounds and configuration
143
+ * @param {CanvasRenderingContext2D} ctx - The canvas context to draw on
144
+ * @param {Bounds} bounds - The bounds of the button to be drawn
145
+ * @param {FullChartConfig} config - The configuration object containing the colors to be used for the button and arrow
146
+ * @returns {void}
147
+ */
148
+ drawRightArrowButton(ctx, bounds, config) {
149
+ ctx.fillStyle = config.colors.navigationMap.buttonColor;
150
+ ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
151
+ ctx.beginPath();
152
+ const leftX = Math.round(bounds.x + bounds.width / 2 - BTN_ARROW_WIDTH / 2);
153
+ const midY = Math.round(bounds.y + bounds.height / 2);
154
+ ctx.moveTo(leftX, midY - BTN_ARROW_WIDTH);
155
+ ctx.lineTo(leftX, midY + BTN_ARROW_WIDTH);
156
+ ctx.lineTo(leftX + BTN_ARROW_WIDTH, midY);
157
+ ctx.fillStyle = config.colors.navigationMap.buttonArrowColor;
158
+ ctx.fill();
159
+ }
160
+ /**
161
+ * Draws a knot button on a canvas context with the given bounds and configuration.
162
+ * @param {CanvasRenderingContext2D} ctx - The canvas context to draw on.
163
+ * @param {Bounds} bounds - The bounds of the knot button.
164
+ * @param {FullChartConfig} config - The configuration for the chart.
165
+ * @param {boolean} isLeft - Whether the knot button is on the left side of the chart.
166
+ * @returns {void}
167
+ */
168
+ drawKnotButton(ctx, bounds, config, isLeft) {
169
+ const borderWidth = config.components.navigationMap.knots.border;
170
+ ctx.fillStyle = config.colors.navigationMap.knotColor;
171
+ const xWithBorder = isLeft ? bounds.x - borderWidth : bounds.x + borderWidth;
172
+ ctx.fillRect(xWithBorder, bounds.y, bounds.width, bounds.height);
173
+ ctx.lineWidth = config.components.navigationMap.knots.lineWidth;
174
+ if (borderWidth > 0) {
175
+ ctx.beginPath();
176
+ ctx.moveTo(xWithBorder, bounds.y);
177
+ ctx.lineTo(xWithBorder, bounds.y + bounds.height);
178
+ ctx.lineTo(xWithBorder + bounds.width, bounds.y + bounds.height);
179
+ ctx.lineTo(xWithBorder + bounds.width, bounds.y);
180
+ ctx.lineTo(xWithBorder, bounds.y);
181
+ ctx.lineWidth = borderWidth;
182
+ ctx.strokeStyle = config.colors.navigationMap.knotBorderColor;
183
+ ctx.stroke();
184
+ }
185
+ ctx.beginPath();
186
+ ctx.moveTo(xWithBorder + bounds.width / 2, bounds.y + bounds.height / 4);
187
+ ctx.lineTo(xWithBorder + bounds.width / 2, bounds.y + (3 * bounds.height) / 4);
188
+ ctx.strokeStyle = config.colors.navigationMap.knotLineColor;
189
+ ctx.stroke();
190
+ }
191
+ /**
192
+ * Draws time labels on the navigation map canvas.
193
+ * @param {CanvasRenderingContext2D} ctx - The 2D rendering context for the canvas.
194
+ * @returns {void}
195
+ */
196
+ drawTimeLabels(ctx) {
197
+ const candleSource = flat(this.chartModel.mainCandleSeries.getSeriesInViewport());
198
+ const timeLabelsConfig = this.config.components.navigationMap.timeLabels;
199
+ const timeLabelsVisible = timeLabelsConfig.visible;
200
+ if (candleSource.length && timeLabelsVisible) {
201
+ const startViewportTimestamp = candleSource[0].candle.timestamp;
202
+ const endViewportTimestamp = candleSource[candleSource.length - 1].candle.timestamp;
203
+ const textLabelL = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_LABEL_L);
204
+ const textLabelR = this.canvasBoundsContainer.getBounds(CanvasElement.N_MAP_LABEL_R);
205
+ const timeLabelsColor = this.config.colors.navigationMap.timeLabelsTextColor;
206
+ const textProperties = {
207
+ textFill: timeLabelsColor,
208
+ textFontFamily: timeLabelsConfig.fontFamily,
209
+ textSize: `${timeLabelsConfig.fontSize}px`,
210
+ };
211
+ const leftLabelProperties = {
212
+ dateFormat: timeLabelsConfig.dateFormat,
213
+ padding: timeLabelsConfig.padding,
214
+ textProperties: Object.assign(Object.assign({}, textProperties), { textAlign: 'left' }),
215
+ };
216
+ const rightLabelProperties = {
217
+ dateFormat: timeLabelsConfig.dateFormat,
218
+ padding: timeLabelsConfig.padding,
219
+ textProperties: Object.assign(Object.assign({}, textProperties), { textAlign: 'right' }),
220
+ };
221
+ this.drawTimeLabel(ctx, textLabelL, startViewportTimestamp, leftLabelProperties);
222
+ this.drawTimeLabel(ctx, textLabelR, endViewportTimestamp, rightLabelProperties);
223
+ }
224
+ }
225
+ /**
226
+ * Draws a time label on a canvas context.
227
+ * @private
228
+ * @param {CanvasRenderingContext2D} ctx - The canvas context to draw on.
229
+ * @param {Bounds} bounds - The bounds of the label.
230
+ * @param {number} timestamp - The timestamp to display.
231
+ * @param {NMapTimeLabelProperties} config - The configuration for the label.
232
+ * @returns {void}
233
+ */
234
+ drawTimeLabel(ctx, bounds, timestamp, config) {
235
+ const padding = config.padding;
236
+ const text = getFormattedTimeLabel(timestamp, config.dateFormat, this.formatterFactory);
237
+ prepareTextForFill(ctx, config.textProperties);
238
+ const lineHeight = getTextLineHeight(ctx);
239
+ const lines = getTextLines(text);
240
+ drawText(ctx, lines, bounds.x + padding.x, bounds.y + lineHeight + padding.y, config.textProperties);
241
+ }
242
+ /**
243
+ * Returns an array of string containing the canvas ID.
244
+ * @returns {Array<string>} An array of string containing the canvas ID.
245
+ */
246
+ getCanvasIds() {
247
+ return [this.canvasModel.canvasId];
248
+ }
249
+ }
@@ -3,5 +3,36 @@
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{getTextBounds as p,getTextLines as d}from"../../utils/canvas/canvas-text-functions.utils";export function calcTimeLabelBounds(e,n,o,i){const t=i.components.navigationMap.timeLabels,s=t.padding,a=getFormattedTimeLabel(n,t.dateFormat,o),x=d(a),c={textFontFamily:t.fontFamily,textSize:`${t.fontSize}px`},[r,m]=p(e,x,c);return[r+s.x*2,m+s.y*2]}export function getFormattedTimeLabel(e,n,o){return o(n)(e).split(" ").join(`
7
- `)}
6
+ import { getTextBounds, getTextLines } from '../../utils/canvas/canvas-text-functions.utils';
7
+ /**
8
+ * Calculates the bounds of a time label based on the provided timestamp, formatterFactory, and config.
9
+ * @param {CanvasRenderingContext2D} ctx - The canvas rendering context.
10
+ * @param {number} timestamp - The timestamp to be formatted.
11
+ * @param {DateTimeFormatterFactory} formatterFactory - The factory used to create the formatter for the timestamp.
12
+ * @param {FullChartConfig} config - The configuration object for the chart.
13
+ * @returns {[number, number]} - An array containing the width and height of the time label, including padding.
14
+ */
15
+ export function calcTimeLabelBounds(ctx, timestamp, formatterFactory, config) {
16
+ const timeLabelsConfig = config.components.navigationMap.timeLabels;
17
+ const paddings = timeLabelsConfig.padding;
18
+ const textWithCR = getFormattedTimeLabel(timestamp, timeLabelsConfig.dateFormat, formatterFactory);
19
+ const textLines = getTextLines(textWithCR);
20
+ const textProperties = {
21
+ textFontFamily: timeLabelsConfig.fontFamily,
22
+ textSize: `${timeLabelsConfig.fontSize}px`,
23
+ };
24
+ const [textWidth, textHeight] = getTextBounds(ctx, textLines, textProperties);
25
+ return [textWidth + paddings.x * 2, textHeight + paddings.y * 2];
26
+ }
27
+ /**
28
+ * Returns a formatted time label.
29
+ *
30
+ * @param {number} timestamp - The timestamp to format.
31
+ * @param {string} format - The format to use for the timestamp.
32
+ * @param {DateTimeFormatterFactory} formatterFactory - The factory function to create a formatter for the given format.
33
+ * @returns {string} The formatted time label with line breaks instead of spaces.
34
+ */
35
+ export function getFormattedTimeLabel(timestamp, format, formatterFactory) {
36
+ const text = formatterFactory(format)(timestamp);
37
+ return text.split(' ').join('\n');
38
+ }
@@ -14,7 +14,7 @@ import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
14
14
  import { BaseType, ChartBaseModel } from '../chart/chart-base.model';
15
15
  export declare class ChartPanComponent extends ChartBaseElement {
16
16
  private eventBus;
17
- private mainScaleModel;
17
+ private mainScale;
18
18
  private canvasBoundsContainer;
19
19
  private config;
20
20
  private canvasAnimation;
@@ -23,7 +23,7 @@ export declare class ChartPanComponent extends ChartBaseElement {
23
23
  chartBaseModel: ChartBaseModel<BaseType>;
24
24
  chartPanComponents: Array<ChartEntity>;
25
25
  chartAreaPanHandler: ChartAreaPanHandler;
26
- constructor(eventBus: EventBus, mainScaleModel: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, mainCanvasParent: Element, chartBaseModel: ChartBaseModel<BaseType>);
26
+ constructor(eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, mainCanvasParent: Element, chartBaseModel: ChartBaseModel<BaseType>);
27
27
  /**
28
28
  * Activates the chart pan handlers.
29
29
  * @protected
@@ -3,4 +3,54 @@
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 o}from"../../model/chart-base-element";import{ChartAreaPanHandler as c}from"../chart/chart-area-pan.handler";export class ChartPanComponent extends o{constructor(a,t,n,s,e,i,h,r){super(),this.eventBus=a,this.mainScaleModel=t,this.canvasBoundsContainer=n,this.config=s,this.canvasAnimation=e,this.canvasInputListener=i,this.mainCanvasParent=h,this.chartBaseModel=r,this.chartPanComponents=[],this.chartAreaPanHandler=new c(this.eventBus,this.config,this.mainScaleModel,this.mainCanvasParent,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this),this.chartPanComponents.push(this.chartAreaPanHandler)}doActivate(){this.activateChartPanHandlers()}doDeactivate(){this.deactivatePanHandlers()}activateChartPanHandlers(){this.chartPanComponents.forEach(a=>a.activate())}deactivatePanHandlers(){this.chartPanComponents.forEach(a=>a.deactivate())}}
6
+ import { ChartBaseElement } from '../../model/chart-base-element';
7
+ import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
8
+ export class ChartPanComponent extends ChartBaseElement {
9
+ constructor(eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, mainCanvasParent, chartBaseModel) {
10
+ super();
11
+ this.eventBus = eventBus;
12
+ this.mainScale = mainScale;
13
+ this.canvasBoundsContainer = canvasBoundsContainer;
14
+ this.config = config;
15
+ this.canvasAnimation = canvasAnimation;
16
+ this.canvasInputListener = canvasInputListener;
17
+ this.mainCanvasParent = mainCanvasParent;
18
+ this.chartBaseModel = chartBaseModel;
19
+ this.chartPanComponents = [];
20
+ this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.mainCanvasParent, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this);
21
+ this.chartPanComponents.push(this.chartAreaPanHandler);
22
+ }
23
+ /**
24
+ * Activates the chart pan handlers.
25
+ * @protected
26
+ * @returns {void}
27
+ */
28
+ doActivate() {
29
+ this.activateChartPanHandlers();
30
+ }
31
+ /**
32
+ * This method is used to deactivate the pan handlers.
33
+ * @returns {void}
34
+ * @protected
35
+ */
36
+ doDeactivate() {
37
+ this.deactivatePanHandlers();
38
+ }
39
+ /**
40
+ * Activates user mouse handlers on main chart view.
41
+ * @function
42
+ * @name activateChartPanHandlers
43
+ * @memberof [object Object]
44
+ * @instance
45
+ * @returns {void}
46
+ */
47
+ activateChartPanHandlers() {
48
+ this.chartPanComponents.forEach(c => c.activate());
49
+ }
50
+ /**
51
+ * Deactivates all the pan handlers of the chart.
52
+ */
53
+ deactivatePanHandlers() {
54
+ this.chartPanComponents.forEach(c => c.deactivate());
55
+ }
56
+ }
@@ -10,36 +10,35 @@ import { ChartBaseElement } from '../../../model/chart-base-element';
10
10
  import { DataSeriesModel } from '../../../model/data-series.model';
11
11
  import { ScaleModel } from '../../../model/scale.model';
12
12
  import { HighLowProvider } from '../../../model/scaling/auto-scale.model';
13
- import { Unit } from '../../../model/scaling/viewport.model';
13
+ import { Pixel, Price, Unit } from '../../../model/scaling/viewport.model';
14
14
  import { ChartBaseModel } from '../../chart/chart-base.model';
15
15
  import { DragNDropYComponent } from '../../dran-n-drop_helper/drag-n-drop-y.component';
16
- import { PriceAxisType } from '../../labels_generator/numeric-axis-labels.generator';
16
+ import { YAxisComponent } from '../../y_axis/y-axis.component';
17
17
  import { PaneHitTestController } from '../pane-hit-test.controller';
18
- import { ExtentYAxis, PaneComponent, YExtentFormatters } from '../pane.component';
18
+ import { PaneComponent, YExtentFormatters } from '../pane.component';
19
19
  export interface YExtentCreationOptions {
20
- scaleModel: ScaleModel;
20
+ scale: ScaleModel;
21
21
  order: number;
22
22
  useDefaultHighLow: boolean;
23
- useDefaultYAxis: boolean;
24
23
  cursor: string;
25
24
  paneFormatters: YExtentFormatters;
26
25
  increment: number | null;
27
26
  }
28
27
  export declare class YExtentComponent extends ChartBaseElement {
29
- paneUuid: string;
28
+ paneUUID: string;
30
29
  idx: number;
31
30
  paneComponent: PaneComponent;
32
31
  private chartBaseModel;
33
32
  private canvasBoundsContainer;
34
33
  private hitTestController;
35
- dataSeriesCanvasModel: CanvasModel;
36
- readonly scaleModel: ScaleModel;
37
- readonly yAxisComponent: ExtentYAxis | undefined;
34
+ dynamicObjectsCanvasModel: CanvasModel;
35
+ readonly scale: ScaleModel;
38
36
  readonly dragNDrop: DragNDropYComponent;
39
37
  dataSeries: Set<DataSeriesModel>;
40
38
  formatters: YExtentFormatters;
41
- private mainDataSeries?;
42
- constructor(paneUuid: string, idx: number, paneComponent: PaneComponent, chartBaseModel: ChartBaseModel<'candle'>, canvasBoundsContainer: CanvasBoundsContainer, hitTestController: PaneHitTestController, dataSeriesCanvasModel: CanvasModel, scaleModel: ScaleModel, yAxisComponent: ExtentYAxis | undefined, dragNDrop: DragNDropYComponent, dataSeries?: Set<DataSeriesModel>, formatters?: YExtentFormatters);
39
+ yAxis: YAxisComponent;
40
+ mainDataSeries?: DataSeriesModel;
41
+ constructor(paneUUID: string, idx: number, paneComponent: PaneComponent, chartBaseModel: ChartBaseModel<'candle'>, canvasBoundsContainer: CanvasBoundsContainer, hitTestController: PaneHitTestController, dynamicObjectsCanvasModel: CanvasModel, scale: ScaleModel, createYAxisComponent: (formatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined) => YAxisComponent, dragNDrop: DragNDropYComponent, dataSeries?: Set<DataSeriesModel>, formatters?: YExtentFormatters);
43
42
  protected doDeactivate(): void;
44
43
  getYAxisBounds: () => Bounds;
45
44
  yAxisHT: import("../../../canvas/canvas-bounds-container").HitBoundsTest;
@@ -48,6 +47,7 @@ export declare class YExtentComponent extends ChartBaseElement {
48
47
  * @returns {Bounds} The bounds of the scale model.
49
48
  */
50
49
  getBounds(): Bounds;
50
+ getBaseline(): number;
51
51
  private toVisualPoints;
52
52
  /**
53
53
  * Creates a new DataSeriesModel object.
@@ -60,6 +60,7 @@ export declare class YExtentComponent extends ChartBaseElement {
60
60
  * @returns {void}
61
61
  */
62
62
  addDataSeries(series: DataSeriesModel): void;
63
+ toY: (value: Price) => Pixel;
63
64
  /**
64
65
  * Removes a data series from the chart.
65
66
  *
@@ -67,13 +68,6 @@ export declare class YExtentComponent extends ChartBaseElement {
67
68
  * @returns {void}
68
69
  */
69
70
  removeDataSeries(series: DataSeriesModel): void;
70
- /**
71
- * Returns the type of the y-axis component for the current pane.
72
- *
73
- * @returns {PriceAxisType} The 'regular' type of the y-axis component for the current pane.
74
- *
75
- */
76
- getAxisType(): PriceAxisType;
77
71
  valueFormatter: (value: Unit, dataSeries?: DataSeriesModel) => string;
78
72
  get regularFormatter(): (value: number) => string;
79
73
  /**