From 20a2da263ff18e7c12ef4ac1111732cacb51de60 Mon Sep 17 00:00:00 2001 From: Anton Vorobev Date: Thu, 17 Oct 2024 13:46:09 +0000 Subject: [PATCH] Pull request #5296: Feature/DXCF-5558 web multiple scales investigate current implementation in chart core Merge in DXCHARTS/dxchart5 from feature/DXCF-5558-web-multiple-scales-investigate-current-implementation-in-chart-core to master * commit '14aab3f12998d78bb90a3af995e122995de9e282': [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // pr fix [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init [DXCF-5558] [Web] Multiple scales - investigate current implementation in chart-core // init GitOrigin-RevId: 290e2aac5062417e2f741362bb60ea2d53f1b543 --- .../components/pane/pane-manager.component.ts | 14 ++++++++++++++ src/chart/components/pane/pane.component.ts | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/chart/components/pane/pane-manager.component.ts b/src/chart/components/pane/pane-manager.component.ts index a443f64..f1c141c 100644 --- a/src/chart/components/pane/pane-manager.component.ts +++ b/src/chart/components/pane/pane-manager.component.ts @@ -286,6 +286,20 @@ export class PaneManager extends ChartBaseElement { this.recalculateState(); } + /** + * Moves data series to a certain pane, or creates a new one if no pane is found + */ + public moveDataSeriesToPane(dataSeries: DataSeriesModel, paneUUID?: string) { + const initialPane = dataSeries.extentComponent.paneComponent; + + const pane = paneUUID && this.panes[paneUUID] ? this.panes[paneUUID] : this.createPane(); + pane.moveDataSeriesToExistingExtentComponent(dataSeries, pane.mainExtent); + + if (initialPane.yExtentComponents.length === 0) { + this.removePane(initialPane.uuid); + } + } + /** * Adds cursors to the chart elements based on the provided uuid and cursor type. * @private diff --git a/src/chart/components/pane/pane.component.ts b/src/chart/components/pane/pane.component.ts index 37a5dca..71e51bb 100644 --- a/src/chart/components/pane/pane.component.ts +++ b/src/chart/components/pane/pane.component.ts @@ -13,7 +13,7 @@ import { HitBoundsTest, } from '../../canvas/canvas-bounds-container'; import { CursorHandler } from '../../canvas/cursor.handler'; -import { FullChartConfig, YAxisConfig } from '../../chart.config'; +import { FullChartConfig, YAxisAlign, YAxisConfig } from '../../chart.config'; import { DrawingManager } from '../../drawers/drawing-manager'; import EventBus from '../../events/event-bus'; import { CanvasInputListenerComponent } from '../../inputlisteners/canvas-input-listener.component'; @@ -267,6 +267,23 @@ export class PaneComponent extends ChartBaseElement { this.canvasBoundsContainer.updateYAxisWidths(); } + public moveDataSeriesToNewExtentComponent(dataSeries: DataSeriesModel, align: YAxisAlign = 'right') { + const extent = this.createExtentComponent(); + extent.yAxis.setYAxisAlign(align); + dataSeries.moveToExtent(extent); + } + + public moveDataSeriesToExistingExtentComponent(dataSeries: DataSeriesModel, extentComponent: YExtentComponent) { + const initialPane = dataSeries.extentComponent.paneComponent; + const initialExtent = dataSeries.extentComponent; + dataSeries.moveToExtent(extentComponent); + + const initialExtentDataSeriesSize = initialExtent.dataSeries.size; + if (initialExtentDataSeriesSize === 0) { + initialPane.removeExtentComponent(initialExtent); + } + } + /** * This method updates the view by calling the doAutoScale method of the scaleModel and firing the Draw event using the eventBus. * @private