From 93219a86695f6b6b6da4361c912dcc22a795fbe9 Mon Sep 17 00:00:00 2001 From: Nadir Ali <36660597+Xnadir@users.noreply.github.com> Date: Mon, 23 Nov 2026 05:34:38 +0500 Subject: [PATCH] fix(bar): draw a polar bar series normally when large is set. close #21856 Large mode is only laid out for cartesian2d, but BarSeries entered it whenever large was set and the data reached largeThreshold. On polar, BarView then built a LargePath with no points and threw "Cannot read properties of undefined (reading 'length')", and nothing was drawn. BarSeries now turns large and progressive rendering off unless the series is on cartesian2d, so a polar bar series falls back to normal rendering. Co-Authored-By: Claude Opus 5.5 --- src/chart/bar/BarSeries.ts | 14 ++++++++-- test/ut/spec/series/bar.test.ts | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts index 101303d11e..e953209763 100644 --- a/src/chart/bar/BarSeries.ts +++ b/src/chart/bar/BarSeries.ts @@ -117,7 +117,7 @@ class BarSeriesModel extends BaseBarSeriesModel { */ getProgressive() { // Do not support progressive in normal mode. - return this.get('large') + return this.get('large') && this._isLargeSupported() ? this.get('progressive') : false; } @@ -130,13 +130,23 @@ class BarSeriesModel extends BaseBarSeriesModel { pipeline: Pick ) { const context = preparePipelineContext(this, view, pipeline); + if (!this._isLargeSupported()) { + // Large mode is only laid out on cartesian2d. On polar, `large: true` + // used to reach LargePath with no points and throw, so draw normally. + context.large = false; + context.progressiveRender = false; + } // Do not support progressive in normal mode. - if (context.progressiveRender) { + else if (context.progressiveRender) { context.large = true; } return context; } + private _isLargeSupported(): boolean { + return this.get('coordinateSystem') === 'cartesian2d'; + } + brushSelector(dataIndex: number, data: SeriesData, selectors: BrushCommonSelectorsForSeries): boolean { return selectors.rect(data.getItemLayout(dataIndex)); } diff --git a/test/ut/spec/series/bar.test.ts b/test/ut/spec/series/bar.test.ts index 73e703d2d9..2704ad823f 100644 --- a/test/ut/spec/series/bar.test.ts +++ b/test/ut/spec/series/bar.test.ts @@ -62,4 +62,50 @@ describe('bar', function () { } }); + it('draws a polar bar series with large: true normally once it reaches largeThreshold', function () { + const chart = createChart({width: 400, height: 300}); + + try { + expect(() => chart.setOption({ + animation: false, + polar: {}, + angleAxis: { type: 'category', data: ['a', 'b', 'c'] }, + radiusAxis: {}, + series: [{ + type: 'bar', + coordinateSystem: 'polar', + large: true, + largeThreshold: 2, + data: [1, 2, 3] + }] + })).not.toThrow(); + + const data = (chart as any).getModel().getSeriesByIndex(0).getData(); + for (let i = 0; i < data.count(); i++) { + expect(data.getItemGraphicEl(i)).toBeTruthy(); + } + } + finally { + chart.dispose(); + } + }); + + it('keeps large mode for a cartesian2d bar series', function () { + const chart = createChart({width: 400, height: 300}); + + try { + chart.setOption({ + animation: false, + xAxis: { type: 'category', data: ['a', 'b', 'c'] }, + yAxis: {}, + series: [{ type: 'bar', large: true, largeThreshold: 2, data: [1, 2, 3] }] + }); + + expect((chart as any).getModel().getSeriesByIndex(0).pipelineContext.large).toBe(true); + } + finally { + chart.dispose(); + } + }); + });