diff --git a/src/chart/canvas/canvas-bounds-container.ts b/src/chart/canvas/canvas-bounds-container.ts index 8b20fd4..ddb0155 100644 --- a/src/chart/canvas/canvas-bounds-container.ts +++ b/src/chart/canvas/canvas-bounds-container.ts @@ -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. @@ -838,6 +843,10 @@ export class CanvasBoundsContainer { return canvasBounds.width > 0 && canvasBounds.height > 0; } + public isAllBoundsAvailable() { + return Object.values(this.bounds).every(el => el.width >= 0 && el.height >= 0); + } + /** * Resizes a pane vertically. * @param {string} uuid - The unique identifier of the pane. diff --git a/src/chart/chart.config.ts b/src/chart/chart.config.ts index 56d2373..4b0ff2d 100644 --- a/src/chart/chart.config.ts +++ b/src/chart/chart.config.ts @@ -1,13 +1,3 @@ -/* - * 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. - * 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. diff --git a/src/chart/components/events/events.drawer.ts b/src/chart/components/events/events.drawer.ts index 600c92f..546249a 100644 --- a/src/chart/components/events/events.drawer.ts +++ b/src/chart/components/events/events.drawer.ts @@ -1,13 +1,3 @@ -/* - * 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. - * 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. diff --git a/src/chart/components/pane/pane-manager.component.ts b/src/chart/components/pane/pane-manager.component.ts index 45953e5..9f104e0 100644 --- a/src/chart/components/pane/pane-manager.component.ts +++ b/src/chart/components/pane/pane-manager.component.ts @@ -299,6 +299,9 @@ export class PaneManager extends ChartBaseElement { paneUUID?: string, extent?: YExtentComponent, direction?: MoveDataSeriesToPaneDirection, + // in some cases pane should not be deleted right after data series move, + // because the next data series could be moved to it + forceKeepPane?: boolean, index = 0, ) { const pane = paneUUID && this.panes[paneUUID]; @@ -306,8 +309,14 @@ export class PaneManager extends ChartBaseElement { if (!pane) { const order = direction && direction === 'above' ? index : this.panesOrder.length + index; const newPane = this.createPane(paneUUID, { order }); - newPane.moveDataSeriesToExistingExtentComponent(dataSeries, initialPane, initialExtent, newPane.mainExtent); - initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid); + newPane.moveDataSeriesToExistingExtentComponent( + dataSeries, + initialPane, + initialExtent, + newPane.mainExtent, + forceKeepPane, + ); + !forceKeepPane && initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid); return; } @@ -321,7 +330,7 @@ export class PaneManager extends ChartBaseElement { initialExtent.yAxis.state.align, ); } - initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid); + !forceKeepPane && initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid); } /** diff --git a/src/chart/components/pane/pane.component.ts b/src/chart/components/pane/pane.component.ts index e4e9381..d2d4ca2 100644 --- a/src/chart/components/pane/pane.component.ts +++ b/src/chart/components/pane/pane.component.ts @@ -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. @@ -295,9 +300,12 @@ export class PaneComponent extends ChartBaseElement { initialPane: PaneComponent, initialExtent: YExtentComponent, extentComponent: YExtentComponent, + // in some cases extent should not be deleted right after data series move, + // because the next data series could be moved to it + forceKeepExtent?: boolean, ) { dataSeries.forEach(series => series.moveToExtent(extentComponent)); - initialExtent.dataSeries.size === 0 && initialPane.removeExtentComponent(initialExtent); + !forceKeepExtent && initialExtent.dataSeries.size === 0 && initialPane.removeExtentComponent(initialExtent); this.yExtentComponentsChangedSubject.next(); } diff --git a/src/chart/utils/object.utils.ts b/src/chart/utils/object.utils.ts index cba6e8e..0641fb8 100644 --- a/src/chart/utils/object.utils.ts +++ b/src/chart/utils/object.utils.ts @@ -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. @@ -95,3 +100,5 @@ export function deepEqual(objA: object, objB: object): boolean { return true; } + +export const isEmpty = (obj: object) => Object.keys(obj).length === 0 && obj.constructor === Object;