使用echart版本: 4.2.0
Chrome版本: 74.0(32位)
相信与版本无关。
当数据为如下样子时, 会报下面的错误:
```
dataset: {
source: [
["value","8","9","10","11","12", '13', '14', '15', '16', '17', '18'],
[0.057,0,0,0,0,0,0,0,0,0,0,0],
[0.076,2,11,12,25,40,49,38,42,61,62,37],
[0.095,0,1,1,3,8,5,7,9,11,8,7],
[0.114,0,1,3,2,3,5,6,7,9,8,5],
]
}
```
报错信息:
TypeError: Cannot read property 'width' of undefined
查看源代码,报错位置如下:
```
// In case width or height are too small.
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
```
报错情况:
当数据系列小于等于5时,显示没有问题,大于5个就会出现上面的报错。系列大于五个时,系列名必须为字母开头的字符串才不会报错。
此问题也有其他人提交过,希望echarts开发团队尽快修复bug。
希望尽快得到得到官方的解释或者修复bug,谢谢。
配置项如下
option = {
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
dataset: {
source: [
["value","8","9","10","11","12", '13', '14', '15', '16', '17', '18'], // 将这一条的数字字符串前加个字母就不报错了
[0.057,0,0,0,0,0,0,0,0,0,0,0],
[0.076,2,11,12,25,40,49,38,42,61,62,37],
[0.095,0,1,1,3,8,5,7,9,11,8,7],
[0.114,0,1,3,2,3,5,6,7,9,8,5],
[0.133,0,0,0,1,3,4,7,7,4,3,5],
[0.152,0,0,1,1,2,3,3,5,5,6,2],
[0.171,0,0,0,2,1,2,4,8,2,4,1],
[0.19,1,1,0,0,1,2,1,5,7,2,4],
[0.209,1,0,0,0,1,4,2,3,2,4,0],
[0.228,0,0,2,0,1,0,1,3,4,0,2],
[0.247,0,0,0,0,1,0,0,2,3,0,1],
[0.266,1,0,0,0,0,0,1,2,0,2,6],
[0.285,0,0,1,1,1,0,2,3,0,1,2],
[0.304,0,0,0,0,0,0,1,1,3,2,1],
[0.323,0,0,0,0,0,0,0,3,1,1,0],
[0.342,0,0,0,0,0,0,2,3,0,1,0],
[0.361,0,0,1,0,0,0,0,0,2,0,0],
[0.38,0,0,0,0,0,0,0,0,1,1,1],
[0.399,0,0,0,0,0,1,0,2,2,0,2],
[0.418,0,0,0,0,0,0,0,0,0,0,1],
[0.437,0,0,0,1,1,0,0,1,2,0,0],
[0.456,0,0,0,0,1,0,0,1,1,0,0],
[0.475,0,0,0,0,0,0,0,0,2,0,0],
[0.494,0,0,0,0,0,1,0,1,0,0,0],
[0.513,0,1,0,0,0,0,0,0,0,2,0],
[0.532,0,0,0,0,1,1,0,0,1,0,0],
[0.551,0,0,1,0,0,0,0,0,1,1,0],
[0.57,0,0,0,0,0,0,0,0,1,0,1],
[0.589,0,0,0,0,0,0,0,0,1,0,0],
[0.608,0,0,0,0,0,0,0,0,1,0,0],
[0.627,0,0,0,0,0,0,1,0,0,0,0],
[0.665,0,0,0,0,0,2,0,0,0,0,0],
[0.684,0,0,0,0,0,0,0,0,0,0,1],
[0.703,0,0,1,0,1,0,0,0,0,1,0],
[0.722,0,0,0,0,0,1,0,0,1,0,0],
[0.741,0,0,1,0,0,0,1,0,1,0,0],
[0.76,0,1,0,0,0,0,0,0,1,0,0],
[0.779,0,0,0,0,0,1,0,0,0,0,0],
[0.836,0,0,0,0,1,0,0,0,0,0,0],
[0.893,0,0,0,0,0,0,0,0,0,0,1],
[0.95,0,1,0,0,0,0,0,0,0,0,0],
[0.969,0,0,0,0,0,0,0,0,1,0,0],
[0.988,0,0,0,0,0,0,0,0,0,0,1],
[1.007,0,0,0,0,0,1,0,0,0,2,0],
[1.045,0,0,0,0,0,0,0,0,1,0,0],
[1.064,0,0,0,0,0,1,0,0,0,0,0],
[1.102,0,0,0,0,0,0,0,0,0,0,1],
[1.121,0,0,0,0,0,1,0,0,0,0,0],
[1.197,0,0,0,0,0,0,1,0,0,0,0],
[1.235,0,0,0,1,0,0,0,0,0,0,0],
[1.254,0,0,0,0,1,0,0,0,0,0,0],
[1.52,0,0,1,0,0,0,0,0,0,0,0],
[1.558,0,0,0,0,0,1,0,0,0,0,0],
[1.672,0,0,0,0,0,0,1,0,0,0,0],
[1.729,0,0,0,0,0,0,0,0,0,1,0],
[1.767,0,0,0,0,1,0,0,0,0,0,0],
[1.919,0,0,1,0,0,0,0,0,0,0,0],
[1.995,0,0,0,1,0,0,0,0,0,0,0],
[2.071,0,0,0,0,1,0,0,0,0,0,0],
[2.299,0,0,0,0,0,0,0,0,1,0,0],
[2.622,0,0,0,0,0,0,0,0,0,1,0],
[3.154,0,0,0,0,0,1,0,1,0,0,0],
[3.496,0,0,0,0,1,1,0,0,1,0,0]
]
},
legend: {
type: 'scroll'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category'
}
],
yAxis : [
{
type : 'value'
}
],
series : Array(11).fill({
animation:false,
stack:1,
type:"bar"
})
};