Commit c24b4c13 authored by Porter Libby's avatar Porter Libby
Browse files

fix graph loops caused by unsorted data

parent ec2eb84b
{ {
"name": "datavis", "name": "datavis",
"version": "0.1.12", "version": "0.1.13",
"description": "A tool for visualizing the data collected from the IFS Earlham trip", "description": "A tool for visualizing the data collected from the IFS Earlham trip",
"main": "datavis.js", "main": "datavis.js",
"scripts": { "scripts": {
......
...@@ -243,14 +243,19 @@ function addData(chart,times,data,types,color,title) { ...@@ -243,14 +243,19 @@ function addData(chart,times,data,types,color,title) {
chart.data.labels = times; chart.data.labels = times;
for (x = 0;x<data.length;x++){ // create plot for each set of data [elevation,pressure,etc...] for (x = 0;x<data.length;x++){ // create plot for each set of data [elevation,pressure,etc...]
var newdata = data[x].sort((a, b) => {
return moment(a.x).diff(b.x);
});
var dataset = { var dataset = {
label: types[x], label: types[x],
borderColor: getRandomColor(), // choose random color for now borderColor: getRandomColor(), // choose random color for now
borderWidth: 3, borderWidth: 3,
fill: false, fill: false,
data: data[x], data: newdata,
} }
chart.data.datasets.push(dataset); chart.data.datasets.push(dataset);
console.log(data[x][0]["x"])
} }
chart.update(); chart.update();
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment