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/01/03 22:40:09 UTC

[incubator-echarts] branch master updated: Fix radar line disappear on hover when there is empty value in data.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e12e991  Fix radar line disappear on hover when there is empty value in data.
e12e991 is described below

commit e12e9912d2d79b70343c5e7ae701b49befa2def6
Author: sushuang <su...@gmail.com>
AuthorDate: Fri Jan 4 06:39:44 2019 +0800

    Fix radar line disappear on hover when there is empty value in data.
---
 src/chart/radar/RadarView.js   |  6 +++++-
 src/chart/radar/radarLayout.js | 18 +++++++++++++++---
 test/radar.html                |  4 ++--
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/chart/radar/RadarView.js b/src/chart/radar/RadarView.js
index ffc9994..ac9c7d9 100644
--- a/src/chart/radar/RadarView.js
+++ b/src/chart/radar/RadarView.js
@@ -103,6 +103,7 @@ export default echarts.extendChartView({
                         points: points
                     }
                 };
+
                 polygon.shape.points = getInitialPoints(points);
                 polyline.shape.points = getInitialPoints(points);
                 graphic.initProps(polygon, target, seriesModel, idx);
@@ -130,6 +131,7 @@ export default echarts.extendChartView({
                         points: data.getItemLayout(newIdx)
                     }
                 };
+
                 if (!target.shape.points) {
                     return;
                 }
@@ -193,6 +195,8 @@ export default echarts.extendChartView({
             symbolGroup.eachChild(function (symbolPath) {
                 symbolPath.setStyle(itemStyle);
                 symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
+                var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
+                (defaultText == null || isNaN(defaultText)) && (defaultText = '');
 
                 graphic.setLabelStyle(
                     symbolPath.style, symbolPath.hoverStyle, labelModel, labelHoverModel,
@@ -200,7 +204,7 @@ export default echarts.extendChartView({
                         labelFetcher: data.hostModel,
                         labelDataIndex: idx,
                         labelDimIndex: symbolPath.__dimIdx,
-                        defaultText: data.get(data.dimensions[symbolPath.__dimIdx], idx),
+                        defaultText: defaultText,
                         autoColor: color,
                         isRectText: true
                     }
diff --git a/src/chart/radar/radarLayout.js b/src/chart/radar/radarLayout.js
index 4185d4e..0092f49 100644
--- a/src/chart/radar/radarLayout.js
+++ b/src/chart/radar/radarLayout.js
@@ -33,7 +33,9 @@ export default function (ecModel) {
         zrUtil.each(axes, function (axis, axisIndex) {
             data.each(data.mapDimension(axes[axisIndex].dim), function (val, dataIndex) {
                 points[dataIndex] = points[dataIndex] || [];
-                points[dataIndex][axisIndex] = coordSys.dataToPoint(val, axisIndex);
+                var point = coordSys.dataToPoint(val, axisIndex);
+                points[dataIndex][axisIndex] = isValidPoint(point)
+                    ? point : getValueMissingPoint(coordSys);
             });
         });
 
@@ -43,12 +45,22 @@ export default function (ecModel) {
             // Is it appropriate to connect to the next data when some data is missing?
             // Or, should trade it like `connectNull` in line chart?
             var firstPoint = zrUtil.find(points[idx], function (point) {
-                return !isNaN(point[0]) && !isNaN(point[1]);
-            }) || [NaN, NaN];
+                return isValidPoint(point);
+            }) || getValueMissingPoint(coordSys);
 
             // Copy the first actual point to the end of the array
             points[idx].push(firstPoint.slice());
             data.setItemLayout(idx, points[idx]);
         });
     });
+}
+
+function isValidPoint(point) {
+    return !isNaN(point[0]) && !isNaN(point[1]);
+}
+
+function getValueMissingPoint(coordSys) {
+    // It is error-prone to input [NaN, NaN] into polygon, polygon.
+    // (probably cause problem when refreshing or animating)
+    return [coordSys.cx, coordSys.cy];
 }
\ No newline at end of file
diff --git a/test/radar.html b/test/radar.html
index e68fad3..4ab8f19 100644
--- a/test/radar.html
+++ b/test/radar.html
@@ -49,7 +49,7 @@ under the License.
                     },
                     tooltip: {},
                     legend: {
-                        data: ['预算分配(Allocated Budget)', '实际开销(Actual Spending)', '第一个元素是 null']
+                        data: ['预算分配(Allocated Budget)', '实际开销(Actual Spending)含有 "-" 数据', '第一个元素是 null']
                     },
                     radar: {
                         radius: [50, '70%'],
@@ -84,7 +84,7 @@ under the License.
                             },
                              {
                                 value : [50, 14000, 28000, 31000, '-', 21000],
-                                name : '实际开销(Actual Spending)'
+                                name : '实际开销(Actual Spending)含有 "-" 数据'
                             },
                             {
                                 value: ['-', 8000, 20000, 20000, 40000, 10000],


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