Skip to content

Commit

Permalink
fix: volumes object is always persists in dynamic objects
Browse files Browse the repository at this point in the history
  • Loading branch information
hokilpet committed Oct 4, 2023
1 parent 5adac58 commit a232736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/chart/components/volumes/volumes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import { PaneManager } from '../pane/pane-manager.component';
import { SeparateVolumesComponent } from './separate-volumes.component';
import { resolveColorForBar, resolveColorForCandle, resolveColorForLine } from './volume-color-resolvers.functions';
import { VolumesDrawer } from './volumes.drawer';
import { VolumesModel } from './volumes.model';
import { VOLUMES_UUID, VolumesModel } from './volumes.model';

export type VolumeColorResolver = (priceMovement: PriceMovement, colors: FullChartColors) => string;

export class VolumesComponent extends ChartBaseElement {
separateVolumes: SeparateVolumesComponent;
dynamicObjectsComponent: DynamicObjectsComponent;
public volumesColorByChartTypeMap: Partial<Record<BarType, VolumeColorResolver>> = {};
volumesModel: VolumesModel;
volumesDrawer: VolumesDrawer
private readonly volumesDrawer: VolumesDrawer;
public volumeVisibilityChangedSubject = new BehaviorSubject<boolean>(false);
public volumeIsSeparateModeChangedSubject = new BehaviorSubject<boolean>(false);

Expand All @@ -38,7 +37,7 @@ export class VolumesComponent extends ChartBaseElement {
drawingManager: DrawingManager,
private config: FullChartConfig,
paneManager: PaneManager,
dynamicObjectsComponent: DynamicObjectsComponent,
private dynamicObjectsComponent: DynamicObjectsComponent,
) {
super();
const volumesModel = new VolumesModel(chartComponent, scale);
Expand All @@ -51,7 +50,6 @@ export class VolumesComponent extends ChartBaseElement {
volumesModel,
paneManager,
);
this.dynamicObjectsComponent = dynamicObjectsComponent;
this.volumesDrawer = new VolumesDrawer(
config,
this.volumesModel,
Expand Down Expand Up @@ -140,7 +138,7 @@ export class VolumesComponent extends ChartBaseElement {
private addVolumesToDynamicObjects() {
this.dynamicObjectsComponent.model.addObject({
id: this.volumesModel.id,
paneId: this.config.components.volumes.showSeparately ? this.volumesModel.id : CHART_UUID,
paneId: this.config.components.volumes.showSeparately ? VOLUMES_UUID : CHART_UUID,
drawer: this.volumesDrawer,
model: this.volumesModel,
});
Expand Down
2 changes: 1 addition & 1 deletion src/chart/components/volumes/volumes.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { firstOf, maxMin } from '../../utils/array.utils';

const volumeMaxMinFn = maxMin<VisualCandle>(candle => candle.candle.volume);

const VOLUMES_UUID = 'volumes';
export const VOLUMES_UUID = 'volumes';
export class VolumesModel extends ChartBaseElement {
public readonly id = VOLUMES_UUID;
// max volume in all data series
Expand Down

0 comments on commit a232736

Please sign in to comment.