Skip to content

Commit 8aa9d6d

Browse files
committed
fix: Revert updateTransform to support progressive rendering (e.g. for 'linesGL' in echarts-gl). It is incorrectly break by v6.1.0.
1 parent c5a48f5 commit 8aa9d6d

7 files changed

Lines changed: 34 additions & 12 deletions

File tree

src/chart/effectScatter/EffectScatterView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import EffectScatterSeriesModel from './EffectScatterSeries';
2929
import { StageHandlerProgressExecutor } from '../../util/types';
3030
import { createCoordSysClipAreaSimply } from '../helper/createClipPathFromCoordSys';
3131
import { SymbolDrawUpdateOpt } from '../helper/baseDraw';
32+
import { isInProgressiveRendering } from '../../util/model';
3233

3334
class EffectScatterView extends ChartView {
3435
static readonly type = 'effectScatter';
@@ -48,6 +49,10 @@ class EffectScatterView extends ChartView {
4849
}
4950

5051
updateTransform(seriesModel: EffectScatterSeriesModel, ecModel: GlobalModel, api: ExtensionAPI) {
52+
if (isInProgressiveRendering(seriesModel)) {
53+
return {update: true} as const;
54+
}
55+
5156
const data = seriesModel.getData();
5257

5358
this.group.dirty();

src/chart/lines/LinesView.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import SeriesData from '../../data/SeriesData';
3535
import type Polar from '../../coord/polar/Polar';
3636
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
3737
import Element from 'zrender/src/Element';
38-
import { getIncrementalId } from '../../util/model';
38+
import { getIncrementalId, isInProgressiveRendering } from '../../util/model';
3939
import { getCurrentCanvasPainter } from '../../util/graphic';
4040
import { ILineDraw } from '../helper/baseDraw';
4141

@@ -134,7 +134,8 @@ class LinesView extends ChartView {
134134
const data = seriesModel.getData();
135135
const lineDraw = this._lineDraw;
136136

137-
if (!this._finished
137+
if (isInProgressiveRendering(seriesModel)
138+
|| !this._finished
138139
|| !lineDraw
139140
// TODO Don't have to do update in large mode. Only do it when there are millions of data.
140141
|| !lineDraw.updateLayout

src/chart/scatter/ScatterView.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import SeriesData from '../../data/SeriesData';
2828
import { TaskProgressParams } from '../../core/task';
2929
import type { StageHandlerProgressExecutor } from '../../util/types';
3030
import Element from 'zrender/src/Element';
31-
import { getIncrementalId } from '../../util/model';
31+
import { getIncrementalId, isInProgressiveRendering } from '../../util/model';
3232
import { createCoordSysClipAreaSimply } from '../helper/createClipPathFromCoordSys';
3333
import { ISymbolDraw, SymbolDrawUpdateOpt } from '../helper/baseDraw';
3434

@@ -78,7 +78,9 @@ class ScatterView extends ChartView {
7878
// PENDING
7979
this.group.dirty();
8080

81-
if (!this._finished) { // FIXME: _finished checking is unnecessary?
81+
if (isInProgressiveRendering(seriesModel)
82+
|| !this._finished
83+
) { // FIXME: _finished checking is unnecessary?
8284
return {update: true} as const;
8385
}
8486
else {

src/core/echarts.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,13 +1973,7 @@ class ECharts extends Eventful<ECEventDefinition> {
19731973
const seriesDirtyMap = createHashMap();
19741974
ecModel.eachSeries(function (seriesModel) {
19751975
const chartView = ecIns._chartsMap[seriesModel.__viewId];
1976-
const pipelineContext = seriesModel.pipelineContext;
1977-
if (chartView.updateTransform
1978-
// Use the progressive pass if enabled, where each frame renders only a small amount.
1979-
// And `ISymbolDraw['updateLayout']` and `ILineDraw['updateLayout']` do not support
1980-
// progressive case.
1981-
&& !pipelineContext.progressiveRender
1982-
) {
1976+
if (chartView.updateTransform) {
19831977
const result = chartView.updateTransform(seriesModel, ecModel, api, payload);
19841978
result && result.update && seriesDirtyMap.set(seriesModel.uid, 1);
19851979
}

src/util/model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,3 +1442,7 @@ export function createSimpleOverallStageHandler2(
14421442
overallReset: overallReset
14431443
};
14441444
}
1445+
1446+
export function isInProgressiveRendering(seriesModel: SeriesModel): boolean {
1447+
return seriesModel.pipelineContext.progressiveRender;
1448+
}

src/view/Chart.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ interface ChartView {
7171
/**
7272
* Update transform directly.
7373
* Implement it if needed.
74+
*
75+
* [NOTICE]: It may be called after normal rendering (via `ChartView['render']`)
76+
* or progressive rendering (via `ChartView['incrementalPrepareRender']` and
77+
* `ChartView['incrementalRender']`).
78+
* For example, echarts-gl `linesGL` supports `updateTransform` to run in
79+
* progressive rendering.
80+
* If a series opts out of supporting `updateTransform` in progressive rendering,
81+
* it can fall back to the normal update path using
82+
* ```js
83+
* updateTransform(seriesModel) {
84+
* if (isInProgressiveRendering(seriesModel)) {
85+
* return {update: true} as const;
86+
* }
87+
* // ...
88+
* }
89+
* ```
7490
*/
7591
updateTransform(
7692
seriesModel: SeriesModel,

test/scatter-gps.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)