diff --git a/src/chart/radar/RadarView.js b/src/chart/radar/RadarView.js index ffc9994b80dfe734162d46aae499f7175c6264f4..ac9c7d9895c8557fa6be21c09146042d9f3a9fb7 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 4185d4ee2a8f1ff3647516975161488aae102c6c..0092f498485d09102d971da6d1007da73257ec95 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 e68fad39281da3fa415e04e6226d3803043be0c2..4ab8f19e30fa14898adba598b3f7616ca5556b84 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],