d3.csv("result.csv", function(flights) { var nestbydate = d3.nest() .key(function(d) { return d3.time.day(d.date); }); .......... when trying run above d3.js code web server executes d3.js loading csv file.
but when trying run d3.js shown below,
d3.csv("d:\\project space\\d3demo\\webcontent\\result.csv", function(flights) { var nestbydate = d3.nest() .key(function(d) { return d3.time.day(d.date); }); .......... then shows following error:
xmlhttprequest cannot load file:///d:/project%20space/d3demo/webcontent/result.csv. cross origin requests supported http`
how solve problem ?
there no way solve problem using d3's convenience functions.
d3.csv fundamentally ajax request , beholden same-origin policy.
when load file location, browser realizes requested file not exist on same domain (likely localhost in case) , prevents request completing.
a simple way around serve content on localhost or whatever using.
alternatively can in cross-origin resource sharing, or better compatibility: jsonp. in both of these cases have roll own function convert csv data javascript array.
Comments
Post a Comment