Skip to content
Snippets Groups Projects
Verified Commit c872891a authored by David Hoese's avatar David Hoese
Browse files

Update and fix preview plots for data ordering

parent ba24af76
Branches
No related tags found
No related merge requests found
...@@ -291,8 +291,10 @@ var update_previews = function(){ ...@@ -291,8 +291,10 @@ var update_previews = function(){
if ($('#last_x_days').is(':checked')) { if ($('#last_x_days').is(':checked')) {
var timeRangeInfo = '-' + 24 * Number(val_or_place('#x_days')) + ':00:00'; var timeRangeInfo = '-' + 24 * Number(val_or_place('#x_days')) + ':00:00';
if(met)met.displayRecent(timeRangeInfo); if (met)
if(buoy)buoy.displayRecent(timeRangeInfo); met.displayRecent(timeRangeInfo);
if (buoy)
buoy.displayRecent(timeRangeInfo);
} else if ($('#date_range').is(':checked')) { } else if ($('#date_range').is(':checked')) {
var start = $('#Start-date-picker').val().split(' ').join('T')+':00'; var start = $('#Start-date-picker').val().split(' ').join('T')+':00';
var end = $('#End-date-picker').val().split(' ').join('T')+':00'; var end = $('#End-date-picker').val().split(' ').join('T')+':00';
... ...
......
...@@ -65,11 +65,13 @@ function API(div, controlDiv, plotsInfo) { ...@@ -65,11 +65,13 @@ function API(div, controlDiv, plotsInfo) {
myDispatcher.dispatch({status: ('hide' + varName), 'emit': 'checkboxEmitter','location':this.div}); myDispatcher.dispatch({status: ('hide' + varName), 'emit': 'checkboxEmitter','location':this.div});
}, },
displayRecent: function(start_time) { displayRecent: function(start_time, interval) {
// interval, if not provided, will be determined based on start time
myDispatcher.dispatch({ myDispatcher.dispatch({
'status': 'get_since_now', 'status': 'get_since_now',
'emit': 'plotEmitter', 'emit': 'plotEmitter',
'time': start_time, 'time': start_time,
'interval': interval
}); });
}, },
... ...
......
...@@ -81,6 +81,7 @@ function getDispatcher() { ...@@ -81,6 +81,7 @@ function getDispatcher() {
this.emit( this.emit(
action.status, action.status,
action.time, action.time,
action.interval,
this.plotsInfo, this.plotsInfo,
this.div); this.div);
}else if (action.status == 'update_table') { }else if (action.status == 'update_table') {
...@@ -178,9 +179,9 @@ function getDispatcher() { ...@@ -178,9 +179,9 @@ function getDispatcher() {
Plot.initPlot(div, plotOrder, plotsInfo); Plot.initPlot(div, plotOrder, plotsInfo);
}); });
plotEmitter.on("get_since_now",function(time, plotsInfo, div){ plotEmitter.on("get_since_now", function(time, interval, plotsInfo, div) {
var interval = dataAccess.requestPlotUpdate(div, plotsInfo, time, var interval = dataAccess.requestPlotUpdate(div, plotsInfo, time,
undefined, undefined, undefined, stopUpdate); undefined, interval, undefined, stopUpdate);
startUpdate(time, interval, plotsInfo); startUpdate(time, interval, plotsInfo);
}); });
... ...
......
...@@ -62,10 +62,11 @@ function plotting(url, var_names, plotsInfo, div, update, err_callback) { ...@@ -62,10 +62,11 @@ function plotting(url, var_names, plotsInfo, div, update, err_callback) {
console.info("No new data downloaded"); console.info("No new data downloaded");
return; return;
} else { } else {
dates = dates.slice(startIndex);
for (var i = 0; i < var_names.length; i++) { for (var i = 0; i < var_names.length; i++) {
dataObj[var_names[i]] = allData[var_names[i]].slice(startIndex); dataObj[var_names[i]] = allData[var_names[i]].slice(startIndex);
} }
dates = dates.slice(startIndex);
dataObj.dates = dates;
} }
} else { } else {
// replace the entire data array // replace the entire data array
... ...
......
...@@ -21,8 +21,9 @@ function replaceData(graphDiv, plotsInfo, dataObj, update) { ...@@ -21,8 +21,9 @@ function replaceData(graphDiv, plotsInfo, dataObj, update) {
var plotName; var plotName;
var plotInfo; var plotInfo;
var trace_anc_data; var trace_anc_data;
var ancHandled = []; // var ancHandled = [];
var plotHandled = []; var plotHandled = [];
var dataObjUpdated = [];
var updateChanges = { var updateChanges = {
x: [], x: [],
y: [], y: [],
...@@ -45,35 +46,44 @@ function replaceData(graphDiv, plotsInfo, dataObj, update) { ...@@ -45,35 +46,44 @@ function replaceData(graphDiv, plotsInfo, dataObj, update) {
// update the Z data instead of the traditional 'y' data // update the Z data instead of the traditional 'y' data
// assumes Y doesn't update between calls // assumes Y doesn't update between calls
_.each(elem.var_names, function (var_name, var_index) { _.each(elem.var_names, function (var_name, var_index) {
if (! dataObjUpdated.includes(var_name)) {
_.each(dataObj[var_name], function (data_elem) { _.each(dataObj[var_name], function (data_elem) {
graphDiv.data[traceIndex + index]['z'][var_index].shift(); graphDiv.data[traceIndex + index]['z'][var_index].shift();
graphDiv.data[traceIndex + index]['z'][var_index].push(data_elem); graphDiv.data[traceIndex + index]['z'][var_index].push(data_elem);
}); });
dataObj[var_name] = graphDiv.data[traceIndex + index]['z'][var_index]; dataObj[var_name] = graphDiv.data[traceIndex + index]['z'][var_index];
dataObjUpdated.push(var_name);
}
}); });
} else { } else {
// scatter plots, assume the y data is the data being updated // scatter plots, assume the y data is the data being updated
_.each(elem.var_names, function (var_name) { _.each(elem.var_names, function (var_name) {
if (! dataObjUpdated.includes(var_name)) {
_.each(dataObj[var_name], function (data_elem) { _.each(dataObj[var_name], function (data_elem) {
graphDiv.data[traceIndex + index]['y'].shift(); graphDiv.data[traceIndex + index]['y'].shift();
graphDiv.data[traceIndex + index]['y'].push(data_elem); graphDiv.data[traceIndex + index]['y'].push(data_elem);
}); });
// hold on to the array to create probe text // hold on to the array to create probe text
dataObj[var_name] = graphDiv.data[traceIndex + index]['y']; dataObj[var_name] = graphDiv.data[traceIndex + index]['y'];
dataObjUpdated.push(var_name);
}
}); });
trace_anc_data = graphDiv.data[traceIndex + index]['anc_data']; trace_anc_data = graphDiv.data[traceIndex + index]['anc_data'];
_.each(elem.anc_variables, function (anc_name, anc_index) { _.each(elem.anc_variables, function (anc_name, anc_index) {
if (ancHandled.includes(anc_name)) { // make sure we have any ancillary data updated
trace_anc_data[anc_index] = dataObj[anc_name]; // but don't write it to the graphDiv "cache", will
return; // do that in the next large block of code
} // yes, we are modifying this data in place, but we'll
// overwrite it later
if (! dataObjUpdated.includes(anc_name)) {
_.each(dataObj[anc_name], function (data_elem) { _.each(dataObj[anc_name], function (data_elem) {
trace_anc_data[anc_index].shift(); trace_anc_data[anc_index].shift();
trace_anc_data[anc_index].push(data_elem); trace_anc_data[anc_index].push(data_elem);
}); });
dataObj[anc_name] = graphDiv.data[traceIndex + index]['anc_data'][anc_index]; dataObj[anc_name] = graphDiv.data[traceIndex + index]['anc_data'][anc_index].slice();
ancHandled.push(anc_name); dataObjUpdated.push(anc_name);
}
}); });
} }
}); });
... ...
......
...@@ -82,11 +82,14 @@ var siteConfigs = { ...@@ -82,11 +82,14 @@ var siteConfigs = {
], ],
yaxis: { yaxis: {
title: 'Relative Humidity (%)', title: 'Relative Humidity (%)',
range: [-0.5, 100.5], range: [-0.5, 110.0], // a little above 100 to show the 100 line
tickvals: [0, 20, 40, 60, 80, 100],
ticktext: ['0', '20', '40', '60', '80', '100'],
convert_value: null, convert_value: null,
units: ' %', units: ' %',
precision: 2, precision: 1,
step: 5.0, step: 2.0,
zeroline: true,
}, },
}, },
wind_speed: { wind_speed: {
... ...
......
...@@ -170,7 +170,6 @@ ...@@ -170,7 +170,6 @@
</div> </div>
<div class="col-xs-12 form-group"> <div class="col-xs-12 form-group">
<button class="btn btn-primary" id="submit">Submit</button> <button class="btn btn-primary" id="submit">Submit</button>
<!--TODO: Fix preview implementation-->
<button class="btn btn-default" id="preview-btn">Show Preview</button> <button class="btn btn-default" id="preview-btn">Show Preview</button>
</div> </div>
</div> </div>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment