提交 100d79ea 编写于 作者: L lang

Null data in line chart

上级 a0c3f5ff
......@@ -174,14 +174,16 @@ define(function (require) {
.execute();
// Update common properties
var itemStyleAccessPath = ['itemStyle', 'normal'];
data.eachItemGraphicEl(function (el, idx) {
var itemModel = data.getItemModel(idx);
var labelModel = itemModel.getModel('itemStyle.normal.label');
var normalItemStyleModel = itemModel.getModel(itemStyleAccessPath);
var labelModel = normalItemStyleModel.getModel('label');
var color = data.getItemVisual(idx, 'color');
zrUtil.extend(
el.style,
itemModel.getModel('itemStyle.normal').getItemStyle(['color'])
normalItemStyleModel.getItemStyle(['color'])
);
if (labelModel.get('show')) {
......
define(function(require) {
'use strict';
var smoothBezier = require('zrender/graphic/helper/smoothBezier');
return require('zrender/graphic/Path').extend({
type: 'ec-area',
shape: {
points: [],
// Offset between stacked base points and points
stackedOnPoints: []
},
buildPath: function (ctx, shape) {
var points = shape.points;
var stackedOnPoints = shape.stackedOnPoints;
var i = 0;
var len = points.length;
while (i < len) {
for (var k = i; k < len; k++) {
var p = points[k];
if (p == null || isNaN(p[0]) || isNaN(p[1])) {
break;
}
ctx[k === i ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
var tmp = k;
for (k--; k >= i; k--) {
var p = stackedOnPoints[k];
ctx.lineTo(p[0], p[1]);
}
i = tmp + 1;
}
}
});
});
\ No newline at end of file
......@@ -9,7 +9,8 @@ define(function(require) {
var DataSymbol = require('../helper/DataSymbol');
var lineAnimationDiff = require('./lineAnimationDiff');
var graphic = require('../../util/graphic');
var AreaPath = require('./Area');
var polyHelper = require('./poly');
function isPointsSame(points1, points2) {
if (points1.length !== points2.length) {
......@@ -193,7 +194,7 @@ define(function(require) {
group.remove(polyline);
}
polyline = new graphic.Polyline({
polyline = new polyHelper.Polyline({
shape: {
points: points
},
......@@ -226,7 +227,7 @@ define(function(require) {
group.remove(polygon);
}
polygon = new AreaPath({
polygon = new polyHelper.Polygon({
shape: {
points: points,
stackedOnPoints: stackedOnPoints
......
// Poly path support NaN point
define(function (require) {
var smoothBezier = require('zrender/graphic/helper/smoothBezier');
var Path = require('zrender/graphic/Path');
return {
Polyline: Path.extend({
type: 'ec-polyline',
shape: {
points: []
},
style: {
fill: null,
stroke: '#000'
},
buildPath: function (ctx, shape) {
var points = shape.points;
var i = 0;
var len = points.length;
while (i < len) {
for (var k = i; k < len; k++) {
var p = points[k];
if (p == null || isNaN(p[0]) || isNaN(p[1])) {
break;
}
ctx[k === i ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
i = k + 1;
}
}
}),
Polygon: Path.extend({
type: 'ec-polygon',
shape: {
points: [],
// Offset between stacked base points and points
stackedOnPoints: []
},
buildPath: function (ctx, shape) {
var points = shape.points;
var stackedOnPoints = shape.stackedOnPoints;
var i = 0;
var len = points.length;
while (i < len) {
for (var k = i; k < len; k++) {
var p = points[k];
if (p == null || isNaN(p[0]) || isNaN(p[1])) {
break;
}
ctx[k === i ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
var tmp = k;
for (k--; k >= i; k--) {
var p = stackedOnPoints[k];
ctx.lineTo(p[0], p[1]);
}
i = tmp + 1;
}
}
})
};
});
\ No newline at end of file
......@@ -195,6 +195,9 @@ define(function (require) {
var tempValue = [];
var rawValueTo1D = false;
var value1D = dimensions.length === 1;
// Use the first data to indicate data type;
var isValueArray = zrUtil.isArray(data[0]);
for (var idx = 0; idx < data.length; idx++) {
var value = data[idx];
// Each data item contains value and option
......@@ -212,7 +215,7 @@ define(function (require) {
// Bar chart, line chart which uses category axis
// only gives the 'y' value. 'x' value is the indices of cateogry
// Use a tempValue to normalize the value to be a (x, y) value
if (!isNaN(value)) {
if (!isValueArray) {
if (!value1D) {
tempValue[0] = idx;
tempValue[1] = value;
......
......@@ -7,10 +7,16 @@ define(function (require) {
var dims = coordSys.dimensions;
data.each(dims, function (x, y, idx) {
var point;
if (!isNaN(y) && !isNaN(x)) {
var point = coordSys.dataToPoint([x, y]);
data.setItemLayout(idx, point);
point = coordSys.dataToPoint([x, y]);
}
else {
// Also {Array.<number>}, not undefined to avoid if...else... statement
point = [NaN, NaN];
}
data.setItemLayout(idx, point);
}, true);
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册