This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix/pie-endAngle-emptyCircle
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit c539b1fe3d3a9561242edb4cd5ba2375e43e7d16
Author: plainheart <[email protected]>
AuthorDate: Sat Feb 24 18:26:26 2024 +0800

    fix(pie): fix `endAngle` is not applied on the empty circle
---
 src/chart/pie/PieView.ts               |  5 +++--
 src/chart/pie/pieLayout.ts             | 16 ++++++++++++++--
 test/pie-endAngle.html                 |  5 ++++-
 test/runTest/actions/__meta__.json     |  2 +-
 test/runTest/actions/pie-endAngle.json |  2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index cb0e1d635..04a81f1e6 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -33,7 +33,7 @@ import { setLabelLineStyle, getLabelLineStatesModels } from 
'../../label/labelGu
 import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
 import { getSectorCornerRadius } from '../helper/sectorHelper';
 import { saveOldStyle } from '../../animation/basicTransition';
-import { getBasicPieLayout } from './pieLayout';
+import { getBasicPieLayout, getSeriesLayoutData } from './pieLayout';
 
 /**
  * Piece of pie including Sector, Label, LabelLine
@@ -260,8 +260,9 @@ class PieView extends ChartView {
         }
         // when all data are filtered, show lightgray empty circle
         if (data.count() === 0 && seriesModel.get('showEmptyCircle')) {
+            const layoutData = getSeriesLayoutData(seriesModel);
             const sector = new graphic.Sector({
-                shape: getBasicPieLayout(seriesModel, api)
+                shape: extend(getBasicPieLayout(seriesModel, api), layoutData)
             });
             
sector.useStyle(seriesModel.getModel('emptyCircleStyle').getItemStyle());
             this._emptyCircleSector = sector;
diff --git a/src/chart/pie/pieLayout.ts b/src/chart/pie/pieLayout.ts
index 2acdcda39..4ec992ec4 100644
--- a/src/chart/pie/pieLayout.ts
+++ b/src/chart/pie/pieLayout.ts
@@ -25,6 +25,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
 import PieSeriesModel from './PieSeries';
 import { SectorShape } from 'zrender/src/graphic/shape/Sector';
 import { normalizeArcAngles } from 'zrender/src/core/PathProxy';
+import { makeInner } from '../../util/model';
 
 const PI2 = Math.PI * 2;
 const RADIAN = Math.PI / 180;
@@ -127,6 +128,11 @@ export default function pieLayout(
 
         [startAngle, endAngle] = angles;
 
+        const layoutData = getSeriesLayoutData(seriesModel);
+        layoutData.startAngle = startAngle;
+        layoutData.endAngle = endAngle;
+        layoutData.clockwise = clockwise;
+
         const angleRange = Math.abs(endAngle - startAngle);
 
         // In the case some sector angle is smaller than minAngle
@@ -224,8 +230,8 @@ export default function pieLayout(
                             actualEndAngle = actualStartAngle;
                         }
                         else {
-                             actualStartAngle = startAngle + dir * idx * angle 
+ halfPadAngle;
-                             actualEndAngle = startAngle + dir * (idx + 1) * 
angle - halfPadAngle;
+                            actualStartAngle = startAngle + dir * idx * angle 
+ halfPadAngle;
+                            actualEndAngle = startAngle + dir * (idx + 1) * 
angle - halfPadAngle;
                         }
 
                         layout.startAngle = actualStartAngle;
@@ -263,3 +269,9 @@ export default function pieLayout(
         }
     });
 }
+
+export const getSeriesLayoutData = makeInner<{
+    startAngle: number
+    endAngle: number
+    clockwise: boolean
+}, PieSeriesModel>();
diff --git a/test/pie-endAngle.html b/test/pie-endAngle.html
index 0d5ed987b..b7e3ace92 100644
--- a/test/pie-endAngle.html
+++ b/test/pie-endAngle.html
@@ -49,6 +49,9 @@ under the License.
 
             function update() {
                 chart.setOption({
+                    legend: {
+                        bottom: '10%'
+                    },
                     series: {
                         type: "pie",
                         startAngle: config.startAngle,
@@ -87,4 +90,4 @@ under the License.
     </script>
 </body>
 
-</html>
\ No newline at end of file
+</html>
diff --git a/test/runTest/actions/__meta__.json 
b/test/runTest/actions/__meta__.json
index 7b2ccc514..bf0a57e02 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -156,7 +156,7 @@
   "pie-animation": 2,
   "pie-calculable": 1,
   "pie-cornerRadius": 1,
-  "pie-endAngle": 1,
+  "pie-endAngle": 2,
   "pie-label": 2,
   "pie-label-extreme": 2,
   "pie-percent": 2,
diff --git a/test/runTest/actions/pie-endAngle.json 
b/test/runTest/actions/pie-endAngle.json
index 8252f9f9e..8bf839f13 100644
--- a/test/runTest/actions/pie-endAngle.json
+++ b/test/runTest/actions/pie-endAngle.json
@@ -1 +1 @@
-[{"name":"Action 
1","ops":[{"type":"mousemove","time":358,"x":603,"y":513},{"type":"mousemove","time":558,"x":610,"y":488},{"type":"screenshot","time":958},{"type":"mousemove","time":1083,"x":610,"y":488},{"type":"mousemove","time":1283,"x":724,"y":87},{"type":"mousemove","time":1485,"x":719,"y":79},{"type":"mousemove","time":1557,"x":719,"y":79},{"type":"mousemove","time":1759,"x":667,"y":46},{"type":"mousemove","time":1959,"x":671,"y":45},{"type":"mousemove","time":2161,"x":658,"y":58}
 [...]
\ No newline at end of file
+[{"name":"Action 
1","ops":[{"type":"mousemove","time":358,"x":603,"y":513},{"type":"mousemove","time":558,"x":610,"y":488},{"type":"screenshot","time":958},{"type":"mousemove","time":1083,"x":610,"y":488},{"type":"mousemove","time":1283,"x":724,"y":87},{"type":"mousemove","time":1485,"x":719,"y":79},{"type":"mousemove","time":1557,"x":719,"y":79},{"type":"mousemove","time":1759,"x":667,"y":46},{"type":"mousemove","time":1959,"x":671,"y":45},{"type":"mousemove","time":2161,"x":658,"y":58}
 [...]
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to