我想两个或多个CSV数据使用不同的代码天,但与D3.js上面只拿到第一张图data.How能做到这一点URL Http请求结合? ,我做错了什么?:两个CSV HTTP URL数据D3
d3.csv("https://website.com/entry.csv?start=2015-11-30%2020:30:00&end=2015-12-01%2008:30:00",
function (error, data) {
data.forEach(function (d) {
d.date = (d.created_at);
d.value = +d.field1;
});
d3.csv("https://website.com/entry.csv?start=2015-12-01%2020:30:00&end=2015-12-02%2008:30:00",
function (error, data1) {
data1.forEach(function (d) {
d.date1 = (d.created_at);
d.value1 = +d.field1;
});
//How to edit this line to avoid chart the two csv url data? x.domain((data).map(function (d) { return (d.date); }));
y.domain([0, d3.max(data, function (d) { return d.value; })]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.9em")
.attr("dy", "-.55em")
.attr("transform", "rotate(-90)");
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Nº Personas");
//Or edit the next part of code to avoid chart the two csv data?
svg.selectAll("bar")
.data(data)
.enter().append("rect")
.style("fill", "steelblue")
.attr("x", function (d) { return x(d.date); })
.attr("width", 14)
.attr("y", function (d) { return y(d.value); })
.attr("height", function (d) { return height - y(d.value); });
});
});
在此先感谢。
谢谢您的答复。我已经使用了你的解决方案,它效果很好。为了得到像这样的内容:[http://robslink.com/SAS/democd6/col5.htm],我如何更改第二个csv url数据中的颜色? – user19566