You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2023/06/27 07:06:52 UTC

[echarts] branch master updated: fix(sunburst): normalize label rotation when decompress from matrix

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

ovilia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new e7ad886d7 fix(sunburst): normalize label rotation when decompress from matrix
     new 0ddf9f77d Merge pull request #18808 from linghaoSu/fix/sunburst-rotate-label
e7ad886d7 is described below

commit e7ad886d7bbe9e7b5001cc888c0c5833b08edb6c
Author: linghao.su <sl...@live.cn>
AuthorDate: Mon Jun 26 23:48:31 2023 +0800

    fix(sunburst): normalize label rotation when decompress from matrix
---
 src/chart/sunburst/SunburstPiece.ts             |   2 +-
 src/label/LabelManager.ts                       |   3 +
 test/runTest/actions/__meta__.json              |   1 +
 test/runTest/actions/sunburst-label-rotate.json |   1 +
 test/sunburst-label-rotate.html                 | 110 ++++++++++++++++++++++++
 5 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/src/chart/sunburst/SunburstPiece.ts b/src/chart/sunburst/SunburstPiece.ts
index f937b59ab..b0d662796 100644
--- a/src/chart/sunburst/SunburstPiece.ts
+++ b/src/chart/sunburst/SunburstPiece.ts
@@ -270,7 +270,7 @@ class SunburstPiece extends graphic.Sector {
                 rotate = rotateType * Math.PI / 180;
             }
 
-            state.rotation = rotate;
+            state.rotation = normalizeRadian(rotate);
         });
 
 
diff --git a/src/label/LabelManager.ts b/src/label/LabelManager.ts
index f2b2aefd3..d20c75f16 100644
--- a/src/label/LabelManager.ts
+++ b/src/label/LabelManager.ts
@@ -53,6 +53,7 @@ import { PathStyleProps } from 'zrender/src/graphic/Path';
 import Model from '../model/Model';
 import { prepareLayoutList, hideOverlap, shiftLayoutOnX, shiftLayoutOnY } from './labelLayoutHelper';
 import { labelInner, animateLabelValue } from './labelStyle';
+import { normalizeRadian } from 'zrender/src/contain/util';
 
 interface LabelDesc {
     label: ZRText
@@ -219,6 +220,8 @@ class LabelManager {
             dummyTransformable.scaleX = dummyTransformable.scaleY = 1;
         }
 
+        dummyTransformable.rotation = normalizeRadian(dummyTransformable.rotation);
+
         const host = label.__hostTarget;
         let hostRect;
         if (host) {
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index e5263c168..dee65260b 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -177,6 +177,7 @@
   "stackBar-dataZoom": 7,
   "sunburst-book": 1,
   "sunburst-canvas": 1,
+  "sunburst-label-rotate": 1,
   "svg-ssr": 1,
   "symbol": 1,
   "symbol2": 1,
diff --git a/test/runTest/actions/sunburst-label-rotate.json b/test/runTest/actions/sunburst-label-rotate.json
new file mode 100644
index 000000000..f2e04c555
--- /dev/null
+++ b/test/runTest/actions/sunburst-label-rotate.json
@@ -0,0 +1 @@
+[{"name":"Action 1","ops":[{"type":"mousemove","time":1481,"x":532,"y":440},{"type":"mousemove","time":1683,"x":530,"y":437},{"type":"mousemove","time":1889,"x":530,"y":437},{"type":"mousemove","time":2092,"x":516,"y":421},{"type":"mousemove","time":2298,"x":510,"y":410},{"type":"mousemove","time":2500,"x":499,"y":393},{"type":"screenshot","time":2642},{"type":"mousemove","time":2705,"x":494,"y":386},{"type":"mousemove","time":2905,"x":447,"y":313},{"type":"mousemove","time":3111,"x":441 [...]
\ No newline at end of file
diff --git a/test/sunburst-label-rotate.html b/test/sunburst-label-rotate.html
new file mode 100644
index 000000000..a249b1b6e
--- /dev/null
+++ b/test/sunburst-label-rotate.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<html>
+    <head>
+        <meta charset="utf-8" />
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <script src="lib/simpleRequire.js"></script>
+        <script src="lib/config.js"></script>
+        <script src="lib/jquery.min.js"></script>
+        <script src="lib/facePrint.js"></script>
+        <script src="lib/testHelper.js"></script>
+        <script src="lib/dat.gui.min.js"></script>
+        <!-- <script src="ut/lib/canteen.js"></script> -->
+        <link rel="stylesheet" href="lib/reset.css" />
+    </head>
+    <body>
+        <style></style>
+
+        <div id="main0"></div>
+
+        <script>
+            require([
+                "echarts",
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                var data = [
+                    {
+                        name: "Grandpa",
+                        children: [
+                            {
+                                name: "Uncle Leo",
+                                value: 15,
+                                children: [
+                                    {
+                                        name: "Cousin Ben",
+                                        value: 4,
+                                    },
+                                ],
+                            },
+                        ],
+                    },
+                    {
+                        name: "Mike",
+                        children: [
+                            {
+                                name: "Uncle Dan",
+                                children: [
+                                    {
+                                        name: "Cousin Lucy",
+                                        value: 3,
+                                    },
+                                    {
+                                        name: "Cousin Luck",
+                                        value: 4,
+                                        children: [
+                                            {
+                                                name: "Nephew",
+                                                value: 2,
+                                            },
+                                        ],
+                                    },
+                                ],
+                            },
+                        ],
+                    },
+                ];
+
+                option = {
+                    series: {
+                        type: "sunburst",
+                        data: data,
+                        labelLayout: {
+                            hideOverlap: true,
+                        },
+                        label: {},
+                    },
+                };
+
+                var chart = testHelper.create(echarts, "main0", {
+                    title: ["Put label in the center if it's a circle"],
+                    option: option,
+                    // height: 300,
+                    // buttons: [{text: 'btn-txt', onclick: function () {}}],
+                    // recordCanvas: true,
+                });
+            });
+        </script>
+    </body>
+</html>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org