You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/10/22 03:58:29 UTC

[incubator-echarts] branch next updated: fix(gauge): disable value animation by default because of precision issue in formatter.

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

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


The following commit(s) were added to refs/heads/next by this push:
     new 21638cd  fix(gauge): disable value animation by default because of precision issue in formatter.
21638cd is described below

commit 21638cd77c1614934349554b3f3081f59d419504
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Oct 22 11:47:07 2020 +0800

    fix(gauge): disable value animation by default because of precision issue in formatter.
---
 src/chart/gauge/GaugeSeries.ts |  4 +-
 src/chart/gauge/GaugeView.ts   |  3 +-
 test/gauge-simple.html         | 98 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/src/chart/gauge/GaugeSeries.ts b/src/chart/gauge/GaugeSeries.ts
index cca18ef..f3fbee7 100644
--- a/src/chart/gauge/GaugeSeries.ts
+++ b/src/chart/gauge/GaugeSeries.ts
@@ -284,7 +284,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
             // 其余属性默认使用全局文本样式,详见TEXTSTYLE
             color: '#464646',
             fontSize: 16,
-            valueAnimation: true
+            valueAnimation: false
         },
         detail: {
             show: true,
@@ -302,7 +302,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
             fontSize: 30,
             fontWeight: 'bold',
             lineHeight: 30,
-            valueAnimation: true
+            valueAnimation: false
         }
     };
 }
diff --git a/src/chart/gauge/GaugeView.ts b/src/chart/gauge/GaugeView.ts
index 00603a0..0560361 100644
--- a/src/chart/gauge/GaugeView.ts
+++ b/src/chart/gauge/GaugeView.ts
@@ -30,7 +30,6 @@ import { ColorString, ECElement, ParsedValue } from '../../util/types';
 import List from '../../data/List';
 import Sausage from '../../util/shape/sausage';
 import {createSymbol} from '../../util/symbol';
-import { labeledStatement } from '@babel/types';
 
 interface PosInfo {
     cx: number
@@ -615,7 +614,7 @@ class GaugeView extends ChartView {
                     }, {inheritColor: detailColor})
                 });
                 setLabelValueAnimation(
-                    labelEl, {normal: itemTitleModel}, seriesModel.getRawValue(idx) as ParsedValue,
+                    labelEl, {normal: itemDetailModel}, seriesModel.getRawValue(idx) as ParsedValue,
                     (value: number) => formatLabel(value, formatter)
                 );
                 hasAnimation && animateLabelValue(labelEl, idx, data, seriesModel);
diff --git a/test/gauge-simple.html b/test/gauge-simple.html
index 1fb46f4..140d115 100644
--- a/test/gauge-simple.html
+++ b/test/gauge-simple.html
@@ -45,6 +45,8 @@ under the License.
 
     <div id="main2"></div>
 
+    <div id="main3"></div>
+
 
 
 
@@ -63,7 +65,7 @@ under the License.
                     {
                         name: 'Pressure',
                         type: 'gauge',
-                        detail: {formatter: '{value}%'},
+                        detail: {formatter: '{value}%', valueAnimation: true},
                         data: [{value: 50, name: 'score'}]
                     }
                 ]
@@ -154,6 +156,100 @@ under the License.
         });
     </script>
 
+    <script>
+        require(['echarts'], function (echarts) {
+            var option = {
+                tooltip: {
+                    formatter: '{a} <br/>{b} : {c}%'
+                },
+                toolbox: {
+                    feature: {
+                        restore: {},
+                        saveAsImage: {}
+                    }
+                },
+                series: [{
+                    name: '学生成绩',
+                    type: 'gauge',
+                    startAngle: 180,
+                    endAngle: 0,
+                    min: 0,
+                    max: 1,
+                    splitNumber: 8,
+                    axisLine: {
+                        lineStyle: {
+                            width: 5,
+                            color: [
+                                [0.25, '#FF6E76'],
+                                [0.5, '#FDDD60'],
+                                [0.75, '#58D9F9'],
+                                [1, '#7CFFB2'],
+                            ]
+                        }
+                    },
+                    pointer: {
+                        length: '80%',
+                        itemStyle: {
+                            color: 'auto'
+                        }
+                    },
+                    axisTick: {
+                        length: 15,
+                        lineStyle: {
+                            color: 'auto'
+                        }
+                    },
+                    splitLine: {
+                        length: 20,
+                        lineStyle: {
+                            color: 'auto',
+                            width: 5
+                        }
+                    },
+                    axisLabel: {
+                        color: '#464646',
+                        fontSize: 20,
+                        distance: -60,
+                        formatter: function(value) {
+                            if (value === 0.875) {
+                                return '优'
+                            } else if (value === 0.625) {
+                                return '中'
+                            } else if (value === 0.375) {
+                                return '良'
+                            } else if (value === 0.125) {
+                                return '差'
+                            }
+                        }
+                    },
+                    title: {
+                        offsetCenter: [0, '-50%'],
+                        fontSize: 40
+                    },
+                    detail: {
+                        valueAnimation: true,
+                        fontSize: 50,
+                        offsetCenter: [0, '-30%'],
+                        formatter: function(value) {
+                            return Math.round(value * 100) + '%';
+                        },
+                        color: 'auto'
+                    },
+                    data: [{
+                        value: 0.75,
+                        name: '成绩评定'
+                    }]
+                }]
+            };
+
+            var chart = testHelper.create(echarts, 'main3', {
+                title: [
+                    'Value animation should be enabled'
+                ],
+                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