0
上没有数据,我在D3.js非常新的,有这个简单的代码,See jsbin output here解析的第一附加D3元素
var data = [
{country: 'Kenya', performance_rate: 5},
{country: 'Uganda', performance_rate: 5},
{country: 'Rwanda', performance_rate: 2},
{country: 'S.Sudan', performance_rate: 1}
];
var chartBody = d3.select('body').append('h1').text('Progress by country');
var chart = d3.selectAll('p');
chart.data(data).enter().append('span')
.classed('bar',true).style('width', function(d){
rate = (d.performance_rate *100)/5;
return rate+'%';}).text(function(d){
return d.country;
});
我试图创建数据集一个简单的柱状图。我的问题是,数据集中的第一项(即{ country: Kenya, performance_rate: 5}
)未在输出中传递。
如何确保我所有的数据集项目都能正确呈现。
感谢Gilsha。我已经看到你在那里做了什么。很棒。 –
很高兴帮助:) – Gilsha
不同的事情,但是,你如何附加上面的代码,我可以运行它。我的意思是“> Run code snippet”和底部的其他按钮。我想在将来做这样的事情。什么是工具?再次感谢。 –