@devexperts/dxcharts-lite 1.0.1 → 2.0.0

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 (379) hide show
  1. package/README.md +4 -4
  2. package/dist/chart/animation/canvas-animation.d.ts +1 -1
  3. package/dist/chart/animation/canvas-animation.js +135 -2
  4. package/dist/chart/animation/types/animation.d.ts +1 -1
  5. package/dist/chart/animation/types/animation.js +44 -2
  6. package/dist/chart/animation/types/color-alpha-animation.d.ts +2 -2
  7. package/dist/chart/animation/types/color-alpha-animation.js +61 -2
  8. package/dist/chart/animation/types/color-transition-animation.d.ts +2 -2
  9. package/dist/chart/animation/types/color-transition-animation.js +87 -2
  10. package/dist/chart/animation/types/viewport-movement-animation.d.ts +1 -1
  11. package/dist/chart/animation/types/viewport-movement-animation.js +64 -2
  12. package/dist/chart/animation/viewport-model-animation.d.ts +1 -1
  13. package/dist/chart/animation/viewport-model-animation.js +21 -2
  14. package/dist/chart/bootstrap.d.ts +52 -49
  15. package/dist/chart/bootstrap.js +450 -2
  16. package/dist/chart/canvas/canvas-bounds-container.d.ts +1 -6
  17. package/dist/chart/canvas/canvas-bounds-container.js +816 -2
  18. package/dist/chart/canvas/canvas-chart-html.d.ts +1 -1
  19. package/dist/chart/canvas/canvas-chart-html.js +17 -19
  20. package/dist/chart/canvas/chart-elements.d.ts +2 -5
  21. package/dist/chart/canvas/chart-elements.js +23 -2
  22. package/dist/chart/canvas/cursor.handler.d.ts +1 -1
  23. package/dist/chart/canvas/cursor.handler.js +123 -2
  24. package/dist/chart/canvas/layout-creator.d.ts +1 -1
  25. package/dist/chart/canvas/layout-creator.js +35 -2
  26. package/dist/chart/canvas/y-axis-bounds.container.d.ts +3 -3
  27. package/dist/chart/canvas/y-axis-bounds.container.js +68 -2
  28. package/dist/chart/chart-container.d.ts +1 -1
  29. package/dist/chart/chart-container.js +2 -2
  30. package/dist/chart/chart.config.d.ts +5 -6
  31. package/dist/chart/chart.config.js +646 -2
  32. package/dist/chart/chart.d.ts +62 -0
  33. package/dist/chart/chart.js +106 -0
  34. package/dist/chart/components/chart/basic-scale.d.ts +3 -3
  35. package/dist/chart/components/chart/basic-scale.js +32 -2
  36. package/dist/chart/components/chart/candle-transformer.functions.d.ts +1 -1
  37. package/dist/chart/components/chart/candle-transformer.functions.js +16 -2
  38. package/dist/chart/components/chart/candle-width-calculator.functions.d.ts +1 -1
  39. package/dist/chart/components/chart/candle-width-calculator.functions.js +3 -2
  40. package/dist/chart/components/chart/candle.functions.d.ts +1 -1
  41. package/dist/chart/components/chart/candle.functions.js +45 -2
  42. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +4 -4
  43. package/dist/chart/components/chart/chart-area-pan.handler.js +198 -2
  44. package/dist/chart/components/chart/chart-base.model.d.ts +1 -1
  45. package/dist/chart/components/chart/chart-base.model.js +67 -2
  46. package/dist/chart/components/chart/chart.component.d.ts +8 -4
  47. package/dist/chart/components/chart/chart.component.js +409 -2
  48. package/dist/chart/components/chart/chart.model.d.ts +5 -12
  49. package/dist/chart/components/chart/chart.model.js +955 -2
  50. package/dist/chart/components/chart/data-series.high-low-provider.d.ts +1 -1
  51. package/dist/chart/components/chart/data-series.high-low-provider.js +35 -2
  52. package/dist/chart/components/chart/fake-candles.d.ts +1 -1
  53. package/dist/chart/components/chart/fake-candles.js +98 -2
  54. package/dist/chart/components/chart/price.formatter.d.ts +1 -1
  55. package/dist/chart/components/chart/price.formatter.js +36 -2
  56. package/dist/chart/components/chart/secondary-chart-colors-pool.d.ts +1 -1
  57. package/dist/chart/components/chart/secondary-chart-colors-pool.js +69 -2
  58. package/dist/chart/components/cross_tool/cross-tool.component.d.ts +1 -1
  59. package/dist/chart/components/cross_tool/cross-tool.component.js +86 -2
  60. package/dist/chart/components/cross_tool/cross-tool.drawer.d.ts +1 -1
  61. package/dist/chart/components/cross_tool/cross-tool.drawer.js +33 -2
  62. package/dist/chart/components/cross_tool/cross-tool.model.d.ts +1 -1
  63. package/dist/chart/components/cross_tool/cross-tool.model.js +108 -2
  64. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.d.ts +1 -1
  65. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +138 -2
  66. package/dist/chart/components/cross_tool/types/none.drawer.d.ts +1 -1
  67. package/dist/chart/components/cross_tool/types/none.drawer.js +4 -2
  68. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.d.ts +1 -1
  69. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +29 -2
  70. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.d.ts +1 -1
  71. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +25 -2
  72. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +1 -1
  73. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +54 -2
  74. package/dist/chart/components/dynamic-objects/dynamic-objects.component.d.ts +13 -0
  75. package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +20 -0
  76. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.d.ts +18 -0
  77. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.js +23 -0
  78. package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +63 -0
  79. package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +136 -0
  80. package/dist/chart/components/events/events-hit-test.drawer.d.ts +1 -1
  81. package/dist/chart/components/events/events-hit-test.drawer.js +64 -2
  82. package/dist/chart/components/events/events.component.d.ts +1 -1
  83. package/dist/chart/components/events/events.component.js +62 -2
  84. package/dist/chart/components/events/events.drawer.d.ts +1 -1
  85. package/dist/chart/components/events/events.drawer.js +196 -2
  86. package/dist/chart/components/events/events.model.d.ts +1 -1
  87. package/dist/chart/components/events/events.model.js +70 -2
  88. package/dist/chart/components/grid/grid.component.d.ts +3 -3
  89. package/dist/chart/components/grid/grid.component.js +32 -2
  90. package/dist/chart/components/grid/grid.drawer.d.ts +5 -4
  91. package/dist/chart/components/grid/grid.drawer.js +107 -2
  92. package/dist/chart/components/high_low/high-low.component.d.ts +1 -1
  93. package/dist/chart/components/high_low/high-low.component.js +13 -2
  94. package/dist/chart/components/high_low/high-low.drawer.d.ts +1 -1
  95. package/dist/chart/components/high_low/high-low.drawer.js +127 -2
  96. package/dist/chart/components/highlights/highlights.component.d.ts +1 -1
  97. package/dist/chart/components/highlights/highlights.component.js +47 -2
  98. package/dist/chart/components/highlights/highlights.drawer.d.ts +1 -1
  99. package/dist/chart/components/highlights/highlights.drawer.js +155 -2
  100. package/dist/chart/components/highlights/highlights.model.d.ts +1 -1
  101. package/dist/chart/components/highlights/highlights.model.js +76 -2
  102. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +2 -2
  103. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +200 -2
  104. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +3 -3
  105. package/dist/chart/components/navigation_map/navigation-map-move.handler.js +109 -2
  106. package/dist/chart/components/navigation_map/navigation-map.component.d.ts +1 -1
  107. package/dist/chart/components/navigation_map/navigation-map.component.js +113 -2
  108. package/dist/chart/components/navigation_map/navigation-map.drawer.d.ts +1 -1
  109. package/dist/chart/components/navigation_map/navigation-map.drawer.js +245 -2
  110. package/dist/chart/components/navigation_map/navigation-map.model.d.ts +1 -1
  111. package/dist/chart/components/navigation_map/navigation-map.model.js +34 -3
  112. package/dist/chart/components/pan/chart-pan.component.d.ts +3 -3
  113. package/dist/chart/components/pan/chart-pan.component.js +52 -2
  114. package/dist/chart/components/pane/extent/y-extent-component.d.ts +13 -19
  115. package/dist/chart/components/pane/extent/y-extent-component.js +121 -2
  116. package/dist/chart/components/pane/pane-hit-test.controller.d.ts +1 -1
  117. package/dist/chart/components/pane/pane-hit-test.controller.js +56 -2
  118. package/dist/chart/components/pane/pane-manager.component.d.ts +11 -6
  119. package/dist/chart/components/pane/pane-manager.component.js +149 -2
  120. package/dist/chart/components/pane/pane.component.d.ts +18 -34
  121. package/dist/chart/components/pane/pane.component.js +279 -2
  122. package/dist/chart/components/resizer/bar-resizer.component.d.ts +1 -1
  123. package/dist/chart/components/resizer/bar-resizer.component.js +140 -2
  124. package/dist/chart/components/resizer/bar-resizer.drawer.d.ts +1 -1
  125. package/dist/chart/components/resizer/bar-resizer.drawer.js +47 -2
  126. package/dist/chart/components/snapshot/snapshot.component.d.ts +1 -1
  127. package/dist/chart/components/snapshot/snapshot.component.js +49 -2
  128. package/dist/chart/components/volumes/separate-volumes.component.d.ts +7 -11
  129. package/dist/chart/components/volumes/separate-volumes.component.js +64 -2
  130. package/dist/chart/components/volumes/volume-color-resolvers.functions.d.ts +1 -1
  131. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +19 -2
  132. package/dist/chart/components/volumes/volumes.component.d.ts +9 -9
  133. package/dist/chart/components/volumes/volumes.component.js +95 -2
  134. package/dist/chart/components/volumes/volumes.drawer.d.ts +6 -13
  135. package/dist/chart/components/volumes/volumes.drawer.js +141 -2
  136. package/dist/chart/components/volumes/volumes.formatter.d.ts +1 -1
  137. package/dist/chart/components/volumes/volumes.formatter.js +32 -2
  138. package/dist/chart/components/volumes/volumes.model.d.ts +3 -3
  139. package/dist/chart/components/volumes/volumes.model.js +44 -2
  140. package/dist/chart/components/watermark/water-mark.component.d.ts +1 -1
  141. package/dist/chart/components/watermark/water-mark.component.js +104 -2
  142. package/dist/chart/components/watermark/water-mark.drawer.d.ts +1 -1
  143. package/dist/chart/components/watermark/water-mark.drawer.js +188 -2
  144. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.d.ts +1 -1
  145. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +28 -2
  146. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.d.ts +1 -1
  147. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +188 -2
  148. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.d.ts +1 -1
  149. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +77 -2
  150. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.d.ts +1 -1
  151. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +80 -2
  152. package/dist/chart/components/x_axis/time/parser/time-formats.model.d.ts +1 -1
  153. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +15 -2
  154. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +2 -2
  155. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +144 -2
  156. package/dist/chart/components/x_axis/time/x-axis-weights.generator.d.ts +1 -1
  157. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +74 -2
  158. package/dist/chart/components/x_axis/x-axis-draw.functions.d.ts +1 -1
  159. package/dist/chart/components/x_axis/x-axis-draw.functions.js +50 -2
  160. package/dist/chart/components/x_axis/x-axis-labels.drawer.d.ts +1 -1
  161. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +71 -2
  162. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +3 -3
  163. package/dist/chart/components/x_axis/x-axis-labels.generator.js +333 -2
  164. package/dist/chart/components/x_axis/x-axis-labels.model.d.ts +1 -1
  165. package/dist/chart/components/x_axis/x-axis-labels.model.js +36 -2
  166. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +3 -3
  167. package/dist/chart/components/x_axis/x-axis-scale.handler.js +61 -2
  168. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.d.ts +1 -1
  169. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +83 -2
  170. package/dist/chart/components/x_axis/x-axis.component.d.ts +3 -3
  171. package/dist/chart/components/x_axis/x-axis.component.js +120 -2
  172. package/dist/chart/components/y_axis/label-color.functions.d.ts +1 -1
  173. package/dist/chart/components/y_axis/label-color.functions.js +54 -2
  174. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +5 -5
  175. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +34 -2
  176. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +4 -4
  177. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +68 -2
  178. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.d.ts +1 -1
  179. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +57 -2
  180. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +1 -1
  181. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +96 -2
  182. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +3 -3
  183. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +120 -2
  184. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +10 -9
  185. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +202 -2
  186. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +7 -8
  187. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +59 -2
  188. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +7 -5
  189. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +48 -2
  190. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +5 -5
  191. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +162 -2
  192. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +3 -3
  193. package/dist/chart/components/y_axis/y-axis-scale.handler.js +73 -2
  194. package/dist/chart/components/y_axis/y-axis.component.d.ts +33 -42
  195. package/dist/chart/components/y_axis/y-axis.component.js +221 -2
  196. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +10 -13
  197. package/dist/chart/components/y_axis/y-axis.drawer.js +97 -2
  198. package/dist/chart/components/y_axis/y-axis.model.d.ts +10 -18
  199. package/dist/chart/components/y_axis/y-axis.model.js +34 -2
  200. package/dist/chart/drawers/chart-background.drawer.d.ts +1 -1
  201. package/dist/chart/drawers/chart-background.drawer.js +70 -2
  202. package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +1 -1
  203. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +70 -2
  204. package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +1 -1
  205. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +58 -2
  206. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +1 -1
  207. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +85 -2
  208. package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +1 -1
  209. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +163 -2
  210. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +1 -1
  211. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +58 -2
  212. package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +1 -1
  213. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +39 -2
  214. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +1 -1
  215. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +20 -2
  216. package/dist/chart/drawers/clear-canvas.drawer.d.ts +1 -1
  217. package/dist/chart/drawers/clear-canvas.drawer.js +15 -2
  218. package/dist/chart/drawers/composite.drawer.d.ts +1 -1
  219. package/dist/chart/drawers/composite.drawer.js +68 -2
  220. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +1 -1
  221. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +51 -2
  222. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +1 -1
  223. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +36 -2
  224. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.d.ts +1 -1
  225. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +17 -2
  226. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +1 -1
  227. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +107 -2
  228. package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +1 -1
  229. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +24 -2
  230. package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +1 -1
  231. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +20 -2
  232. package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +1 -1
  233. package/dist/chart/drawers/data-series-drawers/points.drawer.js +20 -2
  234. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.d.ts +1 -1
  235. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +8 -2
  236. package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +1 -1
  237. package/dist/chart/drawers/data-series-drawers/text.drawer.js +26 -2
  238. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +1 -1
  239. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +36 -2
  240. package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +1 -1
  241. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +23 -2
  242. package/dist/chart/drawers/data-series.drawer.d.ts +6 -8
  243. package/dist/chart/drawers/data-series.drawer.js +57 -2
  244. package/dist/chart/drawers/drawing-manager.d.ts +2 -2
  245. package/dist/chart/drawers/drawing-manager.js +178 -2
  246. package/dist/chart/drawers/ht-data-series.drawer.d.ts +1 -1
  247. package/dist/chart/drawers/ht-data-series.drawer.js +38 -2
  248. package/dist/chart/events/event-bus.d.ts +1 -1
  249. package/dist/chart/events/event-bus.js +74 -2
  250. package/dist/chart/events/events.d.ts +1 -1
  251. package/dist/chart/events/events.js +4 -2
  252. package/dist/chart/inputhandlers/candle-tap.handler.d.ts +1 -1
  253. package/dist/chart/inputhandlers/candle-tap.handler.js +47 -2
  254. package/dist/chart/inputhandlers/chart-resize.handler.d.ts +1 -1
  255. package/dist/chart/inputhandlers/chart-resize.handler.js +99 -2
  256. package/dist/chart/inputhandlers/cross-event-producer.component.d.ts +1 -1
  257. package/dist/chart/inputhandlers/cross-event-producer.component.js +68 -2
  258. package/dist/chart/inputhandlers/hover-producer.component.d.ts +3 -3
  259. package/dist/chart/inputhandlers/hover-producer.component.js +229 -2
  260. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +3 -3
  261. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +81 -2
  262. package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +1 -1
  263. package/dist/chart/inputlisteners/canvas-input-listener.component.js +630 -2
  264. package/dist/chart/model/baseline.model.d.ts +1 -1
  265. package/dist/chart/model/baseline.model.js +89 -2
  266. package/dist/chart/model/bounds.model.d.ts +1 -1
  267. package/dist/chart/model/bounds.model.js +2 -2
  268. package/dist/chart/model/candle-hover.d.ts +1 -1
  269. package/dist/chart/model/candle-hover.js +71 -2
  270. package/dist/chart/model/candle-series-high-low.provider.d.ts +1 -1
  271. package/dist/chart/model/candle-series-high-low.provider.js +46 -2
  272. package/dist/chart/model/candle-series.model.d.ts +4 -4
  273. package/dist/chart/model/candle-series.model.js +246 -2
  274. package/dist/chart/model/candle.model.d.ts +1 -1
  275. package/dist/chart/model/candle.model.js +70 -2
  276. package/dist/chart/model/canvas.model.d.ts +1 -1
  277. package/dist/chart/model/canvas.model.js +229 -2
  278. package/dist/chart/model/chart-base-element.d.ts +1 -1
  279. package/dist/chart/model/chart-base-element.js +130 -2
  280. package/dist/chart/model/compare-series-hover.d.ts +1 -1
  281. package/dist/chart/model/compare-series-hover.js +26 -2
  282. package/dist/chart/model/data-series-view.d.ts +6 -6
  283. package/dist/chart/model/data-series-view.js +112 -2
  284. package/dist/chart/model/data-series.config.d.ts +1 -1
  285. package/dist/chart/model/data-series.config.js +15 -2
  286. package/dist/chart/model/data-series.model.d.ts +5 -5
  287. package/dist/chart/model/data-series.model.js +282 -2
  288. package/dist/chart/model/date-time.formatter.d.ts +1 -1
  289. package/dist/chart/model/date-time.formatter.js +152 -2
  290. package/dist/chart/model/hit-test-canvas.model.d.ts +2 -2
  291. package/dist/chart/model/hit-test-canvas.model.js +257 -2
  292. package/dist/chart/model/main-candle-series.model.d.ts +2 -2
  293. package/dist/chart/model/main-candle-series.model.js +30 -2
  294. package/dist/chart/model/scale.model.d.ts +3 -2
  295. package/dist/chart/model/scale.model.js +317 -2
  296. package/dist/chart/model/scaling/auto-scale.model.d.ts +1 -1
  297. package/dist/chart/model/scaling/auto-scale.model.js +98 -2
  298. package/dist/chart/model/scaling/constrait.functions.d.ts +1 -1
  299. package/dist/chart/model/scaling/constrait.functions.js +62 -2
  300. package/dist/chart/model/scaling/lock-ratio.model.d.ts +1 -1
  301. package/dist/chart/model/scaling/lock-ratio.model.js +18 -2
  302. package/dist/chart/model/scaling/move-chart.functions.d.ts +1 -1
  303. package/dist/chart/model/scaling/move-chart.functions.js +23 -2
  304. package/dist/chart/model/scaling/viewport.model.d.ts +3 -3
  305. package/dist/chart/model/scaling/viewport.model.js +280 -2
  306. package/dist/chart/model/scaling/x-zooming.functions.d.ts +1 -1
  307. package/dist/chart/model/scaling/x-zooming.functions.js +36 -2
  308. package/dist/chart/model/time-zone.model.d.ts +1 -1
  309. package/dist/chart/model/time-zone.model.js +110 -2
  310. package/dist/chart/model/visual-candle.d.ts +1 -1
  311. package/dist/chart/model/visual-candle.js +135 -2
  312. package/dist/chart/utils/__tests__/array.utils.test.d.ts +1 -1
  313. package/dist/chart/utils/__tests__/array.utils.test.js +136 -2
  314. package/dist/chart/utils/{perfomance/debounce.utils.js → __tests__/math.utils.test.d.ts} +2 -2
  315. package/dist/chart/utils/__tests__/math.utils.test.js +19 -0
  316. package/dist/chart/utils/__tests__/object.utils.test.d.ts +1 -1
  317. package/dist/chart/utils/__tests__/object.utils.test.js +12 -2
  318. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.d.ts +1 -1
  319. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +30 -2
  320. package/dist/chart/utils/array.utils.d.ts +2 -2
  321. package/dist/chart/utils/array.utils.js +270 -2
  322. package/dist/chart/utils/auto-period-detector.utils.d.ts +1 -1
  323. package/dist/chart/utils/auto-period-detector.utils.js +40 -2
  324. package/dist/chart/utils/candles-generator-ts.utils.d.ts +1 -1
  325. package/dist/chart/utils/candles-generator-ts.utils.js +21 -2
  326. package/dist/chart/utils/candles-generator.utils.d.ts +1 -1
  327. package/dist/chart/utils/candles-generator.utils.js +162 -2
  328. package/dist/chart/utils/candles.utils.d.ts +1 -1
  329. package/dist/chart/utils/candles.utils.js +43 -2
  330. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.d.ts +1 -1
  331. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +145 -2
  332. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.d.ts +1 -1
  333. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +52 -2
  334. package/dist/chart/utils/canvas/canvas-text-functions.utils.d.ts +1 -1
  335. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +157 -2
  336. package/dist/chart/utils/color.utils.d.ts +1 -1
  337. package/dist/chart/utils/color.utils.js +32 -2
  338. package/dist/chart/utils/device/browser.utils.d.ts +1 -1
  339. package/dist/chart/utils/device/browser.utils.js +11 -2
  340. package/dist/chart/utils/device/device-detector.utils.d.ts +1 -1
  341. package/dist/chart/utils/device/device-detector.utils.js +25 -2
  342. package/dist/chart/utils/device/device-pixel-ratio.utils.d.ts +1 -1
  343. package/dist/chart/utils/device/device-pixel-ratio.utils.js +22 -2
  344. package/dist/chart/utils/device/touchpad.utils.d.ts +1 -1
  345. package/dist/chart/utils/device/touchpad.utils.js +92 -2
  346. package/dist/chart/utils/dom.utils.d.ts +1 -1
  347. package/dist/chart/utils/dom.utils.js +16 -2
  348. package/dist/chart/utils/function.utils.d.ts +1 -1
  349. package/dist/chart/utils/function.utils.js +17 -2
  350. package/dist/chart/utils/linkedList.utils.d.ts +28 -0
  351. package/dist/chart/utils/linkedList.utils.js +138 -0
  352. package/dist/chart/utils/math.utils.d.ts +1 -1
  353. package/dist/chart/utils/math.utils.js +116 -2
  354. package/dist/chart/utils/merge.utils.d.ts +1 -1
  355. package/dist/chart/utils/merge.utils.js +57 -2
  356. package/dist/chart/utils/object.utils.d.ts +1 -1
  357. package/dist/chart/utils/object.utils.js +44 -2
  358. package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +1 -1
  359. package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
  360. package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +1 -1
  361. package/dist/chart/utils/performance/debounce.utils.js +12 -0
  362. package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +1 -1
  363. package/dist/chart/utils/performance/memoize.utils.js +74 -0
  364. package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +1 -1
  365. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
  366. package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +1 -1
  367. package/dist/chart/utils/performance/throttle.utils.js +26 -0
  368. package/dist/chart/utils/price-increments.utils.d.ts +2 -1
  369. package/dist/chart/utils/price-increments.utils.js +128 -2
  370. package/dist/chart/utils/uuid.utils.d.ts +1 -1
  371. package/dist/chart/utils/uuid.utils.js +5 -2
  372. package/dist/dxchart.min.js +10 -13
  373. package/dist/index.d.ts +4 -4
  374. package/dist/index.js +21 -2
  375. package/package.json +4 -4
  376. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
  377. package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
  378. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
  379. package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
@@ -1,6 +1,321 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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 c}from"rxjs";import{startViewportModelAnimation as l}from"../animation/viewport-model-animation";import{cloneUnsafe as u}from"../utils/object.utils";import{AutoScaleViewportSubModel as d}from"./scaling/auto-scale.model";import{zoomConstraint as m}from"./scaling/constrait.functions";import{lockedYEndViewportCalculator as a,ratioFromZoomXY as p}from"./scaling/lock-ratio.model";import{moveXStart as f,moveYStart as S}from"./scaling/move-chart.functions";import{ViewportModel as g,compareStates as x}from"./scaling/viewport.model";import{zoomXToEndViewportCalculator as A,zoomXToPercentViewportCalculator as y}from"./scaling/x-zooming.functions";export const getDefaultHighLowWithIndex=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});export class ScaleModel extends g{constructor(t,s,e){super(),this.config=t,this.getBounds=s,this.canvasAnimation=e,this.scaleInversedSubject=new c,this.history=[],this.zoomXYRatio=0,this.xConstraints=[],this.scalePostProcessor=(o,i)=>this.xConstraints.reduce((n,h)=>h(o,n),i),this.state=u(t.scale),this.autoScaleModel=new d(this),this.offsets=this.config.components.offsets,this.addXConstraint((o,i)=>m(o,i,this.config.components.chart,this.getBounds))}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=Object.assign(Object.assign({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,s,e=!1,o=this.config.scale.zoomSensitivity){this.config.components.yAxis.type==="percent"&&this.haltAnimation();const i=this.export();y(this,i,t,o,s),this.zoomXTo(i,e)}zoomXToEnd(t,s=this.config.scale.zoomSensitivity){this.config.components.yAxis.type==="percent"&&this.haltAnimation();const e=this.export();A(this,e,s,t),this.zoomXTo(e)}haltAnimation(){var t;!((t=this.currentAnimation)===null||t===void 0)&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.doAutoScale())}zoomXTo(t,s){const e=Object.assign({},t),o=this.scalePostProcessor(e,t);this.state.lockPriceToBarRatio&&a(o,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.setAutoAndRecalculateState(o,!0),s?this.apply(o):l(this.canvasAnimation,this,o)}setXScale(t,s){const e=this.export();super.setXScale(t,s,!1);const o=this.export(),i=this.scalePostProcessor(e,o);this.state.lockPriceToBarRatio&&a(i,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.setAutoAndRecalculateState(i,!0),this.apply(i)}moveXStart(t){const s=this.export(),e=Object.assign({},s);this.haltAnimation(),f(s,t);const o=this.scalePostProcessor(e,s);this.state.auto&&this.autoScaleModel.setAutoAndRecalculateState(o,!0),this.apply(o)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const s=this.export();S(s,t),this.apply(s)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const s=this.export();this.autoScaleModel.setAutoAndRecalculateState(s,!0),x(s,this.export())||this.apply(s)}}isViewportAnimationInProgress(){const t=this.currentAnimation;return t==null?void 0:t.animationInProgress}pushToHistory(t){this.history.push(t)}popFromHistory(){return this.history.pop()}clearHistory(){this.history=[]}isDefaultXBounds(){return this.xStart===0&&this.xEnd===0}isDefaultYBounds(){return this.yStart===0&&this.yEnd===0}isScaleReady(){return!this.isDefaultXBounds()&&!this.isDefaultYBounds()}autoScale(t=!0){this.config.components.yAxis.type==="percent"?this.state.auto=!0:this.state.auto=t,t&&(this.clearHistory(),this.doAutoScale())}setLockPriceToBarRatio(t=!1){const{type:s}=this.config.components.yAxis;if(s==="percent"||s==="logarithmic"){this.state.lockPriceToBarRatio=!1;return}t&&this.recalculateZoomXYRatio(),this.state.lockPriceToBarRatio=t}recalculateZoomXYRatio(){this.zoomXYRatio=p(this.zoomX,this.zoomY)}}export class SyncedByXScaleModel extends ScaleModel{constructor(t,s,e,o){super(s,e,o),this.delegate=t,this.config=s,this.getBounds=e}doActivate(){this.addRxSubscription(this.delegate.xChanged.subscribe(()=>this.doAutoScale(this.state.auto)))}get xStart(){return this.delegate.xStart}set xStart(t){this.delegate.xStart=t}get xEnd(){return this.delegate.xEnd}set xEnd(t){this.delegate.xEnd=t}get zoomX(){return this.delegate.zoomX}set zoomX(t){this.delegate.zoomX=t}observeXChanged(){return this.delegate.xChanged}fireChanged(){this.delegate.changed.next(),this.changed.next()}}
6
+ import { Subject } from 'rxjs';
7
+ import { startViewportModelAnimation } from '../animation/viewport-model-animation';
8
+ import { cloneUnsafe } from '../utils/object.utils';
9
+ import { AutoScaleViewportSubModel } from './scaling/auto-scale.model';
10
+ import { zoomConstraint } from './scaling/constrait.functions';
11
+ import { lockedYEndViewportCalculator, ratioFromZoomXY } from './scaling/lock-ratio.model';
12
+ import { moveXStart, moveYStart } from './scaling/move-chart.functions';
13
+ import { ViewportModel, compareStates } from './scaling/viewport.model';
14
+ import { zoomXToEndViewportCalculator, zoomXToPercentViewportCalculator } from './scaling/x-zooming.functions';
15
+ export const getDefaultHighLowWithIndex = () => ({
16
+ high: Number.NEGATIVE_INFINITY,
17
+ low: Number.POSITIVE_INFINITY,
18
+ highIdx: 0,
19
+ lowIdx: 0,
20
+ });
21
+ /**
22
+ * The ScaleModel class represents the state of a chart's scale, including the current viewport, zoom level, and auto-scaling settings.
23
+ * It extends the ViewportModel class, which provides the underlying implementation for handling viewports and zoom levels.
24
+ * Controls current visible CHART viewport.
25
+ * Has additional logic:
26
+ * - auto-scale
27
+ * - locked scale
28
+ * - zooming functions
29
+ * - history
30
+ */
31
+ export class ScaleModel extends ViewportModel {
32
+ constructor(config, getBounds, canvasAnimation) {
33
+ super();
34
+ this.config = config;
35
+ this.getBounds = getBounds;
36
+ this.canvasAnimation = canvasAnimation;
37
+ this.scaleInversedSubject = new Subject();
38
+ // y-axis component needs this subject in order to halt prev animation if axis type is percent
39
+ this.beforeStartAnimationSubject = new Subject();
40
+ // TODO rework, make a new history based on units
41
+ this.history = [];
42
+ this.zoomXYRatio = 0;
43
+ this.xConstraints = [];
44
+ this.scalePostProcessor = (initialState, state) => {
45
+ // for now <s>reduceRight<s/> reduce bcs ChartModel#getZoomConstrait should be invoked first
46
+ // if we will need more complex order handling -> add some managing
47
+ return this.xConstraints.reduce((acc, cur) => cur(initialState, acc), state);
48
+ };
49
+ this.state = cloneUnsafe(config.scale);
50
+ this.autoScaleModel = new AutoScaleViewportSubModel(this);
51
+ this.offsets = this.config.components.offsets;
52
+ this.addXConstraint((initialState, state) => zoomConstraint(initialState, state, this.config.components.chart, this.getBounds));
53
+ }
54
+ /**
55
+ * The method adds a new "constraint" to the existing list of x-axis constraints for charting.
56
+ * The "constrait" is expected to be an object containing information about the constraints, such as the minimum and maximum values for the x-axis.
57
+ * @param constraint
58
+ */
59
+ addXConstraint(constraint) {
60
+ this.xConstraints = [...this.xConstraints, constraint];
61
+ }
62
+ /**
63
+ * The method updates the offsets for the scale model based on the provided "offsets" object.
64
+ * Note that the method modifies the offsets and triggers an autoscale
65
+ * @param offsets
66
+ */
67
+ updateOffsets(offsets) {
68
+ this.offsets = Object.assign(Object.assign({}, this.offsets), offsets);
69
+ this.doAutoScale(true);
70
+ }
71
+ /**
72
+ * @returns current offsets
73
+ */
74
+ getOffsets() {
75
+ return this.offsets;
76
+ }
77
+ /**
78
+ * Zooms the X axis of the chart to a specified percentage of the viewport.
79
+ * @param viewportPercent The percentage of the viewport width to zoom to.
80
+ * @param zoomIn Whether to zoom in or out.
81
+ * @param forceNoAnimation Whether to skip animation.
82
+ * @param zoomSensitivity The sensitivity of the zoom.
83
+ */
84
+ zoomXToPercent(viewportPercent, zoomIn, forceNoAnimation = false, zoomSensitivity = this.config.scale.zoomSensitivity) {
85
+ this.beforeStartAnimationSubject.next();
86
+ const state = this.export();
87
+ zoomXToPercentViewportCalculator(this, state, viewportPercent, zoomSensitivity, zoomIn);
88
+ this.zoomXTo(state, forceNoAnimation);
89
+ }
90
+ /**
91
+ * Zooms the X axis of the chart relativly to the end of the data range.
92
+ * @param zoomIn - If true, the chart will be zoomed in. If false, the chart will be zoomed out.
93
+ * @param zoomSensitivity - The sensitivity of the zoom. Default value is taken from the configuration object.
94
+ */
95
+ zoomXToEnd(zoomIn, zoomSensitivity = this.config.scale.zoomSensitivity) {
96
+ this.beforeStartAnimationSubject.next();
97
+ const state = this.export();
98
+ zoomXToEndViewportCalculator(this, state, zoomSensitivity, zoomIn);
99
+ this.zoomXTo(state);
100
+ }
101
+ haltAnimation() {
102
+ var _a;
103
+ if ((_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.animationInProgress) {
104
+ this.currentAnimation.finishAnimation();
105
+ this.doAutoScale();
106
+ }
107
+ }
108
+ zoomXTo(state, forceNoAnimation) {
109
+ const initialStateCopy = Object.assign({}, state);
110
+ const constrainedState = this.scalePostProcessor(initialStateCopy, state);
111
+ if (this.state.lockPriceToBarRatio) {
112
+ lockedYEndViewportCalculator(constrainedState, this.zoomXYRatio);
113
+ }
114
+ if (this.state.auto) {
115
+ this.autoScaleModel.setAutoAndRecalculateState(constrainedState, true);
116
+ }
117
+ if (forceNoAnimation) {
118
+ this.apply(constrainedState);
119
+ }
120
+ else {
121
+ startViewportModelAnimation(this.canvasAnimation, this, constrainedState);
122
+ }
123
+ }
124
+ /**
125
+ * Moves the viewport to exactly xStart..xEnd place.
126
+ * (you need to fire DRAW event after this)
127
+ * @param xStart - viewport start in units
128
+ * @param xEnd - viewport end in units
129
+ * @param fireChanged
130
+ * @param forceNoAutoScale - force NOT apply auto-scaling (for lazy loading)
131
+ */
132
+ setXScale(xStart, xEnd) {
133
+ const initialState = this.export();
134
+ super.setXScale(xStart, xEnd, false);
135
+ const state = this.export();
136
+ const constraitedState = this.scalePostProcessor(initialState, state);
137
+ if (this.state.lockPriceToBarRatio) {
138
+ lockedYEndViewportCalculator(constraitedState, this.zoomXYRatio);
139
+ }
140
+ if (this.state.auto) {
141
+ this.autoScaleModel.setAutoAndRecalculateState(constraitedState, true);
142
+ }
143
+ this.apply(constraitedState);
144
+ }
145
+ /**
146
+ * Moves both xStart and xEnd without changing the viewport width (zoom).
147
+ * WILL CHANGE the Y axis if scale.auto=true.
148
+ * @param xStart - starting point in units
149
+ */
150
+ moveXStart(xStart) {
151
+ const state = this.export();
152
+ const initialStateCopy = Object.assign({}, state);
153
+ // always stop the animations
154
+ this.haltAnimation();
155
+ moveXStart(state, xStart);
156
+ // there we need only candles constrait
157
+ const constraitedState = this.scalePostProcessor(initialStateCopy, state);
158
+ if (this.state.auto) {
159
+ this.autoScaleModel.setAutoAndRecalculateState(constraitedState, true);
160
+ }
161
+ this.apply(constraitedState);
162
+ }
163
+ /**
164
+ * Moves both yStart and yEnd without changing the viewport height (zoom).
165
+ * Will not move viewport if scale.auto=true
166
+ * @param yStart - starting point in units
167
+ */
168
+ moveYStart(yStart) {
169
+ this.haltAnimation();
170
+ if (this.state.auto) {
171
+ return;
172
+ }
173
+ else {
174
+ const state = this.export();
175
+ moveYStart(state, yStart);
176
+ this.apply(state);
177
+ }
178
+ }
179
+ /**
180
+ * Automatically scales the chart to fit the data range.
181
+ * @param forceApply - If true, the chart will be forcefully auto-scaled even if animation is in progress.
182
+ */
183
+ doAutoScale(forceApply = false) {
184
+ // dont auto-scale if animation, otherwise - forced or config
185
+ if ((!this.isViewportAnimationInProgress() && this.state.auto) || forceApply) {
186
+ const state = this.export();
187
+ this.autoScaleModel.setAutoAndRecalculateState(state, true);
188
+ if (!compareStates(state, this.export())) {
189
+ this.apply(state);
190
+ }
191
+ }
192
+ }
193
+ /**
194
+ * Checks if viewport animation is currently in progress.
195
+ * @returns returns true if viewport animation is in progress, false otherwise.
196
+ */
197
+ isViewportAnimationInProgress() {
198
+ const animation = this.currentAnimation;
199
+ return animation === null || animation === void 0 ? void 0 : animation.animationInProgress;
200
+ }
201
+ /**
202
+ * Adds an item to the scale history.
203
+ * @param item - The item to add to the history.
204
+ */
205
+ pushToHistory(item) {
206
+ this.history.push(item);
207
+ }
208
+ /**
209
+ * Removes the most recent item from the scale history and returns it.
210
+ * @returns - The most recent item from the history, or undefined if the history is empty.
211
+ */
212
+ popFromHistory() {
213
+ return this.history.pop();
214
+ }
215
+ /**
216
+ * Clears the scale history.
217
+ */
218
+ clearHistory() {
219
+ this.history = [];
220
+ }
221
+ /**
222
+ * Checks if the X axis bounds are the default values.
223
+ * @returns if false - it means there are candles and it's possible to do scaling and add drawings
224
+ */
225
+ isDefaultXBounds() {
226
+ return this.xStart === 0 && this.xEnd === 0;
227
+ }
228
+ /**
229
+ * Checks if the Y axis bounds are the default values.
230
+ * @returns if false - it means there are candles and it's possible to do scaling and add drawings
231
+ */
232
+ isDefaultYBounds() {
233
+ return this.yStart === 0 && this.yEnd === 0;
234
+ }
235
+ /**
236
+ * Checks if the scale is ready to be used.
237
+ * @returns - Returns true if the scale is ready, false otherwise.
238
+ */
239
+ isScaleReady() {
240
+ return !this.isDefaultXBounds() && !this.isDefaultYBounds();
241
+ }
242
+ /**
243
+ * Enables or disables auto-scaling of the chart.
244
+ * @param auto - If true, the chart will be automatically scaled. If false, auto-scaling will be disabled.
245
+ */
246
+ autoScale(auto = true) {
247
+ // TODO rework, make this a separate feature toggle, describe in docs; this should be a business-logic level
248
+ if (this.config.components.yAxis.type === 'percent') {
249
+ this.state.auto = true;
250
+ }
251
+ else {
252
+ this.state.auto = auto;
253
+ }
254
+ if (auto) {
255
+ this.clearHistory();
256
+ this.doAutoScale();
257
+ }
258
+ }
259
+ /**
260
+ * Sets whether the price-to-bar ratio should be locked or not.
261
+ * @param value - If true, the price-to-bar ratio will be locked. If false, it will not be locked.
262
+ */
263
+ setLockPriceToBarRatio(value = false) {
264
+ const { type } = this.config.components.yAxis;
265
+ // TODO rework, why such logic? same as above, if we have business-logic like this one => make it separate code
266
+ if (type === 'percent' || type === 'logarithmic') {
267
+ this.state.lockPriceToBarRatio = false;
268
+ return;
269
+ }
270
+ if (value) {
271
+ this.recalculateZoomXYRatio();
272
+ }
273
+ this.state.lockPriceToBarRatio = value;
274
+ }
275
+ /**
276
+ * Recalculates the zoom X/Y ratio based on the current zoom levels.
277
+ */
278
+ recalculateZoomXYRatio() {
279
+ this.zoomXYRatio = ratioFromZoomXY(this.zoomX, this.zoomY);
280
+ }
281
+ }
282
+ /**
283
+ * The SyncedByXScaleModel class extends the ScaleModel class and adds support for synchronization with other ScaleModel instance, so both instances maintain the same X-axis bounds.
284
+ * This is useful for scenarios where multiple charts need to display the same X-axis data, but with different Y-axis scales.
285
+ */
286
+ export class SyncedByXScaleModel extends ScaleModel {
287
+ constructor(delegate, config, getBounds, canvasAnimation) {
288
+ super(config, getBounds, canvasAnimation);
289
+ this.delegate = delegate;
290
+ this.config = config;
291
+ this.getBounds = getBounds;
292
+ }
293
+ doActivate() {
294
+ this.addRxSubscription(this.delegate.xChanged.subscribe(() => this.doAutoScale(this.state.auto)));
295
+ }
296
+ get xStart() {
297
+ return this.delegate.xStart;
298
+ }
299
+ set xStart(value) {
300
+ this.delegate.xStart = value;
301
+ }
302
+ get xEnd() {
303
+ return this.delegate.xEnd;
304
+ }
305
+ set xEnd(value) {
306
+ this.delegate.xEnd = value;
307
+ }
308
+ get zoomX() {
309
+ return this.delegate.zoomX;
310
+ }
311
+ set zoomX(value) {
312
+ this.delegate.zoomX = value;
313
+ }
314
+ observeXChanged() {
315
+ return this.delegate.xChanged;
316
+ }
317
+ fireChanged() {
318
+ this.delegate.changed.next();
319
+ this.changed.next();
320
+ }
321
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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
  */
@@ -1,6 +1,102 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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 AutoScaleViewportSubModel{constructor(o,e){this.delegate=o,this.auto=!0,this.highLowPostPorcessor={},this.highLowProviders=e!=null?e:{}}setHighLowProvider(o,e){this.highLowProviders[o]=e}deleteHighLowProvider(o){delete this.highLowProviders[o]}setHighLowPostProcessor(o,e){this.highLowPostPorcessor[o]=e}setAutoAndRecalculateState(o,e){this.auto=e,e&&autoScaleYViewportTransformer(this.delegate,o,Object.values(this.highLowProviders),Object.values(this.highLowPostPorcessor))}}export const autoScaleYViewportTransformer=(i,o,e,t)=>{const h=e.filter(r=>r.isHighLowActive()).map(r=>r.calculateHighLow(o)),l=mergeHighLow(h),s=t.reduce((r,c)=>c(r),l);o.yStart=s.low,o.yEnd=s.high,o.zoomY=i.calculateZoomY(o.yStart,o.yEnd)};export function mergeHighLow(i){if(i.length===0)return getDefaultHighLow();let o=i[0].high,e=i[0].low;return i.forEach(t=>{isFinite(t.high)&&t.high>=o&&(o=t.high),isFinite(t.low)&&t.low<=e&&(e=t.low)}),{low:e,high:o}}export const getDefaultHighLow=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER});
6
+ /**
7
+ * Auxiliary sub-model to apply X,Y auto-scaling feature.
8
+ * Transforms the original ViewportModel.
9
+ * @doc-tags auto-scale,viewport,scaling
10
+ */
11
+ export class AutoScaleViewportSubModel {
12
+ constructor(delegate, highLowProviders) {
13
+ this.delegate = delegate;
14
+ // local state, used for pane X dragging
15
+ this.auto = true;
16
+ // post processors can apply some changes to high low before applying it
17
+ this.highLowPostPorcessor = {};
18
+ this.highLowProviders = highLowProviders !== null && highLowProviders !== void 0 ? highLowProviders : {};
19
+ }
20
+ /**
21
+ * Sets a HighLowProvider for a given name.
22
+ * @param {string} name - The name of the HighLowProvider.
23
+ * @param {HighLowProvider} provider - The HighLowProvider to be set.
24
+ */
25
+ setHighLowProvider(name, provider) {
26
+ this.highLowProviders[name] = provider;
27
+ }
28
+ /**
29
+ * Deletes a high-low provider from the list of high-low providers.
30
+ * @param {string} name - The name of the high-low provider to be deleted.
31
+ */
32
+ deleteHighLowProvider(name) {
33
+ delete this.highLowProviders[name];
34
+ }
35
+ /**
36
+ * Sets a HighLowPostProcessor for a given name.
37
+ *
38
+ * @param {string} name - The name of the HighLowPostProcessor.
39
+ * @param {HighLowPostProcessor} processor - The HighLowPostProcessor to be set.
40
+ * @returns {void}
41
+ */
42
+ setHighLowPostProcessor(name, processor) {
43
+ this.highLowPostPorcessor[name] = processor;
44
+ }
45
+ /**
46
+ * Sets the auto and recalculates the state of the viewport model.
47
+ * @param {ViewportModelState} state - The state of the viewport model.
48
+ * @param {boolean} auto - The auto value to set.
49
+ * @returns {void}
50
+ */
51
+ setAutoAndRecalculateState(state, auto) {
52
+ this.auto = auto;
53
+ if (auto) {
54
+ autoScaleYViewportTransformer(this.delegate, state, Object.values(this.highLowProviders), Object.values(this.highLowPostPorcessor));
55
+ }
56
+ }
57
+ }
58
+ /**
59
+ * Y auto-scale viewport transformer. Calculates highLow for all chart visuals and recalculates the Y scale.
60
+ * @param vm
61
+ * @param state
62
+ * @param highLowProviders
63
+ * @param highLowPostProcessors
64
+ */
65
+ export const autoScaleYViewportTransformer = (vm, state, highLowProviders, highLowPostProcessors) => {
66
+ const highLowList = highLowProviders
67
+ .filter(provider => provider.isHighLowActive())
68
+ .map(provider => provider.calculateHighLow(state));
69
+ const highLow = mergeHighLow(highLowList);
70
+ const postProcessedHighLow = highLowPostProcessors.reduce((prevResult, postProcessor) => postProcessor(prevResult), highLow);
71
+ state.yStart = postProcessedHighLow.low;
72
+ state.yEnd = postProcessedHighLow.high;
73
+ state.zoomY = vm.calculateZoomY(state.yStart, state.yEnd);
74
+ };
75
+ /**
76
+ * Merges an array of HighLow objects into a single HighLow object.
77
+ * @param {HighLow[]} input - The array of HighLow objects to be merged.
78
+ * @returns {HighLow} - The merged HighLow object.
79
+
80
+ */
81
+ export function mergeHighLow(input) {
82
+ if (input.length === 0) {
83
+ return getDefaultHighLow();
84
+ }
85
+ let max = input[0].high;
86
+ let min = input[0].low;
87
+ input.forEach(highLow => {
88
+ if (isFinite(highLow.high) && highLow.high >= max) {
89
+ max = highLow.high;
90
+ }
91
+ if (isFinite(highLow.low) && highLow.low <= min) {
92
+ min = highLow.low;
93
+ }
94
+ });
95
+ return { low: min, high: max };
96
+ }
97
+ export const getDefaultHighLow = () => {
98
+ return {
99
+ high: Number.MIN_SAFE_INTEGER,
100
+ low: Number.MAX_SAFE_INTEGER,
101
+ };
102
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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
  */
@@ -1,6 +1,66 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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{at as S}from"../../utils/array.utils";import{calculateZoom as E,pixelsToUnits as w}from"./viewport.model";export const candleEdgesConstrait=(d,s,r,l)=>{var t,o,i,a;const n=Object.assign({},d),e=(o=(t=s[r])===null||t===void 0?void 0:t.startUnit)!==null&&o!==void 0?o:0,c=(a=(i=S(-r,s))===null||i===void 0?void 0:i.startUnit)!==null&&a!==void 0?a:0;let m=d.xStart,x=d.xEnd;return n.xStart>=c&&(m=c,x=x-(n.xStart-c)),n.xEnd<e&&(m=e-w(l.width,n.zoomX),x=e),n.xStart=m,n.xEnd=x,n},zoomConstraint=(d,s,r,l)=>{const t=Object.assign({},s),o=l(),i=t.xEnd-t.xStart,a=i<r.minCandles,n=o.width/r.minWidth,e=i>n;if(o.width>0){if(e)return t.xStart=t.xEnd-n,t.zoomX=E(t.xEnd-t.xStart,o.width),t;if(a)return t.xEnd=d.xEnd,t.xStart=t.xEnd-r.minCandles,t.zoomX=E(t.xEnd-t.xStart,o.width),t}return t};
6
+ import { at } from '../../utils/array.utils';
7
+ import { calculateZoom, pixelsToUnits } from './viewport.model';
8
+ /**
9
+ * Return constraited state that handled zooming and moving chart near first/last candles
10
+ * this and other constraits that works with state should mutate and return state
11
+ * @param initialState
12
+ * @param state
13
+ * @param visualCandlesCoordinates
14
+ * @param candleLimit
15
+ * @param bounds
16
+ * @returns
17
+ * @doc-tags viewport,zoom,scaling
18
+ */
19
+ export const candleEdgesConstrait = (state, visualCandlesCoordinates, candleLimit, bounds) => {
20
+ var _a, _b, _c, _d;
21
+ const newState = Object.assign({}, state);
22
+ const leftConstraitCoordinate = (_b = (_a = visualCandlesCoordinates[candleLimit]) === null || _a === void 0 ? void 0 : _a.startUnit) !== null && _b !== void 0 ? _b : 0;
23
+ const rightConstraintCoordinate = (_d = (_c = at(-candleLimit, visualCandlesCoordinates)) === null || _c === void 0 ? void 0 : _c.startUnit) !== null && _d !== void 0 ? _d : 0;
24
+ let normalizedXStart = state.xStart;
25
+ let normalizedXEnd = state.xEnd;
26
+ if (newState.xStart >= rightConstraintCoordinate) {
27
+ normalizedXStart = rightConstraintCoordinate;
28
+ normalizedXEnd = normalizedXEnd - (newState.xStart - rightConstraintCoordinate);
29
+ }
30
+ if (newState.xEnd < leftConstraitCoordinate) {
31
+ normalizedXStart = leftConstraitCoordinate - pixelsToUnits(bounds.width, newState.zoomX);
32
+ normalizedXEnd = leftConstraitCoordinate;
33
+ }
34
+ newState.xStart = normalizedXStart;
35
+ newState.xEnd = normalizedXEnd;
36
+ return newState;
37
+ };
38
+ /**
39
+ * This function limits minimum and maximum chart viewport dependening on visible x-units
40
+ * @returns
41
+ * @doc-tags viewport,zoom,scaling
42
+ */
43
+ export const zoomConstraint = (initialState, state, chartConfig, boundsProvider) => {
44
+ const newState = Object.assign({}, state);
45
+ const bounds = boundsProvider();
46
+ // 1 - is an average candle width: newXEnd - newXStart = avg candles amount in the viewport
47
+ const avgCandlesInViewport = newState.xEnd - newState.xStart;
48
+ const minViewportReached = avgCandlesInViewport < chartConfig.minCandles;
49
+ const maxCandlesInViewport = bounds.width / chartConfig.minWidth;
50
+ const maxViewportReached = avgCandlesInViewport > maxCandlesInViewport;
51
+ // rules work only if chart is shown
52
+ if (bounds.width > 0) {
53
+ if (maxViewportReached) {
54
+ newState.xStart = newState.xEnd - maxCandlesInViewport;
55
+ newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
56
+ return newState;
57
+ }
58
+ if (minViewportReached) {
59
+ newState.xEnd = initialState.xEnd;
60
+ newState.xStart = newState.xEnd - chartConfig.minCandles;
61
+ newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
62
+ return newState;
63
+ }
64
+ }
65
+ return newState;
66
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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
  */
@@ -1,6 +1,22 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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 const ratioFromZoomXY=(o,n)=>o/n,zoomXToZoomY=(o,n)=>o/n,zoomYToZoomX=(o,n)=>o*n,lockedYEndViewportCalculator=(o,n)=>{const Y=o.zoomY;o.zoomY=zoomXToZoomY(o.zoomX,n);const c=o.zoomY/Y,m=o.yEnd-o.yStart,r=m*c-m;o.yEnd=o.yEnd+r};
6
+ export const ratioFromZoomXY = (zoomX, zoomY) => zoomX / zoomY;
7
+ export const zoomXToZoomY = (zoomX, ratio) => zoomX / ratio;
8
+ export const zoomYToZoomX = (zoomY, ratio) => zoomY * ratio;
9
+ /**
10
+ * Locks the zoomY with zoomX and moves yEnd according to ratio changes.
11
+ * @param state
12
+ * @param zoomXYRatio
13
+ */
14
+ export const lockedYEndViewportCalculator = (state, zoomXYRatio) => {
15
+ const prevZoomY = state.zoomY;
16
+ state.zoomY = zoomXToZoomY(state.zoomX, zoomXYRatio);
17
+ const zoomYMult = state.zoomY / prevZoomY;
18
+ const lastYHeight = state.yEnd - state.yStart;
19
+ const newYHeight = lastYHeight * zoomYMult;
20
+ const delta = newYHeight - lastYHeight;
21
+ state.yEnd = state.yEnd + delta;
22
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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
  */
@@ -1,6 +1,27 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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 const moveXStart=(n,o)=>{const r=n.xStart;n.xStart=o,n.xEnd=n.xEnd+(o-r)},moveYStart=(n,o)=>{const r=n.yStart;n.yStart=o,n.yEnd=n.yEnd+(o-r)};
6
+ /**
7
+ * Moves both xStart and xEnd without changing the viewport width (zoomX).
8
+ * @param state
9
+ * @param xStart - left starting point in units
10
+ * @doc-tags scaling,viewport
11
+ */
12
+ export const moveXStart = (state, xStart) => {
13
+ const prev = state.xStart;
14
+ state.xStart = xStart;
15
+ state.xEnd = state.xEnd + (xStart - prev);
16
+ };
17
+ /**
18
+ * Moves both yStart and yEnd without changing the viewport height (zoomY).
19
+ * @param state
20
+ * @param yStart - starting point in units
21
+ * @doc-tags scaling,viewport
22
+ */
23
+ export const moveYStart = (state, yStart) => {
24
+ const prev = state.yStart;
25
+ state.yStart = yStart;
26
+ state.yEnd = state.yEnd + (yStart - prev);
27
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2002 - 2023 Devexperts LLC
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
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
  */
@@ -19,8 +19,8 @@ export type Timestamp = Unit;
19
19
  export type Percent = Unit;
20
20
  export type LogValue = Unit;
21
21
  export type YUnit = Price | Percent | LogValue;
22
- export declare const unitToPercent: (value: Unit, baseLine: Unit) => Percent;
23
- export declare const percentToUnit: (percent: Percent, baseLine: Unit) => Unit;
22
+ export declare const unitToPercent: (value: Unit, baseline: Unit) => Percent;
23
+ export declare const percentToUnit: (percent: Percent, baseline: Unit) => Unit;
24
24
  export declare const calcLogValue: (value: Price) => LogValue;
25
25
  export declare const logValueToUnit: (logValue: LogValue) => number;
26
26
  /**