Skip to content

Commit

Permalink
Improve frontend handling of missing data
Browse files Browse the repository at this point in the history
After graph was updated with partial data (or none at all), it would
sometimes stop working even after new, complete data was given.
It doesn't seem to do that anymore.
  • Loading branch information
nmalkin committed Jun 29, 2012
1 parent ff00e25 commit 181851c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ function loadData(report, callback) {

getData(report.kpi, options, function(data) {
report.series = report.dataToSeries(data);

// If any series are empty, filter them out.
report.series = report.series.filter(function(series) {
return series.data.length > 0;
})

callback();
});
}
Expand Down Expand Up @@ -291,7 +297,12 @@ function updateGraph(report, newSeries) {

// Update the graph with the new series
report.graph.series = newSeries;
report.graph.update();
try {
report.graph.update();
} catch(e) { // Something bad happened while trying to update the graph.
// Draw a new graph
drawGraph(report, newSeries);
}
}

/**
Expand Down Expand Up @@ -326,7 +337,6 @@ function dateChanged(report) {
}

loadData(report, function() {
console.log(report.series);
updateGraph(report, report.series);
});
}
Expand Down Expand Up @@ -679,6 +689,8 @@ setupSegmentControls();
}
}

Rickshaw.Series.zeroFill(series);

return series;
};

Expand Down

0 comments on commit 181851c

Please sign in to comment.