在meteor中访问D3的csv文件 [英] Accessing a csv file with D3 inside meteor
问题描述
我已经成功地呈现了一个HTML表格,使用D3显示来自csv文件的数据,但是当我将相同的代码移动到meteor项目时,我遇到了问题。传递到d3.csv()的回调的数据对象每次检索HTML文件1行,而不是csv数据。
我的代码设置如下:
if(Meteor.isClient){
$ p $ <>
d3.csv(data / dataset.csv,function(data){
console.dir(data);
// do stuff
});
}
if(Meteor.isServer){
//做其他东西
}
解决方案Ashkat根据评论中的@ booyaa的请求评论:)
尝试将您的csv文件放在
public / data / data.csv
I had successfully rendered a HTML table displaying data from a csv file using D3, but when I moved the same code into a meteor project, I'm having problems. The data object being passed into the callback for d3.csv() is picking up the HTML file 1 line at a time instead of the csv data. This only happens when trying to run it in meteor.
My code is set up like this:
if (Meteor.isClient) { d3.csv("data/dataset.csv", function(data) { console.dir(data); // do stuff }); } if (Meteor.isServer) { // do other stuff }
Any ideas on why this might be happening?
解决方案(Simply copying Ashkat's comment as per @booyaa's request in comments:)
try placing your csv file in
public/data/data.csv
这篇关于在meteor中访问D3的csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!