You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/05/17 10:06:22 UTC

[incubator-echarts] 01/02: Add test cases for pie label rotate.

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

sushuang pushed a commit to branch fix/fix-rotate-and-tooltip
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit bceb2dfbf912d1cca6779237fe8820e919f13ddd
Author: sushuang <su...@gmail.com>
AuthorDate: Fri May 17 18:03:46 2019 +0800

    Add test cases for pie label rotate.
---
 test/pie-label.html | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/test/pie-label.html b/test/pie-label.html
index 8df2a00..aee7aa8 100644
--- a/test/pie-label.html
+++ b/test/pie-label.html
@@ -42,6 +42,7 @@ under the License.
         <div id="main0"></div>
         <div id="main1"></div>
         <div id="main2"></div>
+        <div id="main3"></div>
 
 
         <script>
@@ -227,5 +228,89 @@ under the License.
 
 
 
+
+        <script>
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var count = 5;
+
+                function makeData(sign) {
+                    var data = [];
+                    for (var i = 0; i < count; i++) {
+                        var value = Math.random() * 50 * sign;
+                        value = +value.toFixed(2);
+
+                        if (i >= 2
+                            && i <= count - 2
+                            && i % 10 !== 0
+                            // Test the case that the bottom label is normal to display.
+                            && Math.abs(i - Math.round(count / 2)) > 2
+                        ) {
+                            value = sign > 0
+                                ? value - Math.floor(value)
+                                : value - Math.ceil(value);
+                            value = +value.toFixed(2);
+                        }
+
+                        data.push({
+                            name: value,
+                            value: value
+                        });
+                    }
+                    return data;
+                }
+
+                var pos = ['25%', '75%'];
+
+                var option = {
+                    title: [{
+                        text: 'label.rotate: true, label should be in redical direction.',
+                        textAlign: 'center',
+                        left: pos[0]
+                    }, {
+                        text: 'label.rotate: 20',
+                        textAlign: 'center',
+                        left: pos[1]
+                    }],
+                    series: [{
+                        type: 'pie',
+                        center: [pos[0], '50%'],
+                        minShowLabelAngle: 10,
+                        label: {
+                            show: true,
+                            rotate: true
+                        },
+                        labelLine: {
+                            length2: 0
+                        },
+                        radius: '30%',
+                        data: makeData(1)
+                    }, {
+                        type: 'pie',
+                        center: [pos[1], '50%'],
+                        minShowLabelAngle: 2,
+                        label: {
+                            show: true,
+                            rotate: 20
+                        },
+                        radius: '30%',
+                        data: makeData(-1)
+                    }]
+                };
+
+                var chart = testHelper.create(echarts, 'main3', {
+                    title: [
+                        'label should be rotated'
+                    ],
+                    option: option
+                });
+            });
+
+        </script>
+
+
     </body>
 </html>
\ No newline at end of file


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