@devexperts/dxcharts-lite 2.6.1 → 2.6.2

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.
@@ -51,6 +51,7 @@ export declare class PaneComponent extends ChartBaseElement {
51
51
  */
52
52
  ht: HitBoundsTest;
53
53
  yExtentComponents: YExtentComponent[];
54
+ yExtentComponentsChangedSubject: Subject<void>;
54
55
  get scale(): ScaleModel;
55
56
  get yAxis(): YAxisComponent;
56
57
  get dataSeries(): DataSeriesModel<import("../../model/data-series.model").DataSeriesPoint, import("../../model/data-series.model").VisualSeriesPoint>[];
@@ -68,8 +69,10 @@ export declare class PaneComponent extends ChartBaseElement {
68
69
  /**
69
70
  * Creates a new GridComponent instance with the provided parameters.
70
71
  * @param {string} uuid - The unique identifier of the pane.
71
- * @param {ScaleModel} scaleModel - The scale model used to calculate the scale of the grid.
72
- * @param {NumericYAxisLabelsGenerator} yAxisLabelsGenerator - The generator used to create the labels for the y-axis.
72
+ * @param {ScaleModel} scale - The scale model used to calculate the scale of the grid.
73
+ * @param {YAxisConfig} yAxisState - y Axis Config
74
+ * @param {() => NumericAxisLabel[]} yAxisLabelsGetter
75
+ * @param {() => Unit} yAxisBaselineGetter
73
76
  * @returns {GridComponent} - The newly created GridComponent instance.
74
77
  */
75
78
  private createGridComponent;
@@ -77,8 +80,8 @@ export declare class PaneComponent extends ChartBaseElement {
77
80
  * Creates a handler for Y-axis panning of the chart.
78
81
  * @private
79
82
  * @param {string} uuid - The unique identifier of the chart pane.
80
- * @param {ScaleModel} scaleModel - The scale model of the chart.
81
- * @returns {Unsubscriber}
83
+ * @param {ScaleModel} scale - The scale model of the chart.
84
+ * @returns [Unsubscriber, DragNDropYComponent]
82
85
  */
83
86
  private createYPanHandler;
84
87
  private addCursors;
@@ -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 { Subject } from 'rxjs';
6
7
  import { distinctUntilChanged } from 'rxjs/operators';
7
8
  import { areBoundsChanged, CanvasElement, } from '../../canvas/canvas-bounds-container';
8
9
  import { ChartBaseElement } from '../../model/chart-base-element';
@@ -47,6 +48,7 @@ export class PaneComponent extends ChartBaseElement {
47
48
  this.hitTestCanvasModel = hitTestCanvasModel;
48
49
  this.chartResizeHandler = chartResizeHandler;
49
50
  this.yExtentComponents = [];
51
+ this.yExtentComponentsChangedSubject = new Subject();
50
52
  this.getYAxisBounds = () => {
51
53
  return this.canvasBoundsContainer.getBounds(CanvasElement.PANE_UUID_Y_AXIS(this.uuid));
52
54
  };
@@ -84,8 +86,10 @@ export class PaneComponent extends ChartBaseElement {
84
86
  /**
85
87
  * Creates a new GridComponent instance with the provided parameters.
86
88
  * @param {string} uuid - The unique identifier of the pane.
87
- * @param {ScaleModel} scaleModel - The scale model used to calculate the scale of the grid.
88
- * @param {NumericYAxisLabelsGenerator} yAxisLabelsGenerator - The generator used to create the labels for the y-axis.
89
+ * @param {ScaleModel} scale - The scale model used to calculate the scale of the grid.
90
+ * @param {YAxisConfig} yAxisState - y Axis Config
91
+ * @param {() => NumericAxisLabel[]} yAxisLabelsGetter
92
+ * @param {() => Unit} yAxisBaselineGetter
89
93
  * @returns {GridComponent} - The newly created GridComponent instance.
90
94
  */
91
95
  createGridComponent(uuid, scale, yAxisState, yAxisLabelsGetter, yAxisBaselineGetter) {
@@ -97,8 +101,8 @@ export class PaneComponent extends ChartBaseElement {
97
101
  * Creates a handler for Y-axis panning of the chart.
98
102
  * @private
99
103
  * @param {string} uuid - The unique identifier of the chart pane.
100
- * @param {ScaleModel} scaleModel - The scale model of the chart.
101
- * @returns {Unsubscriber}
104
+ * @param {ScaleModel} scale - The scale model of the chart.
105
+ * @returns [Unsubscriber, DragNDropYComponent]
102
106
  */
103
107
  createYPanHandler(uuid, scale) {
104
108
  const chartPaneId = CanvasElement.PANE_UUID(uuid);
@@ -140,6 +144,7 @@ export class PaneComponent extends ChartBaseElement {
140
144
  yExtentComponent.activate();
141
145
  this.yExtentComponents.push(yExtentComponent);
142
146
  this.canvasBoundsContainer.updateYAxisWidths();
147
+ this.yExtentComponentsChangedSubject.next();
143
148
  return yExtentComponent;
144
149
  }
145
150
  removeExtentComponent(extentComponent) {
@@ -148,6 +153,7 @@ export class PaneComponent extends ChartBaseElement {
148
153
  // re-index extents
149
154
  this.yExtentComponents.forEach((c, idx) => (c.idx = idx));
150
155
  this.canvasBoundsContainer.updateYAxisWidths();
156
+ this.yExtentComponentsChangedSubject.next();
151
157
  }
152
158
  /**
153
159
  * Create new pane extent and attach data series to it
@@ -164,6 +170,7 @@ export class PaneComponent extends ChartBaseElement {
164
170
  moveDataSeriesToExistingExtentComponent(dataSeries, initialPane, initialExtent, extentComponent) {
165
171
  dataSeries.forEach(series => series.moveToExtent(extentComponent));
166
172
  initialExtent.dataSeries.size === 0 && initialPane.removeExtentComponent(initialExtent);
173
+ this.yExtentComponentsChangedSubject.next();
167
174
  }
168
175
  /**
169
176
  * This method updates the view by calling the doAutoScale method of the scaleModel and firing the Draw event using the eventBus.
@@ -14,6 +14,7 @@ import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-
14
14
  import { ChartPanComponent } from '../pan/chart-pan.component';
15
15
  import { BoundsProvider } from '../../model/bounds.model';
16
16
  import { HitTestCanvasModel } from '../../model/hit-test-canvas.model';
17
+ export declare const RESIZER_HIT_TEST_EXTENSION: number;
17
18
  /**
18
19
  * Bar separator between panes.
19
20
  * Used to resize the areas height or just draw a fixed line.
@@ -9,6 +9,7 @@ import { DynamicDrawerType } from '../../drawers/drawing-manager';
9
9
  import { ChartBaseElement } from '../../model/chart-base-element';
10
10
  import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
11
11
  import { BarResizerDrawer } from './bar-resizer.drawer';
12
+ export const RESIZER_HIT_TEST_EXTENSION = 8;
12
13
  /**
13
14
  * Bar separator between panes.
14
15
  * Used to resize the areas height or just draw a fixed line.
@@ -60,7 +60,8 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
60
60
  * an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
61
61
  */
62
62
  readonly customLabels: Record<string, VisualYAxisLabel>;
63
- private labelsProviders;
63
+ private _labelsProviders;
64
+ get labelsProviders(): Record<string, Record<string, YAxisLabelsProvider>>;
64
65
  private labelsPositionRecalculatedSubject;
65
66
  private animFrameId;
66
67
  constructor(eventBus: EventBus, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, state: YAxisConfig, canvasModel: CanvasModel, paneUUID: string, updateYAxisWidth: () => void, chartResizeHandler: ChartResizeHandler);
@@ -157,4 +158,5 @@ export declare class FancyYAxisLabelsModel extends ChartBaseElement {
157
158
  */
158
159
  export interface YAxisLabelsProvider {
159
160
  readonly getUnorderedLabels: () => LabelGroup[];
161
+ yAxisBoundsProvider?: () => Bounds;
160
162
  }
@@ -27,6 +27,9 @@ export const LabelsGroups = {
27
27
  * Anything but the base labels which are generated in other component {@link YAxisBaseLabelsModel}
28
28
  */
29
29
  export class FancyYAxisLabelsModel extends ChartBaseElement {
30
+ get labelsProviders() {
31
+ return this._labelsProviders;
32
+ }
30
33
  constructor(eventBus, scale, canvasBoundsContainer, state, canvasModel, paneUUID, updateYAxisWidth, chartResizeHandler) {
31
34
  super();
32
35
  this.eventBus = eventBus;
@@ -42,7 +45,7 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
42
45
  * an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
43
46
  */
44
47
  this.customLabels = {};
45
- this.labelsProviders = {};
48
+ this._labelsProviders = {};
46
49
  this.labelsPositionRecalculatedSubject = new Subject();
47
50
  this.animFrameId = `anim_cache_${uuid()}`;
48
51
  this.initModel();
@@ -30,10 +30,12 @@ export declare class YAxisScaleHandler extends ChartBaseElement {
30
30
  lastYEnd: Unit;
31
31
  lastYHeight: Unit;
32
32
  lastYPxHeight: Pixel;
33
+ private dragNDropYComponent;
33
34
  private dblClickCallback;
34
35
  private touches;
35
36
  private dblTapCallback;
36
37
  constructor(bus: EventBus, config: YAxisConfig, panning: ChartPanComponent, scale: ScaleModel, canvasInputListener: CanvasInputListenerComponent, bounds: CanvasBoundsContainer, hitTest: HitBoundsTest, hitTestCanvasModel: HitTestCanvasModel);
38
+ isDragging(): boolean;
37
39
  protected doActivate(): void;
38
40
  private onYDragStart;
39
41
  private onYDragTick;
@@ -1,3 +1,8 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2024 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
+ */
1
6
  /*
2
7
  * Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
3
8
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
@@ -87,7 +92,14 @@ export class YAxisScaleHandler extends ChartBaseElement {
87
92
  dragPredicate: () => panning.chartAreaPanHandler.chartPanningOptions.vertical && config.type !== 'percent',
88
93
  });
89
94
  this.addChildEntity(dragNDropYComponent);
95
+ this.dragNDropYComponent = dragNDropYComponent;
96
+ }
97
+ }
98
+ isDragging() {
99
+ if (!this.dragNDropYComponent) {
100
+ return false;
90
101
  }
102
+ return Math.abs(this.dragNDropYComponent.draggedPixels) > 0;
91
103
  }
92
104
  doActivate() {
93
105
  if (this.config.customScaleDblClick) {
@@ -4,6 +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 { DataSeriesYAxisLabelsProvider } from '../components/y_axis/price_labels/data-series-y-axis-labels.provider';
7
+ import { LabelsGroups } from '../components/y_axis/price_labels/y-axis-labels.model';
7
8
  import { binarySearch, create2DArray, lastOf, slice2DArray } from '../utils/array.utils';
8
9
  import { floorToDPR } from '../utils/device/device-pixel-ratio.utils';
9
10
  import { MathUtils } from '../utils/math.utils';
@@ -141,6 +142,7 @@ export class DataSeriesModel extends ChartBaseElement {
141
142
  this.addRxSubscription(this.scale.xChanged.subscribe(() => this.recalculateDataViewportIndexes()));
142
143
  this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(() => {
143
144
  this.recalculateVisualPoints();
145
+ this.extentComponent.dynamicObjectsCanvasModel.fireDraw();
144
146
  }));
145
147
  }
146
148
  /**
@@ -161,12 +163,28 @@ export class DataSeriesModel extends ChartBaseElement {
161
163
  */
162
164
  moveToExtent(extent) {
163
165
  var _a;
166
+ const prevExtent = Object.assign({}, this.extentComponent);
164
167
  this.extentComponent.removeDataSeries(this);
165
168
  this.extentComponent = extent;
166
169
  this.scale = extent.scale;
167
170
  this.view = new DataSeriesView(this, this.scale, () => this.extentComponent.yAxis.getAxisType(), this.getBaseline);
168
171
  this.yAxisLabelProvider.yAxisBoundsProvider = extent.getYAxisBounds;
169
172
  this.yAxisLabelProvider.axisState = (_a = extent.yAxis) === null || _a === void 0 ? void 0 : _a.state;
173
+ // move data series labels
174
+ const prevExtentMainLabels = prevExtent.yAxis.model.fancyLabelsModel.labelsProviders[LabelsGroups.MAIN];
175
+ const dataSeriesLabelsId = prevExtentMainLabels && Object.keys(prevExtentMainLabels).find(p => this.parentId && p === this.parentId);
176
+ const currentMainLabels = this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[LabelsGroups.MAIN];
177
+ if (dataSeriesLabelsId) {
178
+ const labelsProvider = prevExtentMainLabels[dataSeriesLabelsId];
179
+ labelsProvider.yAxisBoundsProvider = extent.getYAxisBounds;
180
+ // main group is not created yet (new extent without labels) or main group exists but no data series labels so far
181
+ if (!currentMainLabels || (currentMainLabels && !currentMainLabels[dataSeriesLabelsId])) {
182
+ // create new data series labels group on the new extent
183
+ this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(LabelsGroups.MAIN, labelsProvider, dataSeriesLabelsId);
184
+ // remove labels from previous extent
185
+ prevExtent.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(LabelsGroups.MAIN, dataSeriesLabelsId);
186
+ }
187
+ }
170
188
  // shut down old subscriptions
171
189
  this.deactivate();
172
190
  // and apply new ones (with updated scaleModel)