@@ -112,6 +112,8 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
112112 var sectorShape = zrUtil . extend ( { } , layout ) ;
113113 sectorShape . label = null ;
114114
115+ var animationTypeUpdate = seriesModel . getShallow ( 'animationTypeUpdate' ) ;
116+
115117 if ( firstCreate ) {
116118 sector . setShape ( sectorShape ) ;
117119
@@ -136,9 +138,15 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
136138
137139 }
138140 else {
139- graphic . updateProps ( sector , {
140- shape : sectorShape
141- } , seriesModel , idx ) ;
141+ if ( animationTypeUpdate === 'expansion' ) {
142+ // Sectors are set to be target shape and an overlaying clipPath is used for animation
143+ sector . setShape ( sectorShape ) ;
144+ } else {
145+ // Transition animation from the old shape
146+ graphic . updateProps ( sector , {
147+ shape : sectorShape
148+ } , seriesModel , idx ) ;
149+ }
142150 }
143151
144152 // Update common style
@@ -167,7 +175,9 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
167175 seriesModel . get ( 'animation' )
168176 ) ;
169177
170- this . _updateLabel ( data , idx ) ;
178+ // Label and text animation should be applied only for transition type animation when update
179+ var withAnimation = ! firstCreate && animationTypeUpdate === 'transition' ;
180+ this . _updateLabel ( data , idx , withAnimation ) ;
171181
172182 this . highDownOnUpdate = ( itemModel . get ( 'hoverAnimation' ) && seriesModel . isAnimationEnabled ( ) )
173183 ? function ( fromState , toState ) {
@@ -201,7 +211,7 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
201211 graphic . setHoverStyle ( this ) ;
202212} ;
203213
204- piePieceProto . _updateLabel = function ( data , idx ) {
214+ piePieceProto . _updateLabel = function ( data , idx , withAnimation ) {
205215
206216 var labelLine = this . childAt ( 1 ) ;
207217 var labelText = this . childAt ( 2 ) ;
@@ -218,20 +228,33 @@ piePieceProto._updateLabel = function (data, idx) {
218228 return ;
219229 }
220230
221- graphic . updateProps ( labelLine , {
222- shape : {
223- points : labelLayout . linePoints || [
224- [ labelLayout . x , labelLayout . y ] , [ labelLayout . x , labelLayout . y ] , [ labelLayout . x , labelLayout . y ]
225- ]
226- }
227- } , seriesModel , idx ) ;
231+ var targetLineShape = {
232+ points : labelLayout . linePoints || [
233+ [ labelLayout . x , labelLayout . y ] , [ labelLayout . x , labelLayout . y ] , [ labelLayout . x , labelLayout . y ]
234+ ]
235+ } ;
236+ var targetTextStyle = {
237+ x : labelLayout . x ,
238+ y : labelLayout . y
239+ } ;
240+ if ( withAnimation ) {
241+ graphic . updateProps ( labelLine , {
242+ shape : targetLineShape
243+ } , seriesModel , idx ) ;
244+
245+ graphic . updateProps ( labelText , {
246+ style : targetTextStyle
247+ } , seriesModel , idx ) ;
248+ }
249+ else {
250+ labelLine . attr ( {
251+ shape : targetLineShape
252+ } ) ;
253+ labelText . attr ( {
254+ style : targetTextStyle
255+ } ) ;
256+ }
228257
229- graphic . updateProps ( labelText , {
230- style : {
231- x : labelLayout . x ,
232- y : labelLayout . y
233- }
234- } , seriesModel , idx ) ;
235258 labelText . attr ( {
236259 rotation : labelLayout . rotation ,
237260 origin : [ labelLayout . x , labelLayout . y ] ,
@@ -309,6 +332,7 @@ var PieView = ChartView.extend({
309332 var hasAnimation = ecModel . get ( 'animation' ) ;
310333 var isFirstRender = ! oldData ;
311334 var animationType = seriesModel . get ( 'animationType' ) ;
335+ var animationTypeUpdate = seriesModel . get ( 'animationTypeUpdate' ) ;
312336
313337 var onSectorClick = zrUtil . curry (
314338 updateDataSelected , this . uid , seriesModel , hasAnimation , api
@@ -334,6 +358,12 @@ var PieView = ChartView.extend({
334358 . update ( function ( newIdx , oldIdx ) {
335359 var piePiece = oldData . getItemGraphicEl ( oldIdx ) ;
336360
361+ if ( ! isFirstRender && animationTypeUpdate !== 'transition' ) {
362+ piePiece . eachChild ( function ( child ) {
363+ child . stopAnimation ( true ) ;
364+ } ) ;
365+ }
366+
337367 piePiece . updateData ( data , newIdx ) ;
338368
339369 piePiece . off ( 'click' ) ;
@@ -348,9 +378,8 @@ var PieView = ChartView.extend({
348378 . execute ( ) ;
349379
350380 if (
351- hasAnimation && isFirstRender && data . count ( ) > 0
352- // Default expansion animation
353- && animationType !== 'scale'
381+ hasAnimation && data . count ( ) > 0
382+ && ( isFirstRender ? animationType !== 'scale' : animationTypeUpdate !== 'transition' )
354383 ) {
355384 var shape = data . getItemLayout ( 0 ) ;
356385 for ( var s = 1 ; isNaN ( shape . startAngle ) && s < data . count ( ) ; ++ s ) {
@@ -361,7 +390,7 @@ var PieView = ChartView.extend({
361390
362391 var removeClipPath = zrUtil . bind ( group . removeClipPath , group ) ;
363392 group . setClipPath ( this . _createClipPath (
364- shape . cx , shape . cy , r , shape . startAngle , shape . clockwise , removeClipPath , seriesModel
393+ shape . cx , shape . cy , r , shape . startAngle , shape . clockwise , removeClipPath , seriesModel , isFirstRender
365394 ) ) ;
366395 }
367396 else {
@@ -375,7 +404,7 @@ var PieView = ChartView.extend({
375404 dispose : function ( ) { } ,
376405
377406 _createClipPath : function (
378- cx , cy , r , startAngle , clockwise , cb , seriesModel
407+ cx , cy , r , startAngle , clockwise , cb , seriesModel , isFirstRender
379408 ) {
380409 var clipPath = new graphic . Sector ( {
381410 shape : {
@@ -389,7 +418,8 @@ var PieView = ChartView.extend({
389418 }
390419 } ) ;
391420
392- graphic . initProps ( clipPath , {
421+ var initOrUpdate = isFirstRender ? graphic . initProps : graphic . updateProps ;
422+ initOrUpdate ( clipPath , {
393423 shape : {
394424 endAngle : startAngle + ( clockwise ? 1 : - 1 ) * Math . PI * 2
395425 }
0 commit comments