[Example] Add units to MSL example. Recreates functionality from the old live demo

This commit is contained in:
Henry
2017-04-27 19:02:35 -07:00
parent 1d7d963a4f
commit 69b06364eb
2 changed files with 20 additions and 10 deletions

View File

@ -48,6 +48,13 @@ define(
this.$http = $http;
this.$log = $log;
this.promise = undefined;
this.dataTransforms = {
//Convert from pascals to millibars
'pressure': function pascalsToMillibars(pascals) {
return pascals / 100;
}
};
}
/**
@ -65,6 +72,8 @@ define(
var self = this,
id = request.key;
var dataTransforms = this.dataTransforms;
function processResponse(response){
var data = [];
/*
@ -75,13 +84,14 @@ define(
* Check that valid data exists
*/
if (!isNaN(solData[id])) {
var dataTransform = dataTransforms[id];
/*
* Append each data point to the array of values
* for this data point property (min. temp, etc).
*/
data.unshift({
date: Date.parse(solData[TERRESTRIAL_DATE]),
value: solData[id]
value: dataTransform ? dataTransform(solData[id]) : solData[id]
});
}
});