Reputation: 167
I need to plot CSV file with dygraphs but my CSV files use comma as decimal separator.
Format is:
12,46;35,26;5,19
How can I change decimal separator from . to , in dygraphs?
Input file is given like this.
<script type="text/javascript">
g2 = new Dygraph(
document.getElementById("graphdiv2"),
"values.csv", // path to CSV file
{} // options
);
Upvotes: 0
Views: 333
Reputation: 11962
In order to translate the file content, a possible way is to :
This could be achieve with :
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(xmlhttp.status == 200 && xmlhttp.readyState == 4){
// got the file
var data = xmlhttp.responseText;
// modify content
var data = data.replace(/,/g, ".").replace(/;/g, "\n");
// create the graph with modified data
new Dygraph(document.getElementById("graphdiv2"),data);
}
};
xmlhttp.open("GET","values.csv",true);
xmlhttp.send();
Upvotes: 1