scichart 2.0.2146 → 2.0.2179

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 (342) hide show
  1. package/Builder/buildAnnotations.js +11 -10
  2. package/Builder/buildAxis.js +7 -6
  3. package/Builder/buildDataSeries.js +3 -6
  4. package/Builder/buildModifiers.js +17 -16
  5. package/Builder/buildSeries.js +21 -20
  6. package/Builder/buildSurface.js +29 -27
  7. package/Builder/chartBuilder.d.ts +10 -162
  8. package/Builder/chartBuilder.js +9 -6
  9. package/Builder/classFactory.js +12 -6
  10. package/Charting/ChartModifiers/ChartModifierBase.js +1 -1
  11. package/Charting/ChartModifiers/ChartModifierBase2D.d.ts +1 -1
  12. package/Charting/ChartModifiers/ChartModifierBase2D.js +11 -6
  13. package/Charting/ChartModifiers/CursorModifier.d.ts +1 -1
  14. package/Charting/ChartModifiers/CursorModifier.js +32 -28
  15. package/Charting/ChartModifiers/DataPointSelectionModifier.d.ts +1 -1
  16. package/Charting/ChartModifiers/DataPointSelectionModifier.js +18 -16
  17. package/Charting/ChartModifiers/LegendModifier.d.ts +1 -1
  18. package/Charting/ChartModifiers/LegendModifier.js +3 -1
  19. package/Charting/ChartModifiers/ModifierMouseArgs.js +4 -3
  20. package/Charting/ChartModifiers/MouseWheelZoomModifier.d.ts +52 -2
  21. package/Charting/ChartModifiers/MouseWheelZoomModifier.js +105 -10
  22. package/Charting/ChartModifiers/OverviewRangeSelectionModifier.js +10 -8
  23. package/Charting/ChartModifiers/PinchZoomModifier.d.ts +1 -1
  24. package/Charting/ChartModifiers/PinchZoomModifier.js +4 -2
  25. package/Charting/ChartModifiers/RolloverModifier.d.ts +1 -1
  26. package/Charting/ChartModifiers/RolloverModifier.js +27 -20
  27. package/Charting/ChartModifiers/RubberBandXyZoomModifier.d.ts +1 -1
  28. package/Charting/ChartModifiers/RubberBandXyZoomModifier.js +11 -9
  29. package/Charting/ChartModifiers/SeriesSelectionModifier.d.ts +1 -1
  30. package/Charting/ChartModifiers/SeriesSelectionModifier.js +9 -7
  31. package/Charting/ChartModifiers/XAxisDragModifier.d.ts +1 -1
  32. package/Charting/ChartModifiers/XAxisDragModifier.js +12 -10
  33. package/Charting/ChartModifiers/YAxisDragModifier.d.ts +1 -1
  34. package/Charting/ChartModifiers/YAxisDragModifier.js +12 -10
  35. package/Charting/ChartModifiers/ZoomExtentsModifier.d.ts +17 -1
  36. package/Charting/ChartModifiers/ZoomExtentsModifier.js +65 -10
  37. package/Charting/ChartModifiers/ZoomPanModifier.d.ts +4 -2
  38. package/Charting/ChartModifiers/ZoomPanModifier.js +25 -21
  39. package/Charting/Drawing/BaseCache.js +2 -2
  40. package/Charting/Drawing/BrushCache.js +12 -7
  41. package/Charting/Drawing/PaletteCache.js +4 -2
  42. package/Charting/Drawing/Pen2DCache.js +14 -9
  43. package/Charting/Drawing/SolidBrushCache.js +2 -2
  44. package/Charting/Drawing/TextureCache.js +4 -2
  45. package/Charting/Drawing/WebGlBrush.js +1 -1
  46. package/Charting/Drawing/WebGlPen.js +2 -2
  47. package/Charting/Drawing/WebGlRenderContext2D.js +5 -5
  48. package/Charting/LayoutManager/AxisLayoutHelpers.js +6 -4
  49. package/Charting/LayoutManager/BaseAxisLayoutStrategy.js +4 -4
  50. package/Charting/LayoutManager/BaseCenteredAxisLayoutStrategy.d.ts +1 -1
  51. package/Charting/LayoutManager/BaseCenteredAxisLayoutStrategy.js +3 -1
  52. package/Charting/LayoutManager/BottomAlignedInnerAxisLayoutStrategy.js +6 -4
  53. package/Charting/LayoutManager/BottomAlignedOuterAxisLayoutStrategy.js +6 -4
  54. package/Charting/LayoutManager/BottomAlignedOuterHorizontallyStackedAxisLayoutStrategy.js +7 -5
  55. package/Charting/LayoutManager/CentralAxesLayoutManager.js +7 -3
  56. package/Charting/LayoutManager/LayoutManager.js +2 -2
  57. package/Charting/LayoutManager/LeftAlignedInnerAxisLayoutStrategy.js +6 -4
  58. package/Charting/LayoutManager/LeftAlignedOuterAxisLayoutStrategy.js +6 -4
  59. package/Charting/LayoutManager/LeftAlignedOuterVerticallyStackedAxisLayoutStrategy.js +7 -5
  60. package/Charting/LayoutManager/RightAlignedInnerAxisLayoutStrategy.js +6 -4
  61. package/Charting/LayoutManager/RightAlignedOuterAxisLayoutStrategy.js +6 -4
  62. package/Charting/LayoutManager/RightAlignedOuterVerticallyStackedAxisLayoutStrategy.js +7 -5
  63. package/Charting/LayoutManager/SynchronizedLayoutManager.js +4 -2
  64. package/Charting/LayoutManager/TopAlignedInnerAxisLayoutStrategy.js +6 -4
  65. package/Charting/LayoutManager/TopAlignedOuterAxisLayoutStrategy.js +6 -4
  66. package/Charting/LayoutManager/TopAlignedOuterHorizontallyStackedAxisLayoutStrategy.js +7 -5
  67. package/Charting/Model/BaseDataSeries.js +23 -20
  68. package/Charting/Model/BaseHeatmapDataSeries.js +5 -5
  69. package/Charting/Model/ChartData/HeatmapSeriesInfo.js +4 -2
  70. package/Charting/Model/ChartData/OhlcSeriesInfo.js +3 -1
  71. package/Charting/Model/ChartData/SeriesInfo.d.ts +1 -0
  72. package/Charting/Model/ChartData/SeriesInfo.js +15 -0
  73. package/Charting/Model/ChartData/StackedXySeriesInfo.js +3 -1
  74. package/Charting/Model/ChartData/XySeriesInfo.js +3 -1
  75. package/Charting/Model/ChartData/XyySeriesInfo.js +3 -1
  76. package/Charting/Model/DataPointSelectionPaletteProvider.js +2 -2
  77. package/Charting/Model/Filters/OhlcCustomFilter.js +7 -2
  78. package/Charting/Model/Filters/OhlcFilterBase.js +3 -1
  79. package/Charting/Model/Filters/OhlcScaleOffsetFilter.js +3 -1
  80. package/Charting/Model/Filters/XyCustomFilter.js +3 -1
  81. package/Charting/Model/Filters/XyFilterBase.js +9 -6
  82. package/Charting/Model/Filters/XyLinearTrendFilter.js +3 -1
  83. package/Charting/Model/Filters/XyMovingAverageFilter.js +3 -1
  84. package/Charting/Model/Filters/XyRatioFilter.js +6 -4
  85. package/Charting/Model/Filters/XyScaleOffsetFilter.js +3 -1
  86. package/Charting/Model/Filters/XyyCustomFilter.js +3 -1
  87. package/Charting/Model/Filters/XyyFilterBase.js +7 -5
  88. package/Charting/Model/Filters/XyyScaleOffsetFilter.js +3 -1
  89. package/Charting/Model/Filters/XyzCustomFilter.js +3 -1
  90. package/Charting/Model/Filters/XyzFilterBase.js +7 -5
  91. package/Charting/Model/Filters/XyzScaleOffsetFilter.js +3 -1
  92. package/Charting/Model/OhlcDataSeries.js +27 -25
  93. package/Charting/Model/PaletteFactory.js +3 -3
  94. package/Charting/Model/UniformHeatmapDataSeries.js +3 -1
  95. package/Charting/Model/XyDataSeries.js +9 -7
  96. package/Charting/Model/XyyDataSeries.js +15 -13
  97. package/Charting/Model/XyzDataSeries.js +15 -13
  98. package/Charting/Numerics/CoordinateCalculators/CategoryCoordinateCalculator.js +3 -1
  99. package/Charting/Numerics/CoordinateCalculators/FlippedCategoryCoordinateCalculator.js +3 -1
  100. package/Charting/Numerics/CoordinateCalculators/FlippedNumericCoordinateCalculator.js +3 -1
  101. package/Charting/Numerics/CoordinateCalculators/LogarithmicCoordinateCalculator.js +3 -1
  102. package/Charting/Numerics/CoordinateCalculators/NumericCoordinateCalculator.js +3 -1
  103. package/Charting/Numerics/TickCoordinateProviders/DefaultTickCoordinatesProvider.js +3 -1
  104. package/Charting/Numerics/TickProviders/LogarithmicTickProvider.js +7 -5
  105. package/Charting/Numerics/TickProviders/NumericTickProvider.js +4 -2
  106. package/Charting/Services/SciChartRenderer.js +20 -17
  107. package/Charting/Services/Workers/TextureWorker.d.ts +16 -0
  108. package/Charting/Services/Workers/TextureWorker.js +138 -0
  109. package/Charting/Services/Workers/TextureWorkerSource.d.ts +1 -0
  110. package/Charting/Services/Workers/TextureWorkerSource.js +133 -0
  111. package/Charting/Themes/SciChartJSDarkTheme.js +3 -1
  112. package/Charting/Themes/SciChartJSDarkv2Theme.js +3 -1
  113. package/Charting/Themes/SciChartJSLightTheme.js +3 -1
  114. package/Charting/Visuals/Annotations/AnnotationBase.d.ts +1 -1
  115. package/Charting/Visuals/Annotations/AnnotationBase.js +71 -41
  116. package/Charting/Visuals/Annotations/AxisMarkerAnnotation.d.ts +28 -1
  117. package/Charting/Visuals/Annotations/AxisMarkerAnnotation.js +11 -9
  118. package/Charting/Visuals/Annotations/BoxAnnotation.d.ts +1 -1
  119. package/Charting/Visuals/Annotations/BoxAnnotation.js +18 -16
  120. package/Charting/Visuals/Annotations/CursorTooltipSvgAnnotation.js +32 -13
  121. package/Charting/Visuals/Annotations/CustomAnnotation.d.ts +1 -1
  122. package/Charting/Visuals/Annotations/CustomAnnotation.js +3 -1
  123. package/Charting/Visuals/Annotations/HorizontalLineAnnotation.js +8 -6
  124. package/Charting/Visuals/Annotations/LineAnnotation.d.ts +1 -1
  125. package/Charting/Visuals/Annotations/LineAnnotation.js +21 -17
  126. package/Charting/Visuals/Annotations/OverviewCustomResizableAnnotation.js +20 -17
  127. package/Charting/Visuals/Annotations/RenderContextAnnotationBase.js +3 -1
  128. package/Charting/Visuals/Annotations/RolloverLegendSvgAnnotation.js +3 -1
  129. package/Charting/Visuals/Annotations/RolloverMarkerSvgAnnotation.js +4 -2
  130. package/Charting/Visuals/Annotations/RolloverTooltipSvgAnnotation.js +17 -15
  131. package/Charting/Visuals/Annotations/SvgAnnotationBase.d.ts +1 -1
  132. package/Charting/Visuals/Annotations/SvgAnnotationBase.js +23 -13
  133. package/Charting/Visuals/Annotations/TextAnnotation.d.ts +1 -1
  134. package/Charting/Visuals/Annotations/TextAnnotation.js +4 -2
  135. package/Charting/Visuals/Annotations/VerticalLineAnnotation.js +8 -6
  136. package/Charting/Visuals/Axis/AxisBase2D.d.ts +16 -8
  137. package/Charting/Visuals/Axis/AxisBase2D.js +68 -37
  138. package/Charting/Visuals/Axis/AxisCore.d.ts +1 -1
  139. package/Charting/Visuals/Axis/AxisCore.js +3 -33
  140. package/Charting/Visuals/Axis/AxisRenderer.d.ts +63 -0
  141. package/Charting/Visuals/Axis/AxisRenderer.js +92 -16
  142. package/Charting/Visuals/Axis/AxisTitleRenderer.js +7 -3
  143. package/Charting/Visuals/Axis/CategoryAxis.js +5 -2
  144. package/Charting/Visuals/Axis/CategoryAxisBase.js +10 -8
  145. package/Charting/Visuals/Axis/DeltaCalculator/CategoryDeltaCalculator.js +3 -1
  146. package/Charting/Visuals/Axis/DeltaCalculator/LogarithmicDeltaCalculator.js +3 -1
  147. package/Charting/Visuals/Axis/DeltaCalculator/NumericDeltaCalculator.js +3 -1
  148. package/Charting/Visuals/Axis/LabelProvider/DateLabelProvider.js +5 -3
  149. package/Charting/Visuals/Axis/LabelProvider/LabelCache.d.ts +41 -0
  150. package/Charting/Visuals/Axis/LabelProvider/LabelCache.js +164 -0
  151. package/Charting/Visuals/Axis/LabelProvider/LabelProvider.d.ts +1 -1
  152. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.d.ts +57 -7
  153. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.js +171 -74
  154. package/Charting/Visuals/Axis/LabelProvider/LogarithmicLabelProvider.js +5 -3
  155. package/Charting/Visuals/Axis/LabelProvider/NumericLabelProvider.js +5 -3
  156. package/Charting/Visuals/Axis/LabelProvider/SmartDateLabelProvider.js +30 -37
  157. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.d.ts +5 -2
  158. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.js +86 -5
  159. package/Charting/Visuals/Axis/LogarithmicAxis.js +8 -3
  160. package/Charting/Visuals/Axis/NumericAxis.js +5 -2
  161. package/Charting/Visuals/Axis/getAxisById.js +1 -1
  162. package/Charting/Visuals/Helpers/createNativeRect.js +2 -1
  163. package/Charting/Visuals/Helpers/createPen.js +4 -3
  164. package/Charting/Visuals/Helpers/createSolidBrush.js +5 -4
  165. package/Charting/Visuals/Helpers/drawBorder.js +6 -5
  166. package/Charting/Visuals/Helpers/drawLabel.js +10 -6
  167. package/Charting/Visuals/Legend/SciChartLegend.js +4 -2
  168. package/Charting/Visuals/Legend/SciChartLegendBase.js +16 -14
  169. package/Charting/Visuals/Legend/SciChartPieLegend.js +6 -4
  170. package/Charting/Visuals/PointMarkers/BasePointMarker.js +3 -3
  171. package/Charting/Visuals/PointMarkers/CrossPointMarker.js +3 -1
  172. package/Charting/Visuals/PointMarkers/EllipsePointMarker.js +3 -1
  173. package/Charting/Visuals/PointMarkers/SpritePointMarker.js +3 -1
  174. package/Charting/Visuals/PointMarkers/SquarePointMarker.js +3 -1
  175. package/Charting/Visuals/PointMarkers/TrianglePointMarker.js +3 -1
  176. package/Charting/Visuals/PointMarkers/XPointMarker.js +3 -1
  177. package/Charting/Visuals/RenderableSeries/Animations/BandAnimation.js +6 -4
  178. package/Charting/Visuals/RenderableSeries/Animations/BandAnimationStyle.js +6 -4
  179. package/Charting/Visuals/RenderableSeries/Animations/BaseAnimationStyle.js +1 -1
  180. package/Charting/Visuals/RenderableSeries/Animations/BubbleAnimation.js +3 -1
  181. package/Charting/Visuals/RenderableSeries/Animations/CandlestickAnimation.js +5 -3
  182. package/Charting/Visuals/RenderableSeries/Animations/CandlestickAnimationStyle.js +5 -3
  183. package/Charting/Visuals/RenderableSeries/Animations/ColumnAnimation.js +4 -2
  184. package/Charting/Visuals/RenderableSeries/Animations/ColumnAnimationStyle.js +4 -2
  185. package/Charting/Visuals/RenderableSeries/Animations/CustomPointMarkerStyle.js +3 -1
  186. package/Charting/Visuals/RenderableSeries/Animations/FadeAnimation.js +3 -1
  187. package/Charting/Visuals/RenderableSeries/Animations/LineAnimation.js +3 -1
  188. package/Charting/Visuals/RenderableSeries/Animations/MountainAnimation.js +4 -2
  189. package/Charting/Visuals/RenderableSeries/Animations/MountainAnimationStyle.js +4 -2
  190. package/Charting/Visuals/RenderableSeries/Animations/OhlcAnimation.js +5 -3
  191. package/Charting/Visuals/RenderableSeries/Animations/OhlcAnimationStyle.js +5 -3
  192. package/Charting/Visuals/RenderableSeries/Animations/PointMarkerStyle.js +5 -3
  193. package/Charting/Visuals/RenderableSeries/Animations/ScaleAnimation.d.ts +1 -1
  194. package/Charting/Visuals/RenderableSeries/Animations/ScaleAnimation.js +3 -1
  195. package/Charting/Visuals/RenderableSeries/Animations/ScatterAnimation.js +3 -1
  196. package/Charting/Visuals/RenderableSeries/Animations/SeriesAnimation.d.ts +1 -1
  197. package/Charting/Visuals/RenderableSeries/Animations/SeriesAnimation.js +3 -3
  198. package/Charting/Visuals/RenderableSeries/Animations/SweepAnimation.js +3 -1
  199. package/Charting/Visuals/RenderableSeries/Animations/WaveAnimation.d.ts +1 -1
  200. package/Charting/Visuals/RenderableSeries/Animations/WaveAnimation.js +3 -1
  201. package/Charting/Visuals/RenderableSeries/Animations/animationHelpers.js +2 -2
  202. package/Charting/Visuals/RenderableSeries/BaseBandRenderableSeries.js +3 -1
  203. package/Charting/Visuals/RenderableSeries/BaseLineRenderableSeries.js +3 -1
  204. package/Charting/Visuals/RenderableSeries/BaseMountainRenderableSeries.js +3 -1
  205. package/Charting/Visuals/RenderableSeries/BaseOhlcRenderableSeries.js +3 -1
  206. package/Charting/Visuals/RenderableSeries/BaseRenderableSeries.js +15 -14
  207. package/Charting/Visuals/RenderableSeries/BaseStackedCollection.js +7 -5
  208. package/Charting/Visuals/RenderableSeries/BaseStackedRenderableSeries.js +3 -3
  209. package/Charting/Visuals/RenderableSeries/DrawingProviders/BandSeriesDrawingProvider.js +20 -18
  210. package/Charting/Visuals/RenderableSeries/DrawingProviders/BaseSeriesDrawingProvider.js +12 -12
  211. package/Charting/Visuals/RenderableSeries/DrawingProviders/BubbleSeriesDrawingProvider.js +4 -2
  212. package/Charting/Visuals/RenderableSeries/DrawingProviders/ColumnSeriesDrawingProvider.js +12 -10
  213. package/Charting/Visuals/RenderableSeries/DrawingProviders/LineSeriesDrawingProvider.js +9 -7
  214. package/Charting/Visuals/RenderableSeries/DrawingProviders/MountainSeriesDrawingProvider.js +10 -8
  215. package/Charting/Visuals/RenderableSeries/DrawingProviders/OhlcSeriesDrawingProvider.js +20 -18
  216. package/Charting/Visuals/RenderableSeries/DrawingProviders/PointMarkerDrawingProvider.js +6 -4
  217. package/Charting/Visuals/RenderableSeries/DrawingProviders/UniformContoursDrawingProvider.js +9 -7
  218. package/Charting/Visuals/RenderableSeries/DrawingProviders/UniformHeatmapDrawingProvider.js +6 -4
  219. package/Charting/Visuals/RenderableSeries/FastBandRenderableSeries.js +3 -1
  220. package/Charting/Visuals/RenderableSeries/FastBubbleRenderableSeries.js +3 -1
  221. package/Charting/Visuals/RenderableSeries/FastCandlestickRenderableSeries.js +3 -1
  222. package/Charting/Visuals/RenderableSeries/FastColumnRenderableSeries.js +6 -3
  223. package/Charting/Visuals/RenderableSeries/FastLineRenderableSeries.js +3 -1
  224. package/Charting/Visuals/RenderableSeries/FastMountainRenderableSeries.js +3 -1
  225. package/Charting/Visuals/RenderableSeries/FastOhlcRenderableSeries.js +3 -1
  226. package/Charting/Visuals/RenderableSeries/GlowEffect.js +3 -1
  227. package/Charting/Visuals/RenderableSeries/HitTest/BandSeriesHitTestProvider.js +3 -1
  228. package/Charting/Visuals/RenderableSeries/HitTest/BaseHitTestProvider.js +1 -1
  229. package/Charting/Visuals/RenderableSeries/HitTest/BubbleSeriesHitTestProvider.js +4 -2
  230. package/Charting/Visuals/RenderableSeries/HitTest/ColumnSeriesHitTestProvider.js +4 -2
  231. package/Charting/Visuals/RenderableSeries/HitTest/LineSeriesHitTestProvider.js +8 -6
  232. package/Charting/Visuals/RenderableSeries/HitTest/MountainSeriesHitTestProvider.js +3 -1
  233. package/Charting/Visuals/RenderableSeries/HitTest/OhlcSeriesHitTestProvider.js +4 -2
  234. package/Charting/Visuals/RenderableSeries/HitTest/ScatterSeriesHitTestProvider.js +6 -4
  235. package/Charting/Visuals/RenderableSeries/HitTest/StackedColumnSeriesHitTestProvider.js +7 -5
  236. package/Charting/Visuals/RenderableSeries/HitTest/StackedMountainSeriesHitTestProvider.js +3 -1
  237. package/Charting/Visuals/RenderableSeries/HitTest/UniformHeatmapHitTestProvider.js +3 -1
  238. package/Charting/Visuals/RenderableSeries/HitTest/hitTestHelpers.js +12 -12
  239. package/Charting/Visuals/RenderableSeries/RolloverModifier/RolloverModifierRenderableSeriesProps.js +2 -2
  240. package/Charting/Visuals/RenderableSeries/ShaderEffect.js +4 -4
  241. package/Charting/Visuals/RenderableSeries/ShadowEffect.js +4 -2
  242. package/Charting/Visuals/RenderableSeries/SplineBandRenderableSeries.js +6 -4
  243. package/Charting/Visuals/RenderableSeries/SplineLineRenderableSeries.js +5 -3
  244. package/Charting/Visuals/RenderableSeries/SplineMountainRenderableSeries.js +5 -3
  245. package/Charting/Visuals/RenderableSeries/StackedColumnCollection.js +6 -4
  246. package/Charting/Visuals/RenderableSeries/StackedColumnRenderableSeries.js +11 -9
  247. package/Charting/Visuals/RenderableSeries/StackedMountainCollection.js +7 -5
  248. package/Charting/Visuals/RenderableSeries/StackedMountainRenderableSeries.js +11 -9
  249. package/Charting/Visuals/RenderableSeries/UniformContoursRenderableSeries.js +6 -4
  250. package/Charting/Visuals/RenderableSeries/UniformHeatmapRenderableSeries.js +5 -2
  251. package/Charting/Visuals/RenderableSeries/XyScatterRenderableSeries.js +3 -1
  252. package/Charting/Visuals/RubberBandSvgRect/RubberBandSvgRect.js +3 -3
  253. package/Charting/Visuals/SciChartDefaults.d.ts +11 -0
  254. package/Charting/Visuals/SciChartDefaults.js +18 -0
  255. package/Charting/Visuals/SciChartOverview.js +13 -7
  256. package/Charting/Visuals/SciChartPieSurface/PieSegment/PieSegment.js +1 -1
  257. package/Charting/Visuals/SciChartPieSurface/SciChartPieSurface.js +27 -24
  258. package/Charting/Visuals/SciChartSurface.js +20 -17
  259. package/Charting/Visuals/SciChartSurfaceBase.js +15 -11
  260. package/Charting/Visuals/TextureManager/CanvasTexture.js +5 -5
  261. package/Charting/Visuals/TextureManager/DpiHelper.js +3 -3
  262. package/Charting/Visuals/TextureManager/TextureManager.d.ts +1 -0
  263. package/Charting/Visuals/TextureManager/TextureManager.js +16 -12
  264. package/Charting/Visuals/createMaster.js +6 -5
  265. package/Charting/Visuals/createSingle.js +6 -4
  266. package/Charting/Visuals/licenseManager2D.js +65 -48
  267. package/Charting/Visuals/loader.js +1 -1
  268. package/Charting/Visuals/sciChartInitCommon.js +12 -12
  269. package/Charting3D/CameraController.js +6 -6
  270. package/Charting3D/ChartModifiers/ChartModifierBase3D.js +3 -1
  271. package/Charting3D/ChartModifiers/MouseWheelZoomModifier3D.js +3 -1
  272. package/Charting3D/ChartModifiers/OrbitModifier3D.js +3 -1
  273. package/Charting3D/ChartModifiers/ResetCamera3DModifier.d.ts +79 -0
  274. package/Charting3D/ChartModifiers/ResetCamera3DModifier.js +143 -0
  275. package/Charting3D/Model/DataSeries/BaseGridDataSeries3D.js +4 -2
  276. package/Charting3D/Model/DataSeries/UniformGridDataSeries3D.js +3 -1
  277. package/Charting3D/Model/DataSeries/XyzDataSeries3D.js +6 -4
  278. package/Charting3D/Vector3.js +1 -1
  279. package/Charting3D/Visuals/Axis/AxisBase3D.js +9 -7
  280. package/Charting3D/Visuals/Axis/AxisCubeEntity.js +20 -15
  281. package/Charting3D/Visuals/Axis/NumericAxis3D.d.ts +5 -0
  282. package/Charting3D/Visuals/Axis/NumericAxis3D.js +29 -1
  283. package/Charting3D/Visuals/DefaultViewportManager3D.js +3 -1
  284. package/Charting3D/Visuals/GizmoEntity.js +3 -1
  285. package/Charting3D/Visuals/PointMarkers/BaseMeshPointMarker3D.js +3 -1
  286. package/Charting3D/Visuals/PointMarkers/BaseTexturePointMarker3D.js +3 -1
  287. package/Charting3D/Visuals/PointMarkers/DefaultPointMarkers.js +3 -1
  288. package/Charting3D/Visuals/Primitives/BaseSceneEntity3D.js +2 -2
  289. package/Charting3D/Visuals/Primitives/RenderableSeriesSceneEntity.js +3 -1
  290. package/Charting3D/Visuals/Primitives/ScatterPointsSceneEntity.js +7 -5
  291. package/Charting3D/Visuals/Primitives/SurfaceMeshSceneEntity.js +22 -20
  292. package/Charting3D/Visuals/RenderableSeries/BaseRenderableSeries3D.js +3 -3
  293. package/Charting3D/Visuals/RenderableSeries/ScatterRenderableSeries3D.js +3 -1
  294. package/Charting3D/Visuals/RenderableSeries/SurfaceMesh/GradientColorPalette.js +3 -1
  295. package/Charting3D/Visuals/RenderableSeries/SurfaceMesh/SolidColorBrushPalette.js +5 -3
  296. package/Charting3D/Visuals/RenderableSeries/SurfaceMesh/SurfaceMeshRenderableSeries3D.js +3 -1
  297. package/Charting3D/Visuals/RootSceneEntity.js +3 -1
  298. package/Charting3D/Visuals/SciChart3DRenderer.d.ts +1 -0
  299. package/Charting3D/Visuals/SciChart3DRenderer.js +10 -2
  300. package/Charting3D/Visuals/SciChart3DSurface.d.ts +22 -0
  301. package/Charting3D/Visuals/SciChart3DSurface.js +64 -11
  302. package/Charting3D/Visuals/createMaster3d.js +8 -7
  303. package/Charting3D/Visuals/createSingle3d.js +5 -4
  304. package/Charting3D/Visuals/licenseManager3D.js +7 -6
  305. package/Core/Animations/AnimationFiniteStateMachine.js +4 -2
  306. package/Core/Animations/DoubleAnimator.js +1 -1
  307. package/Core/Animations/GenericAnimation.js +1 -1
  308. package/Core/Guard.js +4 -4
  309. package/Core/Mouse/MouseManager.js +1 -1
  310. package/Core/NumberRange.js +4 -4
  311. package/Core/Point.js +1 -1
  312. package/_wasm/scichart.browser.js +1 -1
  313. package/_wasm/scichart2d.js +95 -95
  314. package/_wasm/scichart2d.wasm +0 -0
  315. package/_wasm/scichart3d.js +95 -95
  316. package/_wasm/scichart3d.wasm +0 -0
  317. package/index.js +1 -0
  318. package/package.json +2 -2
  319. package/types/AxisAlignment.js +6 -4
  320. package/types/ChartModifierType.d.ts +2 -1
  321. package/types/ChartModifierType.js +1 -0
  322. package/utils/array.js +2 -1
  323. package/utils/calcAverage.js +4 -2
  324. package/utils/colorUtil.js +4 -4
  325. package/utils/convertColor.js +6 -4
  326. package/utils/convertToPixel.js +2 -1
  327. package/utils/date.js +26 -17
  328. package/utils/font.js +4 -3
  329. package/utils/guid.js +2 -1
  330. package/utils/hasAllProperties.js +2 -1
  331. package/utils/includedAxis.d.ts +3 -0
  332. package/utils/includedAxis.js +23 -0
  333. package/utils/math.js +6 -3
  334. package/utils/number.js +18 -13
  335. package/utils/parseColor.js +7 -5
  336. package/utils/pointUtil.js +24 -15
  337. package/utils/random.js +2 -1
  338. package/utils/randomPricesDataSource.js +7 -5
  339. package/utils/svgString.js +2 -1
  340. package/utils/translate.js +10 -5
  341. package/utils/tsrExtensions.js +4 -2
  342. package/utils/zeroArray2D.js +3 -2
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.labelCache = void 0;
4
+ var Deleter_1 = require("../../../../Core/Deleter");
5
+ var labelCacheByTextAndStyle = new Map();
6
+ var styleCache = {};
7
+ var lastStyleId = 0;
8
+ var getStyleId = function (style) {
9
+ for (var key in styleCache) {
10
+ if (styleCache.hasOwnProperty(key)) {
11
+ var otherStyle = styleCache[key];
12
+ if (otherStyle) {
13
+ if (checkTextStyleEqual(style, otherStyle.style)) {
14
+ otherStyle.uses++;
15
+ return key;
16
+ }
17
+ }
18
+ }
19
+ }
20
+ lastStyleId++;
21
+ var newStyleId = lastStyleId.toString();
22
+ styleCache[newStyleId] = { style: style, uses: 1 };
23
+ return newStyleId;
24
+ };
25
+ var freeStyle = function (styleId) {
26
+ var style = styleCache[styleId];
27
+ if (style) {
28
+ style.uses--;
29
+ setTimeout(function () {
30
+ var styleToClear = styleCache[styleId];
31
+ if (styleToClear && styleToClear.uses === 0) {
32
+ clearCacheByStyle(styleId);
33
+ }
34
+ }, minAge);
35
+ }
36
+ };
37
+ var makeCacheKey = function (text, styleId) {
38
+ return "".concat(text, "|:|").concat(styleId);
39
+ };
40
+ var parseCacheKey = function (key) {
41
+ var sep = key.indexOf("|:|");
42
+ var text = key.substring(0, sep - 1);
43
+ var styleId = key.substring(sep + 3);
44
+ return { text: text, styleId: styleId };
45
+ };
46
+ var getLabel = function (text, styleId) {
47
+ var key = makeCacheKey(text, styleId);
48
+ var label = labelCacheByTextAndStyle.get(key);
49
+ if (label) {
50
+ label.lastUsed = Date.now();
51
+ }
52
+ return label;
53
+ };
54
+ var setLabel = function (text, styleId, label) {
55
+ var key = makeCacheKey(text, styleId);
56
+ // TODO should we worry about key collisions if using custom textures?
57
+ labelCacheByTextAndStyle.set(key, label);
58
+ };
59
+ var checkStyle = function (currentStyleId, newStyle) {
60
+ var currentStyle = styleCache[currentStyleId.toString()];
61
+ if (currentStyle) {
62
+ return checkTextStyleEqual(currentStyle.style, newStyle);
63
+ }
64
+ return false;
65
+ };
66
+ var clearCacheByStyle = function (styleId) {
67
+ for (var _i = 0, _a = Array.from(labelCacheByTextAndStyle.keys()); _i < _a.length; _i++) {
68
+ var keyStr = _a[_i];
69
+ var _b = parseCacheKey(keyStr), text = _b.text, keyStyleId = _b.styleId;
70
+ if (keyStyleId === styleId) {
71
+ labelCacheByTextAndStyle.delete(keyStr);
72
+ }
73
+ }
74
+ };
75
+ var maxSize = 100;
76
+ var minAge = 1000 * 60;
77
+ var lastUsed = 0;
78
+ var getMaxSize = function () { return maxSize; };
79
+ var setMaxSize = function (size) {
80
+ maxSize = size;
81
+ };
82
+ var getMinAge = function () { return minAge; };
83
+ var setMinAge = function (ageInMs) {
84
+ minAge = ageInMs;
85
+ };
86
+ var pruneCache = function () {
87
+ var latest = Date.now() - minAge;
88
+ if (labelCacheByTextAndStyle.size > maxSize && lastUsed < latest) {
89
+ try {
90
+ // remove more than we need so we do this less.
91
+ var toRemove = (labelCacheByTextAndStyle.size - maxSize) * 2;
92
+ // Sort the items by LastUsed ascending
93
+ var labels = Array.from(labelCacheByTextAndStyle.entries());
94
+ labels.sort(function (a, b) { return a[1].lastUsed - b[1].lastUsed; });
95
+ // remove earliest
96
+ for (var index = 0; index < toRemove; index++) {
97
+ var _a = labels[index], key = _a[0], label = _a[1];
98
+ if (label.lastUsed < latest) {
99
+ label.bitmapTexture = (0, Deleter_1.deleteSafe)(label.bitmapTexture);
100
+ labelCacheByTextAndStyle.delete(key);
101
+ }
102
+ else if (index === 0) {
103
+ lastUsed = label.lastUsed;
104
+ }
105
+ }
106
+ }
107
+ catch (err) {
108
+ console.warn(err);
109
+ }
110
+ }
111
+ };
112
+ var checkTextStyleEqual = function (style1, style2) {
113
+ return (style1.alignment === style2.alignment &&
114
+ style1.color === style2.color &&
115
+ style1.fontFamily === style2.fontFamily &&
116
+ style1.fontSize === style2.fontSize &&
117
+ style1.fontStyle === style2.fontStyle &&
118
+ style1.fontWeight === style2.fontWeight &&
119
+ ((style1.padding === undefined && style2.padding === undefined) || style1.padding.equals(style2.padding)) &&
120
+ style1.extras === style2.extras &&
121
+ style1.rotation === style2.rotation &&
122
+ style1.providerId === style2.providerId);
123
+ };
124
+ var resetCache = function () {
125
+ labelCacheByTextAndStyle.clear();
126
+ // tslint:disable-next-line: forin
127
+ for (var key in styleCache) {
128
+ delete styleCache[key];
129
+ }
130
+ };
131
+ /**
132
+ * A global cache for labels, used by all labelProviders, to reduce the amount of time spent creating label textures.
133
+ */
134
+ exports.labelCache = {
135
+ /** Get an identifier for the given text style. Returns an existing identifier if a matching style exists in the cache */
136
+ getStyleId: getStyleId,
137
+ /**
138
+ * Notify the cache that a style is no longer used.
139
+ * Linked labels are only deleted when there are no remaining uses, and then only after minAge has passed.
140
+ */
141
+ freeStyle: freeStyle,
142
+ /** Get a label from the cache. Returns undefined if none found. */
143
+ getLabel: getLabel,
144
+ /** Add a label to the cache */
145
+ setLabel: setLabel,
146
+ /** Check if a text style matches the one for the given id */
147
+ checkStyle: checkStyle,
148
+ /** Get the maximum number of labels allowed to be stored in the cache. Used when calling pruneCache */
149
+ getMaxSize: getMaxSize,
150
+ /** Set the maximum number of labels allowed to be stored in the cache. Used when calling pruneCache */
151
+ setMaxSize: setMaxSize,
152
+ /** Get the minimum age (time since last used) of labels in the cache.
153
+ * This prevents recently used labels from being pruned, or removed when style is freed
154
+ */
155
+ getMinAge: getMinAge,
156
+ /** Set the minimum age (time since last used) of labels in the cache.
157
+ * This prevents recently used labels from being pruned, or removed when style is freed
158
+ */
159
+ setMinAge: setMinAge,
160
+ /** Remove old labels from the cache, if there are more than MaxSize. */
161
+ pruneCache: pruneCache,
162
+ /** Completely clears and resets the cache. Testing use only */
163
+ resetCache: resetCache
164
+ };
@@ -95,7 +95,7 @@ export declare abstract class LabelProvider {
95
95
  applyFormat(value: string): string;
96
96
  toJSON(): {
97
97
  type: string;
98
- options: Required<Pick<ILabelOptions, "labelFormat" | "labelPrecision" | "cursorLabelFormat" | "cursorLabelPrecision" | "labelPrefix" | "labelPostfix">>;
98
+ options: Required<Omit<ILabelOptions, never>>;
99
99
  };
100
100
  protected invalidateParent(): void;
101
101
  }
@@ -2,26 +2,57 @@ import { IDeletable } from "../../../../Core/IDeletable";
2
2
  import { TSRTexture } from "../../../../types/TSciChart";
3
3
  import { TextureManager, TTextureObject } from "../../TextureManager/TextureManager";
4
4
  import { TTextStyle } from "../AxisCore";
5
+ import { TCachedLabelStyle } from "./LabelCache";
5
6
  import { ILabelOptions, LabelProvider } from "./LabelProvider";
6
- export declare type TLabelInfo = {
7
+ export declare class LabelInfo {
7
8
  tick: number;
8
9
  text: string;
9
10
  bitmapTexture: TSRTexture;
10
11
  textureHeight: number;
11
12
  textureWidth: number;
12
13
  lastUsed: number;
13
- };
14
+ private subs;
15
+ constructor(tick: number, text: string, bitmapTexture: TSRTexture, textureHeight: number, textureWidth: number);
16
+ registerNotifier(callback: () => void): void;
17
+ textureUpdated(): void;
18
+ }
14
19
  export interface ILabel2DOptions extends ILabelOptions {
15
20
  rotation?: number;
21
+ /**
22
+ * Experimental - set true to enable async label texture creation
23
+ * Can be set globally using SciChartDefaults.asyncLabels = true;
24
+ * When false getLabelTexture is used. When true, getLabelTextureAsync is used.
25
+ */
26
+ asyncLabels?: boolean;
27
+ /**
28
+ * Whether to use cached labels from other axes that have the same style.
29
+ * You may need to set this false if you are overriding getLabelTexture or getLabelTextureAsync without setting a unique style.
30
+ */
31
+ useSharedCache?: boolean;
16
32
  }
17
33
  /**
18
34
  * The {@link LabelProviderBase2D} provides base functionality for 2D label providers, including caching of label textures
19
35
  */
20
36
  export declare abstract class LabelProviderBase2D extends LabelProvider implements IDeletable {
21
37
  useCache: boolean;
38
+ /** Whether to use cached labels from other axes that have the same style.
39
+ * You may need to set this false if you are overriding getLabelTexture without setting a unique style.
40
+ * Can be set globally using SciChartDefaults. Currently default false.
41
+ */
42
+ useSharedCache: boolean;
43
+ /**
44
+ * Experimental - set true to enable async label texture creation
45
+ * Can be set globally using SciChartDefaults. Currently default false.
46
+ */
47
+ asyncLabels: boolean;
22
48
  protected tickToText: Map<number, string>;
23
- protected labelCacheByText: Map<string, TLabelInfo>;
24
- private cachedLabelStyle;
49
+ /**
50
+ * This is the id for the text style used by this axis, as stored in the label cache. Cached labels are accessed by text and styleId.
51
+ * If you have useSharedCache = true and are overriding getLabelTexture or getLabelTextureAsync and do not ensure the style is unique,
52
+ * you might not get the labels you expect.
53
+ * You can either set useSharedCache = false, set this to some unique value, or override getCachedStyle
54
+ */
55
+ protected styleId: string;
25
56
  private rotationProperty;
26
57
  constructor(options?: ILabel2DOptions);
27
58
  get rotation(): number;
@@ -72,14 +103,33 @@ export declare abstract class LabelProviderBase2D extends LabelProvider implemen
72
103
  * @param labelStyle The style for the text
73
104
  * @returns A TTextureObject containing the bitmapTexture and the size
74
105
  */
106
+ getCachedLabelTexture(labelText: string, textureManager: TextureManager, labelStyle: TTextStyle): TTextureObject;
107
+ /**
108
+ * Create a texture for the given label text asynchronously. This method is called if asyncLabels is true, otherwise getLabelTexture is used.
109
+ * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
110
+ * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
111
+ */
112
+ getLabelTextureAsync(labelText: string, textureManager: TextureManager, labelStyle: TTextStyle): Promise<TTextureObject>;
113
+ /**
114
+ * Create a texture for the given label text. This method is called if asyncLabels is false, otherwise getLabelTextureAsync is used.
115
+ * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
116
+ * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
117
+ */
75
118
  getLabelTexture(labelText: string, textureManager: TextureManager, labelStyle: TTextStyle): TTextureObject;
76
119
  delete(): void;
77
- checkTextStyleEqual(style1: TTextStyle, style2: TTextStyle): boolean;
78
120
  toJSON(): {
79
121
  type: string;
80
- options: Required<Pick<ILabelOptions, "labelFormat" | "labelPrecision" | "cursorLabelFormat" | "cursorLabelPrecision" | "labelPrefix" | "labelPostfix">>;
122
+ options: Required<Omit<ILabelOptions, never>>;
81
123
  };
124
+ protected providerId: string;
125
+ /**
126
+ * This method creates the text style to be stored in the label cache.
127
+ * When useSharedCache = true, the label cache will generate a new styleId if this style does not match any existing style.
128
+ * Cached labels are accessed by text and styleId.
129
+ * If you are overriding getLabelTexture or getLabelTextureAsync and do not ensure the style is unique, you might not get the labels you expect.
130
+ * You can either set useSharedCache = false, override this and set the extras field in {@link TCachedLabelStyle}, or set styleId directly
131
+ */
132
+ protected getCachedStyle(): TCachedLabelStyle;
82
133
  protected clearCache(): void;
83
134
  protected invalidateParent(): void;
84
- protected pruneCache(maxSize: number): void;
85
135
  }
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -23,26 +25,87 @@ var __assign = (this && this.__assign) || function () {
23
25
  };
24
26
  return __assign.apply(this, arguments);
25
27
  };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
26
64
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.LabelProviderBase2D = void 0;
65
+ exports.LabelProviderBase2D = exports.LabelInfo = void 0;
28
66
  var app_1 = require("../../../../constants/app");
29
- var Deleter_1 = require("../../../../Core/Deleter");
67
+ var guid_1 = require("../../../../utils/guid");
68
+ var TextureWorker_1 = require("../../../Services/Workers/TextureWorker");
69
+ var SciChartDefaults_1 = require("../../SciChartDefaults");
30
70
  var TextureManager_1 = require("../../TextureManager/TextureManager");
71
+ var LabelCache_1 = require("./LabelCache");
31
72
  var LabelProvider_1 = require("./LabelProvider");
73
+ var LabelInfo = /** @class */ (function () {
74
+ function LabelInfo(tick, text, bitmapTexture, textureHeight, textureWidth) {
75
+ this.subs = [];
76
+ this.tick = tick;
77
+ this.text = text;
78
+ this.bitmapTexture = bitmapTexture;
79
+ this.textureHeight = textureHeight;
80
+ this.textureWidth = textureWidth;
81
+ this.lastUsed = Date.now();
82
+ }
83
+ LabelInfo.prototype.registerNotifier = function (callback) {
84
+ this.subs.push(callback);
85
+ };
86
+ LabelInfo.prototype.textureUpdated = function () {
87
+ this.subs.forEach(function (notifier) { return notifier(); });
88
+ this.subs = [];
89
+ };
90
+ return LabelInfo;
91
+ }());
92
+ exports.LabelInfo = LabelInfo;
32
93
  /**
33
94
  * The {@link LabelProviderBase2D} provides base functionality for 2D label providers, including caching of label textures
34
95
  */
96
+ // tslint:disable-next-line: max-classes-per-file
35
97
  var LabelProviderBase2D = /** @class */ (function (_super) {
36
98
  __extends(LabelProviderBase2D, _super);
37
99
  function LabelProviderBase2D(options) {
38
- var _a;
100
+ var _a, _b, _c;
39
101
  var _this = _super.call(this, options) || this;
40
102
  _this.useCache = !app_1.IS_TEST_ENV;
41
103
  _this.tickToText = new Map();
42
- _this.labelCacheByText = new Map();
43
- _this.cachedLabelStyle = null;
44
104
  _this.rotationProperty = 0;
105
+ _this.providerId = (0, guid_1.generateGuid)();
45
106
  _this.rotationProperty = (_a = options === null || options === void 0 ? void 0 : options.rotation) !== null && _a !== void 0 ? _a : _this.rotationProperty;
107
+ _this.asyncLabels = (_b = options === null || options === void 0 ? void 0 : options.asyncLabels) !== null && _b !== void 0 ? _b : SciChartDefaults_1.SciChartDefaults.asyncLabels;
108
+ _this.useSharedCache = (_c = options === null || options === void 0 ? void 0 : options.useSharedCache) !== null && _c !== void 0 ? _c : SciChartDefaults_1.SciChartDefaults.useSharedCache;
46
109
  return _this;
47
110
  }
48
111
  Object.defineProperty(LabelProviderBase2D.prototype, "rotation", {
@@ -50,8 +113,10 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
50
113
  return this.rotationProperty;
51
114
  },
52
115
  set: function (value) {
53
- this.rotationProperty = value;
54
- this.invalidateParent();
116
+ if (this.rotationProperty !== value) {
117
+ this.rotationProperty = value;
118
+ this.invalidateParent();
119
+ }
55
120
  },
56
121
  enumerable: false,
57
122
  configurable: true
@@ -63,12 +128,12 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
63
128
  LabelProviderBase2D.prototype.getLabels = function (majorTicks) {
64
129
  var _this = this;
65
130
  var axis = this.parentAxis;
66
- if (!this.cachedLabelStyle) {
67
- this.cachedLabelStyle = __assign({}, axis.dpiAdjustedLabelStyle);
131
+ if (!this.styleId) {
132
+ this.styleId = LabelCache_1.labelCache.getStyleId(this.getCachedStyle());
68
133
  }
69
- else if (!this.checkTextStyleEqual(this.cachedLabelStyle, axis.dpiAdjustedLabelStyle)) {
134
+ else if (!LabelCache_1.labelCache.checkStyle(this.styleId, this.getCachedStyle())) {
70
135
  this.delete();
71
- this.cachedLabelStyle = __assign({}, axis.dpiAdjustedLabelStyle);
136
+ this.styleId = LabelCache_1.labelCache.getStyleId(this.getCachedStyle());
72
137
  }
73
138
  var ticks = majorTicks;
74
139
  if (this.parentAxis.isCategoryAxis) {
@@ -82,20 +147,21 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
82
147
  var cachedLabelText = this.tickToText.get(tick);
83
148
  var cachedLabel = void 0;
84
149
  if (cachedLabelText) {
85
- cachedLabel = this.labelCacheByText.get(cachedLabelText);
150
+ cachedLabel = LabelCache_1.labelCache.getLabel(cachedLabelText, this.styleId);
86
151
  labels.push(cachedLabelText);
87
- cachedLabel.lastUsed = Date.now();
88
152
  }
89
153
  else {
90
154
  var text = this.formatLabel(tick);
91
- var texture = this.getLabelTexture(text, axis.axisRenderer.textureManager, axis.dpiAdjustedLabelStyle);
92
- cachedLabel = __assign(__assign({ tick: tick, text: text }, texture), { lastUsed: Date.now() });
93
155
  this.tickToText.set(tick, text);
94
- this.labelCacheByText.set(text, cachedLabel);
156
+ var texture = this.getCachedLabelTexture(text, axis.axisRenderer.textureManager, axis.dpiAdjustedLabelStyle);
157
+ if (texture.textureWidth !== null) {
158
+ cachedLabel = new LabelInfo(tick, text, texture.bitmapTexture, texture.textureHeight, texture.textureWidth);
159
+ LabelCache_1.labelCache.setLabel(text, this.styleId, cachedLabel);
160
+ }
95
161
  labels.push(text);
96
162
  }
97
163
  }
98
- this.pruneCache(majorTicks.length * 2);
164
+ LabelCache_1.labelCache.pruneCache();
99
165
  }
100
166
  else {
101
167
  labels = ticks.map(function (t) { return _this.formatLabel(t); });
@@ -111,10 +177,10 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
111
177
  */
112
178
  LabelProviderBase2D.prototype.getLabelHeight = function (ctx, labelText, labelStyle) {
113
179
  if (this.rotationProperty % 90 === 0 || this.parentAxis.isHorizontalAxis) {
114
- var cachedLabel = this.labelCacheByText.get(labelText);
115
- if (!cachedLabel) {
180
+ var cachedLabel = LabelCache_1.labelCache.getLabel(labelText, this.styleId);
181
+ if (!cachedLabel || !cachedLabel.textureHeight) {
116
182
  var fontSize = labelStyle.fontSize, padding = labelStyle.padding;
117
- return TextureManager_1.measureTextHeight(fontSize) + (padding === null || padding === void 0 ? void 0 : padding.top) + (padding === null || padding === void 0 ? void 0 : padding.bottom);
183
+ return (0, TextureManager_1.measureTextHeight)(fontSize) + (padding === null || padding === void 0 ? void 0 : padding.top) + (padding === null || padding === void 0 ? void 0 : padding.bottom);
118
184
  }
119
185
  return cachedLabel.textureHeight;
120
186
  }
@@ -131,10 +197,10 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
131
197
  */
132
198
  LabelProviderBase2D.prototype.getLabelWidth = function (ctx, labelText, labelStyle) {
133
199
  if (this.rotationProperty % 90 === 0 || !this.parentAxis.isHorizontalAxis) {
134
- var cachedlabel = this.labelCacheByText.get(labelText);
135
- if (!cachedlabel) {
200
+ var cachedlabel = LabelCache_1.labelCache.getLabel(labelText, this.styleId);
201
+ if (!cachedlabel || !cachedlabel.textureWidth) {
136
202
  var padding = labelStyle.padding;
137
- return TextureManager_1.measureTextWidth(ctx, labelText) + padding.left + padding.right;
203
+ return (0, TextureManager_1.measureTextWidth)(ctx, labelText) + padding.left + padding.right;
138
204
  }
139
205
  return cachedlabel.textureWidth;
140
206
  }
@@ -183,57 +249,110 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
183
249
  * @param labelStyle The style for the text
184
250
  * @returns A TTextureObject containing the bitmapTexture and the size
185
251
  */
186
- LabelProviderBase2D.prototype.getLabelTexture = function (labelText, textureManager, labelStyle) {
187
- var cachedLabel = this.labelCacheByText.get(labelText);
252
+ LabelProviderBase2D.prototype.getCachedLabelTexture = function (labelText, textureManager, labelStyle) {
253
+ var _this = this;
254
+ var _a;
255
+ var cachedLabel = LabelCache_1.labelCache.getLabel(labelText, this.styleId);
188
256
  if (cachedLabel) {
257
+ if (cachedLabel.textureWidth === undefined) {
258
+ // Log when this texture request was made. Kill and restart if too old
259
+ // Make sure this chart redraws if it is waiting on a label that was requested by a different chart
260
+ cachedLabel.registerNotifier(function () { return _super.prototype.invalidateParent.call(_this); });
261
+ }
189
262
  return {
190
- textureWidth: cachedLabel.textureWidth,
263
+ textureWidth: (_a = cachedLabel.textureWidth) !== null && _a !== void 0 ? _a : null,
191
264
  textureHeight: cachedLabel.textureHeight,
192
265
  bitmapTexture: cachedLabel.bitmapTexture
193
266
  };
194
267
  }
268
+ else if (this.asyncLabels) {
269
+ // Capture the styleId as it might have changed by the time the result comes in.
270
+ var callBackStyleId_1 = this.styleId;
271
+ this.getLabelTextureAsync(labelText, textureManager, labelStyle).then(function (result) {
272
+ var cached = LabelCache_1.labelCache.getLabel(labelText, callBackStyleId_1);
273
+ // This may not exist if the target chart has been deleted already.
274
+ if (cached) {
275
+ cached.textureHeight = result.textureHeight;
276
+ cached.textureWidth = result.textureWidth;
277
+ cached.bitmapTexture = result.bitmapTexture;
278
+ cached.textureUpdated();
279
+ // this.invalidateParent also clears cache, which we don't want here.
280
+ _super.prototype.invalidateParent.call(_this);
281
+ }
282
+ });
283
+ return {
284
+ textureWidth: undefined,
285
+ textureHeight: undefined,
286
+ bitmapTexture: undefined
287
+ };
288
+ }
195
289
  else {
196
- return textureManager.createTextTexture([labelText], labelStyle, this.rotationProperty);
290
+ return this.getLabelTexture(labelText, textureManager, labelStyle);
197
291
  }
198
292
  };
293
+ /**
294
+ * Create a texture for the given label text asynchronously. This method is called if asyncLabels is true, otherwise getLabelTexture is used.
295
+ * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
296
+ * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
297
+ */
298
+ LabelProviderBase2D.prototype.getLabelTextureAsync = function (labelText, textureManager, labelStyle) {
299
+ return __awaiter(this, void 0, void 0, function () {
300
+ var image;
301
+ return __generator(this, function (_a) {
302
+ switch (_a.label) {
303
+ case 0:
304
+ if (!TextureWorker_1.textureWorker.isActive) return [3 /*break*/, 2];
305
+ return [4 /*yield*/, TextureWorker_1.textureWorker.measureAndGetImageData([labelText], labelStyle, this.rotationProperty)];
306
+ case 1:
307
+ image = _a.sent();
308
+ return [2 /*return*/, textureManager.createTextureFromImageData(image.imageData, image.textureWidth, image.textureHeight)];
309
+ case 2: return [2 /*return*/, this.getLabelTexture(labelText, textureManager, labelStyle)];
310
+ }
311
+ });
312
+ });
313
+ };
314
+ /**
315
+ * Create a texture for the given label text. This method is called if asyncLabels is false, otherwise getLabelTextureAsync is used.
316
+ * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
317
+ * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
318
+ */
319
+ LabelProviderBase2D.prototype.getLabelTexture = function (labelText, textureManager, labelStyle) {
320
+ return textureManager.createTextTexture([labelText], labelStyle, this.rotationProperty);
321
+ };
199
322
  LabelProviderBase2D.prototype.delete = function () {
200
- var labels = Array.from(this.labelCacheByText.values());
201
- for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
202
- var label = labels_1[_i];
203
- try {
204
- label.bitmapTexture = Deleter_1.deleteSafe(label.bitmapTexture);
205
- }
206
- catch (err) { }
323
+ if (this.styleId) {
324
+ LabelCache_1.labelCache.freeStyle(this.styleId);
207
325
  }
208
326
  this.tickToText.clear();
209
- this.labelCacheByText.clear();
210
- this.cachedLabelStyle = null;
211
- };
212
- LabelProviderBase2D.prototype.checkTextStyleEqual = function (style1, style2) {
213
- return (style1.alignment === style2.alignment &&
214
- style1.color === style2.color &&
215
- style1.fontFamily === style2.fontFamily &&
216
- style1.fontSize === style2.fontSize &&
217
- style1.fontStyle === style2.fontStyle &&
218
- style1.fontWeight === style2.fontWeight &&
219
- style1.padding.equals(style2.padding));
327
+ this.styleId = null;
220
328
  };
221
329
  LabelProviderBase2D.prototype.toJSON = function () {
222
330
  var json = _super.prototype.toJSON.call(this);
223
331
  var options = {
224
- rotation: this.rotation
332
+ rotation: this.rotation,
333
+ asyncLabels: this.asyncLabels,
334
+ useSharedCache: this.useSharedCache
225
335
  };
226
336
  Object.assign(json.options, options);
227
337
  return json;
228
338
  };
339
+ /**
340
+ * This method creates the text style to be stored in the label cache.
341
+ * When useSharedCache = true, the label cache will generate a new styleId if this style does not match any existing style.
342
+ * Cached labels are accessed by text and styleId.
343
+ * If you are overriding getLabelTexture or getLabelTextureAsync and do not ensure the style is unique, you might not get the labels you expect.
344
+ * You can either set useSharedCache = false, override this and set the extras field in {@link TCachedLabelStyle}, or set styleId directly
345
+ */
346
+ LabelProviderBase2D.prototype.getCachedStyle = function () {
347
+ var axis = this.parentAxis;
348
+ return __assign(__assign({}, axis.dpiAdjustedLabelStyle), { rotation: this.rotation, providerId: this.useSharedCache ? undefined : this.providerId });
349
+ };
229
350
  LabelProviderBase2D.prototype.clearCache = function () {
230
351
  if (this.useCache) {
231
352
  // Clear cache if property changed
232
- var labels = Array.from(this.labelCacheByText.values());
233
- for (var index = 0; index < this.labelCacheByText.size; index++) {
234
- var element = labels[index];
235
- element.bitmapTexture = Deleter_1.deleteSafe(element.bitmapTexture);
236
- this.labelCacheByText.delete(element.text);
353
+ if (this.styleId) {
354
+ LabelCache_1.labelCache.freeStyle(this.styleId);
355
+ this.styleId = undefined;
237
356
  }
238
357
  this.tickToText.clear();
239
358
  }
@@ -242,28 +361,6 @@ var LabelProviderBase2D = /** @class */ (function (_super) {
242
361
  this.clearCache();
243
362
  _super.prototype.invalidateParent.call(this);
244
363
  };
245
- LabelProviderBase2D.prototype.pruneCache = function (maxSize) {
246
- if (this.labelCacheByText.size > maxSize) {
247
- // remove more than we need so we do this less.
248
- var toRemove = (maxSize - this.labelCacheByText.size) * 2;
249
- // Sort the items by LastUsed ascending
250
- var labels = Array.from(this.labelCacheByText.values());
251
- labels.sort(function (a, b) { return a.lastUsed - b.lastUsed; });
252
- var tickMap = Array.from(this.tickToText.entries());
253
- // remove earliest
254
- for (var index = 0; index < toRemove; index++) {
255
- var element = labels[index];
256
- element.bitmapTexture = Deleter_1.deleteSafe(element.bitmapTexture);
257
- this.labelCacheByText.delete(element.text);
258
- for (var _i = 0, tickMap_1 = tickMap; _i < tickMap_1.length; _i++) {
259
- var entry = tickMap_1[_i];
260
- if (entry[1] === element.text) {
261
- this.tickToText.delete(entry[0]);
262
- }
263
- }
264
- }
265
- }
266
- };
267
364
  return LabelProviderBase2D;
268
365
  }(LabelProvider_1.LabelProvider));
269
366
  exports.LabelProviderBase2D = LabelProviderBase2D;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -42,8 +44,8 @@ var LogarithmicLabelProvider = /** @class */ (function (_super) {
42
44
  var _this = _super.call(this, __assign({ labelFormat: (_a = options === null || options === void 0 ? void 0 : options.labelFormat) !== null && _a !== void 0 ? _a : NumericFormat_1.ENumericFormat.Scientific, labelPrecision: (_b = options === null || options === void 0 ? void 0 : options.labelPrecision) !== null && _b !== void 0 ? _b : 1 }, options)) || this;
43
45
  _this.formatLabelProperty = function (dataValue) {
44
46
  return _this.numericFormat === NumericFormat_1.ENumericFormat.Scientific
45
- ? _this.applyFormat(number_1.toScientific(dataValue, _this.precision, _this.logarithmicBase))
46
- : _this.applyFormat(number_1.formatNumber(dataValue, _this.numericFormat, _this.precision));
47
+ ? _this.applyFormat((0, number_1.toScientific)(dataValue, _this.precision, _this.logarithmicBase))
48
+ : _this.applyFormat((0, number_1.formatNumber)(dataValue, _this.numericFormat, _this.precision));
47
49
  };
48
50
  return _this;
49
51
  }