From 19f7a226177479a2f6aaca7713df57fcf6d1763e Mon Sep 17 00:00:00 2001 From: Anton Vorobev Date: Fri, 6 Sep 2024 07:58:32 +0000 Subject: [PATCH] Pull request #5280: Bugfix/DXCF-4662 volume volume are displayed incorrectly Merge in DXCHARTS/dxchart5 from bugfix/DXCF-4662-volume-volume-are-displayed-incorrectly to master * commit '5661fe5d88d2e89d8d960d947748c2e392b030bd': [DXCF-4662] Volume - Volume are displayed incorrectly // init [DXCF-4662] Volume - Volume are displayed incorrectly // init [DXCF-4662] Volume - Volume are displayed incorrectly // init [DXCF-4662] Volume - Volume are displayed incorrectly // init [DXCF-4662] Volume - Volume are displayed incorrectly // init [DXCF-4662] Volume - Volume are displayed incorrectly // init GitOrigin-RevId: 0f12f053bc6e66ff7b7998c4fe02d01e19370126 --- docs/how-to/custom-drawer/README.md | 1 - src/chart/chart.config.ts | 1 - .../components/volumes/separate-volumes.component.ts | 5 +---- src/chart/components/volumes/volumes.component.ts | 10 ++-------- src/chart/components/volumes/volumes.drawer.ts | 8 ++++---- src/chart/drawers/drawing-manager.ts | 3 +-- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/docs/how-to/custom-drawer/README.md b/docs/how-to/custom-drawer/README.md index f75c9768..8f605f8e 100644 --- a/docs/how-to/custom-drawer/README.md +++ b/docs/how-to/custom-drawer/README.md @@ -53,7 +53,6 @@ List of default drawer types: 'HIT_TEST_DRAWINGS', 'GRID', 'VOLUMES', - 'UNDERLAY_VOLUMES_AREA', 'X_AXIS', 'Y_AXIS', 'HIGH_LOW', diff --git a/src/chart/chart.config.ts b/src/chart/chart.config.ts index c95f4174..d919e6af 100644 --- a/src/chart/chart.config.ts +++ b/src/chart/chart.config.ts @@ -576,7 +576,6 @@ export const getDefaultConfig = (): FullChartConfig => ({ 'GRID', 'X_AXIS', 'Y_AXIS', - 'UNDERLAY_VOLUMES_AREA', 'DYNAMIC_OBJECTS', 'WATERMARK', 'N_MAP_CHART', diff --git a/src/chart/components/volumes/separate-volumes.component.ts b/src/chart/components/volumes/separate-volumes.component.ts index 87360aa4..e0740b0b 100644 --- a/src/chart/components/volumes/separate-volumes.component.ts +++ b/src/chart/components/volumes/separate-volumes.component.ts @@ -1,10 +1,9 @@ /* - * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited + * 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/. */ import { FullChartConfig } from '../../chart.config'; -import { DrawingManager } from '../../drawers/drawing-manager'; import { ChartBaseElement } from '../../model/chart-base-element'; import { Pixel, Unit } from '../../model/scaling/viewport.model'; import { ChartComponent } from '../chart/chart.component'; @@ -19,7 +18,6 @@ export class SeparateVolumesComponent extends ChartBaseElement { public pane: PaneComponent | undefined; constructor( private chartComponent: ChartComponent, - private drawingManager: DrawingManager, public config: FullChartConfig, private volumesModel: VolumesModel, private paneManager: PaneManager, @@ -74,7 +72,6 @@ export class SeparateVolumesComponent extends ChartBaseElement { deactiveSeparateVolumes() { this.paneManager.removePane(SeparateVolumesComponent.UUID); delete this.pane; - this.drawingManager.removeDrawerByName('UNDERLAY_VOLUMES_AREA'); } /** diff --git a/src/chart/components/volumes/volumes.component.ts b/src/chart/components/volumes/volumes.component.ts index 032caf2a..aa2f4707 100644 --- a/src/chart/components/volumes/volumes.component.ts +++ b/src/chart/components/volumes/volumes.component.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited + * 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/. */ @@ -43,13 +43,7 @@ export class VolumesComponent extends ChartBaseElement { const volumesModel = new VolumesModel(chartComponent, scale); this.volumesModel = volumesModel; this.addChildEntity(volumesModel); - this.separateVolumes = new SeparateVolumesComponent( - chartComponent, - drawingManager, - config, - volumesModel, - paneManager, - ); + this.separateVolumes = new SeparateVolumesComponent(chartComponent, config, volumesModel, paneManager); this.volumesDrawer = new VolumesDrawer( config, this.volumesModel, diff --git a/src/chart/components/volumes/volumes.drawer.ts b/src/chart/components/volumes/volumes.drawer.ts index f79d00f3..b13bd968 100644 --- a/src/chart/components/volumes/volumes.drawer.ts +++ b/src/chart/components/volumes/volumes.drawer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited + * 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/. */ @@ -118,11 +118,11 @@ export class VolumesDrawer implements DynamicModelDrawer { nextX !== undefined ? nextX - x : floorToDPR(unitToPixels(vCandle.width, viewportModel.zoomX)); if (this.config.components.volumes.showSeparately) { const y = floorToDPR(viewportModel.toY(vCandle.candle.volume)); - const height = floorToDPR(viewportModel.toY(0)) - y; + const height = ceilToDPR(viewportModel.toY(0)) - y; this.drawVolume(canvasModel, vCandle, x, y, width, height); } else { const zoomY = volumeMax / (fullVHeight / OVERLAY_VOLUME_TOTAL_HEIGHT_DIVISOR); - const height = Math.max(unitToPixels(vCandle.candle.volume, zoomY), 2); + const height = Math.max(ceilToDPR(unitToPixels(vCandle.candle.volume, zoomY)), 2); const y = floorToDPR(bounds.y + fullVHeight - height); this.drawVolume(canvasModel, vCandle, x, y, width, height); } @@ -161,7 +161,7 @@ export class VolumesDrawer implements DynamicModelDrawer { ctx.lineTo(x, ceilToDPR(yEnd)); ctx.stroke(); } else { - ctx.fillRect(x, y, width, ceilToDPR(height)); + ctx.fillRect(x, y, width, height); } } } diff --git a/src/chart/drawers/drawing-manager.ts b/src/chart/drawers/drawing-manager.ts index cfd96570..37902277 100644 --- a/src/chart/drawers/drawing-manager.ts +++ b/src/chart/drawers/drawing-manager.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited + * 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/. */ @@ -23,7 +23,6 @@ const drawerTypes = [ 'OVER_SERIES_CLEAR', 'HIT_TEST_DRAWINGS', 'GRID', - 'UNDERLAY_VOLUMES_AREA', 'X_AXIS', 'Y_AXIS', 'HIGH_LOW',