This is an automated email from the ASF dual-hosted git repository. ovilia pushed a commit to branch fix-bar-race in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 0372b4d00389f1157b092138a63fe3214c353bd3 Author: Ovilia <zwl.s...@gmail.com> AuthorDate: Fri Jul 31 22:18:43 2020 +0800 fix(bar-race): fix interpolation --- src/chart/bar/BarView.ts | 13 +++++++------ src/util/graphic.ts | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index 0150d48..62907ea 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -144,8 +144,6 @@ class BarView extends ChartView { else if (__DEV__) { console.warn('Only cartesian2d and polar supported for bar.'); } - - this._isFirstFrame = false; } incrementalPrepareRender(seriesModel: BarSeriesModel): void { @@ -199,8 +197,11 @@ class BarView extends ChartView { const axisSort = coord.type === 'cartesian2d' && axis2DModel.get('sort') && axis2DModel.get('sortSeriesIndex') === seriesModel.seriesIndex; const realtimeSort = axisSort && axis2DModel.get('realtimeSort'); - if (realtimeSort && this._isFirstFrame) { + + // If no data in the first frame, wait for data to initSort + if (realtimeSort && this._isFirstFrame && data.count()) { this._initSort(data, isHorizontalOrRadial, baseAxis as Axis2D, api); + this._isFirstFrame = false; return; } @@ -385,7 +386,7 @@ class BarView extends ChartView { this._data = data; if (lastAnimator) { - lastAnimator.during(percent => { + lastAnimator.during(() => { const orderMap = (idx: number) => { const el = (data.getItemGraphicEl(idx) as Rect); if (el) { @@ -499,7 +500,7 @@ class BarView extends ChartView { * bars are both out of sight, we don't wish to trigger reorder action * as long as the order in the view doesn't change. */ - if (oldOrder[i].ordinalNumber !== newOrder[i].ordinalNumber) { + if (!oldOrder[i] || oldOrder[i].ordinalNumber !== newOrder[i].ordinalNumber) { const action = { type: 'changeAxisOrder', componentType: baseAxis.dim + 'Axis', @@ -525,7 +526,7 @@ class BarView extends ChartView { axisId: baseAxis.index, sortInfo: this._dataSort( data, - idx => parseInt(data.get(isHorizontal ? 'y' : 'x', idx) as string, 10) || 0 + idx => parseFloat(data.get(isHorizontal ? 'y' : 'x', idx) as string) || 0 ) } as Payload; api.dispatchAction(action); diff --git a/src/util/graphic.ts b/src/util/graphic.ts index b456fb6..5ca3ee6 100644 --- a/src/util/graphic.ts +++ b/src/util/graphic.ts @@ -601,12 +601,19 @@ function animateOrSetLabel<Props extends PathProps>( interpolated[i] = (rawValues as [])[i]; } else { + /** + * startValues may be undefined if no data in last setOption but + * have data in this setOption. Use the data in this setOption + * as interpolated value. + */ const startValues = host.startValue as number[]; - const value = interpolateNumber( - startValues && startValues[i] ? startValues[i] : 0, - (interpolateValues as number[])[i], - percent - ); + const value = startValues == null + ? (rawValues as [])[i] + : interpolateNumber( + startValues && startValues[i] ? startValues[i] : 0, + (interpolateValues as number[])[i], + percent + ); interpolated[i] = numberUtil.round(value), precision; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org