@devexperts/dxcharts-lite 2.7.16 → 2.7.17

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 (50) hide show
  1. package/dist/chart/animation/canvas-animation.d.ts +1 -0
  2. package/dist/chart/animation/canvas-animation.js +2 -1
  3. package/dist/chart/animation/viewport-model-animation.d.ts +4 -1
  4. package/dist/chart/animation/viewport-model-animation.js +21 -3
  5. package/dist/chart/bootstrap.js +17 -5
  6. package/dist/chart/chart.config.js +1 -1
  7. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +16 -16
  8. package/dist/chart/components/chart/chart-area-pan.handler.js +8 -2
  9. package/dist/chart/components/chart/chart.component.js +2 -0
  10. package/dist/chart/components/chart/chart.model.d.ts +11 -0
  11. package/dist/chart/components/chart/chart.model.js +20 -0
  12. package/dist/chart/components/cross_tool/cross-tool.component.d.ts +3 -1
  13. package/dist/chart/components/cross_tool/cross-tool.component.js +3 -2
  14. package/dist/chart/components/cross_tool/cross-tool.model.d.ts +6 -3
  15. package/dist/chart/components/cross_tool/cross-tool.model.js +9 -5
  16. package/dist/chart/components/grid/grid.component.d.ts +1 -1
  17. package/dist/chart/components/grid/grid.component.js +2 -2
  18. package/dist/chart/components/grid/grid.drawer.d.ts +2 -1
  19. package/dist/chart/components/grid/grid.drawer.js +3 -2
  20. package/dist/chart/components/pan/chart-pan.component.js +17 -1
  21. package/dist/chart/components/pane/pane.component.js +3 -1
  22. package/dist/chart/drawers/data-series-drawers/trend-points.drawer.d.ts +12 -0
  23. package/dist/chart/drawers/data-series-drawers/trend-points.drawer.js +70 -0
  24. package/dist/chart/drawers/drawing-manager.js +0 -1
  25. package/dist/chart/inputhandlers/chart-resize.handler.d.ts +5 -0
  26. package/dist/chart/inputhandlers/chart-resize.handler.js +9 -1
  27. package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +28 -0
  28. package/dist/chart/inputlisteners/canvas-input-listener.component.js +104 -7
  29. package/dist/chart/model/data-series.config.d.ts +1 -1
  30. package/dist/chart/model/hit-test-canvas.model.d.ts +15 -13
  31. package/dist/chart/model/hit-test-canvas.model.js +2 -2
  32. package/dist/chart/model/scale.model.d.ts +5 -0
  33. package/dist/chart/model/scale.model.js +72 -6
  34. package/dist/chart/utils/device/touchpad.utils.d.ts +1 -0
  35. package/dist/chart/utils/device/touchpad.utils.js +1 -1
  36. package/dist/chart/utils/math.utils.js +1 -1
  37. package/dist/chart/utils/performance/queue-microtask.utils.d.ts +5 -0
  38. package/dist/chart/utils/performance/queue-microtask.utils.js +12 -0
  39. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.d.ts +1 -0
  40. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +3 -0
  41. package/dist/chart/utils/performance/safari/components/animations/safari-canvas-animation.d.ts +77 -0
  42. package/dist/chart/utils/performance/safari/components/animations/safari-canvas-animation.js +137 -0
  43. package/dist/chart/utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler.d.ts +54 -0
  44. package/dist/chart/utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler.js +180 -0
  45. package/dist/chart/utils/performance/safari/safari-performance.model.d.ts +32 -0
  46. package/dist/chart/utils/performance/safari/safari-performance.model.js +31 -0
  47. package/dist/chart/utils/performance/safari/safari-performance.utils.d.ts +18 -0
  48. package/dist/chart/utils/performance/safari/safari-performance.utils.js +34 -0
  49. package/dist/dxchart.min.js +4 -4
  50. package/package.json +2 -2
@@ -9,6 +9,7 @@ import { ViewportModel } from '../model/scaling/viewport.model';
9
9
  import { ColorAlphaAnimation, ColorAlphaAnimationConfig } from './types/color-alpha-animation';
10
10
  import { ColorTransitionAnimation, ColorTransitionAnimationConfig } from './types/color-transition-animation';
11
11
  import { ViewportMovementAnimation, ViewportMovementAnimationConfig } from './types/viewport-movement-animation';
12
+ export declare const DEFAULT_ANIMATION_TIME_MS: number;
12
13
  export declare const VIEWPORT_ANIMATION_ID = "VIEWPORT_ANIMATION";
13
14
  export interface AnimationConfig {
14
15
  duration: number;
@@ -9,7 +9,8 @@ import { uuid } from '../utils/uuid.utils';
9
9
  import { ColorAlphaAnimation } from './types/color-alpha-animation';
10
10
  import { ColorTransitionAnimation } from './types/color-transition-animation';
11
11
  import { ViewportMovementAnimation } from './types/viewport-movement-animation';
12
- const DEFAULT_ANIMATION_TIME_MS = 400;
12
+ import { isSafari } from '../utils/device/touchpad.utils';
13
+ export const DEFAULT_ANIMATION_TIME_MS = isSafari ? 150 : 400;
13
14
  export const VIEWPORT_ANIMATION_ID = 'VIEWPORT_ANIMATION';
14
15
  /**
15
16
  * Singleton animation container for all chart animations.
@@ -5,11 +5,14 @@
5
5
  */
6
6
  import { CanvasAnimation } from './canvas-animation';
7
7
  import { ViewportModel, ViewportModelState } from '../model/scaling/viewport.model';
8
+ import { AutoScaleViewportSubModel } from '../model/scaling/auto-scale.model';
8
9
  /**
9
- * Starts the animation for chart viewport movement.
10
+ * Starts the animation for chart viewport movement for safari.
10
11
  * @param canvasAnimation
11
12
  * @param viewportModel
12
13
  * @param state
14
+ * @param autoScaleModel - Optional autoScale model to apply before animation
13
15
  * @doc-tags animation,viewport
14
16
  */
17
+ export declare const startViewportModelAnimationSafari: (canvasAnimation: CanvasAnimation, viewportModel: ViewportModel, state: ViewportModelState, autoScaleModel?: AutoScaleViewportSubModel) => void;
15
18
  export declare const startViewportModelAnimation: (canvasAnimation: CanvasAnimation, viewportModel: ViewportModel, state: ViewportModelState) => void;
@@ -3,15 +3,33 @@
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 { VIEWPORT_ANIMATION_ID } from './canvas-animation';
7
- const VIEWPORT_ANIMATION_DURATION_MS = 400;
6
+ import { DEFAULT_ANIMATION_TIME_MS, VIEWPORT_ANIMATION_ID } from './canvas-animation';
7
+ const VIEWPORT_ANIMATION_DURATION_MS = DEFAULT_ANIMATION_TIME_MS;
8
+ const STUCK_ANIMATION_THRESHOLD = 0.90; // Force finish animations stuck at 90%+
8
9
  /**
9
- * Starts the animation for chart viewport movement.
10
+ * Starts the animation for chart viewport movement for safari.
10
11
  * @param canvasAnimation
11
12
  * @param viewportModel
12
13
  * @param state
14
+ * @param autoScaleModel - Optional autoScale model to apply before animation
13
15
  * @doc-tags animation,viewport
14
16
  */
17
+ export const startViewportModelAnimationSafari = (canvasAnimation, viewportModel, state, autoScaleModel) => {
18
+ // Force finish stuck animations to prevent memory leaks
19
+ if (viewportModel.currentAnimation && viewportModel.currentAnimation.animationInProgress) {
20
+ const progress = viewportModel.currentAnimation.getProgress();
21
+ // Force finish animation if it's taking too long (prevent stuck animations)
22
+ if (progress > STUCK_ANIMATION_THRESHOLD) {
23
+ viewportModel.currentAnimation.finishAnimation();
24
+ viewportModel.currentAnimation = undefined;
25
+ }
26
+ }
27
+ // Apply autoScale BEFORE starting animation to get correct Y scale
28
+ if (autoScaleModel) {
29
+ autoScaleModel.doAutoYScale(state);
30
+ }
31
+ startViewportModelAnimation(canvasAnimation, viewportModel, state);
32
+ };
15
33
  export const startViewportModelAnimation = (canvasAnimation, viewportModel, state) => {
16
34
  const animation = canvasAnimation.startViewportMovementAnimation(viewportModel, {
17
35
  duration: VIEWPORT_ANIMATION_DURATION_MS,
@@ -45,6 +45,8 @@ import { TimeZoneModel } from './model/time-zone.model';
45
45
  import { clearerSafe } from './utils/function.utils';
46
46
  import { merge } from './utils/merge.utils';
47
47
  import { HitTestComponent } from './components/hit-test/hit-test.component';
48
+ import { isSafari } from './utils/device/touchpad.utils';
49
+ import { SafariCanvasAnimation } from './utils/performance/safari/components/animations/safari-canvas-animation';
48
50
  /**
49
51
  * @deprecated use {Chart} instead
50
52
  */
@@ -100,13 +102,23 @@ export default class ChartBootstrap {
100
102
  this.canvasInputListener = canvasInputListener;
101
103
  this.chartComponents.push(this.canvasInputListener);
102
104
  //#endregion
103
- const hitTestCanvasModel = new HitTestCanvasModel(eventBus, elements.hitTestCanvas, canvasInputListener, canvasBoundsContainer, drawingManager, config, this.canvasModels, elements.chartResizer);
105
+ const hitTestCanvasModelParams = [
106
+ eventBus,
107
+ elements.hitTestCanvas,
108
+ canvasInputListener,
109
+ canvasBoundsContainer,
110
+ drawingManager,
111
+ config,
112
+ this.canvasModels,
113
+ elements.chartResizer,
114
+ ];
115
+ const hitTestCanvasModel = new HitTestCanvasModel(...hitTestCanvasModelParams);
104
116
  this.hitTestCanvasModel = hitTestCanvasModel;
105
117
  const hitTestClearCanvas = new ClearCanvasDrawer(hitTestCanvasModel);
106
118
  drawingManager.addDrawer(hitTestClearCanvas, 'HIT_TEST_CLEAR');
107
119
  //#endregion
108
- // canvas animation container
109
- const canvasAnimation = new CanvasAnimation(eventBus);
120
+ // canvas animation container, safari has separate animation logic due to browser specifics
121
+ const canvasAnimation = isSafari ? new SafariCanvasAnimation(eventBus) : new CanvasAnimation(eventBus);
110
122
  this.canvasAnimation = canvasAnimation;
111
123
  const chartPaneId = CanvasElement.PANE_UUID(CHART_UUID);
112
124
  //#region ScaleModel init
@@ -181,11 +193,11 @@ export default class ChartBootstrap {
181
193
  this.volumesComponent = new VolumesComponent(this.dynamicObjectsCanvasModel, chartComponent, scaleModel, canvasBoundsContainer, drawingManager, config, paneManager, this.dynamicObjects);
182
194
  this.chartComponents.push(this.volumesComponent);
183
195
  // grid component
184
- const verticalGridComponent = new GridComponent(mainCanvasModel, scaleModel, config, this.yAxisComponent.state, 'GRID', drawingManager, () => this.canvasBoundsContainer.getBounds(CanvasElement.ALL_PANES), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.xAxisComponent.xAxisLabelsGenerator.labels, () => [], undefined, undefined, () => config.components.grid.visible);
196
+ const verticalGridComponent = new GridComponent(mainCanvasModel, scaleModel, config, this.yAxisComponent.state, 'GRID', drawingManager, () => this.canvasBoundsContainer.getBounds(CanvasElement.ALL_PANES), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.xAxisComponent.xAxisLabelsGenerator.labels, () => [], undefined, undefined, () => config.components.grid.visible, this.mainPane.mainExtent.idx);
185
197
  this.chartComponents.push(verticalGridComponent);
186
198
  this.hoverProducer = new HoverProducerComponent(this.crossEventProducer, scaleModel, config, chartModel, canvasInputListener, this.canvasBoundsContainer, this.paneManager, timeZoneModel, chartPanComponent.mainCanvasTouchHandler, formatterFactory);
187
199
  this.chartComponents.push(this.hoverProducer);
188
- this.crossToolComponent = new CrossToolComponent(config, crossToolCanvasModel, canvasBoundsContainer, drawingManager, paneManager, this.crossEventProducer, this.hoverProducer, this.chartComponent.baselineModel);
200
+ this.crossToolComponent = new CrossToolComponent(config, crossToolCanvasModel, canvasBoundsContainer, drawingManager, paneManager, this.crossEventProducer, this.hoverProducer, this.chartComponent.baselineModel, this.chartModel);
189
201
  this.chartComponents.push(this.crossToolComponent);
190
202
  // Snapshot component
191
203
  const snapshotCanvasModel = createCanvasModel(eventBus, elements.snapshotCanvas, config, drawingManager, this.canvasModels, elements.chartResizer);
@@ -216,7 +216,7 @@ export const getDefaultConfig = () => ({
216
216
  },
217
217
  crossTool: {
218
218
  type: 'cross-and-labels',
219
- discrete: false,
219
+ discrete: true,
220
220
  magnetTarget: 'none',
221
221
  lineDash: [4, 6],
222
222
  xAxisLabelFormat: [
@@ -11,13 +11,14 @@ import { CanvasInputListenerComponent, Point } from '../../inputlisteners/canvas
11
11
  import { ChartBaseElement } from '../../model/chart-base-element';
12
12
  import { ScaleModel } from '../../model/scale.model';
13
13
  import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
14
+ import { DragInfo } from '../dran-n-drop_helper/drag-n-drop.component';
14
15
  import { ChartPanComponent } from '../pan/chart-pan.component';
15
16
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
16
17
  export interface ChartWheelEvent {
17
18
  readonly originalEvent: WheelEvent;
18
19
  readonly candleIdx: number;
19
20
  }
20
- interface ChartPanningOptions {
21
+ export interface ChartPanningOptions {
21
22
  horizontal: boolean;
22
23
  vertical: boolean;
23
24
  }
@@ -39,15 +40,15 @@ interface ChartPanningOptions {
39
40
  * @param {ChartPanComponent} chartPanComponent - An instance of the ChartPanComponent class.
40
41
  */
41
42
  export declare class ChartAreaPanHandler extends ChartBaseElement {
42
- private bus;
43
- private config;
44
- private scale;
45
- private canvasInputListener;
46
- private canvasBoundsContainer;
47
- private canvasAnimation;
48
- private chartPanComponent;
49
- private hitTestCanvasModel;
50
- private currentPoint;
43
+ protected bus: EventBus;
44
+ protected config: FullChartConfig;
45
+ protected scale: ScaleModel;
46
+ protected canvasInputListener: CanvasInputListenerComponent;
47
+ protected canvasBoundsContainer: CanvasBoundsContainer;
48
+ protected canvasAnimation: CanvasAnimation;
49
+ protected chartPanComponent: ChartPanComponent;
50
+ protected hitTestCanvasModel: HitTestCanvasModel;
51
+ protected currentPoint: Point;
51
52
  xDraggedCandlesDelta: number;
52
53
  lastXStart: number;
53
54
  wheelThrottleTime: number;
@@ -64,14 +65,14 @@ export declare class ChartAreaPanHandler extends ChartBaseElement {
64
65
  * @param {number} zoomSensitivity - zoom sensitivity
65
66
  * @returns {void}
66
67
  */
67
- private zoomXHandler;
68
+ protected zoomXHandler: (e: WheelEvent, zoomSensitivity: number) => void;
68
69
  /**
69
70
  * This method is used to activate the zoom functionality of the canvas. It extends the doActivate method of the parent class.
70
71
  * @protected
71
72
  * @returns {void}
72
73
  */
73
74
  protected doActivate(): void;
74
- private calculateDynamicSesitivity;
75
+ protected calculateDynamicSesitivity(e: WheelEvent, maxSensitivity: number): number;
75
76
  /**
76
77
  * Registers a handler for panning the chart along the Y-axis.
77
78
  * @param {ScaleModel} scale - The scale model of the extent.
@@ -79,9 +80,9 @@ export declare class ChartAreaPanHandler extends ChartBaseElement {
79
80
  * @returns {DragNDropYComponent} - The drag and drop component for panning the chart along the Y-axis.
80
81
  */
81
82
  registerChartYPanHandler(scale: ScaleModel, hitTest: HitBoundsTest): DragNDropYComponent;
82
- private onXDragStart;
83
- private onXDragTick;
84
- private onXDragEnd;
83
+ protected onXDragStart: () => void;
84
+ protected onXDragTick: (dragInfo: DragInfo) => void;
85
+ protected onXDragEnd: () => void;
85
86
  }
86
87
  /**
87
88
  * This function calculates angle between current point and point(0, 0), and compares the result with config values
@@ -91,4 +92,3 @@ export declare class ChartAreaPanHandler extends ChartBaseElement {
91
92
  * @doc-tags chart-core,auto-scale,y-axis
92
93
  */
93
94
  export declare const shouldDisableAutoScale: (point: Point, config: Required<AutoScaleDisableOnDrag>) => boolean;
94
- export {};
@@ -46,7 +46,10 @@ export class ChartAreaPanHandler extends ChartBaseElement {
46
46
  this.xDraggedCandlesDelta = 0;
47
47
  this.lastXStart = 0;
48
48
  this.wheelThrottleTime = 15; // in ms
49
- this.chartPanningOptions = { horizontal: true, vertical: true };
49
+ this.chartPanningOptions = {
50
+ horizontal: true,
51
+ vertical: true,
52
+ };
50
53
  /**
51
54
  * It observes the wheel event on all panes of the canvas and throttles it to the specified time.
52
55
  * It then calculates the zoom sensitivity based on whether the event was triggered by a touchpad or not.
@@ -117,7 +120,10 @@ export class ChartAreaPanHandler extends ChartBaseElement {
117
120
  //#endregion
118
121
  this.addRxSubscription(this.canvasInputListener
119
122
  .observeWheel(allPanesHitTest)
120
- .pipe(filter(() => this.chartPanningOptions.horizontal && this.chartPanningOptions.vertical), throttleTime(this.wheelThrottleTime, animationFrameScheduler, { trailing: true, leading: true }))
123
+ .pipe(filter(() => this.chartPanningOptions.horizontal && this.chartPanningOptions.vertical), throttleTime(this.wheelThrottleTime, animationFrameScheduler, {
124
+ trailing: true,
125
+ leading: true,
126
+ }))
121
127
  .subscribe(e => {
122
128
  const device = deviceDetector();
123
129
  const direction = device === 'apple' || device === 'mobile' ? -1 : 1;
@@ -34,6 +34,7 @@ import { deleteCandlesIndex } from './candle.functions';
34
34
  import { TrendHistogramDrawer } from '../../drawers/data-series-drawers/trend-histogram.drawer';
35
35
  import { debounce } from '../../utils/performance/debounce.utils';
36
36
  import { LinearTrendDrawer } from '../../drawers/data-series-drawers/linear-trend.drawer';
37
+ import { TrendPointsDrawer } from '../../drawers/data-series-drawers/trend-points.drawer';
37
38
  /**
38
39
  * Represents a financial instrument to be displayed on a chart
39
40
  * @class
@@ -187,6 +188,7 @@ export class ChartComponent extends ChartBaseElement {
187
188
  this.registerDataSeriesTypeDrawer('HISTOGRAM', new HistogramDrawer());
188
189
  this.registerDataSeriesTypeDrawer('TREND_HISTOGRAM', new TrendHistogramDrawer());
189
190
  this.registerDataSeriesTypeDrawer('POINTS', new PointsDrawer());
191
+ this.registerDataSeriesTypeDrawer('TREND_POINTS', new TrendPointsDrawer());
190
192
  this.registerDataSeriesTypeDrawer('COLOR_CANDLE', new CandleSeriesWrapper(new ColorCandleDrawer(this.chartModel), this.config, mainChartBoundsProvider));
191
193
  this.registerDataSeriesTypeDrawer('TEXT', new TextDrawer(this.config));
192
194
  this.registerDataSeriesTypeDrawer('TRIANGLE', new TriangleDrawer());
@@ -109,6 +109,12 @@ export declare class ChartModel extends ChartBaseElement {
109
109
  * Applies the basic scale viewport transformer to the visual points of the main candle series and fires a draw event.
110
110
  */
111
111
  doBasicScale(): void;
112
+ /**
113
+ * Applies the basic scale only on x-axis.
114
+ * @param forceNoAnimations - A boolean value for disabling scale animations. Defaults to false.
115
+ * @param withZoom - A boolean value for enabling zoom. Defaults to false.
116
+ */
117
+ doBasicXScale(): void;
112
118
  /**
113
119
  * Changes the time frame scale to the previous one and redraws the chart.
114
120
  * @param {boolean | null} zoomIn - If true, zooms in the chart, if false, zooms out the chart, if null, does not zoom.
@@ -370,6 +376,11 @@ export declare class ChartModel extends ChartBaseElement {
370
376
  * @returns {boolean} - True if the candle is within the viewport, false otherwise.
371
377
  */
372
378
  isCandleInViewport(idx: number): boolean;
379
+ /**
380
+ * Checks if the last candle is within the viewport.
381
+ * @returns {boolean} - True if the last candle is within the viewport, false otherwise.
382
+ */
383
+ isLastCandleInViewport(): boolean;
373
384
  /**
374
385
  * Updates candles in series. Default is main series.
375
386
  * Any number of candles may be provided - they would be matched by their index and updated.
@@ -254,6 +254,15 @@ export class ChartModel extends ChartBaseElement {
254
254
  this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints);
255
255
  this.bus.fireDraw();
256
256
  }
257
+ /**
258
+ * Applies the basic scale only on x-axis.
259
+ * @param forceNoAnimations - A boolean value for disabling scale animations. Defaults to false.
260
+ * @param withZoom - A boolean value for enabling zoom. Defaults to false.
261
+ */
262
+ doBasicXScale() {
263
+ this.scale.setXScaleWithoutYScale(this.mainCandleSeries.visualPoints);
264
+ this.bus.fireDraw();
265
+ }
257
266
  /**
258
267
  * Changes the time frame scale to the previous one and redraws the chart.
259
268
  * @param {boolean | null} zoomIn - If true, zooms in the chart, if false, zooms out the chart, if null, does not zoom.
@@ -746,6 +755,17 @@ export class ChartModel extends ChartBaseElement {
746
755
  isCandleInViewport(idx) {
747
756
  return this.getFirstIdx() <= idx && idx <= this.getLastIdx();
748
757
  }
758
+ /**
759
+ * Checks if the last candle is within the viewport.
760
+ * @returns {boolean} - True if the last candle is within the viewport, false otherwise.
761
+ */
762
+ isLastCandleInViewport() {
763
+ const lastCandle = this.getLastCandle();
764
+ if (lastCandle && lastCandle.idx) {
765
+ return this.isCandleInViewport(lastCandle.idx);
766
+ }
767
+ return false;
768
+ }
749
769
  /**
750
770
  * Updates candles in series. Default is main series.
751
771
  * Any number of candles may be provided - they would be matched by their index and updated.
@@ -11,6 +11,7 @@ import { HoverProducerComponent } from '../../inputhandlers/hover-producer.compo
11
11
  import { BaselineModel } from '../../model/baseline.model';
12
12
  import { CanvasModel } from '../../model/canvas.model';
13
13
  import { ChartBaseElement } from '../../model/chart-base-element';
14
+ import { ChartModel } from '../chart/chart.model';
14
15
  import { PaneManager } from '../pane/pane-manager.component';
15
16
  import { CrossToolTypeDrawer } from './cross-tool.drawer';
16
17
  import { CrossToolModel, CrossToolType } from './cross-tool.model';
@@ -27,9 +28,10 @@ export declare class CrossToolComponent extends ChartBaseElement {
27
28
  private crossEventProducer;
28
29
  private hoverProducer;
29
30
  private baselineModel;
31
+ private chartModel;
30
32
  readonly model: CrossToolModel;
31
33
  private readonly crossToolTypeDrawers;
32
- constructor(config: FullChartConfig, crossToolCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, drawingManager: DrawingManager, paneManager: PaneManager, crossEventProducer: CrossEventProducerComponent, hoverProducer: HoverProducerComponent, baselineModel: BaselineModel);
34
+ constructor(config: FullChartConfig, crossToolCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, drawingManager: DrawingManager, paneManager: PaneManager, crossEventProducer: CrossEventProducerComponent, hoverProducer: HoverProducerComponent, baselineModel: BaselineModel, chartModel: ChartModel);
33
35
  /**
34
36
  * Registers default drawer types for the chart.
35
37
  * @private
@@ -14,7 +14,7 @@ import { NoneDrawerType } from './types/none.drawer';
14
14
  * Default bundled chart cross tool.
15
15
  */
16
16
  export class CrossToolComponent extends ChartBaseElement {
17
- constructor(config, crossToolCanvasModel, canvasBoundsContainer, drawingManager, paneManager, crossEventProducer, hoverProducer, baselineModel) {
17
+ constructor(config, crossToolCanvasModel, canvasBoundsContainer, drawingManager, paneManager, crossEventProducer, hoverProducer, baselineModel, chartModel) {
18
18
  super();
19
19
  this.config = config;
20
20
  this.crossToolCanvasModel = crossToolCanvasModel;
@@ -24,8 +24,9 @@ export class CrossToolComponent extends ChartBaseElement {
24
24
  this.crossEventProducer = crossEventProducer;
25
25
  this.hoverProducer = hoverProducer;
26
26
  this.baselineModel = baselineModel;
27
+ this.chartModel = chartModel;
27
28
  this.crossToolTypeDrawers = {};
28
- this.model = new CrossToolModel(config.components.crossTool, this.crossToolCanvasModel, this.crossEventProducer, this.hoverProducer, this.canvasBoundsContainer, this.baselineModel);
29
+ this.model = new CrossToolModel(config.components.crossTool, this.crossToolCanvasModel, this.crossEventProducer, this.hoverProducer, this.canvasBoundsContainer, this.baselineModel, this.chartModel);
29
30
  this.addChildEntity(this.model);
30
31
  const clearCanvasDrawer = new ClearCanvasDrawer(this.crossToolCanvasModel);
31
32
  this.registerDefaultDrawerTypes();
@@ -11,6 +11,7 @@ import { CanvasModel } from '../../model/canvas.model';
11
11
  import { ChartBaseElement } from '../../model/chart-base-element';
12
12
  import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
13
13
  import { BaselineModel } from '../../model/baseline.model';
14
+ import { ChartModel } from '../chart/chart.model';
14
15
  export type CrossToolType = 'cross-and-labels' | 'only-labels' | 'none' | string;
15
16
  export interface CrossToolHover {
16
17
  x: number;
@@ -25,10 +26,11 @@ export declare class CrossToolModel extends ChartBaseElement {
25
26
  private hoverProducer;
26
27
  private canvasBoundsContainer;
27
28
  private baselineModel;
29
+ private chartModel;
28
30
  currentHoverSubject: BehaviorSubject<CrossToolHover | null>;
29
31
  get currentHover(): CrossToolHover | null;
30
32
  set currentHover(value: CrossToolHover | null);
31
- constructor(config: Required<ChartConfigComponentsCrossTool>, crossToolCanvasModel: CanvasModel, crossEventProducer: CrossEventProducerComponent, hoverProducer: HoverProducerComponent, canvasBoundsContainer: CanvasBoundsContainer, baselineModel: BaselineModel);
33
+ constructor(config: Required<ChartConfigComponentsCrossTool>, crossToolCanvasModel: CanvasModel, crossEventProducer: CrossEventProducerComponent, hoverProducer: HoverProducerComponent, canvasBoundsContainer: CanvasBoundsContainer, baselineModel: BaselineModel, chartModel: ChartModel);
32
34
  /**
33
35
  * Sets the type of the CrossTool object.
34
36
  *
@@ -49,7 +51,8 @@ export declare class CrossToolModel extends ChartBaseElement {
49
51
  /**
50
52
  * Updates the current hover position with the provided hover object.
51
53
  * @param {Object} hover - The hover object containing the x and y coordinates and time formatted.
52
- * @param magnetTarget {MagnetTarget}
54
+ * @param {MagnetTarget} magnetTarget
55
+ * @param {boolean} discrete
53
56
  * @param {number} hover.x - The x coordinate of the hover.
54
57
  * @param {number} hover.y - The y coordinate of the hover.
55
58
  * @param {string} hover.timeFormatted - The formatted time of the hover.
@@ -61,6 +64,6 @@ export declare class CrossToolModel extends ChartBaseElement {
61
64
  * @param {number} hover.candleHover.closestOHLCY - The y coordinate of the closest OHLC price of the candle.
62
65
  * @returns {void}
63
66
  */
64
- updateCrossTool(hover: Hover, magnetTarget?: import("./cross-tool.component").MagnetTarget): void;
67
+ updateCrossTool(hover: Hover, magnetTarget?: import("./cross-tool.component").MagnetTarget, discrete?: boolean): void;
65
68
  private updateCrossToolMobile;
66
69
  }
@@ -14,7 +14,7 @@ export class CrossToolModel extends ChartBaseElement {
14
14
  set currentHover(value) {
15
15
  this.currentHoverSubject.next(value);
16
16
  }
17
- constructor(config, crossToolCanvasModel, crossEventProducer, hoverProducer, canvasBoundsContainer, baselineModel) {
17
+ constructor(config, crossToolCanvasModel, crossEventProducer, hoverProducer, canvasBoundsContainer, baselineModel, chartModel) {
18
18
  super();
19
19
  this.config = config;
20
20
  this.crossToolCanvasModel = crossToolCanvasModel;
@@ -22,6 +22,7 @@ export class CrossToolModel extends ChartBaseElement {
22
22
  this.hoverProducer = hoverProducer;
23
23
  this.canvasBoundsContainer = canvasBoundsContainer;
24
24
  this.baselineModel = baselineModel;
25
+ this.chartModel = chartModel;
25
26
  // the main hover object which will be presented on UI
26
27
  this.currentHoverSubject = new BehaviorSubject(null);
27
28
  }
@@ -84,7 +85,8 @@ export class CrossToolModel extends ChartBaseElement {
84
85
  /**
85
86
  * Updates the current hover position with the provided hover object.
86
87
  * @param {Object} hover - The hover object containing the x and y coordinates and time formatted.
87
- * @param magnetTarget {MagnetTarget}
88
+ * @param {MagnetTarget} magnetTarget
89
+ * @param {boolean} discrete
88
90
  * @param {number} hover.x - The x coordinate of the hover.
89
91
  * @param {number} hover.y - The y coordinate of the hover.
90
92
  * @param {string} hover.timeFormatted - The formatted time of the hover.
@@ -96,12 +98,14 @@ export class CrossToolModel extends ChartBaseElement {
96
98
  * @param {number} hover.candleHover.closestOHLCY - The y coordinate of the closest OHLC price of the candle.
97
99
  * @returns {void}
98
100
  */
99
- updateCrossTool(hover, magnetTarget = this.config.magnetTarget) {
101
+ updateCrossTool(hover, magnetTarget = this.config.magnetTarget, discrete = this.config.discrete) {
102
+ var _a;
103
+ const x = discrete ? this.chartModel.toX((_a = this.chartModel.candleFromX(hover.x, true).idx) !== null && _a !== void 0 ? _a : 0) : hover.x;
100
104
  if (this.currentHover === null) {
101
- this.currentHover = { x: hover.x, y: 0, time: hover.timeFormatted, paneId: hover.paneId };
105
+ this.currentHover = { x, y: 0, time: hover.timeFormatted, paneId: hover.paneId };
102
106
  }
103
107
  else {
104
- this.currentHover.x = hover.x;
108
+ this.currentHover.x = x;
105
109
  this.currentHover.time = hover.timeFormatted;
106
110
  }
107
111
  if (hover.candleHover && hover.paneId === CHART_UUID) {
@@ -15,7 +15,7 @@ export declare class GridComponent extends ChartBaseElement {
15
15
  private drawerName;
16
16
  private drawingManager;
17
17
  private readonly drawer;
18
- constructor(canvasModel: CanvasModel, viewportModel: ViewportModel, config: FullChartConfig, yAxisState: YAxisConfig, drawerName: string, drawingManager: DrawingManager | CompositeDrawer, xBoundsProvider: BoundsProvider, yBoundsProvider: BoundsProvider, xLabelsProvider: () => NumericAxisLabel[], yLabelsProvider: () => NumericAxisLabel[], extentIdx?: number, getBaseline?: () => Unit, drawPredicate?: () => boolean);
18
+ constructor(canvasModel: CanvasModel, viewportModel: ViewportModel, config: FullChartConfig, yAxisState: YAxisConfig, drawerName: string, drawingManager: DrawingManager | CompositeDrawer, xBoundsProvider: BoundsProvider, yBoundsProvider: BoundsProvider, xLabelsProvider: () => NumericAxisLabel[], yLabelsProvider: () => NumericAxisLabel[], extentIdx?: number, getBaseline?: () => Unit, drawPredicate?: () => boolean, mainExtentIdx?: number);
19
19
  /**
20
20
  * This method is used to deactivate the drawer and remove it from the drawing manager.
21
21
  * @protected
@@ -6,11 +6,11 @@
6
6
  import { ChartBaseElement } from '../../model/chart-base-element';
7
7
  import { GridDrawer } from './grid.drawer';
8
8
  export class GridComponent extends ChartBaseElement {
9
- constructor(canvasModel, viewportModel, config, yAxisState, drawerName, drawingManager, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, extentIdx, getBaseline, drawPredicate) {
9
+ constructor(canvasModel, viewportModel, config, yAxisState, drawerName, drawingManager, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, extentIdx, getBaseline, drawPredicate, mainExtentIdx) {
10
10
  super();
11
11
  this.drawerName = drawerName;
12
12
  this.drawingManager = drawingManager;
13
- this.drawer = new GridDrawer(canvasModel, viewportModel, config, yAxisState, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, drawPredicate, extentIdx, getBaseline);
13
+ this.drawer = new GridDrawer(canvasModel, viewportModel, config, yAxisState, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, drawPredicate, extentIdx, getBaseline, mainExtentIdx);
14
14
  }
15
15
  /**
16
16
  * This method is used to deactivate the drawer and remove it from the drawing manager.
@@ -28,7 +28,8 @@ export declare class GridDrawer implements Drawer {
28
28
  private drawPredicate;
29
29
  private extentIdx?;
30
30
  private getBaseline?;
31
- constructor(canvasModel: CanvasModel, viewportModel: ViewportModel, config: FullChartConfig, yAxisState: YAxisConfig, xBoundsProvider: BoundsProvider, yBoundsProvider: BoundsProvider, xLabelsProvider: () => NumericAxisLabel[], yLabelsProvider: () => NumericAxisLabel[], drawPredicate?: () => boolean, extentIdx?: number | undefined, getBaseline?: (() => Unit) | undefined);
31
+ private mainExtentIdx?;
32
+ constructor(canvasModel: CanvasModel, viewportModel: ViewportModel, config: FullChartConfig, yAxisState: YAxisConfig, xBoundsProvider: BoundsProvider, yBoundsProvider: BoundsProvider, xLabelsProvider: () => NumericAxisLabel[], yLabelsProvider: () => NumericAxisLabel[], drawPredicate?: () => boolean, extentIdx?: number | undefined, getBaseline?: (() => Unit) | undefined, mainExtentIdx?: number | undefined);
32
33
  /**
33
34
  * Draws the chart on the canvas if the drawPredicate is true.
34
35
  * @returns {void}
@@ -11,7 +11,7 @@ import { floorToDPR } from '../../utils/device/device-pixel-ratio.utils';
11
11
  * Draws grid lines on chart.
12
12
  */
13
13
  export class GridDrawer {
14
- constructor(canvasModel, viewportModel, config, yAxisState, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, drawPredicate = () => true, extentIdx, getBaseline) {
14
+ constructor(canvasModel, viewportModel, config, yAxisState, xBoundsProvider, yBoundsProvider, xLabelsProvider, yLabelsProvider, drawPredicate = () => true, extentIdx, getBaseline, mainExtentIdx) {
15
15
  this.canvasModel = canvasModel;
16
16
  this.viewportModel = viewportModel;
17
17
  this.config = config;
@@ -23,6 +23,7 @@ export class GridDrawer {
23
23
  this.drawPredicate = drawPredicate;
24
24
  this.extentIdx = extentIdx;
25
25
  this.getBaseline = getBaseline;
26
+ this.mainExtentIdx = mainExtentIdx;
26
27
  }
27
28
  /**
28
29
  * Draws the chart on the canvas if the drawPredicate is true.
@@ -87,7 +88,7 @@ export class GridDrawer {
87
88
  */
88
89
  drawHorizontal(ctx) {
89
90
  const yAxisLabels = this.yLabelsProvider();
90
- if (yAxisLabels.length && this.config.components.grid.horizontal) {
91
+ if (yAxisLabels.length > 0 && this.config.components.grid.horizontal && this.extentIdx === this.mainExtentIdx) {
91
92
  ctx.lineWidth = this.config.components.grid.width;
92
93
  ctx.strokeStyle = this.config.colors.chartAreaTheme.gridColor;
93
94
  ctx.setLineDash(this.config.components.grid.dash || []);
@@ -7,6 +7,8 @@ import { CanvasElement } from '../../canvas/canvas-bounds-container';
7
7
  import { ChartBaseElement } from '../../model/chart-base-element';
8
8
  import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
9
9
  import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
10
+ import { isSafari } from '../../utils/device/touchpad.utils';
11
+ import { SafariChartAreaPanHandler } from '../../utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler';
10
12
  export class ChartPanComponent extends ChartBaseElement {
11
13
  constructor(eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, mainCanvasParent, chartBaseModel, hitTestCanvasModel) {
12
14
  super();
@@ -19,7 +21,21 @@ export class ChartPanComponent extends ChartBaseElement {
19
21
  this.mainCanvasParent = mainCanvasParent;
20
22
  this.chartBaseModel = chartBaseModel;
21
23
  this.hitTestCanvasModel = hitTestCanvasModel;
22
- this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this, this.hitTestCanvasModel);
24
+ const chartAreaPanHandlerParams = [
25
+ this.eventBus,
26
+ this.config,
27
+ this.mainScale,
28
+ this.canvasInputListener,
29
+ this.canvasBoundsContainer,
30
+ this.canvasAnimation,
31
+ this,
32
+ this.hitTestCanvasModel,
33
+ ];
34
+ // Different performance logic for Safari because of browser specifics
35
+ const chartAreaPanHandler = isSafari
36
+ ? new SafariChartAreaPanHandler(...chartAreaPanHandlerParams)
37
+ : new ChartAreaPanHandler(...chartAreaPanHandlerParams);
38
+ this.chartAreaPanHandler = chartAreaPanHandler;
23
39
  this.addChildEntity(this.chartAreaPanHandler);
24
40
  this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES));
25
41
  this.addChildEntity(this.mainCanvasTouchHandler);
@@ -95,8 +95,10 @@ export class PaneComponent extends ChartBaseElement {
95
95
  * @returns {GridComponent} - The newly created GridComponent instance.
96
96
  */
97
97
  createGridComponent(uuid, extentIdx, scale, yAxisState, yAxisLabelsGetter, yAxisBaselineGetter) {
98
+ var _a, _b;
98
99
  const chartPaneId = CanvasElement.PANE_UUID(uuid);
99
- const gridComponent = new GridComponent(this.mainCanvasModel, scale, this.config, yAxisState, `PANE_${uuid}_${extentIdx}_grid_drawer`, this.drawingManager, () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => [], yAxisLabelsGetter, extentIdx, yAxisBaselineGetter, () => this.config.components.grid.visible);
100
+ const mainExtentIdx = (_b = (_a = this.mainExtent) === null || _a === void 0 ? void 0 : _a.idx) !== null && _b !== void 0 ? _b : 0;
101
+ const gridComponent = new GridComponent(this.mainCanvasModel, scale, this.config, yAxisState, `PANE_${uuid}_${extentIdx}_grid_drawer`, this.drawingManager, () => this.canvasBoundsContainer.getBounds(chartPaneId), () => this.canvasBoundsContainer.getBounds(chartPaneId), () => [], yAxisLabelsGetter, extentIdx, yAxisBaselineGetter, () => this.config.components.grid.visible, mainExtentIdx);
100
102
  return gridComponent;
101
103
  }
102
104
  /**
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ import { VisualSeriesPoint, DataSeriesModel } from '../../model/data-series.model';
7
+ import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
8
+ export declare class TrendPointsDrawer implements SeriesDrawer {
9
+ constructor();
10
+ draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
11
+ }
12
+ export declare const previousValue: (arr: VisualSeriesPoint[], idx: number) => number | undefined;