You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/09/29 03:33:40 UTC
[echarts] 01/01: fix(pie): fix a NPE of `labelLine` when `minShowLabelRadian` is set.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix-pie
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 91382c21a86f3afe89b251621aa8fd7ee461220b
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Sep 29 11:31:05 2022 +0800
fix(pie): fix a NPE of `labelLine` when `minShowLabelRadian` is set.
---
src/chart/pie/labelLayout.ts | 7 +++++--
test/pie-label.html | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/chart/pie/labelLayout.ts b/src/chart/pie/labelLayout.ts
index 0c9090891..4ed96f3ac 100644
--- a/src/chart/pie/labelLayout.ts
+++ b/src/chart/pie/labelLayout.ts
@@ -394,8 +394,11 @@ export default function pieLabelLayout(
if (Math.abs(sectorShape.endAngle - sectorShape.startAngle) < minShowLabelRadian) {
each(label.states, setNotShow);
- each(labelLine.states, setNotShow);
- label.ignore = labelLine.ignore = true;
+ label.ignore = true;
+ if (labelLine) {
+ each(labelLine.states, setNotShow);
+ labelLine.ignore = true;
+ }
return;
}
diff --git a/test/pie-label.html b/test/pie-label.html
index 23cb8d39a..4738d0e17 100644
--- a/test/pie-label.html
+++ b/test/pie-label.html
@@ -52,6 +52,7 @@ under the License.
<div id="main9"></div>
<div id="main10"></div>
<div id="main11"></div>
+ <div id="main12"></div>
<script>
@@ -981,5 +982,39 @@ under the License.
});
});
</script>
+
+ <script>
+ require([
+ 'echarts'
+ ], function (echarts) {
+ var option = {
+ series: [{
+ type: 'pie',
+ radius: ['40%', '70%'],
+ minShowLabelAngle: 100,
+ label: {
+ show: true,
+ position: 'inside'
+ },
+ data: [
+ { value: 1048, name: 'Search Engine' },
+ { value: 735, name: 'Direct' },
+ { value: 580, name: 'Email' },
+ { value: 484, name: 'Union Ads' },
+ { value: 300, name: 'Video Ads' }
+ ]
+ }]
+ };
+
+ var chart = testHelper.create(echarts, 'main12', {
+ title: [
+ 'The labels should be rendered correctly and no errors in the console',
+ 'Test case from issue #17712',
+ ],
+ height: 300,
+ option: option
+ });
+ });
+ </script>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org