Skip to content

Commit

Permalink
Pull request #5379: Feature/DXCF-5566 new web multiple scales impleme…
Browse files Browse the repository at this point in the history
…nt right click menu for additional multiple scales

Merge in DXCHARTS/dxchart5 from feature/DXCF-5566-new-web-multiple-scales-implement-right-click-menu-for-additional-multiple-scales to master

* commit 'ba42fb3152e74f902d3fb8892b7485e5a9634715':
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // fix data series align when moved to another pane
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init
  [DXCF-5566] [Web] Multiple scales - implement right-click menu for additional (multiple) scales // init

GitOrigin-RevId: 31927af313e831f0506190e32d54045cad6c0625
  • Loading branch information
Keelaro1 authored and dxcity committed Jan 13, 2025
1 parent 485b70a commit 80f60d7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/chart/components/pane/pane-manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,12 @@ export class PaneManager extends ChartBaseElement {
if (extent) {
pane.moveDataSeriesToExistingExtentComponent(dataSeries, initialPane, initialExtent, extent);
} else {
pane.moveDataSeriesToNewExtentComponent(dataSeries, initialPane, initialExtent);
pane.moveDataSeriesToNewExtentComponent(
dataSeries,
initialPane,
initialExtent,
initialExtent.yAxis.state.align,
);
}
initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
* an easier way to manage custom y-axis labels, than y-axis labels providers, but doesn't support overlapping avoidance
*/
public readonly customLabels: Record<string, VisualYAxisLabel> = {};
private labelsProviders: Record<string, Record<string, YAxisLabelsProvider>> = {};
private _labelsProviders: Record<string, Record<string, YAxisLabelsProvider>> = {};

get labelsProviders(): Record<string, Record<string, YAxisLabelsProvider>> {
return this._labelsProviders;
}

private labelsPositionRecalculatedSubject: Subject<void> = new Subject();
private animFrameId = `anim_cache_${uuid()}`;

Expand Down Expand Up @@ -276,4 +281,5 @@ export class FancyYAxisLabelsModel extends ChartBaseElement {
*/
export interface YAxisLabelsProvider {
readonly getUnorderedLabels: () => LabelGroup[];
yAxisBoundsProvider?: () => Bounds;
}
5 changes: 5 additions & 0 deletions src/chart/components/y_axis/y-axis-scale.handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
Expand Down
26 changes: 26 additions & 0 deletions src/chart/model/data-series.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import { YExtentComponent } from '../components/pane/extent/y-extent-component';
import { DataSeriesYAxisLabelsProvider } from '../components/y_axis/price_labels/data-series-y-axis-labels.provider';
import { LabelsGroups } from '../components/y_axis/price_labels/y-axis-labels.model';
import { binarySearch, create2DArray, lastOf, slice2DArray } from '../utils/array.utils';
import { floorToDPR } from '../utils/device/device-pixel-ratio.utils';
import { MathUtils } from '../utils/math.utils';
Expand Down Expand Up @@ -151,6 +152,7 @@ export class DataSeriesModel<
this.addRxSubscription(
this.scale.scaleInversedSubject.subscribe(() => {
this.recalculateVisualPoints();
this.extentComponent.dynamicObjectsCanvasModel.fireDraw();
}),
);
}
Expand Down Expand Up @@ -185,6 +187,7 @@ export class DataSeriesModel<
* @param extent
*/
public moveToExtent(extent: YExtentComponent) {
const prevExtent = { ...this.extentComponent };
this.extentComponent.removeDataSeries(this);
this.extentComponent = extent;
this.scale = extent.scale;
Expand All @@ -196,6 +199,29 @@ export class DataSeriesModel<
);
this.yAxisLabelProvider.yAxisBoundsProvider = extent.getYAxisBounds;
this.yAxisLabelProvider.axisState = extent.yAxis?.state;
// move data series labels
const prevExtentMainLabels = prevExtent.yAxis.model.fancyLabelsModel.labelsProviders[LabelsGroups.MAIN];
const dataSeriesLabelsId =
prevExtentMainLabels && Object.keys(prevExtentMainLabels).find(p => this.parentId && p === this.parentId);
const currentMainLabels = this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[LabelsGroups.MAIN];
if (dataSeriesLabelsId) {
const labelsProvider = prevExtentMainLabels[dataSeriesLabelsId];
labelsProvider.yAxisBoundsProvider = extent.getYAxisBounds;
// main group is not created yet (new extent without labels) or main group exists but no data series labels so far
if (!currentMainLabels || (currentMainLabels && !currentMainLabels[dataSeriesLabelsId])) {
// create new data series labels group on the new extent
this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(
LabelsGroups.MAIN,
labelsProvider,
dataSeriesLabelsId,
);
// remove labels from previous extent
prevExtent.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(
LabelsGroups.MAIN,
dataSeriesLabelsId,
);
}
}
// shut down old subscriptions
this.deactivate();
// and apply new ones (with updated scaleModel)
Expand Down

0 comments on commit 80f60d7

Please sign in to comment.