[英]bars not showing in bar chart
I am modifying this chart sample to go with my sample data. 我正在修改此图表样本以与样本数据一起使用。
I removed the functions generating random data and have put my hardcoded sample data. 我删除了生成随机数据的函数,并放置了我的硬编码示例数据。 Now, everything is showing up, but not the bars.
现在,一切都显示出来了,但是条形图却没有。
I am getting several errors that are of the same type: 我收到几个相同类型的错误:
Invalid value for <rect> attribute height="NaN"
and 和
Invalid value for <rect> attribute y="NaN"
I believe the input values are numbers, still I am getting these errors. 我相信输入值是数字,但仍然出现这些错误。
What am I missing? 我想念什么?
Your data is in an incorrect format. 您的数据格式不正确。 The pairs should be objects with
x
and y
properties, not arrays. 这些对应该是具有
x
和y
属性的对象,而不是数组。
This should do it: 应该这样做:
data.forEach(function(datum){
datum.values = datum.values.map(function(el){
return {x:el[0], y:el[1]}
});
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.