Reputation:
I have 5 csv files 1.csv,2.csv.. 5.csv. What I am doing is I have a dropdown list. When I select a particular option from the dropdown list a particular file will be loaded and visualized. The data in the files are changing regularly. But the problem is when I select a particular file the data is somehow stored may be in cache. So no change in the file later is taken. Even if I remove the file from the directory the visualization is shown with data loaded first time. I even tried with refreshing the page. My code is following:
selector.on("change", function(d){
var selectedKey = keys[this.selectedIndex];
d3.csv(selectedKey +".csv", function(data){
console.log(selectedKey +".txt");
//var format = d3.time.format("%m/%d/%Y %H:%M:%S");
var format = d3.time.format("%Y/%m/%d %H:%M:%S");
data.forEach(function (e){
e.dist = +e.dist;
e.speed = +e.speed;
e.lat=+e.lat;
e.lon=+e.lon;
e.dd=format.parse(e.time);
//console.log(e.dd);
});
dataset=data;
var ndx = crossfilter(data);
dimx = ndx.dimension(function(d) {return d.bearing});
g = dimx.group(function(v){return v;});
var output = g.top(Infinity);
}
});
Can anyone help me to find the problem? After selecting 2.csv the chart is first time shown fine. Then when I change data in 2.csv the visualization is shown with previous data. Even I delete 2.csv file from the directory the visualizations are shown with previous data. This happens even after refreshing the page and reselecting the key also
Upvotes: 3
Views: 1673
Reputation: 84
The issue might be browser caching. Try clearing cache or opening the link in an incognito window.
Upvotes: -1
Reputation: 1
This is the question I've been searching an answer for. I have csv data that d3 displays on a table. The csv file is continuously being updated but the old data still displays until I refresh the page. I hope this d3.csv(selectedKey +".csv"+'?' + Math.floor(Math.random() * 1000), function(data){}
will work. Though, mine will be this something like this d3.csv( "csvfile.csv"+'?' + Math.floor(Math.random() * 1000).then( function(data){})
Upvotes: -1
Reputation:
d3.csv(selectedKey +".csv"+'?' + Math.floor(Math.random() * 1000), function(data){}
Will solve the problem
Upvotes: 2