@devexperts/dxcharts-lite 2.5.5 → 2.5.7

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 (34) hide show
  1. package/dist/chart/bootstrap.js +1 -1
  2. package/dist/chart/canvas/canvas-bounds-container.d.ts +21 -0
  3. package/dist/chart/canvas/canvas-bounds-container.js +31 -1
  4. package/dist/chart/chart.js +2 -1
  5. package/dist/chart/components/chart/basic-scale.js +0 -1
  6. package/dist/chart/components/chart/chart.model.d.ts +0 -21
  7. package/dist/chart/components/chart/chart.model.js +3 -33
  8. package/dist/chart/components/pan/chart-pan.component.js +2 -1
  9. package/dist/chart/components/pane/pane-manager.component.d.ts +3 -1
  10. package/dist/chart/components/pane/pane-manager.component.js +3 -2
  11. package/dist/chart/components/pane/pane.component.d.ts +3 -1
  12. package/dist/chart/components/pane/pane.component.js +3 -2
  13. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +4 -2
  14. package/dist/chart/components/x_axis/x-axis-scale.handler.js +16 -8
  15. package/dist/chart/components/x_axis/x-axis.component.js +1 -1
  16. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +3 -1
  17. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +5 -3
  18. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +1 -0
  19. package/dist/chart/components/y_axis/y-axis-scale.handler.js +18 -1
  20. package/dist/chart/components/y_axis/y-axis.component.d.ts +3 -1
  21. package/dist/chart/components/y_axis/y-axis.component.js +3 -2
  22. package/dist/chart/components/y_axis/y-axis.model.d.ts +2 -1
  23. package/dist/chart/components/y_axis/y-axis.model.js +2 -2
  24. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +3 -1
  25. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +4 -3
  26. package/dist/chart/model/scale.model.d.ts +5 -10
  27. package/dist/chart/model/scale.model.js +35 -34
  28. package/dist/chart/model/scaling/lock-ratio.model.d.ts +6 -6
  29. package/dist/chart/model/scaling/lock-ratio.model.js +27 -21
  30. package/dist/chart/model/scaling/viewport.model.js +6 -1
  31. package/dist/chart/utils/color.utils.d.ts +3 -0
  32. package/dist/chart/utils/color.utils.js +5 -1
  33. package/dist/dxchart.min.js +4 -4
  34. package/package.json +1 -1
@@ -130,7 +130,7 @@ export default class ChartBootstrap {
130
130
  const hitTestComponent = new HitTestComponent(hitTestCanvasModel, canvasAnimation, eventBus);
131
131
  this.hitTestComponent = hitTestComponent;
132
132
  this.chartComponents.push(hitTestComponent);
133
- const paneManager = new PaneManager(chartBaseModel, this.dynamicObjectsCanvasModel, this.userInputListenerComponents, eventBus, scaleModel, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, this.cursorHandler, this.crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, this.hitTestCanvasModel);
133
+ const paneManager = new PaneManager(chartBaseModel, this.dynamicObjectsCanvasModel, this.userInputListenerComponents, eventBus, scaleModel, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, this.cursorHandler, this.crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, this.hitTestCanvasModel, this.chartResizeHandler);
134
134
  this.paneManager = paneManager;
135
135
  const mainPane = this.paneManager.panes[CHART_UUID];
136
136
  this.mainPane = mainPane;
@@ -328,6 +328,27 @@ export declare class CanvasBoundsContainer {
328
328
  * @deprecated This method should be removed as candleSeries is not a part of CanvasBoundsContainer.
329
329
  */
330
330
  setMainCandleSeries(candleSeries: CandleSeriesModel): void;
331
+ /**
332
+ * Returns the effective width of the Y axis.
333
+ *
334
+ * @function
335
+ * @name getEffectiveYAxisWidth
336
+ * @returns {number} The effective width of the Y axis.
337
+ */
338
+ getEffectiveYAxisWidth(): number;
339
+ /**
340
+ * Returns the effective width of the chart.
341
+ *
342
+ * @function
343
+ * @returns {number} The effective width of the chart.
344
+ */
345
+ getEffectiveChartWidth(): number;
346
+ /**
347
+ * Returns the effective height of the chart.
348
+ *
349
+ * @returns {number} The effective height of the chart.
350
+ */
351
+ getEffectiveChartHeight(): number;
331
352
  }
332
353
  export declare const getHeightRatios: (pecLength: number) => [number, number];
333
354
  export declare const isInBounds: (point: Point, bounds: Bounds) => boolean;
@@ -83,7 +83,7 @@ export class CanvasBoundsContainer {
83
83
  this.rightRatio = 0;
84
84
  this.boundsChangedSubject = new Subject();
85
85
  this.barResizerChangedSubject = new Subject();
86
- this._graphsHeightRatio = { chart: 1 };
86
+ this._graphsHeightRatio = { [CHART_UUID]: 1 };
87
87
  this.graphsHeightRatioChangedSubject = new Subject();
88
88
  this.boundsChangedSubscriptions = {};
89
89
  chartResizeHandler.canvasResized.subscribe(bcr => {
@@ -824,6 +824,36 @@ export class CanvasBoundsContainer {
824
824
  setMainCandleSeries(candleSeries) {
825
825
  this.mainCandleSeries = candleSeries;
826
826
  }
827
+ /**
828
+ * Returns the effective width of the Y axis.
829
+ *
830
+ * @function
831
+ * @name getEffectiveYAxisWidth
832
+ * @returns {number} The effective width of the Y axis.
833
+ */
834
+ getEffectiveYAxisWidth() {
835
+ const yAxis = this.getBounds(CanvasElement.PANE_UUID_Y_AXIS(CHART_UUID));
836
+ return yAxis.width;
837
+ }
838
+ /**
839
+ * Returns the effective width of the chart.
840
+ *
841
+ * @function
842
+ * @returns {number} The effective width of the chart.
843
+ */
844
+ getEffectiveChartWidth() {
845
+ const chart = this.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
846
+ return chart.width;
847
+ }
848
+ /**
849
+ * Returns the effective height of the chart.
850
+ *
851
+ * @returns {number} The effective height of the chart.
852
+ */
853
+ getEffectiveChartHeight() {
854
+ const chart = this.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
855
+ return chart.height;
856
+ }
827
857
  }
828
858
  // paneCounter=chartHeightRatio: 0=1, 1=0.8, 2=0.6, 3=0.5, 4=0.4, 5=0.4
829
859
  const DEFAULT_RATIOS = {
@@ -100,7 +100,8 @@ export class Chart extends ChartBootstrap {
100
100
  this.bus.fireDraw();
101
101
  }
102
102
  setChartType(type) {
103
- this.chartComponent.setChartType(type);
103
+ this.data.setChartType(type);
104
+ this.yAxis.updateOrderedLabels();
104
105
  }
105
106
  createPane() {
106
107
  return this.paneManager.createPane();
@@ -15,7 +15,6 @@ export const createBasicScaleViewportTransformer = (scale) => (visualCandleSourc
15
15
  const endCandle = vCandles[vCandles.length - 1];
16
16
  scale.setXScale(startCandle.startUnit, endCandle.startUnit + endCandle.width + scale.offsets.right);
17
17
  scale.doAutoScale(true);
18
- scale.recalculateZoomXYRatio();
19
18
  scale.fireChanged();
20
19
  }
21
20
  };
@@ -173,27 +173,6 @@ export declare class ChartModel extends ChartBaseElement {
173
173
  * @returns {void}
174
174
  */
175
175
  setAutoScale(auto: boolean): void;
176
- /**
177
- * Returns the effective width of the Y axis.
178
- *
179
- * @function
180
- * @name getEffectiveYAxisWidth
181
- * @returns {number} The effective width of the Y axis.
182
- */
183
- getEffectiveYAxisWidth(): number;
184
- /**
185
- * Returns the effective width of the chart.
186
- *
187
- * @function
188
- * @returns {number} The effective width of the chart.
189
- */
190
- getEffectiveChartWidth(): number;
191
- /**
192
- * Returns the effective height of the chart.
193
- *
194
- * @returns {number} The effective height of the chart.
195
- */
196
- getEffectiveChartHeight(): number;
197
176
  /**
198
177
  * Updates the offsets of the chart components and redraws the chart.
199
178
  * @param {Partial<ChartConfigComponentsOffsets>} offsets - The new offsets to be applied to the chart components.
@@ -103,8 +103,8 @@ export class ChartModel extends ChartBaseElement {
103
103
  */
104
104
  handleChartResize(nextCB) {
105
105
  if (nextCB.width > MIN_SUPPORTED_CANVAS_SIZE.width && nextCB.height > MIN_SUPPORTED_CANVAS_SIZE.height) {
106
- const nextChartWidth = this.getEffectiveChartWidth();
107
- const nextYAxisWidth = this.getEffectiveYAxisWidth();
106
+ const nextChartWidth = this.canvasBoundsContainer.getEffectiveChartWidth();
107
+ const nextYAxisWidth = this.canvasBoundsContainer.getEffectiveYAxisWidth();
108
108
  if (this.prevChartWidth === 0) {
109
109
  this.scale.isViewportValid() ? this.scale.recalculateZoom() : this.doBasicScale();
110
110
  this.prevChartWidth = nextChartWidth;
@@ -420,36 +420,6 @@ export class ChartModel extends ChartBaseElement {
420
420
  setAutoScale(auto) {
421
421
  this.scale.autoScale(auto);
422
422
  }
423
- /**
424
- * Returns the effective width of the Y axis.
425
- *
426
- * @function
427
- * @name getEffectiveYAxisWidth
428
- * @returns {number} The effective width of the Y axis.
429
- */
430
- getEffectiveYAxisWidth() {
431
- const yAxis = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(CHART_UUID));
432
- return yAxis.width;
433
- }
434
- /**
435
- * Returns the effective width of the chart.
436
- *
437
- * @function
438
- * @returns {number} The effective width of the chart.
439
- */
440
- getEffectiveChartWidth() {
441
- const chart = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
442
- return chart.width;
443
- }
444
- /**
445
- * Returns the effective height of the chart.
446
- *
447
- * @returns {number} The effective height of the chart.
448
- */
449
- getEffectiveChartHeight() {
450
- const chart = this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID(CHART_UUID));
451
- return chart.height;
452
- }
453
423
  /**
454
424
  * Updates the offsets of the chart components and redraws the chart.
455
425
  * @param {Partial<ChartConfigComponentsOffsets>} offsets - The new offsets to be applied to the chart components.
@@ -682,7 +652,7 @@ export class ChartModel extends ChartBaseElement {
682
652
  * @returns {number} - The maximum number of candles that can fit in the chart width
683
653
  */
684
654
  getMaxCandlesFitLength() {
685
- return floor(this.getEffectiveChartWidth() / this.config.components.chart.minWidth);
655
+ return floor(this.canvasBoundsContainer.getEffectiveChartWidth() / this.config.components.chart.minWidth);
686
656
  }
687
657
  /**
688
658
  * Returns an array of CandleSeriesModel objects representing the secondary candle series.
@@ -3,6 +3,7 @@
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 { CanvasElement } from '../../canvas/canvas-bounds-container';
6
7
  import { ChartBaseElement } from '../../model/chart-base-element';
7
8
  import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
8
9
  import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
@@ -20,7 +21,7 @@ export class ChartPanComponent extends ChartBaseElement {
20
21
  this.hitTestCanvasModel = hitTestCanvasModel;
21
22
  this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this, this.hitTestCanvasModel);
22
23
  this.addChildEntity(this.chartAreaPanHandler);
23
- this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent);
24
+ this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES));
24
25
  this.addChildEntity(this.mainCanvasTouchHandler);
25
26
  }
26
27
  /**
@@ -23,6 +23,7 @@ import { PaneHitTestController } from './pane-hit-test.controller';
23
23
  import { PaneComponent } from './pane.component';
24
24
  import { DataSeriesModel } from '../../model/data-series.model';
25
25
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
26
+ import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
26
27
  export declare class PaneManager extends ChartBaseElement {
27
28
  private chartBaseModel;
28
29
  private dynamicObjectsCanvasModel;
@@ -40,6 +41,7 @@ export declare class PaneManager extends ChartBaseElement {
40
41
  private mainCanvasModel;
41
42
  private yAxisLabelsCanvasModel;
42
43
  private hitTestCanvasModel;
44
+ private chartResizeHandler;
43
45
  panes: Record<string, PaneComponent>;
44
46
  paneRemovedSubject: Subject<PaneComponent>;
45
47
  paneAddedSubject: Subject<Record<string, PaneComponent>>;
@@ -50,7 +52,7 @@ export declare class PaneManager extends ChartBaseElement {
50
52
  * Returns order of panes in the chart from top to bottom.
51
53
  */
52
54
  get panesOrder(): string[];
53
- constructor(chartBaseModel: ChartBaseModel<'candle'>, dynamicObjectsCanvasModel: CanvasModel, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, hitTestCanvasModel: HitTestCanvasModel);
55
+ constructor(chartBaseModel: ChartBaseModel<'candle'>, dynamicObjectsCanvasModel: CanvasModel, userInputListenerComponents: ChartEntity[], eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, drawingManager: DrawingManager, cursorHandler: CursorHandler, crossEventProducer: CrossEventProducerComponent, chartPanComponent: ChartPanComponent, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler);
54
56
  private addBounds;
55
57
  /**
56
58
  * Adds a resizer to the canvas bounds container for the given uuid.
@@ -20,7 +20,7 @@ export class PaneManager extends ChartBaseElement {
20
20
  get panesOrder() {
21
21
  return this.canvasBoundsContainer.panesOrder;
22
22
  }
23
- constructor(chartBaseModel, dynamicObjectsCanvasModel, userInputListenerComponents, eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, cursorHandler, crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, hitTestCanvasModel) {
23
+ constructor(chartBaseModel, dynamicObjectsCanvasModel, userInputListenerComponents, eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, drawingManager, cursorHandler, crossEventProducer, chartPanComponent, mainCanvasModel, yAxisLabelsCanvasModel, hitTestCanvasModel, chartResizeHandler) {
24
24
  super();
25
25
  this.chartBaseModel = chartBaseModel;
26
26
  this.dynamicObjectsCanvasModel = dynamicObjectsCanvasModel;
@@ -38,6 +38,7 @@ export class PaneManager extends ChartBaseElement {
38
38
  this.mainCanvasModel = mainCanvasModel;
39
39
  this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
40
40
  this.hitTestCanvasModel = hitTestCanvasModel;
41
+ this.chartResizeHandler = chartResizeHandler;
41
42
  this.panes = {};
42
43
  this.paneRemovedSubject = new Subject();
43
44
  this.paneAddedSubject = new Subject();
@@ -95,7 +96,7 @@ export class PaneManager extends ChartBaseElement {
95
96
  if (this.panes[uuid] !== undefined) {
96
97
  return this.panes[uuid];
97
98
  }
98
- const paneComponent = new PaneComponent(this.chartBaseModel, this.mainCanvasModel, this.yAxisLabelsCanvasModel, this.dynamicObjectsCanvasModel, this.hitTestController, this.config, this.mainScale, this.drawingManager, this.chartPanComponent, this.canvasInputListener, this.canvasAnimation, this.cursorHandler, this.eventBus, this.canvasBoundsContainer, uuid, this.dataSeriesAddedSubject, this.dataSeriesRemovedSubject, this.hitTestCanvasModel, options);
99
+ const paneComponent = new PaneComponent(this.chartBaseModel, this.mainCanvasModel, this.yAxisLabelsCanvasModel, this.dynamicObjectsCanvasModel, this.hitTestController, this.config, this.mainScale, this.drawingManager, this.chartPanComponent, this.canvasInputListener, this.canvasAnimation, this.cursorHandler, this.eventBus, this.canvasBoundsContainer, uuid, this.dataSeriesAddedSubject, this.dataSeriesRemovedSubject, this.hitTestCanvasModel, this.chartResizeHandler, options);
99
100
  // TODO: is resizer should be added always?
100
101
  if (this.config.components.paneResizer.visible) {
101
102
  paneComponent.addChildEntity(this.addResizer(uuid));
@@ -25,6 +25,7 @@ import { YAxisComponent } from '../y_axis/y-axis.component';
25
25
  import { YExtentComponent, YExtentCreationOptions } from './extent/y-extent-component';
26
26
  import { PaneHitTestController } from './pane-hit-test.controller';
27
27
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
28
+ import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
28
29
  export declare class PaneComponent extends ChartBaseElement {
29
30
  chartBaseModel: ChartBaseModel<'candle'>;
30
31
  private mainCanvasModel;
@@ -44,6 +45,7 @@ export declare class PaneComponent extends ChartBaseElement {
44
45
  seriesAddedSubject: Subject<DataSeriesModel>;
45
46
  seriesRemovedSubject: Subject<DataSeriesModel>;
46
47
  private hitTestCanvasModel;
48
+ private chartResizeHandler;
47
49
  /**
48
50
  * Pane hit test (without Y-Axis and resizer)
49
51
  */
@@ -54,7 +56,7 @@ export declare class PaneComponent extends ChartBaseElement {
54
56
  get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
55
57
  get visible(): boolean;
56
58
  mainExtent: YExtentComponent;
57
- constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, hitTestCanvasModel: HitTestCanvasModel, options?: AtLeastOne<YExtentCreationOptions>);
59
+ constructor(chartBaseModel: ChartBaseModel<'candle'>, mainCanvasModel: CanvasModel, yAxisLabelsCanvasModel: CanvasModel, dynamicObjectsCanvasModel: CanvasModel, hitTestController: PaneHitTestController, config: FullChartConfig, mainScale: ScaleModel, drawingManager: DrawingManager, chartPanComponent: ChartPanComponent, canvasInputListener: CanvasInputListenerComponent, canvasAnimation: CanvasAnimation, cursorHandler: CursorHandler, eventBus: EventBus, canvasBoundsContainer: CanvasBoundsContainer, uuid: string, seriesAddedSubject: Subject<DataSeriesModel>, seriesRemovedSubject: Subject<DataSeriesModel>, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler, options?: AtLeastOne<YExtentCreationOptions>);
58
60
  /**
59
61
  * Method that activates the canvas bounds container and recalculates the zoom Y of the scale model.
60
62
  * @protected
@@ -25,7 +25,7 @@ export class PaneComponent extends ChartBaseElement {
25
25
  get visible() {
26
26
  return this.canvasBoundsContainer.graphsHeightRatio[this.uuid] > 0;
27
27
  }
28
- constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, hitTestCanvasModel, options) {
28
+ constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, hitTestCanvasModel, chartResizeHandler, options) {
29
29
  super();
30
30
  this.chartBaseModel = chartBaseModel;
31
31
  this.mainCanvasModel = mainCanvasModel;
@@ -45,6 +45,7 @@ export class PaneComponent extends ChartBaseElement {
45
45
  this.seriesAddedSubject = seriesAddedSubject;
46
46
  this.seriesRemovedSubject = seriesRemovedSubject;
47
47
  this.hitTestCanvasModel = hitTestCanvasModel;
48
+ this.chartResizeHandler = chartResizeHandler;
48
49
  this.yExtentComponents = [];
49
50
  this.getYAxisBounds = () => {
50
51
  return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.uuid));
@@ -125,7 +126,7 @@ export class PaneComponent extends ChartBaseElement {
125
126
  const [unsub, dragNDrop] = this.createYPanHandler(this.uuid, scaleModel);
126
127
  // creating partially resolved constructor except formatter & dataSeriesProvider - bcs it's not possible to provide formatter
127
128
  // before y-extent is created
128
- const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx, this.hitTestCanvasModel, initialYAxisState);
129
+ const createYAxisComponent = (formatter, dataSeriesProvider) => new YAxisComponent(this.eventBus, this.config, this.yAxisLabelsCanvasModel, scaleModel, this.canvasInputListener, this.canvasBoundsContainer, this.chartPanComponent, this.cursorHandler, formatter, dataSeriesProvider, this.uuid, extentIdx, this.hitTestCanvasModel, this.chartResizeHandler, initialYAxisState);
129
130
  const yExtentComponent = new YExtentComponent(this.uuid, extentIdx, this, this.chartBaseModel, this.canvasBoundsContainer, this.hitTestController, this.dynamicObjectsCanvasModel, scaleModel, createYAxisComponent, dragNDrop);
130
131
  yExtentComponent.addSubscription(unsub);
131
132
  yExtentComponent.addSubscription(this.addCursors(extentIdx, yExtentComponent.yAxis));
@@ -4,7 +4,7 @@
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
6
  import { ChartBaseElement } from '../../model/chart-base-element';
7
- import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
7
+ import { CanvasBoundsContainer, HitBoundsTest } from '../../canvas/canvas-bounds-container';
8
8
  import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component';
9
9
  import { ScaleModel } from '../../model/scale.model';
10
10
  import { Pixel, Unit } from '../../model/scaling/viewport.model';
@@ -21,13 +21,15 @@ export declare class XAxisScaleHandler extends ChartBaseElement {
21
21
  private canvasBoundsContainer;
22
22
  private chartPanComponent;
23
23
  private chartModel;
24
+ private hitTest;
24
25
  private hitTestCanvasModel;
25
26
  lastXStart: Unit;
26
27
  lastXWidth: Unit;
27
28
  lastXPxWidth: Pixel;
28
29
  private dblClickCallback;
30
+ private touches;
29
31
  private dblTapCallback;
30
- constructor(scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, chartModel: ChartModel, hitTestCanvasModel: HitTestCanvasModel);
32
+ constructor(scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, chartModel: ChartModel, hitTest: HitBoundsTest, hitTestCanvasModel: HitTestCanvasModel);
31
33
  /**
32
34
  * This method is used to activate the canvas input listener and add a subscription to it.
33
35
  * It calls the parent class's doActivate method and then subscribes to the canvasInputListener's observeDbClick method.
@@ -11,13 +11,14 @@ import { DragNDropXComponent } from '../dran-n-drop_helper/drag-n-drop-x.compone
11
11
  * @doc-tags scaling,zoom,viewport
12
12
  */
13
13
  export class XAxisScaleHandler extends ChartBaseElement {
14
- constructor(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, chartModel, hitTestCanvasModel) {
14
+ constructor(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, chartModel, hitTest, hitTestCanvasModel) {
15
15
  super();
16
16
  this.scale = scale;
17
17
  this.canvasInputListener = canvasInputListener;
18
18
  this.canvasBoundsContainer = canvasBoundsContainer;
19
19
  this.chartPanComponent = chartPanComponent;
20
20
  this.chartModel = chartModel;
21
+ this.hitTest = hitTest;
21
22
  this.hitTestCanvasModel = hitTestCanvasModel;
22
23
  this.lastXStart = 0;
23
24
  this.lastXWidth = 0;
@@ -50,7 +51,7 @@ export class XAxisScaleHandler extends ChartBaseElement {
50
51
  this.setDblClickCallback = (cb) => this.dblClickCallback = cb;
51
52
  this.dblClickCallback = () => chartModel.doBasicScale();
52
53
  this.dblTapCallback = () => chartModel.doBasicScale();
53
- const dragNDropXComponent = new DragNDropXComponent(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS), {
54
+ const dragNDropXComponent = new DragNDropXComponent(hitTest, {
54
55
  onDragStart: this.onXDragStart,
55
56
  onDragTick: this.onXDragTick,
56
57
  onDragEnd: this.onXDragEnd,
@@ -69,12 +70,19 @@ export class XAxisScaleHandler extends ChartBaseElement {
69
70
  */
70
71
  doActivate() {
71
72
  super.doActivate();
72
- this.addRxSubscription(this.canvasInputListener
73
- .observeDbClick(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS))
74
- .subscribe(() => this.dblClickCallback()));
75
- this.addRxSubscription(this.canvasInputListener
76
- .observeDbTap(this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS))
77
- .subscribe(() => this.dblTapCallback()));
73
+ this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(() => this.dblClickCallback()));
74
+ this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(() => {
75
+ var _a;
76
+ // apply dbl tap only if single finger taps are made
77
+ if (this.touches && ((_a = this.touches) === null || _a === void 0 ? void 0 : _a.length) > 1) {
78
+ this.touches = undefined;
79
+ return;
80
+ }
81
+ this.dblTapCallback();
82
+ }));
83
+ this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(e => {
84
+ this.touches = e.touches;
85
+ }));
78
86
  this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({ prependedCandlesWidth }) => (this.lastXStart += prependedCandlesWidth)));
79
87
  }
80
88
  }
@@ -50,7 +50,7 @@ export class XAxisComponent extends ChartBaseElement {
50
50
  xAxisCompositeDrawer.addDrawer(this.xAxisDrawer);
51
51
  this.xAxisLabelsDrawer = new XAxisLabelsDrawer(config, canvasModel, canvasBoundsContainer, this.xAxisLabelsModel);
52
52
  xAxisCompositeDrawer.addDrawer(this.xAxisLabelsDrawer);
53
- this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel, hitTestCanvasModel);
53
+ this.xAxisScaleHandler = new XAxisScaleHandler(scale, canvasInputListener, canvasBoundsContainer, chartPanComponent, this.chartComponent.chartModel, canvasBoundsContainer.getBoundsHitTest(CanvasElement.X_AXIS), hitTestCanvasModel);
54
54
  this.addChildEntity(this.xAxisScaleHandler);
55
55
  cursorHandler.setCursorForCanvasEl(CanvasElement.X_AXIS, config.components.xAxis.cursor);
56
56
  }
@@ -13,6 +13,7 @@ import { ChartBaseElement } from '../../../model/chart-base-element';
13
13
  import { ScaleModel } from '../../../model/scale.model';
14
14
  import { Unit } from '../../../model/scaling/viewport.model';
15
15
  import { YAxisLabelDrawConfig } from '../y-axis-labels.drawer';
16
+ import { ChartResizeHandler } from '../../../inputhandlers/chart-resize.handler';
16
17
  export type YAxisVisualLabelType = 'badge' | 'rectangle' | 'plain';
17
18
  export interface VisualYAxisLabel extends YAxisLabelDrawConfig {
18
19
  y: Unit;
@@ -53,6 +54,7 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
53
54
  private canvasModel;
54
55
  private paneUUID;
55
56
  private updateYAxisWidth;
57
+ private chartResizeHandler;
56
58
  orderedLabels: LabelGroup[];
57
59
  /**
58
60
  * an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
@@ -61,7 +63,7 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
61
63
  private labelsProviders;
62
64
  private labelsPositionRecalculatedSubject;
63
65
  private animFrameId;
64
- constructor(eventBus: EventBus, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, state: YAxisConfig, canvasModel: CanvasModel, paneUUID: string, updateYAxisWidth: () => void);
66
+ constructor(eventBus: EventBus, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, state: YAxisConfig, canvasModel: CanvasModel, paneUUID: string, updateYAxisWidth: () => void, chartResizeHandler: ChartResizeHandler);
65
67
  /**
66
68
  * This method is used to activate the chart and subscribe to the observables that will trigger the update of the labels.
67
69
  * It calls the parent method doActivate() and adds a new Rx subscription to the merge of the following observables:
@@ -3,7 +3,8 @@
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 { merge, Subject } from 'rxjs';
6
+ import { animationFrameScheduler, merge, Subject } from 'rxjs';
7
+ import { throttleTime } from 'rxjs/operators';
7
8
  import { CanvasElement } from '../../../canvas/canvas-bounds-container';
8
9
  import { ChartBaseElement } from '../../../model/chart-base-element';
9
10
  import { flat } from '../../../utils/array.utils';
@@ -26,7 +27,7 @@ export const LabelsGroups = {
26
27
  * Anything but the base labels which are generated in other component {@link YAxisBaseLabelsModel}
27
28
  */
28
29
  export class FancyYAxisLabelsModel extends ChartBaseElement {
29
- constructor(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, updateYAxisWidth) {
30
+ constructor(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, updateYAxisWidth, chartResizeHandler) {
30
31
  super();
31
32
  this.eventBus = eventBus;
32
33
  this.scale = scale;
@@ -35,6 +36,7 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
35
36
  this.canvasModel = canvasModel;
36
37
  this.paneUUID = paneUUID;
37
38
  this.updateYAxisWidth = updateYAxisWidth;
39
+ this.chartResizeHandler = chartResizeHandler;
38
40
  this.orderedLabels = [];
39
41
  /**
40
42
  * an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
@@ -56,7 +58,7 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
56
58
  */
57
59
  doActivate() {
58
60
  super.doActivate();
59
- this.addRxSubscription(merge(this.canvasBoundsContainer.observeBoundsChanged(CanvasElement.PANE_UUID(this.paneUUID)), this.canvasBoundsContainer.barResizerChangedSubject, this.scale.changed).subscribe(() => {
61
+ this.addRxSubscription(merge(this.canvasBoundsContainer.barResizerChangedSubject, this.scale.changed, merge(this.canvasBoundsContainer.observeBoundsChanged(CanvasElement.PANE_UUID(this.paneUUID)), this.chartResizeHandler.canvasResized).pipe(throttleTime(50, animationFrameScheduler, { trailing: true, leading: true }))).subscribe(() => {
60
62
  this.updateLabels();
61
63
  }));
62
64
  }
@@ -31,6 +31,7 @@ export declare class YAxisScaleHandler extends ChartBaseElement {
31
31
  lastYHeight: Unit;
32
32
  lastYPxHeight: Pixel;
33
33
  private dblClickCallback;
34
+ private touches;
34
35
  private dblTapCallback;
35
36
  constructor(bus: EventBus, config: YAxisConfig, panning: ChartPanComponent, scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, bounds: CanvasBoundsContainer, hitTest: HitBoundsTest, hitTestCanvasModel: HitTestCanvasModel);
36
37
  protected doActivate(): void;
@@ -39,7 +39,15 @@ export class YAxisScaleHandler extends ChartBaseElement {
39
39
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(false);
40
40
  };
41
41
  this.onYDragTick = (dragInfo) => {
42
- const { delta: absoluteYDelta } = dragInfo;
42
+ let { delta: absoluteYDelta } = dragInfo;
43
+ // check how many touch events are at the axis
44
+ // if multitouch - take the first two and apply delta the following way:
45
+ // the touch above keeps the initial delta because top => bottom gesture
46
+ // the touch below has the reversed delta because the gesture is bottom => top
47
+ if (this.touches && this.touches.length > 1) {
48
+ const top = Math.min(this.touches[0].clientY, this.touches[1].clientY);
49
+ absoluteYDelta = top === this.touches[0].clientY ? absoluteYDelta : -absoluteYDelta;
50
+ }
43
51
  // 1/3..3
44
52
  let zoomYMult;
45
53
  if (absoluteYDelta < 0) {
@@ -88,9 +96,18 @@ export class YAxisScaleHandler extends ChartBaseElement {
88
96
  this.bus.fireDraw();
89
97
  }));
90
98
  this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(() => {
99
+ var _a;
100
+ // apply dbl tap only if single finger taps are made
101
+ if (this.touches && ((_a = this.touches) === null || _a === void 0 ? void 0 : _a.length) > 1) {
102
+ this.touches = undefined;
103
+ return;
104
+ }
91
105
  this.dblTapCallback();
92
106
  this.bus.fireDraw();
93
107
  }));
108
+ this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(e => {
109
+ this.touches = e.touches;
110
+ }));
94
111
  }
95
112
  }
96
113
  }
@@ -22,6 +22,7 @@ import { VisualYAxisLabel, YAxisLabelsProvider } from './price_labels/y-axis-lab
22
22
  import { YAxisScaleHandler } from './y-axis-scale.handler';
23
23
  import { YAxisModel } from './y-axis.model';
24
24
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
25
+ import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
25
26
  export type LabelColorResolver = (priceMovement: PriceMovement, colors: FullChartColors) => string;
26
27
  /**
27
28
  * Y axis component. Contains all Y axis related logic.
@@ -35,12 +36,13 @@ export declare class YAxisComponent extends ChartBaseElement {
35
36
  private cursors;
36
37
  paneUUID: string;
37
38
  extentIdx: number;
39
+ private chartResizeHandler;
38
40
  private labelsColorByChartTypeMap;
39
41
  yAxisScaleHandler: YAxisScaleHandler;
40
42
  model: YAxisModel;
41
43
  axisTypeSetSubject: Subject<PriceAxisType>;
42
44
  readonly state: YAxisConfig;
43
- constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, cursors: CursorHandler, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, paneUUID: string, extentIdx: number, hitTestCanvasModel: HitTestCanvasModel, initialState?: YAxisConfig);
45
+ constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, cursors: CursorHandler, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, paneUUID: string, extentIdx: number, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler, initialState?: YAxisConfig);
44
46
  /**
45
47
  * Registers default label color resolvers for different chart types.
46
48
  * @private
@@ -17,7 +17,7 @@ import { cloneUnsafe } from '../../utils/object.utils';
17
17
  * Y axis component. Contains all Y axis related logic.
18
18
  */
19
19
  export class YAxisComponent extends ChartBaseElement {
20
- constructor(eventBus, config, canvasModel, scale, canvasInputListeners, canvasBoundsContainer, chartPanComponent, cursors, valueFormatter, dataSeriesProvider, paneUUID, extentIdx, hitTestCanvasModel, initialState) {
20
+ constructor(eventBus, config, canvasModel, scale, canvasInputListeners, canvasBoundsContainer, chartPanComponent, cursors, valueFormatter, dataSeriesProvider, paneUUID, extentIdx, hitTestCanvasModel, chartResizeHandler, initialState) {
21
21
  super();
22
22
  this.eventBus = eventBus;
23
23
  this.config = config;
@@ -27,6 +27,7 @@ export class YAxisComponent extends ChartBaseElement {
27
27
  this.cursors = cursors;
28
28
  this.paneUUID = paneUUID;
29
29
  this.extentIdx = extentIdx;
30
+ this.chartResizeHandler = chartResizeHandler;
30
31
  this.labelsColorByChartTypeMap = {};
31
32
  this.axisTypeSetSubject = new Subject();
32
33
  /* This function assigns a callback to be executed when a double-click event is detected.
@@ -50,7 +51,7 @@ export class YAxisComponent extends ChartBaseElement {
50
51
  this.yAxisScaleHandler = new YAxisScaleHandler(eventBus, this.state, chartPanComponent, scale, canvasInputListeners, canvasBoundsContainer, canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(paneUUID, extentIdx)), hitTestCanvasModel);
51
52
  this.addChildEntity(this.yAxisScaleHandler);
52
53
  //#endregion
53
- this.model = new YAxisModel(this.paneUUID, eventBus, this.state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx);
54
+ this.model = new YAxisModel(this.paneUUID, eventBus, this.state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx, this.chartResizeHandler);
54
55
  this.addChildEntity(this.model);
55
56
  this.updateCursor();
56
57
  this.registerDefaultLabelColorResolvers();
@@ -6,6 +6,7 @@
6
6
  import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
7
7
  import { YAxisConfig } from '../../chart.config';
8
8
  import EventBus from '../../events/event-bus';
9
+ import { ChartResizeHandler } from '../../inputhandlers/chart-resize.handler';
9
10
  import { CanvasModel } from '../../model/canvas.model';
10
11
  import { ChartBaseElement } from '../../model/chart-base-element';
11
12
  import { DataSeriesModel } from '../../model/data-series.model';
@@ -21,6 +22,6 @@ export declare class YAxisModel extends ChartBaseElement {
21
22
  labelsGenerator: NumericYAxisLabelsGenerator;
22
23
  baseLabelsModel: YAxisBaseLabelsModel;
23
24
  fancyLabelsModel: FancyYAxisLabelsModel;
24
- constructor(paneUUID: string, eventBus: EventBus, state: YAxisConfig, canvasBoundsContainer: CanvasBoundsContainer, canvasModel: CanvasModel, scale: ScaleModel, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, extentIdx: number);
25
+ constructor(paneUUID: string, eventBus: EventBus, state: YAxisConfig, canvasBoundsContainer: CanvasBoundsContainer, canvasModel: CanvasModel, scale: ScaleModel, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, extentIdx: number, chartResizeHandler: ChartResizeHandler);
25
26
  protected doActivate(): void;
26
27
  }
@@ -8,7 +8,7 @@ import { NumericYAxisLabelsGenerator } from './numeric-y-axis-labels.generator';
8
8
  import { FancyYAxisLabelsModel } from './price_labels/y-axis-labels.model';
9
9
  import { YAxisBaseLabelsModel } from './y-axis-base-labels.model';
10
10
  export class YAxisModel extends ChartBaseElement {
11
- constructor(paneUUID, eventBus, state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx) {
11
+ constructor(paneUUID, eventBus, state, canvasBoundsContainer, canvasModel, scale, valueFormatter, dataSeriesProvider, extentIdx, chartResizeHandler) {
12
12
  super();
13
13
  this.paneUUID = paneUUID;
14
14
  this.state = state;
@@ -17,7 +17,7 @@ export class YAxisModel extends ChartBaseElement {
17
17
  this.labelsGenerator = new NumericYAxisLabelsGenerator(null, dataSeriesProvider, scale, valueFormatter, () => this.state.type, state.labelHeight);
18
18
  this.baseLabelsModel = new YAxisBaseLabelsModel(scale, this.labelsGenerator, this.canvasBoundsContainer, paneUUID, extentIdx);
19
19
  this.addChildEntity(this.baseLabelsModel);
20
- this.fancyLabelsModel = new FancyYAxisLabelsModel(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, () => this.canvasBoundsContainer.updateYAxisWidths());
20
+ this.fancyLabelsModel = new FancyYAxisLabelsModel(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, () => this.canvasBoundsContainer.updateYAxisWidths(), chartResizeHandler);
21
21
  this.addChildEntity(this.fancyLabelsModel);
22
22
  }
23
23
  doActivate() {
@@ -7,6 +7,7 @@ import { ChartBaseElement } from '../model/chart-base-element';
7
7
  import { CanvasInputListenerComponent } from '../inputlisteners/canvas-input-listener.component';
8
8
  import { ScaleModel } from '../model/scale.model';
9
9
  import { ChartAreaPanHandler } from '../components/chart/chart-area-pan.handler';
10
+ import { HitBoundsTest } from '../canvas/canvas-bounds-container';
10
11
  /**
11
12
  * Handles chart touch events.
12
13
  */
@@ -15,8 +16,9 @@ export declare class MainCanvasTouchHandler extends ChartBaseElement {
15
16
  private scale;
16
17
  private canvasInputListeners;
17
18
  private mainCanvasParent;
19
+ private hitTest;
18
20
  private touchedCandleIndexes;
19
- constructor(chartAreaPanHandler: ChartAreaPanHandler, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, mainCanvasParent: Element);
21
+ constructor(chartAreaPanHandler: ChartAreaPanHandler, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, mainCanvasParent: Element, hitTest: HitBoundsTest);
20
22
  /**
21
23
  * Activates canvas input listeners for touch start and touch move events.
22
24
  * @protected