Skip to content

Commit

Permalink
Merge pull request #1138 from albertshaw/master
Browse files Browse the repository at this point in the history
Pie Chart allow to control inner label position #1122
  • Loading branch information
kener committed Jan 9, 2015
2 parents 4bbd19c + ae7b8a6 commit 14f304f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/chart/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ define(function (require) {
textAlign = 'center';
}
else if (labelControl.position === 'inner' || labelControl.position === 'inside') {
// 内部显示
radius = (radius[0] + radius[1]) / 2;
// 内部标签显示, 按外半径比例计算标签位置
radius = (radius[0] + radius[1]) * (labelControl.distance || 0.5);
x = Math.round(centerX + radius * zrMath.cos(midAngle, true));
y = Math.round(centerY - radius * zrMath.sin(midAngle, true));
defaultColor = '#fff';
Expand Down Expand Up @@ -1051,4 +1051,4 @@ define(function (require) {
require('../chart').define('pie', Pie);

return Pie;
});
});
8 changes: 5 additions & 3 deletions test/allchart/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ <h3 class="test-head"><a href="../../index.html">ECharts</a> - test all <button
normal : {
label : {
position : 'inner',
formatter : function (a,b,c,d) {return (d - 0).toFixed(0) + '%'}
formatter : function (a,b,c,d) {return (d - 0).toFixed(0) + '%'},
distance : 0.7
},
labelLine : {
show : false
Expand All @@ -838,7 +839,8 @@ <h3 class="test-head"><a href="../../index.html">ECharts</a> - test all <button
emphasis : {
label : {
show : true,
formatter : "{b}\n{d}%"
formatter : "{b}\n{d}%",
distance : 0.6
}
}

Expand Down Expand Up @@ -1988,4 +1990,4 @@ <h3 class="test-head"><a href="../../index.html">ECharts</a> - test all <button
<script src="../../doc/asset/js/jquery.js"></script>
<script src="all.js"></script>
</body>
</html>
</html>

0 comments on commit 14f304f

Please sign in to comment.