@devexperts/dxcharts-lite 1.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 (364) hide show
  1. package/LICENSE +151 -0
  2. package/README.md +184 -0
  3. package/dist/chart/animation/canvas-animation.d.ts +96 -0
  4. package/dist/chart/animation/canvas-animation.js +6 -0
  5. package/dist/chart/animation/types/animation.d.ts +35 -0
  6. package/dist/chart/animation/types/animation.js +6 -0
  7. package/dist/chart/animation/types/color-alpha-animation.d.ts +43 -0
  8. package/dist/chart/animation/types/color-alpha-animation.js +6 -0
  9. package/dist/chart/animation/types/color-transition-animation.d.ts +59 -0
  10. package/dist/chart/animation/types/color-transition-animation.js +6 -0
  11. package/dist/chart/animation/types/viewport-movement-animation.d.ts +44 -0
  12. package/dist/chart/animation/types/viewport-movement-animation.js +6 -0
  13. package/dist/chart/animation/viewport-model-animation.d.ts +15 -0
  14. package/dist/chart/animation/viewport-model-animation.js +6 -0
  15. package/dist/chart/bootstrap.d.ts +266 -0
  16. package/dist/chart/bootstrap.js +6 -0
  17. package/dist/chart/canvas/canvas-bounds-container.d.ts +347 -0
  18. package/dist/chart/canvas/canvas-bounds-container.js +6 -0
  19. package/dist/chart/canvas/canvas-chart-html.d.ts +7 -0
  20. package/dist/chart/canvas/canvas-chart-html.js +23 -0
  21. package/dist/chart/canvas/chart-elements.d.ts +22 -0
  22. package/dist/chart/canvas/chart-elements.js +6 -0
  23. package/dist/chart/canvas/cursor.handler.d.ts +71 -0
  24. package/dist/chart/canvas/cursor.handler.js +6 -0
  25. package/dist/chart/canvas/layout-creator.d.ts +20 -0
  26. package/dist/chart/canvas/layout-creator.js +6 -0
  27. package/dist/chart/canvas/y-axis-bounds.container.d.ts +54 -0
  28. package/dist/chart/canvas/y-axis-bounds.container.js +6 -0
  29. package/dist/chart/chart-container.d.ts +18 -0
  30. package/dist/chart/chart-container.js +6 -0
  31. package/dist/chart/chart.config.d.ts +774 -0
  32. package/dist/chart/chart.config.js +6 -0
  33. package/dist/chart/components/chart/basic-scale.d.ts +22 -0
  34. package/dist/chart/components/chart/basic-scale.js +6 -0
  35. package/dist/chart/components/chart/candle-transformer.functions.d.ts +11 -0
  36. package/dist/chart/components/chart/candle-transformer.functions.js +6 -0
  37. package/dist/chart/components/chart/candle-width-calculator.functions.d.ts +7 -0
  38. package/dist/chart/components/chart/candle-width-calculator.functions.js +6 -0
  39. package/dist/chart/components/chart/candle.functions.d.ts +19 -0
  40. package/dist/chart/components/chart/candle.functions.js +6 -0
  41. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +88 -0
  42. package/dist/chart/components/chart/chart-area-pan.handler.js +6 -0
  43. package/dist/chart/components/chart/chart-base.model.d.ts +55 -0
  44. package/dist/chart/components/chart/chart-base.model.js +6 -0
  45. package/dist/chart/components/chart/chart.component.d.ts +251 -0
  46. package/dist/chart/components/chart/chart.component.js +6 -0
  47. package/dist/chart/components/chart/chart.model.d.ts +448 -0
  48. package/dist/chart/components/chart/chart.model.js +6 -0
  49. package/dist/chart/components/chart/data-series.high-low-provider.d.ts +25 -0
  50. package/dist/chart/components/chart/data-series.high-low-provider.js +6 -0
  51. package/dist/chart/components/chart/fake-candles.d.ts +18 -0
  52. package/dist/chart/components/chart/fake-candles.js +6 -0
  53. package/dist/chart/components/chart/price.formatter.d.ts +12 -0
  54. package/dist/chart/components/chart/price.formatter.js +6 -0
  55. package/dist/chart/components/chart/secondary-chart-colors-pool.d.ts +43 -0
  56. package/dist/chart/components/chart/secondary-chart-colors-pool.js +6 -0
  57. package/dist/chart/components/cross_tool/cross-tool.component.d.ts +69 -0
  58. package/dist/chart/components/cross_tool/cross-tool.component.js +6 -0
  59. package/dist/chart/components/cross_tool/cross-tool.drawer.d.ts +32 -0
  60. package/dist/chart/components/cross_tool/cross-tool.drawer.js +6 -0
  61. package/dist/chart/components/cross_tool/cross-tool.model.d.ts +63 -0
  62. package/dist/chart/components/cross_tool/cross-tool.model.js +6 -0
  63. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.d.ts +44 -0
  64. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +6 -0
  65. package/dist/chart/components/cross_tool/types/none.drawer.d.ts +9 -0
  66. package/dist/chart/components/cross_tool/types/none.drawer.js +6 -0
  67. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.d.ts +27 -0
  68. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +6 -0
  69. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.d.ts +23 -0
  70. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +6 -0
  71. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +46 -0
  72. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +6 -0
  73. package/dist/chart/components/events/events-hit-test.drawer.d.ts +34 -0
  74. package/dist/chart/components/events/events-hit-test.drawer.js +6 -0
  75. package/dist/chart/components/events/events.component.d.ts +45 -0
  76. package/dist/chart/components/events/events.component.js +6 -0
  77. package/dist/chart/components/events/events.drawer.d.ts +87 -0
  78. package/dist/chart/components/events/events.drawer.js +6 -0
  79. package/dist/chart/components/events/events.model.d.ts +64 -0
  80. package/dist/chart/components/events/events.model.js +6 -0
  81. package/dist/chart/components/grid/grid.component.d.ts +34 -0
  82. package/dist/chart/components/grid/grid.component.js +6 -0
  83. package/dist/chart/components/grid/grid.drawer.d.ts +55 -0
  84. package/dist/chart/components/grid/grid.drawer.js +6 -0
  85. package/dist/chart/components/high_low/high-low.component.d.ts +17 -0
  86. package/dist/chart/components/high_low/high-low.component.js +6 -0
  87. package/dist/chart/components/high_low/high-low.drawer.d.ts +69 -0
  88. package/dist/chart/components/high_low/high-low.drawer.js +6 -0
  89. package/dist/chart/components/highlights/highlights.component.d.ts +42 -0
  90. package/dist/chart/components/highlights/highlights.component.js +6 -0
  91. package/dist/chart/components/highlights/highlights.drawer.d.ts +56 -0
  92. package/dist/chart/components/highlights/highlights.drawer.js +6 -0
  93. package/dist/chart/components/highlights/highlights.model.d.ts +66 -0
  94. package/dist/chart/components/highlights/highlights.model.js +6 -0
  95. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +63 -0
  96. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +6 -0
  97. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +36 -0
  98. package/dist/chart/components/navigation_map/navigation-map-move.handler.js +6 -0
  99. package/dist/chart/components/navigation_map/navigation-map.component.d.ts +52 -0
  100. package/dist/chart/components/navigation_map/navigation-map.component.js +6 -0
  101. package/dist/chart/components/navigation_map/navigation-map.drawer.d.ts +96 -0
  102. package/dist/chart/components/navigation_map/navigation-map.drawer.js +6 -0
  103. package/dist/chart/components/navigation_map/navigation-map.model.d.ts +25 -0
  104. package/dist/chart/components/navigation_map/navigation-map.model.js +7 -0
  105. package/dist/chart/components/pan/chart-pan.component.d.ts +52 -0
  106. package/dist/chart/components/pan/chart-pan.component.js +6 -0
  107. package/dist/chart/components/pane/extent/y-extent-component.d.ts +91 -0
  108. package/dist/chart/components/pane/extent/y-extent-component.js +6 -0
  109. package/dist/chart/components/pane/pane-hit-test.controller.d.ts +39 -0
  110. package/dist/chart/components/pane/pane-hit-test.controller.js +6 -0
  111. package/dist/chart/components/pane/pane-manager.component.d.ts +87 -0
  112. package/dist/chart/components/pane/pane-manager.component.js +6 -0
  113. package/dist/chart/components/pane/pane.component.d.ts +193 -0
  114. package/dist/chart/components/pane/pane.component.js +6 -0
  115. package/dist/chart/components/resizer/bar-resizer.component.d.ts +72 -0
  116. package/dist/chart/components/resizer/bar-resizer.component.js +6 -0
  117. package/dist/chart/components/resizer/bar-resizer.drawer.d.ts +34 -0
  118. package/dist/chart/components/resizer/bar-resizer.drawer.js +6 -0
  119. package/dist/chart/components/snapshot/snapshot.component.d.ts +31 -0
  120. package/dist/chart/components/snapshot/snapshot.component.js +6 -0
  121. package/dist/chart/components/volumes/separate-volumes.component.d.ts +45 -0
  122. package/dist/chart/components/volumes/separate-volumes.component.js +6 -0
  123. package/dist/chart/components/volumes/volume-color-resolvers.functions.d.ts +11 -0
  124. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +6 -0
  125. package/dist/chart/components/volumes/volumes.component.d.ts +59 -0
  126. package/dist/chart/components/volumes/volumes.component.js +6 -0
  127. package/dist/chart/components/volumes/volumes.drawer.d.ts +71 -0
  128. package/dist/chart/components/volumes/volumes.drawer.js +6 -0
  129. package/dist/chart/components/volumes/volumes.formatter.d.ts +6 -0
  130. package/dist/chart/components/volumes/volumes.formatter.js +6 -0
  131. package/dist/chart/components/volumes/volumes.model.d.ts +32 -0
  132. package/dist/chart/components/volumes/volumes.model.js +6 -0
  133. package/dist/chart/components/watermark/water-mark.component.d.ts +75 -0
  134. package/dist/chart/components/watermark/water-mark.component.js +6 -0
  135. package/dist/chart/components/watermark/water-mark.drawer.d.ts +68 -0
  136. package/dist/chart/components/watermark/water-mark.drawer.js +6 -0
  137. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.d.ts +25 -0
  138. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +6 -0
  139. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.d.ts +55 -0
  140. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +6 -0
  141. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.d.ts +23 -0
  142. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +6 -0
  143. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.d.ts +28 -0
  144. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +6 -0
  145. package/dist/chart/components/x_axis/time/parser/time-formats.model.d.ts +33 -0
  146. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +6 -0
  147. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +62 -0
  148. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +6 -0
  149. package/dist/chart/components/x_axis/time/x-axis-weights.generator.d.ts +33 -0
  150. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +6 -0
  151. package/dist/chart/components/x_axis/x-axis-draw.functions.d.ts +17 -0
  152. package/dist/chart/components/x_axis/x-axis-draw.functions.js +6 -0
  153. package/dist/chart/components/x_axis/x-axis-labels.drawer.d.ts +42 -0
  154. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +6 -0
  155. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +141 -0
  156. package/dist/chart/components/x_axis/x-axis-labels.generator.js +6 -0
  157. package/dist/chart/components/x_axis/x-axis-labels.model.d.ts +39 -0
  158. package/dist/chart/components/x_axis/x-axis-labels.model.js +6 -0
  159. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +38 -0
  160. package/dist/chart/components/x_axis/x-axis-scale.handler.js +6 -0
  161. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.d.ts +54 -0
  162. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +6 -0
  163. package/dist/chart/components/x_axis/x-axis.component.d.ts +73 -0
  164. package/dist/chart/components/x_axis/x-axis.component.js +6 -0
  165. package/dist/chart/components/y_axis/label-color.functions.d.ts +18 -0
  166. package/dist/chart/components/y_axis/label-color.functions.js +6 -0
  167. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +22 -0
  168. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +6 -0
  169. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +33 -0
  170. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +6 -0
  171. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.d.ts +27 -0
  172. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +6 -0
  173. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +35 -0
  174. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +6 -0
  175. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +23 -0
  176. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +6 -0
  177. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +159 -0
  178. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +6 -0
  179. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +23 -0
  180. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +6 -0
  181. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +31 -0
  182. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +6 -0
  183. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +70 -0
  184. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +6 -0
  185. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +32 -0
  186. package/dist/chart/components/y_axis/y-axis-scale.handler.js +6 -0
  187. package/dist/chart/components/y_axis/y-axis.component.d.ts +158 -0
  188. package/dist/chart/components/y_axis/y-axis.component.js +6 -0
  189. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +72 -0
  190. package/dist/chart/components/y_axis/y-axis.drawer.js +6 -0
  191. package/dist/chart/components/y_axis/y-axis.model.d.ts +33 -0
  192. package/dist/chart/components/y_axis/y-axis.model.js +6 -0
  193. package/dist/chart/drawers/chart-background.drawer.d.ts +19 -0
  194. package/dist/chart/drawers/chart-background.drawer.js +6 -0
  195. package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +13 -0
  196. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +6 -0
  197. package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +14 -0
  198. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +6 -0
  199. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +15 -0
  200. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +6 -0
  201. package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +25 -0
  202. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +6 -0
  203. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +13 -0
  204. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +6 -0
  205. package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +13 -0
  206. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +6 -0
  207. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +13 -0
  208. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +6 -0
  209. package/dist/chart/drawers/clear-canvas.drawer.d.ts +16 -0
  210. package/dist/chart/drawers/clear-canvas.drawer.js +6 -0
  211. package/dist/chart/drawers/composite.drawer.d.ts +25 -0
  212. package/dist/chart/drawers/composite.drawer.js +6 -0
  213. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +23 -0
  214. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +6 -0
  215. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +17 -0
  216. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +6 -0
  217. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.d.ts +8 -0
  218. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +6 -0
  219. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +21 -0
  220. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +6 -0
  221. package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +11 -0
  222. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +6 -0
  223. package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +12 -0
  224. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +6 -0
  225. package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +11 -0
  226. package/dist/chart/drawers/data-series-drawers/points.drawer.js +6 -0
  227. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.d.ts +9 -0
  228. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +6 -0
  229. package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +13 -0
  230. package/dist/chart/drawers/data-series-drawers/text.drawer.js +6 -0
  231. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +12 -0
  232. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +6 -0
  233. package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +12 -0
  234. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +6 -0
  235. package/dist/chart/drawers/data-series.drawer.d.ts +39 -0
  236. package/dist/chart/drawers/data-series.drawer.js +6 -0
  237. package/dist/chart/drawers/drawing-manager.d.ts +61 -0
  238. package/dist/chart/drawers/drawing-manager.js +6 -0
  239. package/dist/chart/drawers/ht-data-series.drawer.d.ts +22 -0
  240. package/dist/chart/drawers/ht-data-series.drawer.js +6 -0
  241. package/dist/chart/events/event-bus.d.ts +48 -0
  242. package/dist/chart/events/event-bus.js +6 -0
  243. package/dist/chart/events/events.d.ts +8 -0
  244. package/dist/chart/events/events.js +6 -0
  245. package/dist/chart/inputhandlers/candle-tap.handler.d.ts +27 -0
  246. package/dist/chart/inputhandlers/candle-tap.handler.js +6 -0
  247. package/dist/chart/inputhandlers/chart-resize.handler.d.ts +67 -0
  248. package/dist/chart/inputhandlers/chart-resize.handler.js +6 -0
  249. package/dist/chart/inputhandlers/cross-event-producer.component.d.ts +44 -0
  250. package/dist/chart/inputhandlers/cross-event-producer.component.js +6 -0
  251. package/dist/chart/inputhandlers/hover-producer.component.d.ts +140 -0
  252. package/dist/chart/inputhandlers/hover-producer.component.js +6 -0
  253. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +54 -0
  254. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +6 -0
  255. package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +311 -0
  256. package/dist/chart/inputlisteners/canvas-input-listener.component.js +6 -0
  257. package/dist/chart/model/baseline.model.d.ts +54 -0
  258. package/dist/chart/model/baseline.model.js +6 -0
  259. package/dist/chart/model/bounds.model.d.ts +16 -0
  260. package/dist/chart/model/bounds.model.js +6 -0
  261. package/dist/chart/model/candle-hover.d.ts +35 -0
  262. package/dist/chart/model/candle-hover.js +6 -0
  263. package/dist/chart/model/candle-series-high-low.provider.d.ts +20 -0
  264. package/dist/chart/model/candle-series-high-low.provider.js +6 -0
  265. package/dist/chart/model/candle-series.model.d.ts +150 -0
  266. package/dist/chart/model/candle-series.model.js +6 -0
  267. package/dist/chart/model/candle.model.d.ts +46 -0
  268. package/dist/chart/model/candle.model.js +6 -0
  269. package/dist/chart/model/canvas.model.d.ts +131 -0
  270. package/dist/chart/model/canvas.model.js +6 -0
  271. package/dist/chart/model/chart-base-element.d.ts +103 -0
  272. package/dist/chart/model/chart-base-element.js +6 -0
  273. package/dist/chart/model/compare-series-hover.d.ts +22 -0
  274. package/dist/chart/model/compare-series-hover.js +6 -0
  275. package/dist/chart/model/data-series-view.d.ts +58 -0
  276. package/dist/chart/model/data-series-view.js +6 -0
  277. package/dist/chart/model/data-series.config.d.ts +31 -0
  278. package/dist/chart/model/data-series.config.js +6 -0
  279. package/dist/chart/model/data-series.model.d.ts +172 -0
  280. package/dist/chart/model/data-series.model.js +6 -0
  281. package/dist/chart/model/date-time.formatter.d.ts +23 -0
  282. package/dist/chart/model/date-time.formatter.js +6 -0
  283. package/dist/chart/model/hit-test-canvas.model.d.ts +128 -0
  284. package/dist/chart/model/hit-test-canvas.model.js +6 -0
  285. package/dist/chart/model/main-candle-series.model.d.ts +27 -0
  286. package/dist/chart/model/main-candle-series.model.js +6 -0
  287. package/dist/chart/model/scale.model.d.ts +180 -0
  288. package/dist/chart/model/scale.model.js +6 -0
  289. package/dist/chart/model/scaling/auto-scale.model.d.ts +79 -0
  290. package/dist/chart/model/scaling/auto-scale.model.js +6 -0
  291. package/dist/chart/model/scaling/constrait.functions.d.ts +43 -0
  292. package/dist/chart/model/scaling/constrait.functions.js +6 -0
  293. package/dist/chart/model/scaling/lock-ratio.model.d.ts +16 -0
  294. package/dist/chart/model/scaling/lock-ratio.model.js +6 -0
  295. package/dist/chart/model/scaling/move-chart.functions.d.ts +20 -0
  296. package/dist/chart/model/scaling/move-chart.functions.js +6 -0
  297. package/dist/chart/model/scaling/viewport.model.d.ts +223 -0
  298. package/dist/chart/model/scaling/viewport.model.js +6 -0
  299. package/dist/chart/model/scaling/x-zooming.functions.d.ts +26 -0
  300. package/dist/chart/model/scaling/x-zooming.functions.js +6 -0
  301. package/dist/chart/model/time-zone.model.d.ts +65 -0
  302. package/dist/chart/model/time-zone.model.js +6 -0
  303. package/dist/chart/model/visual-candle.d.ts +106 -0
  304. package/dist/chart/model/visual-candle.js +6 -0
  305. package/dist/chart/utils/__tests__/array.utils.test.d.ts +6 -0
  306. package/dist/chart/utils/__tests__/array.utils.test.js +6 -0
  307. package/dist/chart/utils/__tests__/object.utils.test.d.ts +6 -0
  308. package/dist/chart/utils/__tests__/object.utils.test.js +6 -0
  309. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.d.ts +6 -0
  310. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +6 -0
  311. package/dist/chart/utils/array.utils.d.ts +101 -0
  312. package/dist/chart/utils/array.utils.js +6 -0
  313. package/dist/chart/utils/auto-period-detector.utils.d.ts +16 -0
  314. package/dist/chart/utils/auto-period-detector.utils.js +6 -0
  315. package/dist/chart/utils/candles-generator-ts.utils.d.ts +41 -0
  316. package/dist/chart/utils/candles-generator-ts.utils.js +6 -0
  317. package/dist/chart/utils/candles-generator.utils.d.ts +13 -0
  318. package/dist/chart/utils/candles-generator.utils.js +6 -0
  319. package/dist/chart/utils/candles.utils.d.ts +8 -0
  320. package/dist/chart/utils/candles.utils.js +6 -0
  321. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.d.ts +68 -0
  322. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +6 -0
  323. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.d.ts +20 -0
  324. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +6 -0
  325. package/dist/chart/utils/canvas/canvas-text-functions.utils.d.ts +76 -0
  326. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +6 -0
  327. package/dist/chart/utils/color.utils.d.ts +6 -0
  328. package/dist/chart/utils/color.utils.js +6 -0
  329. package/dist/chart/utils/device/browser.utils.d.ts +9 -0
  330. package/dist/chart/utils/device/browser.utils.js +6 -0
  331. package/dist/chart/utils/device/device-detector.utils.d.ts +12 -0
  332. package/dist/chart/utils/device/device-detector.utils.js +6 -0
  333. package/dist/chart/utils/device/device-pixel-ratio.utils.d.ts +16 -0
  334. package/dist/chart/utils/device/device-pixel-ratio.utils.js +6 -0
  335. package/dist/chart/utils/device/touchpad.utils.d.ts +30 -0
  336. package/dist/chart/utils/device/touchpad.utils.js +6 -0
  337. package/dist/chart/utils/dom.utils.d.ts +13 -0
  338. package/dist/chart/utils/dom.utils.js +6 -0
  339. package/dist/chart/utils/function.utils.d.ts +13 -0
  340. package/dist/chart/utils/function.utils.js +6 -0
  341. package/dist/chart/utils/math.utils.d.ts +40 -0
  342. package/dist/chart/utils/math.utils.js +6 -0
  343. package/dist/chart/utils/merge.utils.d.ts +27 -0
  344. package/dist/chart/utils/merge.utils.js +6 -0
  345. package/dist/chart/utils/object.utils.d.ts +46 -0
  346. package/dist/chart/utils/object.utils.js +6 -0
  347. package/dist/chart/utils/perfomance/animation-frame-cache.utils.d.ts +53 -0
  348. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +6 -0
  349. package/dist/chart/utils/perfomance/debounce.utils.d.ts +6 -0
  350. package/dist/chart/utils/perfomance/debounce.utils.js +6 -0
  351. package/dist/chart/utils/perfomance/memoize.utils.d.ts +21 -0
  352. package/dist/chart/utils/perfomance/memoize.utils.js +6 -0
  353. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.d.ts +15 -0
  354. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +6 -0
  355. package/dist/chart/utils/perfomance/throttle.utils.d.ts +15 -0
  356. package/dist/chart/utils/perfomance/throttle.utils.js +6 -0
  357. package/dist/chart/utils/price-increments.utils.d.ts +44 -0
  358. package/dist/chart/utils/price-increments.utils.js +6 -0
  359. package/dist/chart/utils/uuid.utils.d.ts +6 -0
  360. package/dist/chart/utils/uuid.utils.js +6 -0
  361. package/dist/dxchart.min.js +26 -0
  362. package/dist/index.d.ts +9 -0
  363. package/dist/index.js +6 -0
  364. package/package.json +103 -0
@@ -0,0 +1,448 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import { Observable, Subject } from 'rxjs';
7
+ import { PriceAxisType } from '../labels_generator/numeric-axis-labels.generator';
8
+ import { ChartBaseElement } from '../../model/chart-base-element';
9
+ import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
10
+ import { BarType, ChartConfigComponentsOffsets, FullChartConfig } from '../../chart.config';
11
+ import { CanvasModel } from '../../model/canvas.model';
12
+ import EventBus from '../../events/event-bus';
13
+ import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
14
+ import { CandleSeriesColors, CandleSeriesModel, PartialCandleSeriesColors } from '../../model/candle-series.model';
15
+ import { Candle } from '../../model/candle.model';
16
+ import { DataSeriesType } from '../../model/data-series.config';
17
+ import { ScaleModel } from '../../model/scale.model';
18
+ import { Index, Pixel, Price, Timestamp, Unit } from '../../model/scaling/viewport.model';
19
+ import VisualCandle from '../../model/visual-candle';
20
+ import { PaneManager } from '../pane/pane-manager.component';
21
+ import { PaneComponent } from '../pane/pane.component';
22
+ import { LabelGroup } from '../y_axis/price_labels/y-axis-labels.model';
23
+ import { ChartBaseModel } from './chart-base.model';
24
+ import { CandleSeries, ChartInstrument, PartialCandle } from './chart.component';
25
+ import { SecondaryChartColorsPool } from './secondary-chart-colors-pool';
26
+ export type VisualCandleCalculator = (candle: Candle, options: {
27
+ width: Unit;
28
+ x: Unit;
29
+ prevCandle?: Candle;
30
+ activeCandle?: Candle;
31
+ }) => VisualCandle;
32
+ export type LastCandleLabelHandler = (labels: LabelGroup, candleSeries: CandleSeriesModel) => void;
33
+ export type CandleWidthCalculator = (candle: Candle) => Unit;
34
+ export declare class ChartModel extends ChartBaseElement {
35
+ chartBaseModel: ChartBaseModel<'candle'>;
36
+ private paneManager;
37
+ bus: EventBus;
38
+ private canvasModel;
39
+ config: FullChartConfig;
40
+ scaleModel: ScaleModel;
41
+ formatterFactory: (format: string) => (timestamp: number) => string;
42
+ mainCanvasParent: Element;
43
+ private canvasBoundsContainer;
44
+ chartResizeHandler: ChartResizeHandler;
45
+ private prevChartWidth;
46
+ private prevYWidth;
47
+ candleSeries: Array<CandleSeriesModel>;
48
+ get mainCandleSeries(): CandleSeriesModel;
49
+ get secondaryCandleSeries(): Array<CandleSeriesModel>;
50
+ readonly nextCandleTimeStampSubject: Subject<void>;
51
+ readonly axisTypeSetSubject: Subject<PriceAxisType>;
52
+ readonly chartTypeChanged: Subject<BarType>;
53
+ readonly mainInstrumentChangedSubject: Subject<ChartInstrument>;
54
+ readonly scaleInversedSubject: Subject<void>;
55
+ readonly offsetsChanged: Subject<void>;
56
+ private candlesTransformersByChartType;
57
+ lastCandleLabelsByChartType: Partial<Record<BarType, LastCandleLabelHandler>>;
58
+ private candleWidthByChartType;
59
+ secondaryChartColors: SecondaryChartColorsPool;
60
+ lastTimeFrame: TimeFrameRange;
61
+ basicScaleViewportTransformer: (visualCandleSource: VisualCandle[]) => void;
62
+ timeFrameViewportTransformer: (timeframe: [number, number], zoomIn?: boolean | null) => void;
63
+ private FAKE_CANDLES_DEFAULT;
64
+ readonly pane: PaneComponent;
65
+ constructor(chartBaseModel: ChartBaseModel<'candle'>, paneManager: PaneManager, bus: EventBus, canvasModel: CanvasModel, config: FullChartConfig, scaleModel: ScaleModel, formatterFactory: (format: string) => (timestamp: number) => string, mainCanvasParent: Element, canvasBoundsContainer: CanvasBoundsContainer, chartResizeHandler: ChartResizeHandler);
66
+ get candlesUpdatedSubject(): Subject<void>;
67
+ get candlesSetSubject(): Subject<void>;
68
+ get candlesRemovedSubject(): Subject<void>;
69
+ get candlesPrependSubject(): Subject<import("./chart-base.model").PrependedCandlesData>;
70
+ /**
71
+ * Method that activates the canvas bounds container and subscribes to its bounds changes and bar resizer changes.
72
+ * @protected
73
+ * @returns {void}
74
+ */
75
+ protected doActivate(): void;
76
+ /**
77
+ * This method keeps the same candle width on chart canvas resize, so chart candles aren't squeezed when canvas becomes smaller
78
+ * If chart width was changed after Yaxis width changed, scale will be adjusted to right/left, and visually nothing will be changed
79
+ * @private
80
+ * @param nextCB - Next chart bounds
81
+ */
82
+ private handleChartResize;
83
+ /**
84
+ * Sets the main candle series with the provided candles and instrument.
85
+ * @param {Array<Candle>} candles - The array of candles to set as the main candle series.
86
+ * @param {ChartInstrument} instrument - The instrument to set for the main candle series.
87
+ * @returns {void}
88
+ */
89
+ setMainCandleSeries(candles: Array<Candle>, instrument: ChartInstrument): void;
90
+ /**
91
+ * Sets a secondary candle series based on the provided candles array and instrument.
92
+ * @param {Array<Candle>} candles - An array of candles to set as the secondary candle series.
93
+ * @param {ChartInstrument} instrument - The instrument to set as the secondary candle series. Defaults to the main candle series instrument.
94
+ * @param {boolean} recalculateAndUpdate - A boolean indicating whether to recalculate and update the candle series. Defaults to true.
95
+ * @returns {CandleSeriesModel | undefined} - The newly created secondary candle series model or undefined if it could not be created.
96
+ */
97
+ setSecondaryCandleSeries(candles: Array<PartialCandle>, instrument?: ChartInstrument, recalculateAndUpdate?: boolean): CandleSeriesModel | undefined;
98
+ /**
99
+ * Shouldn't be called outside chart-core, use ChartComponent#setAllSeries instead
100
+ * @param mainSeries
101
+ * @param secondarySeries
102
+ */
103
+ setAllSeries(mainSeries: CandleSeries, secondarySeries?: CandleSeries[]): void;
104
+ /**
105
+ * This function checks if the autoScaleOnCandles state is true. If it is, it calls the doBasicScale() function and then calls the autoScale() function with a true parameter.
106
+ * @function
107
+ * @name autoScaleOnCandles
108
+ * @memberof ClassName
109
+ * @returns {void}
110
+ */
111
+ autoScaleOnCandles(): void;
112
+ /**
113
+ * Applies the basic scale viewport transformer to the visual points of the main candle series and fires a draw event.
114
+ */
115
+ doBasicScale(): void;
116
+ /**
117
+ * Changes the time frame scale to the previous one and redraws the chart.
118
+ * @param {boolean | null} zoomIn - If true, zooms in the chart, if false, zooms out the chart, if null, does not zoom.
119
+ * @returns {void}
120
+ */
121
+ doPreviousTimeFrameScale(zoomIn?: boolean | null): void;
122
+ /**
123
+ * Saves the current timeframe by getting the start and end timestamps of the visual candles in the main candle series.
124
+ * If there are no visual candles, the last timeframe is not updated.
125
+ */
126
+ rememberCurrentTimeframe(): void;
127
+ /**
128
+ * Shouldn't be called outside chart-core, use ChartComponent#updateAllSeries instead
129
+ * @param mainSeries
130
+ * @param secondarySeries
131
+ */
132
+ updateAllSeries(mainSeries: CandleSeries, secondarySeries?: CandleSeries[]): void;
133
+ /**
134
+ * Removes all data points from the main candle series that are newer than the given timestamp.
135
+ * Can be useful for data replay.
136
+ * @param startTimestamp
137
+ */
138
+ removeDataFrom(startTimestamp: Timestamp): void;
139
+ /**
140
+ * Creates a secondary candle series model for a given instrument.
141
+ * @param {ChartInstrument} instrument - The instrument for which the secondary candle series model is created.
142
+ * @returns {CandleSeriesModel | undefined} - The created secondary candle series model or undefined if it cannot be created.
143
+ */
144
+ createSecondaryCandleSeriesModel(instrument: ChartInstrument): CandleSeriesModel | undefined;
145
+ /**
146
+ * Creates a new CandleSeriesModel object and adds it to the chart.
147
+ * @param {ChartInstrument} instrument - The instrument to be displayed in the chart.
148
+ * @param {CandleSeriesColors} [colors] - Optional colors for the candle series.
149
+ * @returns {CandleSeriesModel} - The newly created CandleSeriesModel object.
150
+ */
151
+ private createCandleSeriesModel;
152
+ /**
153
+ * Removes a secondary candle series from the chart and returns its colors.
154
+ * @param {CandleSeriesModel} series - The candle series to be removed.
155
+ * @returns {CandleSeriesColors | undefined} - The colors of the removed series or undefined if the series was not found.
156
+ */
157
+ removeSecondaryCandleSeries(series: CandleSeriesModel): CandleSeriesColors | undefined;
158
+ /**
159
+ * Adjusts secondary series to present them nicely with main series:
160
+ * - fill gaps in secondarySeries with fake candles OHLC of same price (=close price)
161
+ * - do not add any candles which are not in main series
162
+ * @param mainSeries - main series
163
+ * @param secondarySeries - secondarySeries to adjust
164
+ */
165
+ private secondarySeriesAdjustments;
166
+ /**
167
+ * Updates the configuration of the secondary candle series with the provided colors and instrument symbol.
168
+ * @param {PartialCandleSeriesColors} config - The partial configuration object containing the colors to update.
169
+ * @param {string} instrumentSymbol - The symbol of the instrument to update the colors for.
170
+ * @param {DataSeriesType} chartType - The type of chart to update the series to.
171
+ * @returns {void}
172
+ */
173
+ updateSecondaryCandleSeriesConfig(config: PartialCandleSeriesColors, instrumentSymbol: string, chartType: DataSeriesType): void;
174
+ /**
175
+ * Sets the autoScale property of the scaleModel object.
176
+ * @param {boolean} auto - The value to be set for the autoScale property.
177
+ * @returns {void}
178
+ */
179
+ setAutoScale(auto: boolean): void;
180
+ /**
181
+ * Returns the effective width of the Y axis.
182
+ *
183
+ * @function
184
+ * @name getEffectiveYAxisWidth
185
+ * @returns {number} The effective width of the Y axis.
186
+ */
187
+ getEffectiveYAxisWidth(): number;
188
+ /**
189
+ * Returns the effective width of the chart.
190
+ *
191
+ * @function
192
+ * @returns {number} The effective width of the chart.
193
+ */
194
+ getEffectiveChartWidth(): number;
195
+ /**
196
+ * Returns the effective height of the chart.
197
+ *
198
+ * @returns {number} The effective height of the chart.
199
+ */
200
+ getEffectiveChartHeight(): number;
201
+ /**
202
+ * Updates the offsets of the chart components and redraws the chart.
203
+ * @param {Partial<ChartConfigComponentsOffsets>} offsets - The new offsets to be applied to the chart components.
204
+ * @returns {void}
205
+ */
206
+ setOffsets(offsets: Partial<ChartConfigComponentsOffsets>): void;
207
+ /**
208
+ * Returns the offsets of the chart components.
209
+ * @returns {ChartConfigComponentsOffsets} The offsets of the chart components.
210
+ */
211
+ getOffsets(): ChartConfigComponentsOffsets;
212
+ /**
213
+ * Converts "y" in pixels to: price / percent / other value.
214
+ * @param y - source value in pixels
215
+ */
216
+ fromY(y: Pixel): Unit;
217
+ /**
218
+ * Converts "y" in pixels to price
219
+ * @param y - source value in pixels
220
+ * @param candleSeriesModel - (optional) candle series
221
+ */
222
+ priceFromY(y: Pixel, candleSeriesModel?: CandleSeriesModel): Price;
223
+ /**
224
+ * Converts "x" in pixels to timestamp
225
+ * @param x - source value in pixels
226
+ */
227
+ fromX(x: Pixel): Timestamp;
228
+ toY: (value: Price) => Pixel;
229
+ /**
230
+ * Converts index to pixel.
231
+ * @param idx - index of candle
232
+ */
233
+ toX(idx: Index): Pixel;
234
+ /**
235
+ * Returns the baseline of the main candle series.
236
+ * @returns {Unit} The baseline of the main candle series.
237
+ */
238
+ getBaseLine(): Unit;
239
+ /**
240
+ * Transforms X coordinate (relative to canvas element) to Candle object.
241
+ * If extrapolate = false, then it takes leftmost/rightmost existing candle
242
+ */
243
+ candleFromX(x: Pixel, extrapolate?: boolean, selectedCandleSeries?: CandleSeriesModel): Candle;
244
+ /**
245
+ * Returns a candle object based on the provided unit, which is searched for in the visualPoints array of the selectedCandleSeries.
246
+ * If extrapolate is true and the unit is outside the visualPoints array, a fake candle is returned.
247
+ * If extrapolate is false and the unit is outside the visualPoints array, null is returned.
248
+ * If the unit is within the visualPoints array, the corresponding candle object is returned.
249
+ *
250
+ * @param {Unit} unit - The unit to search for in the visualPoints array.
251
+ * @param {boolean} extrapolate - Whether to extrapolate a fake candle if the unit is outside the visualPoints array.
252
+ * @param {CandleSeriesModel} selectedCandleSeries - The candle series to search in. Defaults to the mainCandleSeries.
253
+ * @returns {Candle} - The corresponding candle object, or null if extrapolate is false and the unit is outside the visualPoints array.
254
+ */
255
+ candleFromUnit(unit: Unit, extrapolate?: boolean, selectedCandleSeries?: CandleSeriesModel): Candle;
256
+ /**
257
+ * For given timestamp finds the closest candle in dataset.
258
+ * @param timestamp
259
+ */
260
+ candleFromTimestamp(timestamp: Timestamp, shouldExtrapolate?: boolean): VisualCandle;
261
+ /**
262
+ * For given index returns the closest visual candle, or fake candle with correct X coordinate.
263
+ * @param idx - index of candle
264
+ */
265
+ candleFromIdx(idx: Index): VisualCandle;
266
+ /**
267
+ * Check whether model is ready for drawing.
268
+ */
269
+ isReady(): boolean;
270
+ /**
271
+ * You can use this method to determine logic of visual candle transformation for specified chart type.
272
+ * @param chartType
273
+ * @param calculator
274
+ */
275
+ registerCandlesTransformer(chartType: BarType, calculator: VisualCandleCalculator): void;
276
+ /**
277
+ * You can use this method to determine chart width calculation for specified chart type.
278
+ * @param chartType
279
+ * @param calculator
280
+ */
281
+ registerCandlesWidthCalculator(chartType: BarType, calculator: CandleWidthCalculator): void;
282
+ /**
283
+ * You can use this method to modify labels for last candle.
284
+ * @param chartType
285
+ * @param handler
286
+ */
287
+ registerLastCandleLabelHandler(chartType: BarType, handler: LastCandleLabelHandler): void;
288
+ /**
289
+ * Checks if the main candle series has visual points.
290
+ * @returns {boolean} Returns true if the main candle series has visual points, otherwise false.
291
+ */
292
+ hasCandles(): boolean;
293
+ /**
294
+ * Returns a visual candle object from the main candle series based on the provided index.
295
+ * @param {Index} idx - The index of the visual candle to retrieve.
296
+ * @returns {VisualCandle|undefined} - The visual candle object or undefined if it doesn't exist.
297
+ */
298
+ getVisualCandle(idx: Index): VisualCandle | undefined;
299
+ /**
300
+ * Returns the index of the first data point in the main candle series.
301
+ *
302
+ * @returns {number} The index of the first data point in the main candle series.
303
+ */
304
+ getFirstIdx(): number;
305
+ /**
306
+ * Returns the last index of the data in the mainCandleSeries.
307
+ *
308
+ * @returns {number} - The last index of the data in the mainCandleSeries.
309
+ */
310
+ getLastIdx(): number;
311
+ /**
312
+ * Returns the timestamp of the first candle in the viewport dataset
313
+ * @param dataBased - if false will return timestamp which matches first viewport point even if candle is not available
314
+ * @returns {Timestamp} The timestamp of the first candle
315
+ */
316
+ getFirstTimestamp(dataBased?: boolean): Timestamp;
317
+ /**
318
+ * Returns the timestamp of the last candle in the viewport candle array
319
+ * @param dataBased - if false will return timestamp which matches first viewport point even if candle is not available
320
+ * @returns {Timestamp} The timestamp of the last candle
321
+ */
322
+ getLastTimestamp(dataBased?: boolean): Timestamp;
323
+ /**
324
+ * Sets the timestamp range of the chart by setting the x-axis scale.
325
+ * @param {Timestamp} start - The start timestamp of the range.
326
+ * @param {Timestamp} end - The end timestamp of the range.
327
+ * @returns {void}
328
+ */
329
+ setTimestampRange(start: Timestamp, end: Timestamp): void;
330
+ /**
331
+ * Returns the last candle of the main candle series.
332
+ * @returns {Candle | undefined} The last candle of the main candle series or undefined if the series is empty.
333
+ */
334
+ getLastCandle(): Candle | undefined;
335
+ /**
336
+ * Returns the last visual candle of the main candle series.
337
+ * @returns {VisualCandle | undefined} The last visual candle of the main candle series or undefined if the series is empty.
338
+
339
+ */
340
+ getLastVisualCandle(): VisualCandle | undefined;
341
+ /**
342
+ * Calculates the maximum number of candles that can fit in the chart width based on the minimum candle width
343
+ * @returns {number} - The maximum number of candles that can fit in the chart width
344
+ */
345
+ getMaxCandlesFitLength(): number;
346
+ /**
347
+ * Returns an array of CandleSeriesModel objects representing the secondary candle series.
348
+ * @returns {Array<CandleSeriesModel>} An array of CandleSeriesModel objects representing the secondary candle series.
349
+ */
350
+ getSecondarySeries(): Array<CandleSeriesModel>;
351
+ /**
352
+ * Checks if a given symbol matches the symbol of a given CandleSeriesModel's instrument.
353
+ * @param {CandleSeriesModel} series - The CandleSeriesModel to check.
354
+ * @param {ChartInstrument['symbol']} symbol - The symbol to compare with the instrument's symbol.
355
+ * @returns {boolean} - Returns true if the symbol matches the instrument's symbol, false otherwise.
356
+ */
357
+ private isSeriesInstrument;
358
+ /**
359
+ * Returns an array of CandleSeriesModel objects that match the provided symbol.
360
+ *
361
+ * @param {string} symbol - The symbol to search for.
362
+ * @returns {CandleSeriesModel[]} - An array of CandleSeriesModel objects that match the provided symbol.
363
+ */
364
+ findSeriesBySymbol(symbol: ChartInstrument['symbol']): CandleSeriesModel[];
365
+ /**
366
+ * Finds a secondary candle series by symbol
367
+ *
368
+ * @param {string} symbol - The symbol of the chart instrument
369
+ * @returns {CandleSeriesModel | undefined} - The secondary candle series or undefined if not found
370
+ */
371
+ findSecondarySeriesBySymbol(symbol: ChartInstrument['symbol']): CandleSeriesModel | undefined;
372
+ /**
373
+ * Reindexes candles based on a given series.
374
+ * @private
375
+ * @param {Array<Candle>} baseSeries - The base series to search for candles.
376
+ * @param {Array<Candle>} series - The series to reindex.
377
+ * @returns {Array<Candle>} - The reindexed series.
378
+ */
379
+ private reindexCandlesBasedOnSeries;
380
+ getPeriod(): number;
381
+ /**
382
+ * Checks if a given candle is within the viewport.
383
+ * @param {number} idx - The index of the candle to check.
384
+ * @returns {boolean} - True if the candle is within the viewport, false otherwise.
385
+ */
386
+ isCandleInViewport(idx: number): boolean;
387
+ /**
388
+ * Updates candles in series. Default is main series.
389
+ * Any number of candles may be provided - they would be matched by their index and updated.
390
+ * @param candles - any list of new (updated) candles
391
+ * @param instrument - name of instrument to update
392
+ */
393
+ updateCandles(candles: Array<Candle>, instrumentSymbol?: string): void;
394
+ /**
395
+ * Triggers when candles set or updated
396
+ */
397
+ observeCandlesChanged(): Observable<void>;
398
+ /**
399
+ * Returns an array of Candle objects representing the data points of the main candle series.
400
+ * @returns {Array<Candle>} An array of Candle objects.
401
+ */
402
+ getCandles(): Array<Candle>;
403
+ /***
404
+ * Returns candles array which consists of real candles and fake candles if from and to can't be satisfied with real ones.
405
+ * @param from - if not specified set to first candle timestamp
406
+ * @param to - if not specified set to last candle timestamp + right offset
407
+ */
408
+ getCandlesWithFake(from?: number, to?: number): Candle[];
409
+ /**
410
+ * Returns the number of candles in the main candle series.
411
+ *
412
+ * @returns {number} The number of candles in the main candle series.
413
+ */
414
+ getCandlesCount(): number;
415
+ /**
416
+ * Returns the number of candles with the right offset.
417
+ * @returns {number} - The number of candles with the right offset.
418
+ */
419
+ getCandlesCountWithRightOffset(): number;
420
+ /**
421
+ * Clears the data of all candle series in the chart.
422
+ */
423
+ clearData(): void;
424
+ /**
425
+ * Adds new candles array to the existing one at the start, mostly used in lazy loading
426
+ * @param target - initial candles array
427
+ * @param prependUpdate - additional candles array, which will be added to the target array
428
+ */
429
+ prependCandles(target: Candle[], prependUpdate: Candle[]): UpdateCandlesResult;
430
+ /**
431
+ * Adds new candle to the chart
432
+ * @param candle - new candle
433
+ * @param instrument - name of the instrument to update
434
+ */
435
+ addLastCandle(candle: Candle, instrumentSymbol?: string): void;
436
+ /**
437
+ * Updates last candle value
438
+ * @param candle - updated candle
439
+ * @param instrument - name of the instrument to update
440
+ */
441
+ updateLastCandle(candle: Candle, instrumentSymbol?: string): void;
442
+ }
443
+ export interface UpdateCandlesResult {
444
+ prepended: number;
445
+ appended?: number;
446
+ candles: Candle[];
447
+ }
448
+ export type TimeFrameRange = [number, number];
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import{Subject as p,merge as U}from"rxjs";import{distinctUntilChanged as A}from"rxjs/operators";import{ChartBaseElement as D}from"../../model/chart-base-element";import{CHART_UUID as C,CanvasElement as f,areBoundsChanged as W}from"../../canvas/canvas-bounds-container";import{getDefaultConfig as j}from"../../chart.config";import{MIN_SUPPORTED_CANVAS_SIZE as M}from"../../model/canvas.model";import{CandleSeriesModel as _}from"../../model/candle-series.model";import{copyCandle as O}from"../../model/candle.model";import{MainCandleSeriesModel as V}from"../../model/main-candle-series.model";import{candleEdgesConstrait as L}from"../../model/scaling/constrait.functions";import{pixelsToUnits as b}from"../../model/scaling/viewport.model";import{merge as X}from"../../utils/merge.utils";import{createBasicScaleViewportTransformer as Y,createTimeFrameViewportTransformer as R}from"./basic-scale";import{calculateCandleWidth as N}from"./candle-width-calculator.functions";import{deleteCandlesIndex as H,prepareCandle as S,reindexCandles as P}from"./candle.functions";import{ChartInstrument as k}from"./chart.component";import{fakeCandle as g}from"./fake-candles";import{SecondaryChartColorsPool as z}from"./secondary-chart-colors-pool";import{binarySearch as T,lastOf as w}from"../../utils/array.utils";import{searchCandleIndex as v}from"../../utils/candles.utils";import{floor as Z,round as K}from"../../utils/math.utils";export class ChartModel extends D{get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(e=>e!==this.mainCandleSeries)}constructor(e,t,s,i,a,n,d,l,r,o){super(),this.chartBaseModel=e,this.paneManager=t,this.bus=s,this.canvasModel=i,this.config=a,this.scaleModel=n,this.formatterFactory=d,this.mainCanvasParent=l,this.canvasBoundsContainer=r,this.chartResizeHandler=o,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.nextCandleTimeStampSubject=new p,this.axisTypeSetSubject=new p,this.chartTypeChanged=new p,this.mainInstrumentChangedSubject=new p,this.scaleInversedSubject=new p,this.offsetsChanged=new p,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new z(this.config);const c=new V(this.chartBaseModel,this.paneManager.paneComponents[C].mainYExtentComponent,this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scaleModel,new k,this.candlesTransformersByChartType,this.candleWidthByChartType,Object.assign({},this.config.colors));c.config.type=this.config.components.chart.type,this.candleSeries.push(c),n.addXConstraint((u,m)=>L(m,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,n.getBounds())),this.basicScaleViewportTransformer=Y(n),this.timeFrameViewportTransformer=R(n,this),this.pane=this.paneManager.paneComponents[C]}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(f.PANE_UUID(C)).pipe(A(W)).subscribe(e=>{this.handleChartResize(e)}))}handleChartResize(e){if(e.width>M.width&&e.height>M.height){const t=this.getEffectiveChartWidth(),s=this.getEffectiveYAxisWidth();if(this.prevChartWidth===0){this.scaleModel.isViewportValid()?this.scaleModel.recalculateZoom():this.doBasicScale(),this.prevChartWidth=t,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const a=b(s-this.prevYWidth,this.scaleModel.zoomX);this.scaleModel.setXScale(this.scaleModel.xStart,this.scaleModel.xEnd-a)}else this.scaleModel.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=t;return}const i=b(t-this.prevChartWidth,this.scaleModel.zoomX);this.scaleModel.setXScale(this.scaleModel.xStart-i,this.scaleModel.xEnd),this.scaleModel.recalculateZoomY(),this.prevYWidth=s,this.prevChartWidth=t}}setMainCandleSeries(e,t){this.mainCandleSeries.instrument=t,this.setAllSeries({candles:e,instrument:t},this.getSecondarySeries().map(s=>{const i=s.dataPoints;return H(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(e,t=this.mainCandleSeries.instrument,s=!0){const i=y(e.map(S)),a=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),n=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,a),l=this.secondaryCandleSeries.some(r=>r.instrument.symbol===t.symbol)?this.secondaryCandleSeries.find(r=>r.instrument.symbol===t.symbol):this.createSecondaryCandleSeriesModel(t);if(l)return l.dataPoints=n,s&&(this.scaleModel.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.bus.fireDraw([this.canvasModel.canvasId])),l}setAllSeries(e,t=[]){var s;this.mainCandleSeries.instrument=(s=e.instrument)!==null&&s!==void 0?s:this.mainCandleSeries.instrument,e.instrument&&this.mainInstrumentChangedSubject.next(e.instrument),this.rememberCurrentTimeframe();const i=y(e.candles.map(S));this.mainCandleSeries.clearData(),P(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(a=>t.filter(n=>{var d;return((d=n.instrument)===null||d===void 0?void 0:d.symbol)===a.instrument.symbol}).length===0).forEach(a=>this.removeSecondaryCandleSeries(a)),t.map(a=>this.setSecondaryCandleSeries(a.candles,a.instrument,!1)),this.candleSeries.forEach(a=>{a.recalculateDataViewportIndexes(),a.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.scaleModel.doAutoScale(),this.candlesSetSubject.next(),this.bus.fireDraw([this.canvasModel.canvasId])}autoScaleOnCandles(){this.scaleModel.state.autoScaleOnCandles&&(this.doBasicScale(),this.scaleModel.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(e=null){this.timeFrameViewportTransformer(this.lastTimeFrame,e),this.scaleModel.state.autoScaleOnCandles&&this.scaleModel.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scaleModel.toX(this.scaleModel.xStart),!0).timestamp,this.candleFromX(this.scaleModel.toX(this.scaleModel.xEnd),!0).timestamp])}updateAllSeries(e,t=[]){e=Object.assign({},e),e.instrument||(e.instrument=this.mainCandleSeries.instrument);const s=[e,...t];if(!this.candleSeries.every(l=>s.find(r=>{var o;return((o=r.instrument)===null||o===void 0?void 0:o.symbol)===l.instrument.symbol}))||t.length!==this.secondaryCandleSeries.length){console.error("All series update failed. Instruments for series are different.");return}const i=y(e.candles.map(S)),a=I(this.mainCandleSeries.dataPoints,i),n=a.candles;P(n),this.mainCandleSeries.dataPoints=n,t.map(l=>{var r,o,c,u;const m=y(l.candles.map(S)),x=I((u=(c=this.findSecondarySeriesBySymbol((o=(r=l.instrument)===null||r===void 0?void 0:r.symbol)!==null&&o!==void 0?o:""))===null||c===void 0?void 0:c.dataPoints)!==null&&u!==void 0?u:[],m).candles;return this.setSecondaryCandleSeries(x,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints(),l.recalculateDataViewportIndexes()});const d=this.chartBaseModel.mainVisualPoints.slice(0,a.prepended).reduce((l,r)=>l+r.width,0);this.scaleModel.moveXStart(this.scaleModel.xStart+d),this.candlesPrependSubject.next({prependedCandlesWidth:d,preparedCandles:i}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(e){Object.values(this.paneManager.paneComponents).forEach(t=>{t.dataSeries.forEach(s=>{const i=T(s.dataPoints,e,n=>n.timestamp),a=i.exact?i.index:i.index+1;s.dataPoints=s.dataPoints.slice(0,a)})}),this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}createSecondaryCandleSeriesModel(e){const t=Object.assign(Object.assign({},this.config.colors),this.secondaryChartColors.takeColorFromPool(e.symbol));return this.createCandleSeriesModel(e,t)}createCandleSeriesModel(e,t){const s=new _(this.paneManager.paneComponents[C].mainYExtentComponent,this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scaleModel,e,this.candlesTransformersByChartType,this.candleWidthByChartType,t);return s.config.type="line",this.candleSeries.push(s),s}removeSecondaryCandleSeries(e){return this.secondaryChartColors.addColorToPool(e.instrument.symbol),this.candleSeries=this.candleSeries.filter(t=>t!==e),e.deactivate(),this.paneManager.paneComponents[C].removeDataSeries(e),this.scaleModel.doAutoScale(),e.colors}secondarySeriesAdjustments(e,t){const s=[];return e.forEach(i=>{var a;const n=(a=i.idx)!==null&&a!==void 0?a:0,d=t[n];if(d)s.push(d);else{let l=B(t,n,-1);if(l||(l=B(t,n,1)),l){const r=O(l,n,!0);s.push(r)}}}),s}updateSecondaryCandleSeriesConfig(e,t,s){const i=X(e,j().colors);this.secondaryChartColors.updateColorConfig(t,i);const a=this.findSecondarySeriesBySymbol(t);a&&(a.config.type=s,a.updateCandleSeriesColors(i),this.bus.fireDraw([this.canvasModel.canvasId])),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(e){this.scaleModel.autoScale(e)}getEffectiveYAxisWidth(){return this.canvasBoundsContainer.getBounds(f.PANE_UUID_Y_AXIS(C)).width}getEffectiveChartWidth(){return this.canvasBoundsContainer.getBounds(f.PANE_UUID(C)).width}getEffectiveChartHeight(){return this.canvasBoundsContainer.getBounds(f.PANE_UUID(C)).height}setOffsets(e){this.scaleModel.updateOffsets(e);const t=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&t>=s.length&&this.scaleModel.setXScale(this.scaleModel.xStart,this.candleFromIdx(t).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scaleModel.getOffsets()}fromY(e){return this.scaleModel.fromY(e)}priceFromY(e,t){return(t!=null?t:this.mainCandleSeries).view.priceFromY(e)}fromX(e){return this.scaleModel.fromX(e)}toX(e){const t=this.candleFromIdx(e);return this.scaleModel.toX(t.centerUnit)}getBaseLine(){return this.mainCandleSeries.getBaseLine()}candleFromX(e,t=!1,s=this.mainCandleSeries){const i=this.scaleModel.fromX(e);return this.candleFromUnit(i,t,s)}candleFromUnit(e,t=!1,s=this.mainCandleSeries){var i,a;const n=T(s.visualPoints,e,c=>c.startUnit),d=s.visualPoints,l=this.getLastVisualCandle();d[n.index]!==void 0&&(e<0||l&&e>l.startUnit+l.width)&&(n.index+=K((e-d[n.index].centerUnit)/this.mainCandleSeries.meanCandleWidth));const r=n.index,o=Math.max(Math.min(d.length-1,r),0);return(r<0||r>=d.length)&&t?g(this.mainCandleSeries.dataPoints,r,this.chartBaseModel.period):(a=(i=d[o])===null||i===void 0?void 0:i.candle)!==null&&a!==void 0?a:g(this.mainCandleSeries.dataPoints,o,this.chartBaseModel.period)}candleFromTimestamp(e,t=!0){return this.chartBaseModel.dataFromTimestamp(e,t)}candleFromIdx(e){return this.chartBaseModel.dataFromIdx(e)}isReady(){return this.canvasModel.isReady()&&this.hasCandles()}registerCandlesTransformer(e,t){this.candlesTransformersByChartType[e]=t}registerCandlesWidthCalculator(e,t){this.candleWidthByChartType[e]=t}registerLastCandleLabelHandler(e,t){this.lastCandleLabelsByChartType[e]=t}hasCandles(){return this.mainCandleSeries.visualPoints.length!==0}getVisualCandle(e){var t,s,i;const a=e-((i=(s=(t=this.mainCandleSeries.visualPoints[0])===null||t===void 0?void 0:t.candle)===null||s===void 0?void 0:s.idx)!==null&&i!==void 0?i:0);return this.mainCandleSeries.visualPoints[a]}getFirstIdx(){return this.mainCandleSeries.dataIdxStart}getLastIdx(){return this.mainCandleSeries.dataIdxEnd}getFirstTimestamp(e=!0){return e?this.candleFromIdx(this.getFirstIdx()).candle.timestamp:this.candleFromUnit(this.scaleModel.xStart,!0).timestamp}getLastTimestamp(e=!0){return e?this.candleFromIdx(this.getLastIdx()).candle.timestamp:this.candleFromUnit(this.scaleModel.xEnd,!0).timestamp}setTimestampRange(e,t){const s=this.candleFromTimestamp(e).startUnit,i=this.candleFromTimestamp(t),a=i.startUnit+i.width;return this.scaleModel.setXScale(s,a)}getLastCandle(){const e=this.mainCandleSeries.dataPoints;return w(e)}getLastVisualCandle(){const e=this.mainCandleSeries.visualPoints;return w(e)}getMaxCandlesFitLength(){return Z(this.getEffectiveChartWidth()/this.config.components.chart.minWidth)}getSecondarySeries(){return this.secondaryCandleSeries}isSeriesInstrument(e,t){return e.instrument.symbol===t}findSeriesBySymbol(e){return this.candleSeries.filter(t=>this.isSeriesInstrument(t,e))}findSecondarySeriesBySymbol(e){return this.secondaryCandleSeries.find(t=>this.isSeriesInstrument(t,e))}reindexCandlesBasedOnSeries(e,t){return t.reduce((s,i)=>{const a=i.timestamp,n=v(a,!1,e,this.chartBaseModel.period);return n.index>=0&&n.index<e.length&&(i.idx=n.index,s[n.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(e){return this.getFirstIdx()<=e&&e<=this.getLastIdx()}updateCandles(e,t=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===t,i=this.findSeriesBySymbol(t);if(i.length===0){console.warn("updateCandles failed. Can't find series",t);return}i.forEach(a=>{const n=a.dataPoints;let d=!1,l=!1,r;e.forEach(o=>{var c;if(!o)return;const u=v(o.timestamp,!0,n,this.getPeriod()),m=Math.min(u.index,n.length);d=d||m===n.length,n[m]=o,o.idx=m,a.dataPoints=n,a.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(m);const x=m>=n.length-1,E=r&&o.timestamp<r.timestamp;if(x&&!E&&(r=o),d&&r&&s&&l){const F=(c=this.candleWidthByChartType[this.config.components.chart.type])!==null&&c!==void 0?c:N;this.scaleModel.moveXStart(this.scaleModel.xStart+F(r))}}),r&&a.updateCurrentPrice(r.close),l&&r&&e.length===1?this.bus.fireDraw([this.canvasModel.canvasId]):a.recalculateVisualPoints()}),this.scaleModel.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return U(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(e=0,t){let s=this.getCandles().slice();const i=this.getCandlesCount(),a=t!=null?t:i+this.FAKE_CANDLES_DEFAULT;s=s.slice(Math.max(0,e),Math.min(i,a));const n=[],d=[];for(let r=i;r<a;r++)n.push(g(this.mainCandleSeries.dataPoints,r,this.getPeriod()));const l=Math.min(0,a);for(let r=e;r<l;r++)d.push(g(this.mainCandleSeries.dataPoints,r,this.getPeriod()));return[...d,...s,...n]}getCandlesCount(){return this.mainCandleSeries.dataPoints.length}getCandlesCountWithRightOffset(){return this.getCandlesCount()+this.getOffsets().right}clearData(){this.candleSeries.forEach(e=>e.clearData())}prependCandles(e,t){const s=e.slice(),i=[];return t.forEach(a=>{const d=v(a.timestamp,!1,e).index;d<0?i.push(a):e[d].timestamp===a.timestamp?s[d]=a:console.warn(`Couldn't update candle with timestamp ${a.timestamp}`)}),{prepended:i.length,candles:[...i,...s]}}addLastCandle(e,t=this.mainCandleSeries.instrument.symbol){this.updateCandles([e],t)}updateLastCandle(e,t=this.mainCandleSeries.instrument.symbol){this.updateCandles([e],t)}}const y=h=>h.slice().sort((e,t)=>e.timestamp===t.timestamp?0:e.timestamp>t.timestamp?1:-1),B=(h,e,t)=>{if(e>=h.length)return h[h.length-1];for(let s=e;s<h.length&&s>=0;s+=t){const i=h[s];if(i)return i}},I=(h,e)=>{const t=h.slice(),s=[],i=[];return e.forEach(a=>{const d=v(a.timestamp,!0,h).index;d<0?s.push(a):d>=h.length?i.push(a):h[d].timestamp===a.timestamp?t[d]=a:console.warn(`Couldn't update candle with timestamp ${a.timestamp}`)}),{prepended:s.length,appended:i.length,candles:[...s,...t,...i]}};
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import { ChartConfigComponentsOffsets } from '../../chart.config';
7
+ import { HighLow, HighLowProvider } from '../../model/scaling/auto-scale.model';
8
+ /**
9
+ * Constraint on top of high low provider - makes additional offset bounds.
10
+ * @doc-tags viewport,scaling
11
+ * @param offsetsProvider
12
+ * @doc-tags viewport,scaling,offsets
13
+ */
14
+ export declare const createHighLowOffsetCalculator: (offsetsProvider: () => ChartConfigComponentsOffsets) => (highLow: HighLow) => {
15
+ low: number;
16
+ high: number;
17
+ };
18
+ /**
19
+ * Constraint on top of high low provider - makes additional offset bounds.
20
+ * @doc-tags viewport,scaling
21
+ * @param offsetsProvider
22
+ * @param highLowProvider
23
+ * @doc-tags viewport,scaling,offsets
24
+ */
25
+ export declare const createCandlesOffsetProvider: (offsetsProvider: () => ChartConfigComponentsOffsets, highLowProvider: HighLowProvider) => HighLowProvider;
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ export const createHighLowOffsetCalculator=e=>t=>{const{top:c,bottom:s}=e(),o=t.high-t.low,n=o===0?1:o,r=n*c/100,l=n*s/100,a=t.low-l,f=t.high+r;return{low:a,high:f}},createCandlesOffsetProvider=(e,t)=>{const c=createHighLowOffsetCalculator(e);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const o=t.calculateHighLow(s);return c(o)}}};
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import { Candle } from '../../model/candle.model';
7
+ import { DataSeriesPoint, VisualSeriesPoint } from '../../model/data-series.model';
8
+ import { Index } from '../../model/scaling/viewport.model';
9
+ import VisualCandle from '../../model/visual-candle';
10
+ /**
11
+ * Generates fake candle for left and right "out of data range" zones.
12
+ * Requires period to calculate the fake timestamp.
13
+ * The timestamp won't take session breaks or holidays into account.
14
+ */
15
+ export declare const fakeVisualCandle: (dataPoints: Candle[], visualCandles: VisualCandle[], candleWidth: number, index: Index, period?: number) => VisualCandle;
16
+ export declare const fakeVisualPoint: (dataPoints: DataSeriesPoint[], visualPoints: VisualSeriesPoint[], meanDataWidth: number, index: Index, period?: number) => VisualSeriesPoint;
17
+ export declare const fakeCandle: (candles: Candle[], index: Index, period?: number) => Candle;
18
+ export declare const fakeDataPoint: (candles: DataSeriesPoint[], index: Index, period?: number) => DataSeriesPoint;
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import{nameDirection as u}from"../../model/candle.model";import{VisualSeriesPoint as g}from"../../model/data-series.model";import C from"../../model/visual-candle";import{firstOf as N,lastOf as w}from"../../utils/array.utils";import{round as h}from"../../utils/math.utils";const m=60;export const fakeVisualCandle=(n,t,o,e,l=m)=>{const r=fakeCandle(n,e,l);r.volume=o;let s;if(t.length===0)s=0;else if(e>=t.length){const c=t[t.length-1],f=(e-(t.length-1))*o;s=c.centerUnit+f}else{const c=t[0],f=-e*o;s=c.centerUnit-f}return new C(s,o,r.open,r.close,r.lo,r.hi,u(r.open,r.close),r)},fakeVisualPoint=(n,t,o,e,l=m)=>{const r=fakeDataPoint(n,e,l);let s;if(t.length===0)s=0;else if(e>=t.length){const c=t[t.length-1],f=(e-(t.length-1))*o;s=c.centerUnit+f}else{const c=t[0],f=-e*o;s=c.centerUnit-f}return new g(s,r.close)},fakeCandle=(n,t,o=m)=>({hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:i(n,t,o),volume:NaN,expansion:!0,idx:t}),fakeDataPoint=(n,t,o=m)=>({close:NaN,timestamp:i(n,t,o)});function i(n,t,o=m){var e,l;const r=h(t);if(n.length===0)return 0;const s=w(n);if(r>=n.length&&s)return p(s,n.length-1,r,o);const c=N(n);return r<0&&c?p(c,0,r,o):(l=(e=n[r])===null||e===void 0?void 0:e.timestamp)!==null&&l!==void 0?l:0}const p=(n,t,o,e=m)=>n.timestamp+(o-(t!=null?t:0))*e;
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import { DataSeriesModel } from '../../model/data-series.model';
7
+ import { Unit } from '../../model/scaling/viewport.model';
8
+ import { YExtentComponent } from '../pane/extent/y-extent-component';
9
+ import { YExtentFormatters } from '../pane/pane.component';
10
+ export declare const createRegularPriceFormatter: (extent: YExtentComponent) => (value: unknown) => string;
11
+ export declare const createPercentFormatter: (extent: YExtentComponent) => (value: Unit, dataSeries?: DataSeriesModel) => string;
12
+ export declare const createYExtentFormatters: (extent: YExtentComponent) => YExtentFormatters;
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import{unitToPercent as a}from"../../model/scaling/viewport.model";import{PriceIncrementsUtils as s}from"../../utils/price-increments.utils";export const createRegularPriceFormatter=t=>r=>{let e;if(typeof r=="number")e=r;else if(typeof r=="string")e=Number(r);else return"\u2014";const[n]=t.dataSeries;if(n!==void 0){const i=s.getPricePrecision(e,n.pricePrecisions);return e.toFixed(i)}return`${e}`},createPercentFormatter=t=>(r,e)=>{const[n]=t.dataSeries;let i=r;const o=e!=null?e:n;o!==void 0&&(i=a(r,o.getBaseLine()));const c=i.toFixed(s.DEFAULT_PRECISION).replace("-","\u2212")+" %";return c==="\u22120.00 %"?"0.00 %":c},createYExtentFormatters=t=>({percent:createPercentFormatter(t),regular:createRegularPriceFormatter(t)});
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import { FullChartColors, FullChartConfig } from '../../chart.config';
7
+ import { CandleSeriesColors } from '../../model/candle-series.model';
8
+ export declare class SecondaryChartColorsPool {
9
+ private config;
10
+ private secondaryChartColorsPool;
11
+ private usedChartColors;
12
+ private symbolsToColorKeys;
13
+ constructor(config: FullChartConfig);
14
+ /**
15
+ * Creates a color pool object based on the provided color array
16
+ * @param {SecondaryChartTheme[]} colorArray - An array of SecondaryChartTheme objects
17
+ * @returns {Object} - An object containing a key-value pair for each color in the colorArray
18
+ * The key is a string in the format "colorX" where X is the index of the color in the array
19
+ * The value is an object containing the FullChartColors for the color, with lineTheme and areaTheme properties
20
+ */
21
+ private createColorPool;
22
+ /**
23
+ * Takes a color from the secondaryChartColorsPool and assigns it to a symbol.
24
+ * @param {string} symbol - The symbol to assign the color to.
25
+ * @returns {string} The color assigned to the symbol.
26
+ */
27
+ takeColorFromPool(symbol: string): FullChartColors;
28
+ /**
29
+ * Adds a color to the chart color pool.
30
+ *
31
+ * @param {string} symbol - The symbol of the color to be added.
32
+ *
33
+ * @returns {void}
34
+ */
35
+ addColorToPool(symbol: string): void;
36
+ /**
37
+ * Updates the color configuration for a given symbol in the chart.
38
+ * @param {string} symbol - The symbol for which the color configuration needs to be updated.
39
+ * @param {CandleSeriesColors} config - The new color configuration for the symbol.
40
+ * @returns {void}
41
+ */
42
+ updateColorConfig(symbol: string, config: CandleSeriesColors): void;
43
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (C) 2002 - 2023 Devexperts LLC
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
+ */
6
+ import{cloneUnsafe as a}from"../../utils/object.utils";export class SecondaryChartColorsPool{constructor(e){this.config=e,this.usedChartColors={},this.symbolsToColorKeys={},this.secondaryChartColorsPool=this.createColorPool(this.config.colors.secondaryChartTheme),this.usedChartColors=Object.keys(this.secondaryChartColorsPool).reduce((o,s)=>Object.assign(Object.assign({},o),{[s]:0}),{})}createColorPool(e){return e.reduce((o,s,r)=>(o[`color${r}`]=Object.assign(Object.assign({},a(this.config.colors)),{lineTheme:Object.assign({},s.lineTheme),areaTheme:Object.assign({},s.areaTheme)}),o),{})}takeColorFromPool(e){let o=Number.MAX_SAFE_INTEGER,s="";for(const[r,t]of Object.entries(this.usedChartColors))t<o&&(o=t,s=r);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[e]=s,this.secondaryChartColorsPool[s]}addColorToPool(e){const o=this.symbolsToColorKeys[e];this.usedChartColors[o]&&(this.usedChartColors[o]=this.usedChartColors[o]-1)}updateColorConfig(e,o){var s,r;const t=this.secondaryChartColorsPool[this.usedChartColors[e]];if(t){const l=o;this.secondaryChartColorsPool[this.usedChartColors[e]]=Object.assign(Object.assign({},o),{lineTheme:Object.assign(t.lineTheme,(s=l.lineTheme)!==null&&s!==void 0?s:{}),areaTheme:Object.assign(t.areaTheme,(r=l.areaTheme)!==null&&r!==void 0?r:{})})}}}