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/11/15 11:01:12 UTC

[echarts] branch fix/pie-coordinate-system created (now a7d1c403d)

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

wangzx pushed a change to branch fix/pie-coordinate-system
in repository https://gitbox.apache.org/repos/asf/echarts.git


      at a7d1c403d fix(pie): fix `center` may not be converted to the correct point when coordinate system is specified due to being normalized to an array.

This branch includes the following new commits:

     new a7d1c403d fix(pie): fix `center` may not be converted to the correct point when coordinate system is specified due to being normalized to an array.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[echarts] 01/01: fix(pie): fix `center` may not be converted to the correct point when coordinate system is specified due to being normalized to an array.

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a7d1c403d4fe934a8a4e2ecf973c25f1c7bc0de5
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Tue Nov 15 18:56:24 2022 +0800

    fix(pie): fix `center` may not be converted to the correct point when coordinate system is specified due to being normalized to an array.
---
 src/chart/pie/pieLayout.ts      |   7 +-
 test/pie-coordinate-system.html | 252 +++++++++++++++++++++-------------------
 2 files changed, 137 insertions(+), 122 deletions(-)

diff --git a/src/chart/pie/pieLayout.ts b/src/chart/pie/pieLayout.ts
index 0a6998c70..c5c52ccfc 100644
--- a/src/chart/pie/pieLayout.ts
+++ b/src/chart/pie/pieLayout.ts
@@ -41,15 +41,13 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI
     Pick<SectorShape, 'cx' | 'cy' | 'r' | 'r0'> {
     const viewRect = getViewRect(seriesModel, api);
 
+    // center can be string or number when coordinateSystem is specified
     let center = seriesModel.get('center');
     let radius = seriesModel.get('radius');
 
     if (!zrUtil.isArray(radius)) {
         radius = [0, radius];
     }
-    if (!zrUtil.isArray(center)) {
-        center = [center, center];
-    }
     const width = parsePercent(viewRect.width, api.getWidth());
     const height = parsePercent(viewRect.height, api.getHeight());
     const size = Math.min(width, height);
@@ -66,6 +64,9 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI
         cy = point[1] || 0;
     }
     else {
+        if (!zrUtil.isArray(center)) {
+            center = [center, center];
+        }
         cx = parsePercent(center[0], width) + viewRect.x;
         cy = parsePercent(center[1], height) + viewRect.y;
     }
diff --git a/test/pie-coordinate-system.html b/test/pie-coordinate-system.html
index ad0703edd..7ce8eec08 100644
--- a/test/pie-coordinate-system.html
+++ b/test/pie-coordinate-system.html
@@ -31,126 +31,13 @@ under the License.
         <style>
         </style>
 
-        <div id="main0"></div>
         <div id="main1"></div>
         <div id="main2"></div>
         <div id="main3"></div>
         <div id="main4"></div>
         <div id="main5"></div>
         <div id="main6"></div>
-
-        <script src="https://api.map.baidu.com/api?v=2.0&ak=KOmVjPVUAey1G2E8zNhPiuQ6QiEmAwZu"></script>
-        <script>
-            require([
-                'echarts',
-                'extension/bmap'
-            ], function (echarts) {
-
-                var option = {
-                    bmap: {
-                        center: [115, 30],
-                        zoom: 5,
-                        roam: true,
-                    },
-                    tooltip: {},
-                    series: [
-                        {
-                            type: 'pie',
-                            name: 'BMap',
-                            coordinateSystem: 'bmap',
-                            radius: 20,
-                            center: [120, 30],
-                            data: [
-                                { value: 1048, name: 'A' },
-                                { value: 735, name: 'B' },
-                                { value: 580, name: 'C' },
-                                { value: 484, name: 'D' },
-                                { value: 300, name: 'E' }
-                            ]
-                        },
-                        {
-                            type: 'pie',
-                            name: 'No CRS',
-                            // coordinateSystem: 'bmap',
-                            radius: 20,
-                            center: [110, 36],
-                            data: [
-                                { value: 1048, name: 'A' },
-                                { value: 735, name: 'B' },
-                                { value: 580, name: 'C' },
-                                { value: 484, name: 'D' },
-                                { value: 300, name: 'E' }
-                            ]
-                        }
-                    ]
-                };
-
-                var chart = testHelper.create(echarts, 'main0', {
-                    title: ['Pie series on BMap'],
-                    option: option,
-                    buttons: [{
-                        text: 'Convert point [120, 30] to pixel',
-                        onclick: function () {
-                            alert(chart.convertToPixel('bmap', [120, 30]));
-                        }
-                    }]
-                });
-            });
-        </script>
-
-        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=c0ee23ad2324c26661065de94f5b5676"></script>
-        <script>
-            require([
-                'echarts',
-                'https://fastly.jsdelivr.net/npm/echarts-extension-amap/dist/echarts-extension-amap.js'
-            ], function (echarts) {
-
-                var option = {
-                    amap: {
-                        viewMode: '3d',
-                        center: [115, 30],
-                        zoom: 5
-                    },
-                    tooltip: {},
-                    series: [
-                        {
-                            type: 'pie',
-                            name: 'AMap',
-                            coordinateSystem: 'amap',
-                            radius: 20,
-                            center: [120, 30],
-                            data: [
-                                { value: 1048, name: 'A' },
-                                { value: 735, name: 'B' },
-                                { value: 580, name: 'C' },
-                                { value: 484, name: 'D' },
-                                { value: 300, name: 'E' }
-                            ]
-                        },
-                        {
-                            type: 'pie',
-                            name: 'No CRS',
-                            // coordinateSystem: 'amap',
-                            radius: 20,
-                            center: [110, 36],
-                            data: [
-                                { value: 1048, name: 'A' },
-                                { value: 735, name: 'B' },
-                                { value: 580, name: 'C' },
-                                { value: 484, name: 'D' },
-                                { value: 300, name: 'E' }
-                            ]
-                        }
-                    ]
-                };
-
-                testHelper.create(echarts, 'main1', {
-                    title: ['Pie series on AMap'],
-                    option: option
-                })
-
-            });
-        </script>
+        <div id="main7"></div>
 
         <script>
             require([
@@ -205,7 +92,7 @@ under the License.
                     ]
                 };
 
-                testHelper.create(echarts, 'main2', {
+                testHelper.create(echarts, 'main1', {
                     title: ['Pie series on Calendar'],
                     option: option
                 })
@@ -238,11 +125,25 @@ under the License.
                                 { value: 484, name: 'D' },
                                 { value: 300, name: 'E' }
                             ]
+                        },
+                        {
+                            type: 'pie',
+                            name: 'Geo',
+                            coordinateSystem: 'geo',
+                            radius: 20,
+                            center: '北京',
+                            data: [
+                                { value: 1048, name: 'A' },
+                                { value: 735, name: 'B' },
+                                { value: 580, name: 'C' },
+                                { value: 484, name: 'D' },
+                                { value: 300, name: 'E' }
+                            ]
                         }
                     ]
                 };
 
-                testHelper.create(echarts, 'main3', {
+                testHelper.create(echarts, 'main2', {
                     title: ['Pie series on Geo Map'],
                     option: option
                 })
@@ -282,7 +183,7 @@ under the License.
                     ]
                 };
 
-                testHelper.create(echarts, 'main4', {
+                testHelper.create(echarts, 'main3', {
                     title: ['Pie series on Geo SVG'],
                     option: option
                 })
@@ -322,7 +223,7 @@ under the License.
                     ]
                 };
 
-                testHelper.create(echarts, 'main5', {
+                testHelper.create(echarts, 'main4', {
                     title: ['Pie series on Cartesian2D', 'Category Axes'],
                     option: option
                 })
@@ -370,12 +271,125 @@ under the License.
                     ]
                 };
 
-                testHelper.create(echarts, 'main6', {
+                testHelper.create(echarts, 'main5', {
                     title: ['Pie series on Cartesian2D', 'category axis & value axis (not perfectly supported)'],
                     option: option
                 })
             });
         </script>
 
+        <script src="https://api.map.baidu.com/api?v=2.0&ak=KOmVjPVUAey1G2E8zNhPiuQ6QiEmAwZu"></script>
+        <script>
+            require([
+                'echarts',
+                'extension/bmap'
+            ], function (echarts) {
+
+                var option = {
+                    bmap: {
+                        center: [115, 30],
+                        zoom: 5,
+                        roam: true,
+                    },
+                    tooltip: {},
+                    series: [
+                        {
+                            type: 'pie',
+                            name: 'BMap',
+                            coordinateSystem: 'bmap',
+                            radius: 20,
+                            center: [120, 30],
+                            data: [
+                                { value: 1048, name: 'A' },
+                                { value: 735, name: 'B' },
+                                { value: 580, name: 'C' },
+                                { value: 484, name: 'D' },
+                                { value: 300, name: 'E' }
+                            ]
+                        },
+                        {
+                            type: 'pie',
+                            name: 'No CRS',
+                            // coordinateSystem: 'bmap',
+                            radius: 20,
+                            center: [110, 36],
+                            data: [
+                                { value: 1048, name: 'A' },
+                                { value: 735, name: 'B' },
+                                { value: 580, name: 'C' },
+                                { value: 484, name: 'D' },
+                                { value: 300, name: 'E' }
+                            ]
+                        }
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main6', {
+                    title: ['Pie series on BMap'],
+                    option: option,
+                    buttons: [{
+                        text: 'Convert point [120, 30] to pixel',
+                        onclick: function () {
+                            alert(chart.convertToPixel('bmap', [120, 30]));
+                        }
+                    }]
+                });
+            });
+        </script>
+
+        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=c0ee23ad2324c26661065de94f5b5676"></script>
+        <script>
+            require([
+                'echarts',
+                'https://fastly.jsdelivr.net/npm/echarts-extension-amap/dist/echarts-extension-amap.js'
+            ], function (echarts) {
+
+                var option = {
+                    amap: {
+                        viewMode: '3d',
+                        center: [115, 30],
+                        zoom: 5
+                    },
+                    tooltip: {},
+                    series: [
+                        {
+                            type: 'pie',
+                            name: 'AMap',
+                            coordinateSystem: 'amap',
+                            radius: 20,
+                            center: [120, 30],
+                            data: [
+                                { value: 1048, name: 'A' },
+                                { value: 735, name: 'B' },
+                                { value: 580, name: 'C' },
+                                { value: 484, name: 'D' },
+                                { value: 300, name: 'E' }
+                            ]
+                        },
+                        {
+                            type: 'pie',
+                            name: 'No CRS',
+                            // coordinateSystem: 'amap',
+                            radius: 20,
+                            center: [110, 36],
+                            data: [
+                                { value: 1048, name: 'A' },
+                                { value: 735, name: 'B' },
+                                { value: 580, name: 'C' },
+                                { value: 484, name: 'D' },
+                                { value: 300, name: 'E' }
+                            ]
+                        }
+                    ]
+                };
+
+                testHelper.create(echarts, 'main7', {
+                    title: ['Pie series on AMap'],
+                    option: option
+                })
+
+            });
+        </script>
+
     </body>
 </html>


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