Skip to content

Commit

Permalink
fix: 修复repaint shape属性不生效。Closed #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Dec 4, 2020
1 parent fc32d66 commit b1ba85e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/animation/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ function addAnimate(cache, shapes, canvas) {
if (isFunction(animate)) {
animate(updateShape, animateCfg, coord);
} else {
updateShape.attr(cacheAttrs);
const startState = {};
each(endState, function(value, key) {
startState[key] = cacheAttrs[key];
});
updateShape.attr(startState);
updateShape.animate().to({
attrs: endState,
duration: animateCfg.duration,
Expand Down
61 changes: 61 additions & 0 deletions test/bug/issue-1102-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import F2 from '../../src/index';

const canvas = document.createElement('canvas');
canvas.style.width = '350px';
canvas.style.height = '300px';
document.body.appendChild(canvas);

describe('issue 1102', () => {
it('repaint shape属性不生效', done => {
const data = [{
date: '2017-06-05',
value: 116
}, {
date: '2017-06-06',
value: 129
}, {
date: '2017-06-07',
value: 135
}, {
date: '2017-06-08',
value: 86
}, {
date: '2017-06-09',
value: 73
}, {
date: '2017-06-10',
value: 85
}, {
date: '2017-06-11',
value: 73
}, {
date: '2017-06-12',
value: 68
}];

const chart = new F2.Chart({
el: canvas,
pixelRatio: window.devicePixelRatio
});

chart.source(data, {
date: {
type: 'timeCat',
tickCount: 3
}
});
const line = chart.line().position('date*value');
chart.render();

setTimeout(() => {
line.shape('smooth').color('red');
chart.repaint();
setTimeout(() => {
const container = line.get('container');
const shape = container.get('children')[0];
expect(shape._attrs.attrs.strokeStyle).toBe('red');
done();
}, 200);
}, 100);
});
});

0 comments on commit b1ba85e

Please sign in to comment.