Skip to content

Commit

Permalink
Fix #6642: ckp
Browse files Browse the repository at this point in the history
  • Loading branch information
git-user committed Jan 29, 2024
1 parent d83b8bc commit d14f4e4
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions sirepo/package_data/static/js/sirepo-plotting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3891,7 +3891,16 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
});
};

$scope._labels = (plots) => {
var res = [];
for (var plot of plots) {
res.push(plot.label);
}
return res;
}

$scope.load = function(json) {
srdbg('loading');
if (! json.plots && ! json.points) {
//TODO(pjm): plot may be loaded with { state: 'canceled' }?
return;
Expand Down Expand Up @@ -4093,34 +4102,43 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
}
});

function _labels(plots) {
var res = [];
for (var plot of plots) {
res.push(plot.label);
}
return res;
}

function handlePlotSelection() {
const currentSelection = _labels(plots);
srdbg('handling selection');
const currentSelection = $scope._labels(plots);
const previousSelection = appState.models[$scope.modelName + 'SelectedPlots'] || currentSelection;
srdbg(currentSelection, previousSelection);
if (JSON.stringify(currentSelection) != JSON.stringify(previousSelection)) {
plots.forEach((plot, i) => {
plotVisibility[$scope.modelName][i] = false;
});
appState.models[$scope.modelName + 'SelectedPlots'] = currentSelection;
appState.saveChanges($scope.modelName);
}
}

handlePlotSelection();
$scope.$on(
$scope.modelName + '.changed',
() => {
appState.models[$scope.modelName + 'SelectedPlots'] = _labels(plots);
}
);
// $scope.$on(
// // TODO (gurhar123): Looks like we call the all the previously defined listeners
// // when we trigger this from the saveChanges. If this can be moved out of .load()
// // then it solves a lot of problems
// $scope.modelName + '.changed',
// () => {
// const l = _labels(plots);
// srdbg('caching l=', l);
// appState.models[$scope.modelName + 'SelectedPlots'] = l;
// }
// );
};

$scope.$on($scope.modelName + '.changed',
() => {
const l = $scope._labels($scope.axes.y.plots);
srdbg('caching l=', l);
appState.models[$scope.modelName + 'SelectedPlots'] = l;

}
)

$scope.recalculateYDomain = function() {
var ydom;
var xdom = $scope.axes.x.scale.domain();
Expand Down

0 comments on commit d14f4e4

Please sign in to comment.