@devexperts/dxcharts-lite 1.0.2 → 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 (255) hide show
  1. package/README.md +2 -2
  2. package/dist/chart/animation/canvas-animation.js +134 -1
  3. package/dist/chart/animation/types/animation.js +43 -1
  4. package/dist/chart/animation/types/color-alpha-animation.d.ts +1 -1
  5. package/dist/chart/animation/types/color-alpha-animation.js +60 -1
  6. package/dist/chart/animation/types/color-transition-animation.d.ts +1 -1
  7. package/dist/chart/animation/types/color-transition-animation.js +86 -1
  8. package/dist/chart/animation/types/viewport-movement-animation.js +63 -1
  9. package/dist/chart/animation/viewport-model-animation.js +20 -1
  10. package/dist/chart/bootstrap.d.ts +51 -48
  11. package/dist/chart/bootstrap.js +449 -1
  12. package/dist/chart/canvas/canvas-bounds-container.d.ts +0 -5
  13. package/dist/chart/canvas/canvas-bounds-container.js +815 -1
  14. package/dist/chart/canvas/canvas-chart-html.js +16 -18
  15. package/dist/chart/canvas/chart-elements.d.ts +1 -4
  16. package/dist/chart/canvas/chart-elements.js +22 -1
  17. package/dist/chart/canvas/cursor.handler.js +122 -1
  18. package/dist/chart/canvas/layout-creator.js +34 -1
  19. package/dist/chart/canvas/y-axis-bounds.container.d.ts +2 -2
  20. package/dist/chart/canvas/y-axis-bounds.container.js +67 -1
  21. package/dist/chart/chart-container.js +1 -1
  22. package/dist/chart/chart.config.d.ts +4 -5
  23. package/dist/chart/chart.config.js +645 -1
  24. package/dist/chart/chart.d.ts +62 -0
  25. package/dist/chart/chart.js +106 -0
  26. package/dist/chart/components/chart/basic-scale.d.ts +2 -2
  27. package/dist/chart/components/chart/basic-scale.js +31 -1
  28. package/dist/chart/components/chart/candle-transformer.functions.js +15 -1
  29. package/dist/chart/components/chart/candle-width-calculator.functions.js +2 -1
  30. package/dist/chart/components/chart/candle.functions.js +44 -1
  31. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +3 -3
  32. package/dist/chart/components/chart/chart-area-pan.handler.js +197 -1
  33. package/dist/chart/components/chart/chart-base.model.js +66 -1
  34. package/dist/chart/components/chart/chart.component.d.ts +7 -3
  35. package/dist/chart/components/chart/chart.component.js +408 -1
  36. package/dist/chart/components/chart/chart.model.d.ts +4 -11
  37. package/dist/chart/components/chart/chart.model.js +954 -1
  38. package/dist/chart/components/chart/data-series.high-low-provider.js +34 -1
  39. package/dist/chart/components/chart/fake-candles.js +97 -1
  40. package/dist/chart/components/chart/price.formatter.js +35 -1
  41. package/dist/chart/components/chart/secondary-chart-colors-pool.js +68 -1
  42. package/dist/chart/components/cross_tool/cross-tool.component.js +85 -1
  43. package/dist/chart/components/cross_tool/cross-tool.drawer.js +32 -1
  44. package/dist/chart/components/cross_tool/cross-tool.model.js +107 -1
  45. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +137 -1
  46. package/dist/chart/components/cross_tool/types/none.drawer.js +3 -1
  47. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +28 -1
  48. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +24 -1
  49. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +53 -1
  50. package/dist/chart/components/dynamic-objects/dynamic-objects.component.d.ts +13 -0
  51. package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +20 -0
  52. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.d.ts +18 -0
  53. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.js +23 -0
  54. package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +63 -0
  55. package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +136 -0
  56. package/dist/chart/components/events/events-hit-test.drawer.js +63 -1
  57. package/dist/chart/components/events/events.component.js +61 -1
  58. package/dist/chart/components/events/events.drawer.js +195 -1
  59. package/dist/chart/components/events/events.model.js +69 -1
  60. package/dist/chart/components/grid/grid.component.d.ts +2 -2
  61. package/dist/chart/components/grid/grid.component.js +31 -1
  62. package/dist/chart/components/grid/grid.drawer.d.ts +4 -3
  63. package/dist/chart/components/grid/grid.drawer.js +106 -1
  64. package/dist/chart/components/high_low/high-low.component.js +12 -1
  65. package/dist/chart/components/high_low/high-low.drawer.js +126 -1
  66. package/dist/chart/components/highlights/highlights.component.js +46 -1
  67. package/dist/chart/components/highlights/highlights.drawer.js +154 -1
  68. package/dist/chart/components/highlights/highlights.model.js +75 -1
  69. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +1 -1
  70. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +199 -1
  71. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +2 -2
  72. package/dist/chart/components/navigation_map/navigation-map-move.handler.js +108 -1
  73. package/dist/chart/components/navigation_map/navigation-map.component.js +112 -1
  74. package/dist/chart/components/navigation_map/navigation-map.drawer.js +244 -1
  75. package/dist/chart/components/navigation_map/navigation-map.model.js +33 -2
  76. package/dist/chart/components/pan/chart-pan.component.d.ts +2 -2
  77. package/dist/chart/components/pan/chart-pan.component.js +51 -1
  78. package/dist/chart/components/pane/extent/y-extent-component.d.ts +12 -18
  79. package/dist/chart/components/pane/extent/y-extent-component.js +120 -1
  80. package/dist/chart/components/pane/pane-hit-test.controller.js +55 -1
  81. package/dist/chart/components/pane/pane-manager.component.d.ts +10 -5
  82. package/dist/chart/components/pane/pane-manager.component.js +148 -1
  83. package/dist/chart/components/pane/pane.component.d.ts +16 -32
  84. package/dist/chart/components/pane/pane.component.js +278 -1
  85. package/dist/chart/components/resizer/bar-resizer.component.js +139 -1
  86. package/dist/chart/components/resizer/bar-resizer.drawer.js +46 -1
  87. package/dist/chart/components/snapshot/snapshot.component.js +48 -1
  88. package/dist/chart/components/volumes/separate-volumes.component.d.ts +6 -10
  89. package/dist/chart/components/volumes/separate-volumes.component.js +63 -1
  90. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +18 -1
  91. package/dist/chart/components/volumes/volumes.component.d.ts +6 -7
  92. package/dist/chart/components/volumes/volumes.component.js +94 -1
  93. package/dist/chart/components/volumes/volumes.drawer.d.ts +5 -12
  94. package/dist/chart/components/volumes/volumes.drawer.js +140 -1
  95. package/dist/chart/components/volumes/volumes.formatter.js +31 -1
  96. package/dist/chart/components/volumes/volumes.model.d.ts +2 -2
  97. package/dist/chart/components/volumes/volumes.model.js +43 -1
  98. package/dist/chart/components/watermark/water-mark.component.js +103 -1
  99. package/dist/chart/components/watermark/water-mark.drawer.js +187 -1
  100. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +27 -1
  101. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +187 -1
  102. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +76 -1
  103. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +79 -1
  104. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +14 -1
  105. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +1 -1
  106. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +143 -1
  107. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +73 -1
  108. package/dist/chart/components/x_axis/x-axis-draw.functions.js +49 -1
  109. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +70 -1
  110. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
  111. package/dist/chart/components/x_axis/x-axis-labels.generator.js +332 -1
  112. package/dist/chart/components/x_axis/x-axis-labels.model.js +35 -1
  113. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +2 -2
  114. package/dist/chart/components/x_axis/x-axis-scale.handler.js +60 -1
  115. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +82 -1
  116. package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -2
  117. package/dist/chart/components/x_axis/x-axis.component.js +119 -1
  118. package/dist/chart/components/y_axis/label-color.functions.js +53 -1
  119. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +4 -4
  120. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +33 -1
  121. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +3 -3
  122. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +67 -1
  123. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +56 -1
  124. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +95 -1
  125. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +2 -2
  126. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +119 -1
  127. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +9 -8
  128. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +201 -1
  129. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +6 -7
  130. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +58 -1
  131. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +6 -4
  132. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +47 -1
  133. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +4 -4
  134. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +161 -1
  135. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +2 -2
  136. package/dist/chart/components/y_axis/y-axis-scale.handler.js +72 -1
  137. package/dist/chart/components/y_axis/y-axis.component.d.ts +32 -41
  138. package/dist/chart/components/y_axis/y-axis.component.js +220 -1
  139. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +9 -12
  140. package/dist/chart/components/y_axis/y-axis.drawer.js +96 -1
  141. package/dist/chart/components/y_axis/y-axis.model.d.ts +9 -17
  142. package/dist/chart/components/y_axis/y-axis.model.js +33 -1
  143. package/dist/chart/drawers/chart-background.drawer.js +69 -1
  144. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +69 -1
  145. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +57 -1
  146. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +84 -1
  147. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +162 -1
  148. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +57 -1
  149. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +38 -1
  150. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +19 -1
  151. package/dist/chart/drawers/clear-canvas.drawer.js +14 -1
  152. package/dist/chart/drawers/composite.drawer.js +67 -1
  153. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +50 -1
  154. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +35 -1
  155. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +16 -1
  156. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +106 -1
  157. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +23 -1
  158. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +19 -1
  159. package/dist/chart/drawers/data-series-drawers/points.drawer.js +19 -1
  160. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +7 -1
  161. package/dist/chart/drawers/data-series-drawers/text.drawer.js +25 -1
  162. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +35 -1
  163. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +22 -1
  164. package/dist/chart/drawers/data-series.drawer.d.ts +5 -7
  165. package/dist/chart/drawers/data-series.drawer.js +56 -1
  166. package/dist/chart/drawers/drawing-manager.d.ts +1 -1
  167. package/dist/chart/drawers/drawing-manager.js +177 -1
  168. package/dist/chart/drawers/ht-data-series.drawer.js +37 -1
  169. package/dist/chart/events/event-bus.js +73 -1
  170. package/dist/chart/events/events.js +3 -1
  171. package/dist/chart/inputhandlers/candle-tap.handler.js +46 -1
  172. package/dist/chart/inputhandlers/chart-resize.handler.js +98 -1
  173. package/dist/chart/inputhandlers/cross-event-producer.component.js +67 -1
  174. package/dist/chart/inputhandlers/hover-producer.component.d.ts +2 -2
  175. package/dist/chart/inputhandlers/hover-producer.component.js +228 -1
  176. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +2 -2
  177. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +80 -1
  178. package/dist/chart/inputlisteners/canvas-input-listener.component.js +629 -1
  179. package/dist/chart/model/baseline.model.js +88 -1
  180. package/dist/chart/model/bounds.model.js +1 -1
  181. package/dist/chart/model/candle-hover.js +70 -1
  182. package/dist/chart/model/candle-series-high-low.provider.js +45 -1
  183. package/dist/chart/model/candle-series.model.d.ts +3 -3
  184. package/dist/chart/model/candle-series.model.js +245 -1
  185. package/dist/chart/model/candle.model.js +69 -1
  186. package/dist/chart/model/canvas.model.js +228 -1
  187. package/dist/chart/model/chart-base-element.js +129 -1
  188. package/dist/chart/model/compare-series-hover.js +25 -1
  189. package/dist/chart/model/data-series-view.d.ts +5 -5
  190. package/dist/chart/model/data-series-view.js +111 -1
  191. package/dist/chart/model/data-series.config.js +14 -1
  192. package/dist/chart/model/data-series.model.d.ts +4 -4
  193. package/dist/chart/model/data-series.model.js +281 -1
  194. package/dist/chart/model/date-time.formatter.js +151 -1
  195. package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
  196. package/dist/chart/model/hit-test-canvas.model.js +256 -1
  197. package/dist/chart/model/main-candle-series.model.d.ts +1 -1
  198. package/dist/chart/model/main-candle-series.model.js +29 -1
  199. package/dist/chart/model/scale.model.d.ts +2 -1
  200. package/dist/chart/model/scale.model.js +316 -1
  201. package/dist/chart/model/scaling/auto-scale.model.js +97 -1
  202. package/dist/chart/model/scaling/constrait.functions.js +61 -1
  203. package/dist/chart/model/scaling/lock-ratio.model.js +17 -1
  204. package/dist/chart/model/scaling/move-chart.functions.js +22 -1
  205. package/dist/chart/model/scaling/viewport.model.d.ts +2 -2
  206. package/dist/chart/model/scaling/viewport.model.js +279 -1
  207. package/dist/chart/model/scaling/x-zooming.functions.js +35 -1
  208. package/dist/chart/model/time-zone.model.js +109 -1
  209. package/dist/chart/model/visual-candle.js +134 -1
  210. package/dist/chart/utils/__tests__/array.utils.test.js +135 -1
  211. package/dist/chart/utils/__tests__/math.utils.test.js +14 -1
  212. package/dist/chart/utils/__tests__/object.utils.test.js +11 -1
  213. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +29 -1
  214. package/dist/chart/utils/array.utils.d.ts +1 -1
  215. package/dist/chart/utils/array.utils.js +269 -1
  216. package/dist/chart/utils/auto-period-detector.utils.js +39 -1
  217. package/dist/chart/utils/candles-generator-ts.utils.js +20 -1
  218. package/dist/chart/utils/candles-generator.utils.js +161 -1
  219. package/dist/chart/utils/candles.utils.js +42 -1
  220. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +144 -1
  221. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +51 -1
  222. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +156 -1
  223. package/dist/chart/utils/color.utils.js +31 -1
  224. package/dist/chart/utils/device/browser.utils.js +10 -1
  225. package/dist/chart/utils/device/device-detector.utils.js +24 -1
  226. package/dist/chart/utils/device/device-pixel-ratio.utils.js +21 -1
  227. package/dist/chart/utils/device/touchpad.utils.js +91 -1
  228. package/dist/chart/utils/dom.utils.js +15 -1
  229. package/dist/chart/utils/function.utils.js +16 -1
  230. package/dist/chart/utils/linkedList.utils.d.ts +28 -0
  231. package/dist/chart/utils/linkedList.utils.js +138 -0
  232. package/dist/chart/utils/math.utils.js +115 -1
  233. package/dist/chart/utils/merge.utils.js +56 -1
  234. package/dist/chart/utils/object.utils.js +43 -1
  235. package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
  236. package/dist/chart/utils/{perfomance → performance}/debounce.utils.js +7 -1
  237. package/dist/chart/utils/performance/memoize.utils.js +74 -0
  238. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
  239. package/dist/chart/utils/performance/throttle.utils.js +26 -0
  240. package/dist/chart/utils/price-increments.utils.d.ts +1 -0
  241. package/dist/chart/utils/price-increments.utils.js +127 -1
  242. package/dist/chart/utils/uuid.utils.js +4 -1
  243. package/dist/dxchart.min.js +9 -12
  244. package/dist/index.d.ts +3 -3
  245. package/dist/index.js +20 -1
  246. package/package.json +4 -4
  247. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
  248. package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
  249. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
  250. package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
  251. /package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +0 -0
  252. /package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +0 -0
  253. /package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +0 -0
  254. /package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +0 -0
  255. /package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +0 -0
@@ -3,21 +3,19 @@
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 default a=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
7
- <div data-element="chartContainer" style="position: absolute; height: 100%; width: 100%;" class="chart chartArea--graph">
8
- <div data-element="canvasArea" style="position: relative; height: 100%; width: 100%; touch-action: manipulation;">
9
- <canvas data-element="snapshotCanvas" style="z-index: 0"></canvas>
10
- <canvas data-element="backgroundCanvas" style="z-index: 1"></canvas>
11
- <canvas data-element="mainCanvas" style="z-index: 2"></canvas>
12
- <canvas data-element="staticDrawingCanvas" style="z-index: 3"></canvas>
13
- <canvas data-element="dataSeriesCanvas" style="z-index: 5"></canvas>
14
- <canvas data-element="overDataSeriesCanvas" style="z-index: 6"></canvas>
15
- <canvas data-element="dynamicDrawingCanvas" style="z-index: 7"></canvas>
16
- <canvas data-element="yAxisLabelsCanvas" style="z-index: 8"></canvas>
17
- <canvas data-element="crossToolCanvas" style="z-index: 9"></canvas>
18
- <canvas data-element="hitTestCanvas" style="z-index: 10"></canvas>
19
- ${a?` <p style="position: absolute; visibility: hidden;">If you have any suggestions or are experiencing any issues, please feel free to contact us at <a href="https://devexperts.com/dxcharts/">devexperts.com</a></p>
20
- `:""} </div>
21
- </div>
22
- </div>
23
- `;
6
+ export default (devexpertsPromoLink) => '<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">\n' +
7
+ '\t<div data-element="chartContainer" style="position: absolute; height: 100%; width: 100%;" class="chart chartArea--graph">\n' +
8
+ '\t\t<div data-element="canvasArea" style="position: relative; height: 100%; width: 100%; touch-action: manipulation;">\n' +
9
+ '\t\t\t<canvas data-element="snapshotCanvas" style="z-index: 0"></canvas>\n' +
10
+ '\t\t\t<canvas data-element="backgroundCanvas" style="z-index: 1"></canvas>\n' +
11
+ '\t\t\t<canvas data-element="mainCanvas" style="z-index: 2"></canvas>\n' +
12
+ '\t\t\t<canvas data-element="dynamicObjectsCanvas" style="z-index: 3"></canvas>\n' +
13
+ '\t\t\t<canvas data-element="yAxisLabelsCanvas" style="z-index: 4"></canvas>\n' +
14
+ '\t\t\t<canvas data-element="crossToolCanvas" style="z-index: 5"></canvas>\n' +
15
+ '\t\t\t<canvas data-element="hitTestCanvas" style="z-index: 6"></canvas>\n' +
16
+ `${devexpertsPromoLink
17
+ ? '\t\t\t<p style="position: absolute; visibility: hidden;">If you have any suggestions or are experiencing any issues, please feel free to contact us at <a href="https://devexperts.com/dxcharts/">devexperts.com</a></p>\n'
18
+ : ''}` +
19
+ '\t\t</div>\n' +
20
+ '\t</div>\n' +
21
+ '</div>\n';
@@ -8,10 +8,7 @@ export interface ChartElements {
8
8
  snapshotCanvas?: HTMLCanvasElement;
9
9
  backgroundCanvas?: HTMLCanvasElement;
10
10
  mainCanvas?: HTMLCanvasElement;
11
- dataSeriesCanvas?: HTMLCanvasElement;
12
- overDataSeriesCanvas?: HTMLCanvasElement;
13
- staticDrawingCanvas?: HTMLCanvasElement;
14
- dynamicDrawingCanvas?: HTMLCanvasElement;
11
+ dynamicObjectsCanvas?: HTMLCanvasElement;
15
12
  yAxisLabelsCanvas?: HTMLCanvasElement;
16
13
  crossToolCanvas?: HTMLCanvasElement;
17
14
  hitTestCanvas?: HTMLCanvasElement;
@@ -3,4 +3,25 @@
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 validateChartElements=a=>{const n=a.canvasArea!==null,l=a.snapshotCanvas!==null,s=a.backgroundCanvas!==null,t=a.mainCanvas!==null,v=a.overDataSeriesCanvas!==null,i=a.staticDrawingCanvas!==null,o=a.dynamicDrawingCanvas!==null,c=a.yAxisLabelsCanvas!==null,r=a.crossToolCanvas!==null,e=a.hitTestCanvas!==null,C=a.chartResizer!==null,b=a.chartContainer!==null,A=a.dataSeriesCanvas!==null;return n&&l&&s&&t&&v&&i&&o&&c&&r&&e&&C&&b&&A};
6
+ export const validateChartElements = (els) => {
7
+ const canvasAreaAvailable = els.canvasArea !== null;
8
+ const snapshotCanvasAvailable = els.snapshotCanvas !== null;
9
+ const backgroundCanvasAvailable = els.backgroundCanvas !== null;
10
+ const mainCanvasAvailable = els.mainCanvas !== null;
11
+ const yAxisLabelsCanvasAvailable = els.yAxisLabelsCanvas !== null;
12
+ const crossToolCanvasAvailable = els.crossToolCanvas !== null;
13
+ const hitTestCanvasAvailable = els.hitTestCanvas !== null;
14
+ const chartResizerAvailable = els.chartResizer !== null;
15
+ const chartContainerAvailable = els.chartContainer !== null;
16
+ const dynamicObjectsCanvasAvailable = els.dynamicObjectsCanvas !== null;
17
+ return (canvasAreaAvailable &&
18
+ snapshotCanvasAvailable &&
19
+ backgroundCanvasAvailable &&
20
+ mainCanvasAvailable &&
21
+ yAxisLabelsCanvasAvailable &&
22
+ crossToolCanvasAvailable &&
23
+ hitTestCanvasAvailable &&
24
+ chartResizerAvailable &&
25
+ chartContainerAvailable &&
26
+ dynamicObjectsCanvasAvailable);
27
+ };
@@ -3,4 +3,125 @@
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 i}from"rxjs";import{distinctUntilChanged as n,throttleTime as a}from"rxjs/operators";import{ChartBaseElement as u}from"../model/chart-base-element";import{CanvasBoundsContainer as h}from"./canvas-bounds-container";export class CursorHandler extends u{constructor(e,t,s,r){super(),this.element=e,this.canvasInputListener=t,this.canvasBoundsContainer=s,this.hitTestCanvasModel=r,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new i}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(a(100,void 0,{trailing:!0})).subscribe(e=>{const t=this.hitTestCanvasModel.resolveCursor(e);if(t!==void 0){this.updateCursor(t);return}e&&(this.normalLayer.forEach(s=>{s.hitTest(e.x,e.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(e.x,e.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(e,t,s,r=0){const o=h.hitTestOf(t,{extensionY:r});r?this.extensionLayer.set(e,{cursor:s,hitTest:o}):this.normalLayer.set(e,{cursor:s,hitTest:o})}setCursorForCanvasEl(e,t,s){this.observeCursorType(e,t,s)}removeCursorForCanvasEl(e){this.normalLayer.delete(e),this.extensionLayer.delete(e)}observeCursorChanged(){return this.cursorChangedSubject.pipe(n())}observeCursorType(e,t,s){const r=s?this.canvasBoundsContainer.getBoundsHitTest(e,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(e);s?this.extensionLayer.set(e,{cursor:t,hitTest:r}):this.normalLayer.set(e,{cursor:t,hitTest:r})}updateCursor(e){this.element.style.cursor!==e&&(this.element.style.cursor=e,this.cursorChangedSubject.next(e))}}
6
+ import { Subject } from 'rxjs';
7
+ import { distinctUntilChanged, throttleTime } from 'rxjs/operators';
8
+ import { ChartBaseElement } from '../model/chart-base-element';
9
+ import { CanvasBoundsContainer } from './canvas-bounds-container';
10
+ /**
11
+ * This class is responsible for changing cursor for different entities which are drawn on the canvas.
12
+ * @doc-tags chart-core,cursor
13
+ */
14
+ export class CursorHandler extends ChartBaseElement {
15
+ constructor(element, canvasInputListener, canvasBoundsContainer, hitTestCanvasModel) {
16
+ super();
17
+ this.element = element;
18
+ this.canvasInputListener = canvasInputListener;
19
+ this.canvasBoundsContainer = canvasBoundsContainer;
20
+ this.hitTestCanvasModel = hitTestCanvasModel;
21
+ this.normalLayer = new Map();
22
+ this.extensionLayer = new Map();
23
+ this.cursorChangedSubject = new Subject();
24
+ }
25
+ /**
26
+ * This method is called when the user activates the canvas. It subscribes to the mouse move event and checks if the mouse pointer is over any of the elements in the normalLayer or extensionLayer. If the mouse pointer is over any of the elements, it updates the cursor to the corresponding cursor of the element.
27
+ */
28
+ doActivate() {
29
+ super.doActivate();
30
+ this.canvasInputListener
31
+ .observeMouseMoveNoDrag()
32
+ .pipe(throttleTime(100, undefined, { trailing: true }))
33
+ .subscribe(point => {
34
+ const cursorFromHT = this.hitTestCanvasModel.resolveCursor(point);
35
+ if (cursorFromHT !== undefined) {
36
+ this.updateCursor(cursorFromHT);
37
+ return;
38
+ }
39
+ if (point) {
40
+ this.normalLayer.forEach(val => {
41
+ if (val.hitTest(point.x, point.y)) {
42
+ this.updateCursor(val.cursor);
43
+ }
44
+ });
45
+ this.extensionLayer.forEach(val => {
46
+ if (val.hitTest(point.x, point.y)) {
47
+ this.updateCursor(val.cursor);
48
+ }
49
+ });
50
+ }
51
+ });
52
+ }
53
+ /***
54
+ * @param elId
55
+ * @param bounds
56
+ * @param cursorType
57
+ * @param extension is an extra area beyond the borders of the bounds
58
+ */
59
+ setCursorForBounds(elId, bounds, cursorType, extension = 0) {
60
+ const hitTest = CanvasBoundsContainer.hitTestOf(bounds, { extensionY: extension });
61
+ if (extension) {
62
+ // extension layer has a higher priority, so if its hitTest intersects with other hitTests
63
+ // the cursor will be of type specified in extension layer
64
+ this.extensionLayer.set(elId, { cursor: cursorType, hitTest });
65
+ }
66
+ else {
67
+ this.normalLayer.set(elId, { cursor: cursorType, hitTest });
68
+ }
69
+ }
70
+ /**
71
+ * Sets a cursor for a canvas element
72
+ * @param {string} canvasEl - The canvas element to add the cursor to
73
+ * @param {CursorType} cursor - The type of cursor to add
74
+ * @param {number} [extensionRadius] - The extension radius of the cursor
75
+ */
76
+ setCursorForCanvasEl(canvasEl, cursor, extensionRadius) {
77
+ this.observeCursorType(canvasEl, cursor, extensionRadius);
78
+ }
79
+ /**
80
+ * Removes the cursor for a given canvas element.
81
+ *
82
+ * @param {string} canvasEl - The canvas element to remove the cursor from.
83
+ * @returns {void}
84
+ */
85
+ removeCursorForCanvasEl(canvasEl) {
86
+ this.normalLayer.delete(canvasEl);
87
+ this.extensionLayer.delete(canvasEl);
88
+ }
89
+ /**
90
+ * Returns an Observable that emits the latest CursorType value whenever the cursorChangedSubject emits a new value.
91
+ * The emitted value is guaranteed to be distinct from the previous one.
92
+ * @returns {Observable<CursorType>} An Observable that emits the latest CursorType value.
93
+ */
94
+ observeCursorChanged() {
95
+ return this.cursorChangedSubject.pipe(distinctUntilChanged());
96
+ }
97
+ /**
98
+ * Sets the cursor type for a given canvas element and optionally extends the hit test area.
99
+ * @param {string} canvasElement - The ID of the canvas element to observe.
100
+ * @param {CursorType} cursorType - The type of cursor to set.
101
+ * @param {number} [extensionY] - Optional extension of the hit test area in the Y axis.
102
+ * @returns {void}
103
+ */
104
+ observeCursorType(canvasElement, cursorType, extensionY) {
105
+ const hitTest = extensionY
106
+ ? this.canvasBoundsContainer.getBoundsHitTest(canvasElement, { extensionY })
107
+ : this.canvasBoundsContainer.getBoundsHitTest(canvasElement);
108
+ if (extensionY) {
109
+ this.extensionLayer.set(canvasElement, { cursor: cursorType, hitTest });
110
+ }
111
+ else {
112
+ this.normalLayer.set(canvasElement, { cursor: cursorType, hitTest });
113
+ }
114
+ }
115
+ /**
116
+ * Updates the cursor type of an element based on the mouse enter or leave event.
117
+ * @param {CursorType} cursorType - The type of cursor to be set on the element.
118
+ * @returns {void}
119
+ */
120
+ updateCursor(cursorType) {
121
+ if (this.element.style.cursor === cursorType) {
122
+ return;
123
+ }
124
+ this.element.style.cursor = cursorType;
125
+ this.cursorChangedSubject.next(cursorType);
126
+ }
127
+ }
@@ -3,4 +3,37 @@
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{validateChartElements as o}from"./chart-elements";import l from"./canvas-chart-html";export function createDefaultLayoutTemplate(t){const e=document.createElement("template");return e.innerHTML=l(t.devexpertsPromoLink),e}export function extractElements(t){const e={},n=Array.from(t.querySelectorAll("[data-element]"));if(n.length!==0&&n.forEach(a=>{var r;e[(r=a.getAttribute("data-element"))!==null&&r!==void 0?r:""]=a}),o(e))return e;throw new Error("Some chart elements are missing")}
6
+ import { validateChartElements } from './chart-elements';
7
+ import generateNewCanvasChartHTML from './canvas-chart-html';
8
+ /**
9
+ * Creates a default layout template for a canvas chart.
10
+ * @function
11
+ * @returns {HTMLTemplateElement} - The default layout template for a canvas chart.
12
+ */
13
+ export function createDefaultLayoutTemplate(config) {
14
+ const template = document.createElement('template');
15
+ template.innerHTML = generateNewCanvasChartHTML(config.devexpertsPromoLink);
16
+ return template;
17
+ }
18
+ /**
19
+ * Extracts chart elements from a given container and returns them as a validated object.
20
+ * @param {Element} container - The container element to search for chart elements.
21
+ * @returns {ValidatedChartElements} - An object containing the chart elements as properties.
22
+ * @throws {Error} - If some chart elements are missing.
23
+ */
24
+ export function extractElements(container) {
25
+ const result = {};
26
+ const elements = Array.from(container.querySelectorAll('[data-element]'));
27
+ if (elements.length !== 0) {
28
+ elements.forEach(el => {
29
+ var _a;
30
+ result[(_a = el.getAttribute('data-element')) !== null && _a !== void 0 ? _a : ''] = el;
31
+ });
32
+ }
33
+ if (validateChartElements(result)) {
34
+ return result;
35
+ }
36
+ else {
37
+ throw new Error('Some chart elements are missing');
38
+ }
39
+ }
@@ -3,12 +3,12 @@
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 { FullChartConfig, YAxisAlign } from '../chart.config';
6
+ import { YAxisConfig, FullChartConfig } from '../chart.config';
7
7
  import { CanvasModel } from '../model/canvas.model';
8
8
  export interface YAxisWidthContributor {
9
9
  getLargestLabel: () => string;
10
10
  getYAxisIndex: () => number;
11
- getYAxisAlign: () => YAxisAlign;
11
+ getYAxisState: () => YAxisConfig;
12
12
  getPaneUUID: () => string;
13
13
  }
14
14
  export type ExtentsOrder = Map<string, // uuid of the pane
@@ -3,4 +3,70 @@
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{getFontFromConfig as g}from"../chart.config";import{calculateTextWidth as c}from"../utils/canvas/canvas-font-measure-tool.utils";export class YAxisBoundsContainer{constructor(t,i){this.config=t,this.mainCanvasModel=i,this.extentsOrder=new Map,this.yAxisWidthContributors=[]}registerYAxisWidthContributor(t){this.yAxisWidthContributors.push(t)}removeYAxisWidthContributor(t){this.yAxisWidthContributors=this.yAxisWidthContributors.filter(i=>i!==t)}getTextWidth(t){const i=g(this.config.components.yAxis);return c(t,this.mainCanvasModel.ctx,i)}getYAxisWidths(){this.extentsOrder.clear();const t=[],i=[],l=this.config.components.yAxis.labelBoxMargin.start+this.config.components.yAxis.labelBoxMargin.end;return this.yAxisWidthContributors.forEach(n=>{var o,r,h;const x=this.getTextWidth(n.getLargestLabel())+l,a=n.getYAxisIndex(),d=n.getPaneUUID(),s=(o=this.extentsOrder.get(d))!==null&&o!==void 0?o:{left:[],right:[]};if(n.getYAxisAlign()==="left"){const e=s.left.length;t[e]=Math.max((r=t[e])!==null&&r!==void 0?r:0,x),s.left.push(a)}else{const e=s.right.length;i[e]=Math.max((h=i[e])!==null&&h!==void 0?h:0,x),s.right.push(a)}this.extentsOrder.set(d,s)}),{left:t,right:i}}}
6
+ import { getFontFromConfig } from '../chart.config';
7
+ import { calculateTextWidth } from '../utils/canvas/canvas-font-measure-tool.utils';
8
+ export class YAxisBoundsContainer {
9
+ constructor(config, mainCanvasModel) {
10
+ this.config = config;
11
+ this.mainCanvasModel = mainCanvasModel;
12
+ this.extentsOrder = new Map();
13
+ this.yAxisWidthContributors = [];
14
+ }
15
+ /**
16
+ * Registers a YAxisWidthContributor to the chart.
17
+ *
18
+ * @param {YAxisWidthContributor} contributor - The YAxisWidthContributor to be registered.
19
+ * @returns {void}
20
+ */
21
+ registerYAxisWidthContributor(contributor) {
22
+ this.yAxisWidthContributors.push(contributor);
23
+ }
24
+ /**
25
+ * Removes a YAxisWidthContributor from the chart.
26
+ *
27
+ * @param {YAxisWidthContributor} contributor - The YAxisWidthContributor to be removed.
28
+ * @returns {void}
29
+ */
30
+ removeYAxisWidthContributor(contributor) {
31
+ this.yAxisWidthContributors = this.yAxisWidthContributors.filter(c => c !== contributor);
32
+ }
33
+ /**
34
+ * Calculates the width of a given text using the font from the yAxis component of the chart configuration
35
+ * @param {string} text - The text to calculate the width of
36
+ * @returns {number} - The width of the text in pixels
37
+ */
38
+ getTextWidth(text) {
39
+ const font = getFontFromConfig(this.config.components.yAxis);
40
+ return calculateTextWidth(text, this.mainCanvasModel.ctx, font);
41
+ }
42
+ /**
43
+ * Updates width of Y axis.
44
+ * Considers max text of YAxis labels.
45
+ */
46
+ getYAxisWidths() {
47
+ this.extentsOrder.clear();
48
+ const left = [];
49
+ const right = [];
50
+ this.yAxisWidthContributors.forEach(c => {
51
+ var _a, _b, _c;
52
+ const state = c.getYAxisState();
53
+ const margin = state.labelBoxMargin.start + state.labelBoxMargin.end;
54
+ const width = this.getTextWidth(c.getLargestLabel()) + margin;
55
+ const idx = c.getYAxisIndex();
56
+ const uuid = c.getPaneUUID();
57
+ const extentOrder = (_a = this.extentsOrder.get(uuid)) !== null && _a !== void 0 ? _a : { left: [], right: [] };
58
+ if (state.align === 'left') {
59
+ const i = extentOrder.left.length;
60
+ left[i] = Math.max((_b = left[i]) !== null && _b !== void 0 ? _b : 0, width);
61
+ extentOrder.left.push(idx);
62
+ }
63
+ else {
64
+ const i = extentOrder.right.length;
65
+ right[i] = Math.max((_c = right[i]) !== null && _c !== void 0 ? _c : 0, width);
66
+ extentOrder.right.push(idx);
67
+ }
68
+ this.extentsOrder.set(uuid, extentOrder);
69
+ });
70
+ return { left, right };
71
+ }
72
+ }
@@ -3,4 +3,4 @@
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{};
6
+ export {};
@@ -223,7 +223,7 @@ export interface ChartScale {
223
223
  */
224
224
  lockPriceToBarRatio: boolean;
225
225
  /**
226
- * Inverses the Y scale vertically. TODO move to components.yAxis.
226
+ * Inverses the Y scale vertically.
227
227
  */
228
228
  inverse: boolean;
229
229
  /**
@@ -261,7 +261,7 @@ export interface AutoScaleDisableOnDrag {
261
261
  export interface ChartComponents {
262
262
  chart: ChartConfigComponentsChart;
263
263
  xAxis: ChartConfigComponentsXAxis;
264
- yAxis: ChartConfigComponentsYAxis;
264
+ yAxis: YAxisConfig;
265
265
  grid: GridComponentConfig;
266
266
  volumes: ChartConfigComponentsVolumes;
267
267
  offsets: ChartConfigComponentsOffsets;
@@ -362,7 +362,7 @@ export interface ChartConfigComponentsXAxis {
362
362
  fontStyle: string;
363
363
  }
364
364
  export type YAxisAlign = 'left' | 'right';
365
- export interface ChartConfigComponentsYAxis {
365
+ export interface YAxisConfig {
366
366
  visible: boolean;
367
367
  /**
368
368
  * Type of Y axis. Currently supported 'regular', 'percent', 'logarithmic'.
@@ -699,7 +699,6 @@ export interface ChartAreaTheme {
699
699
  backgroundColor: string;
700
700
  backgroundGradientTopColor: string;
701
701
  backgroundGradientBottomColor: string;
702
- axisColor: string;
703
702
  gridColor: string;
704
703
  }
705
704
  export type ChartColors = DeepPartial<FullChartColors>;
@@ -771,4 +770,4 @@ export interface ChartConfigComponentsEventsIcons {
771
770
  conferenceCalls?: CustomIcon;
772
771
  }
773
772
  export type CursorType = string;
774
- export declare const getFontFromConfig: (config: ChartConfigComponentsYAxis) => string;
773
+ export declare const getFontFromConfig: (config: YAxisConfig) => string;