From a9148cf1a13398862f9c42c2c95b822d4cac24cd Mon Sep 17 00:00:00 2001 From: signatenkov Date: Mon, 18 Nov 2024 08:48:51 +0000 Subject: [PATCH] Add method priceLines in ISeriesAPI --- src/api/iseries-api.ts | 5 +++++ src/api/series-api.ts | 4 ++++ src/model/series.ts | 4 ++++ tests/e2e/graphics/test-cases/series/price-lines-remove.js | 5 +++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/api/iseries-api.ts b/src/api/iseries-api.ts index a38ac606a9..b1adac3724 100644 --- a/src/api/iseries-api.ts +++ b/src/api/iseries-api.ts @@ -306,6 +306,11 @@ export interface ISeriesApi< */ removePriceLine(line: IPriceLine): void; + /** + * Returns an array of price lines. + */ + priceLines(): IPriceLine[]; + /** * Return current series type. * diff --git a/src/api/series-api.ts b/src/api/series-api.ts index e0a2a8dd34..eb3ef640c8 100644 --- a/src/api/series-api.ts +++ b/src/api/series-api.ts @@ -221,6 +221,10 @@ export class SeriesApi< this._series.removePriceLine((line as PriceLine).priceLine()); } + public priceLines(): IPriceLine[] { + return this._series.priceLines(); + } + public seriesType(): TSeriesType { return this._series.seriesType(); } diff --git a/src/model/series.ts b/src/model/series.ts index 20dc13c8be..efee66aae6 100644 --- a/src/model/series.ts +++ b/src/model/series.ts @@ -345,6 +345,10 @@ export class Series extends PriceDataSource implements IDe this.model().updateSource(this); } + public priceLines(): CustomPriceLine[] { + return this._customPriceLines.slice(); + } + public seriesType(): T { return this._seriesType; } diff --git a/tests/e2e/graphics/test-cases/series/price-lines-remove.js b/tests/e2e/graphics/test-cases/series/price-lines-remove.js index 8c94fccef4..f0edd4c210 100644 --- a/tests/e2e/graphics/test-cases/series/price-lines-remove.js +++ b/tests/e2e/graphics/test-cases/series/price-lines-remove.js @@ -18,11 +18,12 @@ function runTestCase(container) { const series = chart.addLineSeries(); series.setData(generateData()); - const line1 = series.createPriceLine({ price: 10 }); - const line2 = series.createPriceLine({ price: 20 }); + series.createPriceLine({ price: 10 }); + series.createPriceLine({ price: 20 }); return new Promise(resolve => { setTimeout(() => { + const [line1, line2] = series.priceLines(); series.removePriceLine(line2); series.removePriceLine(line1); resolve();