Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pie): label not show when animation is disabled. fix #12110 #12243

Merged
merged 3 commits into from Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/chart/pie/PieView.js
Expand Up @@ -180,31 +180,36 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
var withAnimation = !firstCreate && animationTypeUpdate === 'transition';
this._updateLabel(data, idx, withAnimation);

this.highDownOnUpdate = (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled())
this.highDownOnUpdate = !seriesModel.get('silent')
? function (fromState, toState) {
const hasAnimation = seriesModel.isAnimationEnabled() && itemModel.get('hoverAnimation');
if (toState === 'emphasis') {
Ovilia marked this conversation as resolved.
Show resolved Hide resolved
labelLine.ignore = labelLine.hoverIgnore;
labelText.ignore = labelText.hoverIgnore;

// Sector may has animation of updating data. Force to move to the last frame
// Or it may stopped on the wrong shape
sector.stopAnimation(true);
sector.animateTo({
shape: {
r: layout.r + seriesModel.get('hoverOffset')
}
}, 300, 'elasticOut');
if (hasAnimation) {
sector.stopAnimation(true);
sector.animateTo({
shape: {
r: layout.r + seriesModel.get('hoverOffset')
}
}, 300, 'elasticOut');
}
}
else {
labelLine.ignore = labelLine.normalIgnore;
labelText.ignore = labelText.normalIgnore;

sector.stopAnimation(true);
sector.animateTo({
shape: {
r: layout.r
}
}, 300, 'elasticOut');
if (hasAnimation) {
sector.stopAnimation(true);
sector.animateTo({
shape: {
r: layout.r
}
}, 300, 'elasticOut');
}
}
}
: null;
Expand Down
47 changes: 46 additions & 1 deletion test/pie-animation.html
Expand Up @@ -31,7 +31,8 @@
html,
body,
#main1,
#main2 {
#main2,
#main3 {
width: 100%;
height: 250px;
margin: 0;
Expand All @@ -57,6 +58,9 @@
<button id="btn2">Go</button>
<div id="main2"></div>

<div class="test-title">Should display labels on emphasis if no animation</div>
<div id="main3"></div>

<script>

require([
Expand Down Expand Up @@ -164,6 +168,47 @@
});

</script>



<script>

require([
'echarts'
], function (echarts) {
var chart = echarts.init(
document.getElementById('main3'),
null,
{
renderer: 'svg'
}
);

var option = {
"series": [
{
"type": "pie",
"radius": ["40%", "70%"],
"animation": false,
"label": {
"show": false,
"emphasis": {
"show": true,
"textStyle": {
"fontSize": "50"
}
}
},
"data": [
{"value": 335, "name": "A"}
]
}
]
};
chart.setOption(option);
});

</script>
</body>

</html>
1 change: 1 addition & 0 deletions test/runTest/actions/__meta__.json
Expand Up @@ -109,6 +109,7 @@
"pie": 1,
"pie-action": 1,
"pie-alignTo": 4,
"pie-animation": 1,
"pie-calculable": 1,
"polar-rounded": 3,
"polarLine": 1,
Expand Down
1 change: 1 addition & 0 deletions test/runTest/actions/pie-animation.json
@@ -0,0 +1 @@
[{"name":"Action 1","ops":[{"type":"mousemove","time":2246,"x":225,"y":453},{"type":"mousemove","time":2453,"x":225,"y":453},{"type":"mousemove","time":2845,"x":225,"y":453},{"type":"mousemove","time":3045,"x":268,"y":465},{"type":"mousemove","time":3245,"x":312,"y":468},{"type":"mousemove","time":3449,"x":328,"y":469},{"type":"mousemove","time":3669,"x":328,"y":469},{"type":"screenshot","time":4152}],"scrollY":390,"scrollX":0,"timestamp":1583724042816}]