aboutsummaryrefslogtreecommitdiff
path: root/app/static/js
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-06-10 14:34:48 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-06-10 14:34:48 +0100
commit3a2404010f8c0fdb3a9e9940202f59b84cb2791f (patch)
tree3de6bfe5db4bf623e38d335899a715d3e8c65c76 /app/static/js
parentUse tojson instead of safe (diff)
downloadAnnotateChange-3a2404010f8c0fdb3a9e9940202f59b84cb2791f.tar.gz
AnnotateChange-3a2404010f8c0fdb3a9e9940202f59b84cb2791f.zip
Validate data according to a schema
It became clear that a formal schema would make it easier to validate data. This is now added and the code is updated to work with this schema.
Diffstat (limited to 'app/static/js')
-rw-r--r--app/static/js/makeChart.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/static/js/makeChart.js b/app/static/js/makeChart.js
index 85d743b..1a0283d 100644
--- a/app/static/js/makeChart.js
+++ b/app/static/js/makeChart.js
@@ -3,10 +3,12 @@
function preprocessData(data) {
var n = 0;
- data.forEach(function(d) {
- d.X = n++;
- d.Y = d.value;
- });
+ cleanData = [];
+ for (i=0; i<data.values[0].raw.length; i++) {
+ d = data.values[0].raw[i];
+ cleanData.push({"X": n++, "Y": d});
+ }
+ return cleanData;
}
function scaleAndAxis(data, width, height) {
@@ -50,7 +52,7 @@ function noZoom() {
function baseChart(selector, data, clickFunction, annotations, annotationFunction) {
// preprocess the data
- preprocessData(data);
+ data = preprocessData(data);
var divWidth = 1000;
var divHeight = 480;