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(); + } + }); + });