You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by yu...@apache.org on 2021/01/07 11:07:58 UTC

[incubator-echarts] branch fix-13892 created (now c50c8c4)

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

yufeng04 pushed a change to branch fix-13892
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


      at c50c8c4  fix(loading): showLoading aligin center

This branch includes the following new commits:

     new c50c8c4  fix(loading): showLoading aligin center

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


[incubator-echarts] 01/01: fix(loading): showLoading aligin center

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

yufeng04 pushed a commit to branch fix-13892
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit c50c8c4d040a220debe9c068e621aa5166108407
Author: yufeng04 <74...@qq.com>
AuthorDate: Thu Jan 7 19:05:31 2021 +0800

    fix(loading): showLoading aligin center
---
 src/loading/default.ts | 10 +++++++---
 test/loading.html      | 26 ++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/loading/default.ts b/src/loading/default.ts
index c267e17..43e6ead 100644
--- a/src/loading/default.ts
+++ b/src/loading/default.ts
@@ -51,7 +51,7 @@ export default function defaultLoading(
     zrUtil.defaults(opts, {
         text: 'loading',
         textColor: '#000',
-        fontSize: '12px',
+        fontSize: 12,
         maskColor: 'rgba(255, 255, 255, 0.8)',
         showSpinner: true,
         color: '#5470c6',
@@ -68,7 +68,8 @@ export default function defaultLoading(
         z: 10000
     });
     group.add(mask);
-    const font = opts.fontSize + ' sans-serif';
+
+    const font = `${parseInt(opts.fontSize + '', 10)}px sans-serif`;
     const labelRect = new graphic.Rect({
         style: {
             fill: 'none'
@@ -127,8 +128,11 @@ export default function defaultLoading(
         // cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2
         // textDistance needs to be calculated when both animation and text exist
         const cx = (api.getWidth() - r * 2 - (opts.showSpinner && textWidth ? 10 : 0) - textWidth) / 2
+            - (opts.showSpinner && textWidth ? 0 : 5 + textWidth / 2)
             // only show the text
-            - (opts.showSpinner ? 0 : textWidth / 2);
+            + (opts.showSpinner ? 0 : textWidth / 2)
+            // only show the spinner
+            + (textWidth ? 0 : r);
         const cy = api.getHeight() / 2;
         opts.showSpinner && arc.setShape({
             cx: cx,
diff --git a/test/loading.html b/test/loading.html
index 8d029b5..a68cfe0 100644
--- a/test/loading.html
+++ b/test/loading.html
@@ -46,6 +46,8 @@ under the License.
         <div class="chart" id="main2"></div>
         <h1>fontSzie: 25px, arcRadius: 12, lineWidth: 8</h1>
         <div class="chart" id="main3"></div>
+        <h1>fontSzie: 25, arcRadius: 12, lineWidth: 8</h1>
+        <div class="chart" id="main4"></div>
         <script>
 
             require([
@@ -57,21 +59,36 @@ under the License.
 
                 var chart1 = echarts.init(document.getElementById('main1'));
                 chart1.showLoading({
-                    text: ''
+                    text: '',
+                    spinnerRadius: 50
                 });
 
                 var chart2 = echarts.init(document.getElementById('main2'));
                 chart2.showLoading({
-                    showAnimation: false
+                    text: '没有 spinner 时,文字需要居中显示',
+                    textColor: '#000',
+                    fontSize: 20,
+                    showSpinner: false
                 });
                 var chart3 = echarts.init(document.getElementById('main3'));
                 chart3.showLoading({
-                    text: '暂无数据',
+                    text: '暂时没有数据',
                     textColor: '#000',
                     fontSize: '25px',
                     maskColor: 'rgba(255, 255, 255, 0.8)',
                     color: '#c23531',
-                    arcRadius: 12,
+                    arcRadius: 20,
+                    lineWidth: 8,
+                    zlevel: 0
+                });
+                var chart4 = echarts.init(document.getElementById('main4'));
+                chart4.showLoading({
+                    text: '暂时没有数据',
+                    textColor: '#000',
+                    fontSize: 25,
+                    maskColor: 'rgba(255, 255, 255, 0.8)',
+                    color: '#c23531',
+                    arcRadius: 20,
                     lineWidth: 8,
                     zlevel: 0
                 });
@@ -80,6 +97,7 @@ under the License.
                     chart1.resize();
                     chart2.resize();
                     chart3.resize();
+                    chart4.resize();
                 };
             });
         </script>


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