Skip to content
Snippets Groups Projects
Commit 9fd261b7 authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

plots update when aliases change, fixed table alias update, #20

parent 3d81e30e
No related branches found
No related tags found
1 merge request!223Reports overhaul
...@@ -47,6 +47,25 @@ angular.module('reportApp') ...@@ -47,6 +47,25 @@ angular.module('reportApp')
PlotService.addPlot(scope.group, scope.id, scope.renderDivId); PlotService.addPlot(scope.group, scope.id, scope.renderDivId);
}); });
let plotTimer;
const updatePlot = () => {
clearTimeout(plotTimer);
const queueUpdate = () => {
let el = document.querySelector(`#${scope.renderDivId}`);
// if the container is rendered and it already has had a render,
// redo the render
if(el && el.childNodes.length > 0){
el.innerHTML = '';
PlotService.addPlot(scope.group, scope.id, scope.renderDivId);
}
};
plotTimer = setTimeout(queueUpdate, 1000);
};
// if the group has exps added/removed, rerender the plot // if the group has exps added/removed, rerender the plot
scope.$watch( scope.$watch(
// angular doesnt watch arrays properly (i.e. watching scope.group._experimentNames), // angular doesnt watch arrays properly (i.e. watching scope.group._experimentNames),
...@@ -55,15 +74,13 @@ angular.module('reportApp') ...@@ -55,15 +74,13 @@ angular.module('reportApp')
// because it compares shallowly and getters commonly return a new obj each time. // because it compares shallowly and getters commonly return a new obj each time.
// so, watch the getters length instead // so, watch the getters length instead
() => scope.group.experiments.length, () => scope.group.experiments.length,
(newExps, oldExps) => { updatePlot
let el = document.querySelector(`#${scope.renderDivId}`); );
// if the container is rendered and it already has had a render,
// redo the render // if the group has aliases changed, rerender the plot
if(el && el.childNodes.length > 0){ scope.$watch(
el.innerHTML = ''; () => JSON.stringify(scope.group._aliases),
PlotService.addPlot(scope.group, scope.id, scope.renderDivId); updatePlot
}
}
); );
scope.exportSrcFunc = () => () => { scope.exportSrcFunc = () => () => {
......
...@@ -72,12 +72,20 @@ angular.module('reportApp') ...@@ -72,12 +72,20 @@ angular.module('reportApp')
}; };
// gets the field val for the given exp // gets the field val for the given exp
scope.getFieldVal = (expName, field) => { scope.getFieldVal = (expName, field) => {
const alias = scope.group.aliases[expName].length > 0 ? scope.group.aliases[expName] : expName; const alias = scope.group.aliases[expName].length > 0 ?
scope.group.aliases[expName] : expName;
let fVal = scope.tableables[alias] ? const name = scope.tableables[alias] ?
scope.tableables[alias][field] : undefined; alias : expName;
let fVal = scope.tableables[name] ? scope.tableables[name][field] : undefined;
let val; let val;
console.log(expName);
console.log(alias);
console.log(scope.tableables);
console.log(fVal);
if(field === scope.fields[0]){ if(field === scope.fields[0]){
val = alias; val = alias;
} else if(!fVal){ } else if(!fVal){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment