Skip to content

Commit

Permalink
Merge branch 'master' into 50-disable-yaxis-when-candles-on-chart-not…
Browse files Browse the repository at this point in the history
…-presented
  • Loading branch information
DeltaZN authored Oct 5, 2023
2 parents 15fd8e9 + 32e1566 commit b2853e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/chart/components/dynamic-objects/dynamic-objects.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ export class DynamicObjectsModel extends ChartBaseElement {

/**
* @returns `DynamicObject` position in associated pane `LinkedList`
* @returns `-1` if an object was not found
*
*/
getObjectPosition(id: DynamicObjectId): number | undefined {
getObjectPosition(id: DynamicObjectId): number {
const objInfo = this.getObjectInfoById(id);

if (!objInfo) {
return;
return -1;
}

const [obj, paneList] = objInfo;
Expand Down
11 changes: 9 additions & 2 deletions src/chart/components/volumes/volumes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ export class VolumesComponent extends ChartBaseElement {
public setVisible(visible = true) {
this.config.components.volumes.visible = visible;
this.volumeVisibilityChangedSubject.next(visible);
visible ?
this.addVolumesToDynamicObjects() : this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);
visible
? this.addVolumesToDynamicObjects()
: this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);
if (this.config.components.volumes.showSeparately) {
if (visible) {
this.separateVolumes.activateSeparateVolumes();
Expand All @@ -136,6 +137,12 @@ export class VolumesComponent extends ChartBaseElement {
}

private addVolumesToDynamicObjects() {
// check if the volumes dynamic object is already added
const position = this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id);
if (position !== -1) {
return;
}

this.dynamicObjectsComponent.model.addObject({
id: this.volumesModel.id,
paneId: this.config.components.volumes.showSeparately ? VOLUMES_UUID : CHART_UUID,
Expand Down

0 comments on commit b2853e2

Please sign in to comment.