From d1063642093e112069ed7b54ec80391bc1b0851f Mon Sep 17 00:00:00 2001 From: dmkokovtsev Date: Tue, 3 Oct 2023 13:30:42 +0300 Subject: [PATCH] fix: errors in XAxisTimeLabelsGenerator after prepending candles --- src/chart/components/chart/chart-base.model.ts | 1 + src/chart/components/chart/chart.model.ts | 1 + src/chart/components/x_axis/x-axis.component.ts | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/chart/components/chart/chart-base.model.ts b/src/chart/components/chart/chart-base.model.ts index d160c91f..7dc12255 100644 --- a/src/chart/components/chart/chart-base.model.ts +++ b/src/chart/components/chart/chart-base.model.ts @@ -18,6 +18,7 @@ type DataPoint = T extends 'candle' ? Candle : DataSeriesPoi type VisualPoint = T extends 'candle' ? VisualCandle : VisualSeriesPoint; export interface PrependedCandlesData { prependedCandlesWidth: number; + prependedCandlesCount: number; preparedCandles: Candle[]; } diff --git a/src/chart/components/chart/chart.model.ts b/src/chart/components/chart/chart.model.ts index 0d29f9ac..870d5bdb 100755 --- a/src/chart/components/chart/chart.model.ts +++ b/src/chart/components/chart/chart.model.ts @@ -389,6 +389,7 @@ export class ChartModel extends ChartBaseElement { this.scale.moveXStart(this.scale.xStart + prependedCandlesWidth); this.candlesPrependSubject.next({ prependedCandlesWidth, + prependedCandlesCount: updateResult.prepended, preparedCandles, }); diff --git a/src/chart/components/x_axis/x-axis.component.ts b/src/chart/components/x_axis/x-axis.component.ts index bd46677f..dd4ddd32 100644 --- a/src/chart/components/x_axis/x-axis.component.ts +++ b/src/chart/components/x_axis/x-axis.component.ts @@ -120,11 +120,11 @@ export class XAxisComponent extends ChartBaseElement { this.addRxSubscription( this.chartComponent.chartModel.candlesPrependSubject .pipe( - filter(({ preparedCandles }) => preparedCandles.length !== 0), - map(({ preparedCandles }) => { + filter(({ prependedCandlesCount }) => prependedCandlesCount !== 0), + map(({ prependedCandlesCount }) => { return this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice( 0, - preparedCandles.length, + prependedCandlesCount, ); }), )