@devexperts/dxcharts-lite 2.4.6 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/chart/__tests__/model/date-time.formatter.test.d.ts +6 -0
  2. package/dist/chart/__tests__/model/date-time.formatter.test.js +30 -0
  3. package/dist/chart/canvas/canvas-bounds-container.d.ts +7 -3
  4. package/dist/chart/canvas/canvas-bounds-container.js +149 -105
  5. package/dist/chart/canvas/y-axis-bounds.container.js +4 -0
  6. package/dist/chart/chart.config.js +4 -4
  7. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +1 -5
  8. package/dist/chart/components/chart/chart-area-pan.handler.js +1 -8
  9. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.d.ts +0 -6
  10. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +0 -8
  11. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.d.ts +0 -5
  12. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +0 -7
  13. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +0 -11
  14. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +0 -16
  15. package/dist/chart/components/pan/chart-pan.component.d.ts +3 -14
  16. package/dist/chart/components/pan/chart-pan.component.js +7 -21
  17. package/dist/chart/components/pane/pane-manager.component.d.ts +29 -0
  18. package/dist/chart/components/pane/pane-manager.component.js +71 -8
  19. package/dist/chart/components/pane/pane.component.d.ts +5 -17
  20. package/dist/chart/components/pane/pane.component.js +11 -28
  21. package/dist/chart/components/resizer/bar-resizer.component.d.ts +1 -1
  22. package/dist/chart/components/resizer/bar-resizer.component.js +3 -1
  23. package/dist/chart/components/y_axis/y-axis-scale.handler.js +3 -3
  24. package/dist/chart/components/y_axis/y-axis.component.js +1 -1
  25. package/dist/chart/inputhandlers/hover-producer.component.d.ts +1 -1
  26. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +11 -2
  27. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +34 -2
  28. package/dist/chart/model/baseline.model.d.ts +3 -0
  29. package/dist/chart/model/baseline.model.js +5 -0
  30. package/dist/chart/model/chart-base-element.d.ts +2 -0
  31. package/dist/chart/model/chart-base-element.js +2 -0
  32. package/dist/chart/model/date-time.formatter.d.ts +20 -3
  33. package/dist/chart/model/date-time.formatter.js +62 -14
  34. package/dist/chart/model/scale.model.d.ts +5 -0
  35. package/dist/chart/model/scale.model.js +9 -1
  36. package/dist/chart/model/scaling/constrait.functions.d.ts +5 -7
  37. package/dist/chart/model/scaling/constrait.functions.js +3 -3
  38. package/dist/chart/model/time-zone.model.js +3 -1
  39. package/dist/dxchart.min.js +4 -4
  40. package/package.json +1 -1
@@ -29,17 +29,6 @@ export declare class DragNDropComponent extends ChartBaseElement {
29
29
  dragging: boolean;
30
30
  draggedPixels: number;
31
31
  constructor(hitTest: HitBoundsTest, dragCallbacks: DragNDropComponentCallbacks, canvasInputListener: CanvasInputListenerComponent, chartPanComponent: ChartPanComponent, dragComponentOptions: DragComponentOptions);
32
- /**
33
- * Calls the parent class's doActivate method and performs any additional activation logic.
34
- * This method is protected and can only be accessed by the class itself and its subclasses.
35
- */
36
- protected doActivate(): void;
37
- /**
38
- * This method overrides the doDeactivate method of the parent class and calls it using the super keyword.
39
- * It is a protected method that can only be accessed within the class and its subclasses.
40
- * This method is responsible for deactivating the current object.
41
- */
42
- protected doDeactivate(): void;
43
32
  protected onDragStart: (point: Point) => void;
44
33
  protected onDragTick: (yDelta: number) => void;
45
34
  protected onDragEnd: () => void;
@@ -40,24 +40,8 @@ export class DragNDropComponent extends ChartBaseElement {
40
40
  if (this.dragging) {
41
41
  this.dragging = false;
42
42
  this.dragCallbacks.onDragEnd && this.dragCallbacks.onDragEnd(this.draggedPixels);
43
- this.chartPanComponent.activateChartPanHandlers();
44
43
  }
45
44
  }
46
45
  };
47
46
  }
48
- /**
49
- * Calls the parent class's doActivate method and performs any additional activation logic.
50
- * This method is protected and can only be accessed by the class itself and its subclasses.
51
- */
52
- doActivate() {
53
- super.doActivate();
54
- }
55
- /**
56
- * This method overrides the doDeactivate method of the parent class and calls it using the super keyword.
57
- * It is a protected method that can only be accessed within the class and its subclasses.
58
- * This method is responsible for deactivating the current object.
59
- */
60
- doDeactivate() {
61
- super.doDeactivate();
62
- }
63
47
  }
@@ -7,12 +7,13 @@ import { CanvasAnimation } from '../../animation/canvas-animation';
7
7
  import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
8
8
  import { FullChartConfig } from '../../chart.config';
9
9
  import EventBus from '../../events/event-bus';
10
- import { ChartBaseElement, ChartEntity } from '../../model/chart-base-element';
10
+ import { ChartBaseElement } from '../../model/chart-base-element';
11
11
  import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component';
12
12
  import { ScaleModel } from '../../model/scale.model';
13
13
  import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
14
14
  import { BaseType, ChartBaseModel } from '../chart/chart-base.model';
15
15
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
16
+ import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
16
17
  export declare class ChartPanComponent extends ChartBaseElement {
17
18
  private eventBus;
18
19
  private mainScale;
@@ -23,21 +24,9 @@ export declare class ChartPanComponent extends ChartBaseElement {
23
24
  private mainCanvasParent;
24
25
  chartBaseModel: ChartBaseModel<BaseType>;
25
26
  private hitTestCanvasModel;
26
- chartPanComponents: Array<ChartEntity>;
27
27
  chartAreaPanHandler: ChartAreaPanHandler;
28
+ mainCanvasTouchHandler: MainCanvasTouchHandler;
28
29
  constructor(eventBus: EventBus, mainScale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, config: FullChartConfig, canvasAnimation: CanvasAnimation, canvasInputListener: CanvasInputListenerComponent, mainCanvasParent: Element, chartBaseModel: ChartBaseModel<BaseType>, hitTestCanvasModel: HitTestCanvasModel);
29
- /**
30
- * Activates the chart pan handlers.
31
- * @protected
32
- * @returns {void}
33
- */
34
- protected doActivate(): void;
35
- /**
36
- * This method is used to deactivate the pan handlers.
37
- * @returns {void}
38
- * @protected
39
- */
40
- protected doDeactivate(): void;
41
30
  /**
42
31
  * Activates user mouse handlers on main chart view.
43
32
  * @function
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { ChartBaseElement } from '../../model/chart-base-element';
7
7
  import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
8
+ import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
8
9
  export class ChartPanComponent extends ChartBaseElement {
9
10
  constructor(eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, mainCanvasParent, chartBaseModel, hitTestCanvasModel) {
10
11
  super();
@@ -17,25 +18,10 @@ export class ChartPanComponent extends ChartBaseElement {
17
18
  this.mainCanvasParent = mainCanvasParent;
18
19
  this.chartBaseModel = chartBaseModel;
19
20
  this.hitTestCanvasModel = hitTestCanvasModel;
20
- this.chartPanComponents = [];
21
- this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.mainCanvasParent, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this, this.hitTestCanvasModel);
22
- this.chartPanComponents.push(this.chartAreaPanHandler);
23
- }
24
- /**
25
- * Activates the chart pan handlers.
26
- * @protected
27
- * @returns {void}
28
- */
29
- doActivate() {
30
- this.activateChartPanHandlers();
31
- }
32
- /**
33
- * This method is used to deactivate the pan handlers.
34
- * @returns {void}
35
- * @protected
36
- */
37
- doDeactivate() {
38
- this.deactivatePanHandlers();
21
+ this.chartAreaPanHandler = new ChartAreaPanHandler(this.eventBus, this.config, this.mainScale, this.canvasInputListener, this.canvasBoundsContainer, this.canvasAnimation, this, this.hitTestCanvasModel);
22
+ this.addChildEntity(this.chartAreaPanHandler);
23
+ this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent);
24
+ this.addChildEntity(this.mainCanvasTouchHandler);
39
25
  }
40
26
  /**
41
27
  * Activates user mouse handlers on main chart view.
@@ -46,13 +32,13 @@ export class ChartPanComponent extends ChartBaseElement {
46
32
  * @returns {void}
47
33
  */
48
34
  activateChartPanHandlers() {
49
- this.chartPanComponents.forEach(c => c.activate());
35
+ this.activate();
50
36
  }
51
37
  /**
52
38
  * Deactivates all the pan handlers of the chart.
53
39
  */
54
40
  deactivatePanHandlers() {
55
- this.chartPanComponents.forEach(c => c.deactivate());
41
+ this.deactivate();
56
42
  }
57
43
  setChartPanningOptions(horizontal, vertical) {
58
44
  this.chartAreaPanHandler.chartPanningOptions = { horizontal, vertical };
@@ -71,11 +71,40 @@ export declare class PaneManager extends ChartBaseElement {
71
71
  * @returns
72
72
  */
73
73
  createPane(uuid?: string, options?: AtLeastOne<YExtentCreationOptions>): PaneComponent;
74
+ /**
75
+ * Moves the canvas bounds container up by calling the movePaneUp method with the uuid of the current object.
76
+ * @returns {void}
77
+ */
78
+ movePaneUp(uuid: string): void;
79
+ /**
80
+ * Moves the canvas bounds container down by calling the movePaneDown method with the uuid of the current object.
81
+ * @returns {void}
82
+ */
83
+ movePaneDown(uuid: string): void;
84
+ /**
85
+ * Checks if the current pane can move up.
86
+ * @returns {boolean} - Returns true if the current pane can move up, otherwise false.
87
+ */
88
+ canMovePaneUp(uuid: string): boolean;
89
+ /**
90
+ * Checks if the current pane can move down.
91
+ *
92
+ * @returns {boolean} - Returns true if the current pane is not the last one in the canvasBoundsContainer, otherwise returns false.
93
+ */
94
+ canMovePaneDown(uuid: string): boolean;
74
95
  /**
75
96
  * Removes pane from the chart and all related components
76
97
  * @param uuid
77
98
  */
78
99
  removePane(uuid: string): void;
100
+ /**
101
+ * Hides a pane from the chart and all related components
102
+ */
103
+ hidePane(paneUUID: string): void;
104
+ /**
105
+ * Shows a pane, use if the pane is hidden
106
+ */
107
+ showPane(paneUUID: string): void;
79
108
  /**
80
109
  * Adds cursors to the chart elements based on the provided uuid and cursor type.
81
110
  * @private
@@ -12,7 +12,7 @@ import { BarResizerComponent } from '../resizer/bar-resizer.component';
12
12
  import { createDefaultYExtentHighLowProvider, } from './extent/y-extent-component';
13
13
  import { PaneHitTestController } from './pane-hit-test.controller';
14
14
  import { PaneComponent } from './pane.component';
15
- import { flatMap } from '../../utils/array.utils';
15
+ import { firstOf, flatMap, lastOf } from '../../utils/array.utils';
16
16
  export class PaneManager extends ChartBaseElement {
17
17
  /**
18
18
  * Returns order of panes in the chart from top to bottom.
@@ -53,7 +53,7 @@ export class PaneManager extends ChartBaseElement {
53
53
  }
54
54
  addBounds(uuid, order) {
55
55
  this.canvasBoundsContainer.addPaneBounds(uuid, order);
56
- return () => this.canvasBoundsContainer.removedPaneBounds(uuid);
56
+ return () => this.canvasBoundsContainer.removePaneBounds(uuid);
57
57
  }
58
58
  /**
59
59
  * Adds a resizer to the canvas bounds container for the given uuid.
@@ -110,19 +110,82 @@ export class PaneManager extends ChartBaseElement {
110
110
  this.paneAddedSubject.next(this.panes);
111
111
  return paneComponent;
112
112
  }
113
+ /**
114
+ * Moves the canvas bounds container up by calling the movePaneUp method with the uuid of the current object.
115
+ * @returns {void}
116
+ */
117
+ movePaneUp(uuid) {
118
+ this.canvasBoundsContainer.movePaneUp(uuid);
119
+ }
120
+ /**
121
+ * Moves the canvas bounds container down by calling the movePaneDown method with the uuid of the current object.
122
+ * @returns {void}
123
+ */
124
+ movePaneDown(uuid) {
125
+ this.canvasBoundsContainer.movePaneDown(uuid);
126
+ }
127
+ /**
128
+ * Checks if the current pane can move up.
129
+ * @returns {boolean} - Returns true if the current pane can move up, otherwise false.
130
+ */
131
+ canMovePaneUp(uuid) {
132
+ var _a, _b;
133
+ const firstVisiblePane = firstOf(this.canvasBoundsContainer.panesOrder.filter(uuid => { var _a, _b; return (_b = (_a = this.panes[uuid]) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : false; }));
134
+ return uuid !== firstVisiblePane && ((_b = (_a = this.panes[uuid]) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : false);
135
+ }
136
+ /**
137
+ * Checks if the current pane can move down.
138
+ *
139
+ * @returns {boolean} - Returns true if the current pane is not the last one in the canvasBoundsContainer, otherwise returns false.
140
+ */
141
+ canMovePaneDown(uuid) {
142
+ var _a, _b;
143
+ const lastVisiblePane = lastOf(this.canvasBoundsContainer.panesOrder.filter(uuid => { var _a, _b; return (_b = (_a = this.panes[uuid]) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : false; }));
144
+ return uuid !== lastVisiblePane && ((_b = (_a = this.panes[uuid]) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : false);
145
+ }
113
146
  /**
114
147
  * Removes pane from the chart and all related components
115
148
  * @param uuid
116
149
  */
117
150
  removePane(uuid) {
118
151
  const pane = this.panes[uuid];
119
- if (pane !== undefined) {
120
- this.paneRemovedSubject.next(pane);
121
- pane.disable();
122
- pane.yExtentComponents.forEach(yExtentComponent => yExtentComponent.disable());
123
- delete this.panes[uuid];
124
- this.recalculateState();
152
+ if (pane === undefined) {
153
+ return;
154
+ }
155
+ this.paneRemovedSubject.next(pane);
156
+ pane.disable();
157
+ pane.yExtentComponents.forEach(yExtentComponent => yExtentComponent.disable());
158
+ delete this.panes[uuid];
159
+ this.recalculateState();
160
+ }
161
+ /**
162
+ * Hides a pane from the chart and all related components
163
+ */
164
+ hidePane(paneUUID) {
165
+ const pane = this.panes[paneUUID];
166
+ // hide pane only if we have more than one visible pane
167
+ if (pane === undefined || !pane.visible) {
168
+ return;
125
169
  }
170
+ const paneResizerId = CanvasElement.PANE_UUID_RESIZER(paneUUID);
171
+ const resizer = this.userInputListenerComponents.find(el => el instanceof BarResizerComponent && el.id === paneResizerId);
172
+ resizer === null || resizer === void 0 ? void 0 : resizer.disable();
173
+ this.canvasBoundsContainer.hidePaneBounds(paneUUID);
174
+ this.recalculateState();
175
+ }
176
+ /**
177
+ * Shows a pane, use if the pane is hidden
178
+ */
179
+ showPane(paneUUID) {
180
+ const pane = this.panes[paneUUID];
181
+ const paneResizerId = CanvasElement.PANE_UUID_RESIZER(paneUUID);
182
+ if (pane === undefined || pane.visible) {
183
+ return;
184
+ }
185
+ const resizer = this.userInputListenerComponents.find(el => el instanceof BarResizerComponent && el.id === paneResizerId);
186
+ resizer === null || resizer === void 0 ? void 0 : resizer.enable();
187
+ this.canvasBoundsContainer.showPaneBounds(paneUUID);
188
+ this.recalculateState();
126
189
  }
127
190
  /**
128
191
  * Adds cursors to the chart elements based on the provided uuid and cursor type.
@@ -44,7 +44,6 @@ export declare class PaneComponent extends ChartBaseElement {
44
44
  seriesAddedSubject: Subject<DataSeriesModel>;
45
45
  seriesRemovedSubject: Subject<DataSeriesModel>;
46
46
  private hitTestCanvasModel;
47
- private _paneOrder;
48
47
  /**
49
48
  * Pane hit test (without Y-Axis and resizer)
50
49
  */
@@ -53,6 +52,7 @@ export declare class PaneComponent extends ChartBaseElement {
53
52
  get scale(): ScaleModel;
54
53
  get yAxis(): YAxisComponent;
55
54
  get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
55
+ get visible(): boolean;
56
56
  mainExtent: YExtentComponent;
57
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>);
58
58
  /**
@@ -96,22 +96,6 @@ export declare class PaneComponent extends ChartBaseElement {
96
96
  * Returns the bounds of the pane component.
97
97
  */
98
98
  getBounds(): Bounds;
99
- /**
100
- * Hides the pane by removing its bounds from the canvasBoundsContainer and firing a draw event.
101
- * @function
102
- * @name hide
103
- * @memberof PaneComponent
104
- * @returns {void}
105
- */
106
- hide(): void;
107
- /**
108
- * Adds the bounds of the pane to the canvas bounds container and fires a draw event.
109
- * @function
110
- * @name show
111
- * @memberof PaneComponent
112
- * @returns {void}
113
- */
114
- show(): void;
115
99
  /**
116
100
  * Creates a new DataSeriesModel object.
117
101
  * @returns {DataSeriesModel} - The newly created DataSeriesModel object.
@@ -140,22 +124,26 @@ export declare class PaneComponent extends ChartBaseElement {
140
124
  /**
141
125
  * Moves the canvas bounds container up by calling the movePaneUp method with the uuid of the current object.
142
126
  * @returns {void}
127
+ * @deprecated Use `paneManager.movePaneUp()` instead
143
128
  */
144
129
  moveUp(): void;
145
130
  /**
146
131
  * Moves the canvas bounds container down by calling the movePaneDown method with the uuid of the current object.
147
132
  * @returns {void}
133
+ * @deprecated Use `paneManager.movePaneDown()` instead
148
134
  */
149
135
  moveDown(): void;
150
136
  /**
151
137
  * Checks if the current pane can move up.
152
138
  * @returns {boolean} - Returns true if the current pane can move up, otherwise false.
139
+ * @deprecated Use `paneManager.canMovePaneUp()` instead
153
140
  */
154
141
  canMoveUp(): boolean;
155
142
  /**
156
143
  * Checks if the current pane can move down.
157
144
  *
158
145
  * @returns {boolean} - Returns true if the current pane is not the last one in the canvasBoundsContainer, otherwise returns false.
146
+ * @deprecated Use `paneManager.canMovePaneDown()` instead
159
147
  */
160
148
  canMoveDown(): boolean;
161
149
  valueFormatter: (value: Unit, dataSeries?: DataSeriesModel) => string;
@@ -22,6 +22,9 @@ export class PaneComponent extends ChartBaseElement {
22
22
  get dataSeries() {
23
23
  return flatMap(this.yExtentComponents, c => Array.from(c.dataSeries));
24
24
  }
25
+ get visible() {
26
+ return this.canvasBoundsContainer.graphsHeightRatio[this.uuid] > 0;
27
+ }
25
28
  constructor(chartBaseModel, mainCanvasModel, yAxisLabelsCanvasModel, dynamicObjectsCanvasModel, hitTestController, config, mainScale, drawingManager, chartPanComponent, canvasInputListener, canvasAnimation, cursorHandler, eventBus, canvasBoundsContainer, uuid, seriesAddedSubject, seriesRemovedSubject, hitTestCanvasModel, options) {
26
29
  super();
27
30
  this.chartBaseModel = chartBaseModel;
@@ -42,7 +45,6 @@ export class PaneComponent extends ChartBaseElement {
42
45
  this.seriesAddedSubject = seriesAddedSubject;
43
46
  this.seriesRemovedSubject = seriesRemovedSubject;
44
47
  this.hitTestCanvasModel = hitTestCanvasModel;
45
- this._paneOrder = 0;
46
48
  this.yExtentComponents = [];
47
49
  this.getYAxisBounds = () => {
48
50
  return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.uuid));
@@ -176,29 +178,6 @@ export class PaneComponent extends ChartBaseElement {
176
178
  getBounds() {
177
179
  return this.mainExtent.getBounds();
178
180
  }
179
- /**
180
- * Hides the pane by removing its bounds from the canvasBoundsContainer and firing a draw event.
181
- * @function
182
- * @name hide
183
- * @memberof PaneComponent
184
- * @returns {void}
185
- */
186
- hide() {
187
- this._paneOrder = this.canvasBoundsContainer.panesOrder.indexOf(this.uuid);
188
- this.canvasBoundsContainer.removedPaneBounds(this.uuid);
189
- this.eventBus.fireDraw();
190
- }
191
- /**
192
- * Adds the bounds of the pane to the canvas bounds container and fires a draw event.
193
- * @function
194
- * @name show
195
- * @memberof PaneComponent
196
- * @returns {void}
197
- */
198
- show() {
199
- this.canvasBoundsContainer.addPaneBounds(this.uuid, this._paneOrder);
200
- this.eventBus.fireDraw();
201
- }
202
181
  /**
203
182
  * Creates a new DataSeriesModel object.
204
183
  * @returns {DataSeriesModel} - The newly created DataSeriesModel object.
@@ -239,6 +218,7 @@ export class PaneComponent extends ChartBaseElement {
239
218
  /**
240
219
  * Moves the canvas bounds container up by calling the movePaneUp method with the uuid of the current object.
241
220
  * @returns {void}
221
+ * @deprecated Use `paneManager.movePaneUp()` instead
242
222
  */
243
223
  moveUp() {
244
224
  this.canvasBoundsContainer.movePaneUp(this.uuid);
@@ -246,6 +226,7 @@ export class PaneComponent extends ChartBaseElement {
246
226
  /**
247
227
  * Moves the canvas bounds container down by calling the movePaneDown method with the uuid of the current object.
248
228
  * @returns {void}
229
+ * @deprecated Use `paneManager.movePaneDown()` instead
249
230
  */
250
231
  moveDown() {
251
232
  this.canvasBoundsContainer.movePaneDown(this.uuid);
@@ -253,19 +234,21 @@ export class PaneComponent extends ChartBaseElement {
253
234
  /**
254
235
  * Checks if the current pane can move up.
255
236
  * @returns {boolean} - Returns true if the current pane can move up, otherwise false.
237
+ * @deprecated Use `paneManager.canMovePaneUp()` instead
256
238
  */
257
239
  canMoveUp() {
258
- const firstPane = firstOf(this.canvasBoundsContainer.panesOrder);
259
- return this.uuid !== firstPane;
240
+ const firstVisiblePane = firstOf(this.canvasBoundsContainer.panesOrder.filter(uuid => this.canvasBoundsContainer.graphsHeightRatio[uuid] > 0));
241
+ return this.uuid !== firstVisiblePane && this.visible;
260
242
  }
261
243
  /**
262
244
  * Checks if the current pane can move down.
263
245
  *
264
246
  * @returns {boolean} - Returns true if the current pane is not the last one in the canvasBoundsContainer, otherwise returns false.
247
+ * @deprecated Use `paneManager.canMovePaneDown()` instead
265
248
  */
266
249
  canMoveDown() {
267
- const lastPane = lastOf(this.canvasBoundsContainer.panesOrder);
268
- return this.uuid !== lastPane;
250
+ const lastVisiblePane = lastOf(this.canvasBoundsContainer.panesOrder.filter(uuid => this.canvasBoundsContainer.graphsHeightRatio[uuid] > 0));
251
+ return this.uuid !== lastVisiblePane && this.visible;
269
252
  }
270
253
  get regularFormatter() {
271
254
  return this.mainExtent.formatters.regular;
@@ -22,7 +22,7 @@ import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
22
22
  * @doc-tags chart-core,resizer
23
23
  */
24
24
  export declare class BarResizerComponent extends ChartBaseElement {
25
- private id;
25
+ readonly id: string;
26
26
  private boundsProvider;
27
27
  private hitTest;
28
28
  private dragTickCb;
@@ -39,6 +39,7 @@ export class BarResizerComponent extends ChartBaseElement {
39
39
  this.initialY = this.boundsProvider().y;
40
40
  // Stop redrawing hit test
41
41
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(false);
42
+ this.chartPanComponent.deactivatePanHandlers();
42
43
  };
43
44
  this.onYDragEnd = () => {
44
45
  this.config.components.crossTool.type = 'cross-and-labels';
@@ -46,6 +47,7 @@ export class BarResizerComponent extends ChartBaseElement {
46
47
  this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio);
47
48
  // Continue redrawing hit test
48
49
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(true);
50
+ this.chartPanComponent.activateChartPanHandlers();
49
51
  };
50
52
  this.onYDragTick = (dragInfo) => {
51
53
  const { delta: yDelta, draggedPixels } = dragInfo;
@@ -75,7 +77,7 @@ export class BarResizerComponent extends ChartBaseElement {
75
77
  const dragNDropYComponent = new DragNDropYComponent(this.hitTest, {
76
78
  onDragTick: this.onYDragTick,
77
79
  onDragStart: this.onYDragStart,
78
- onDragEnd: this.onYDragEnd
80
+ onDragEnd: this.onYDragEnd,
79
81
  }, this.canvasInputListener, this.chartPanComponent, {
80
82
  dragPredicate: this.dragPredicate,
81
83
  });
@@ -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 { Subject } from 'rxjs';
7
- import { CanvasElement } from '../../canvas/canvas-bounds-container';
7
+ import { CanvasElement, DEFAULT_MIN_PANE_HEIGHT } from '../../canvas/canvas-bounds-container';
8
8
  import { ChartBaseElement } from '../../model/chart-base-element';
9
9
  import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
10
10
  // if you drag full Y height from top to bottom - you will have x3 zoom, and vice-versa
@@ -35,7 +35,7 @@ export class YAxisScaleHandler extends ChartBaseElement {
35
35
  this.lastYStart = this.scale.yStart;
36
36
  this.lastYEnd = this.scale.yEnd;
37
37
  this.lastYHeight = this.scale.yEnd - this.scale.yStart;
38
- this.lastYPxHeight = this.bounds.getBounds(CanvasElement.Y_AXIS).height;
38
+ this.lastYPxHeight = Math.max(this.bounds.getBounds(CanvasElement.Y_AXIS).height, DEFAULT_MIN_PANE_HEIGHT);
39
39
  // Stop redrawing hit test
40
40
  this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(false);
41
41
  };
@@ -73,7 +73,7 @@ export class YAxisScaleHandler extends ChartBaseElement {
73
73
  onDragStart: this.onYDragStart,
74
74
  onDragEnd: this.onYDragEnd,
75
75
  }, canvasInputListener, panning, {
76
- dragPredicate: () => panning.chartAreaPanHandler.chartPanningOptions.vertical && config.type !== 'percent' && config.visible,
76
+ dragPredicate: () => panning.chartAreaPanHandler.chartPanningOptions.vertical && config.type !== 'percent',
77
77
  });
78
78
  this.addChildEntity(dragNDropYComponent);
79
79
  }
@@ -176,7 +176,7 @@ export class YAxisComponent extends ChartBaseElement {
176
176
  setVisible(isVisible) {
177
177
  this.state.visible = isVisible;
178
178
  this.config.components.yAxis.visible = isVisible;
179
- isVisible ? this.enable() : this.disable();
179
+ isVisible ? this.activate() : this.deactivate();
180
180
  this.model.fancyLabelsModel.updateLabels();
181
181
  this.model.baseLabelsModel.updateLabels();
182
182
  }
@@ -58,7 +58,7 @@ export declare class HoverProducerComponent extends ChartBaseElement {
58
58
  private longTouchActivatedSubject;
59
59
  private hoverProducerParts;
60
60
  xFormatter: DateTimeFormatter;
61
- constructor(crossEventProducer: CrossEventProducerComponent, scale: ScaleModel, config: FullChartConfig, chartModel: ChartModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, paneManager: PaneManager, timeZoneModel: TimeZoneModel, formatterFactory: (format: string) => (timestamp: number | Date) => string);
61
+ constructor(crossEventProducer: CrossEventProducerComponent, scale: ScaleModel, config: FullChartConfig, chartModel: ChartModel, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, paneManager: PaneManager, timeZoneModel: TimeZoneModel, formatterFactory: (format: string) => (timestamp: number) => string);
62
62
  /**
63
63
  * This method is responsible for activating the chart hover functionality. It subscribes to several observables to
64
64
  * update the hover when the chart is updated or when the user interacts with it. It also handles special behavior
@@ -6,15 +6,19 @@
6
6
  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
+ import { ChartAreaPanHandler } from '../components/chart/chart-area-pan.handler';
9
10
  /**
10
11
  * Handles chart touch events.
11
12
  */
12
13
  export declare class MainCanvasTouchHandler extends ChartBaseElement {
14
+ private chartAreaPanHandler;
13
15
  private scale;
14
16
  private canvasInputListeners;
15
17
  private mainCanvasParent;
16
18
  private touchedCandleIndexes;
17
- constructor(scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, mainCanvasParent: Element);
19
+ private pinchDistance;
20
+ private isDraggable;
21
+ constructor(chartAreaPanHandler: ChartAreaPanHandler, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, mainCanvasParent: Element);
18
22
  /**
19
23
  * Activates canvas input listeners for touch start and touch move events.
20
24
  * @protected
@@ -31,8 +35,13 @@ export declare class MainCanvasTouchHandler extends ChartBaseElement {
31
35
  * Handles touch move event
32
36
  * @param {TouchEvent} e - The touch event object
33
37
  * @returns {void}
34
- */
38
+ */
35
39
  private handleTouchMoveEvent;
40
+ /**
41
+ * Handles touch end event
42
+ * @returns {void}
43
+ */
44
+ private handleTouchEndEvent;
36
45
  /**
37
46
  * Gets candle positions touched by user in pixels.
38
47
  * @param e - touch event with "touches" array
@@ -4,17 +4,23 @@
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
+ const MIN_PINCH_DISTANCE = 30;
7
8
  /**
8
9
  * Handles chart touch events.
9
10
  */
10
11
  export class MainCanvasTouchHandler extends ChartBaseElement {
11
- constructor(scale, canvasInputListeners, mainCanvasParent) {
12
+ constructor(chartAreaPanHandler, scale, canvasInputListeners, mainCanvasParent) {
12
13
  super();
14
+ this.chartAreaPanHandler = chartAreaPanHandler;
13
15
  this.scale = scale;
14
16
  this.canvasInputListeners = canvasInputListeners;
15
17
  this.mainCanvasParent = mainCanvasParent;
16
18
  // 2 candles indexes touched by 2 fingers when pinching
17
19
  this.touchedCandleIndexes = [0, 0];
20
+ // number of px between touch events
21
+ this.pinchDistance = 0;
22
+ // used when maximum zoom in/out reached, can't use deactivate because it unsubscribes from all touch events
23
+ this.isDraggable = true;
18
24
  }
19
25
  /**
20
26
  * Activates canvas input listeners for touch start and touch move events.
@@ -24,6 +30,7 @@ export class MainCanvasTouchHandler extends ChartBaseElement {
24
30
  doActivate() {
25
31
  this.addRxSubscription(this.canvasInputListeners.observeTouchStart().subscribe(e => this.handleTouchStartEvent(e)));
26
32
  this.addRxSubscription(this.canvasInputListeners.observeTouchMove().subscribe(e => this.handleTouchMoveEvent(e)));
33
+ this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(e => this.handleTouchEndEvent(e)));
27
34
  }
28
35
  /**
29
36
  * Handles the touch start event.
@@ -32,6 +39,8 @@ export class MainCanvasTouchHandler extends ChartBaseElement {
32
39
  */
33
40
  handleTouchStartEvent(e) {
34
41
  if (e.touches.length === 2) {
42
+ this.isDraggable = true;
43
+ this.chartAreaPanHandler.deactivate();
35
44
  // @ts-ignore
36
45
  // TODO rework this
37
46
  this.touchedCandleIndexes = this.getXPositions(e).map(x => this.scale.fromX(x));
@@ -41,12 +50,22 @@ export class MainCanvasTouchHandler extends ChartBaseElement {
41
50
  * Handles touch move event
42
51
  * @param {TouchEvent} e - The touch event object
43
52
  * @returns {void}
44
- */
53
+ */
45
54
  handleTouchMoveEvent(e) {
46
55
  if (e.touches.length === 2) {
47
56
  this.pinchHandler(this.touchedCandleIndexes, this.getXPositions(e));
48
57
  }
49
58
  }
59
+ /**
60
+ * Handles touch end event
61
+ * @returns {void}
62
+ */
63
+ handleTouchEndEvent(e) {
64
+ // zero touches means the user stopped resizing completely (both fingers are up)
65
+ if (e.touches.length === 0) {
66
+ this.chartAreaPanHandler.activate();
67
+ }
68
+ }
50
69
  /**
51
70
  * Gets candle positions touched by user in pixels.
52
71
  * @param e - touch event with "touches" array
@@ -70,11 +89,24 @@ export class MainCanvasTouchHandler extends ChartBaseElement {
70
89
  * @returns {void}
71
90
  */
72
91
  pinchHandler(candleIndexes, touchPositions) {
92
+ const diff = Math.abs(touchPositions[0]) - Math.abs(touchPositions[1]);
93
+ const pinchDistance = Math.abs(diff);
94
+ const zoomIn = pinchDistance > this.pinchDistance;
95
+ if (this.scale.isMaxZoomXReached(zoomIn)) {
96
+ this.isDraggable = false;
97
+ }
98
+ if (!this.isDraggable || pinchDistance < MIN_PINCH_DISTANCE) {
99
+ return;
100
+ }
101
+ this.pinchDistance = pinchDistance;
73
102
  const first = (touchPositions[0] * candleIndexes[1] - touchPositions[1] * candleIndexes[0]) /
74
103
  (touchPositions[0] - touchPositions[1]);
75
104
  const last = first +
76
105
  ((candleIndexes[0] - candleIndexes[1]) / (touchPositions[0] - touchPositions[1])) *
77
106
  this.scale.getBounds().width;
107
+ if (first >= last) {
108
+ return;
109
+ }
78
110
  this.scale.setXScale(first, last);
79
111
  }
80
112
  }