protected initializeDrawing(
formatObservable?: Observable<ChartOptionsModel>,
initialEvent?: MouseEventParams,
startDrawing?: (point: Point) => void,
): void {
if (formatObservable) {
this.subscriptions.add(
formatObservable.subscribe((format) => {
this.displayFormat = format;
this.render();
}),
);
}
this.series.attachPrimitive(this as unknown as ISeriesPrimitive<Time>);
if (initialEvent?.sourceEvent && startDrawing) {
startDrawing(this.getEventPoint(initialEvent.sourceEvent));
}
}
if (this.profileKind === 'visibleRange') {
this.chart.timeScale().subscribeVisibleLogicalRangeChange(this.handleVisibleLogicalRangeChange);
this.calculateProfile();
}
this.initializeDrawing(
formatObservable,
this.profileKind === 'fixedRange' ? initialEvent : undefined,
(point) => this.startDrawing(point),
);
resetTriggers.forEach((trigger) => {
this.subscriptions.add(
trigger.pipe(skip(1)).subscribe(() => {
this.removeSelf?.();
}),
);
});
this.initializeDrawing(formatObservable);
if (initialEvent) {
this.handleChartClick(initialEvent);
}
constructor({
chart,
series,
container,
interaction,
formatObservable,
removeSelf,
openSettings,
initialEvent,
}: TraectoryParams) {
super({
chart,
series,
container,
interaction,
});
this.removeSelf = removeSelf;
this.openSettings = openSettings;
this.paneView = new TraectoryPaneView(this);
this.timeAxisPaneView = new CustomTimeAxisPaneView({
getAxisSegments: () => this.getTimeAxisSegments(),
});
this.priceAxisPaneView = new CustomPriceAxisPaneView({
getAxisSegments: () => this.getPriceAxisSegments(),
});
this.initializeDrawing(formatObservable, initialEvent, (point) => this.startDrawing(point));
}