diff --git a/src/app/d3Bindings/eventDistribution/eventDistributionController.js b/src/app/d3Bindings/eventDistribution/eventDistributionController.js index 9136852a..743140ce 100644 --- a/src/app/d3Bindings/eventDistribution/eventDistributionController.js +++ b/src/app/d3Bindings/eventDistribution/eventDistributionController.js @@ -42,7 +42,7 @@ angular // object reference! let defaults = Object.assign({ - initialExtent: null, + initialSelection: null, visualizationYMax: 1000, visualizationTileHeight: 100 }, $scope.options); @@ -79,7 +79,7 @@ angular visualizationMiddles.map(x => moment.duration(x, "seconds").humanize()) || ""; } - $scope.options.functions.extentUpdated(newExtent); + $scope.options.functions.extentUpdated(newExtent, selectedLane); function update() { // object reference! @@ -135,16 +135,21 @@ angular // new behaviour, set default extent to full width of data if (self.data.items.length > 0) { - let extent = [self.data.minimum, self.data.maximum]; + let extent = [self.data.minimum, self.data.maximum], + category = null; // additionally, support setting initial extent for deep linking scenarios - if ($scope.options.initialExtent) { - extent = $scope.options.initialExtent; + if ($scope.options.initialSelection) { + + ({extent, category} = $scope.options.initialSelection); // jshint ignore:line // only set initial extent once - $scope.options.initialExtent = null; + $scope.options.initialSelection = null; } + if (category) { + self.detail.selectedCategory = category; + } $scope.options.functions.extentUpdate(extent); } } diff --git a/src/app/visualize/visualize.js b/src/app/visualize/visualize.js index 0a0e19be..34355d18 100644 --- a/src/app/visualize/visualize.js +++ b/src/app/visualize/visualize.js @@ -24,19 +24,21 @@ angular paths, constants, modelAssociations, Project, Site, AudioRecording, AnalysisResultFile, UserProfile) { const extent0Key = "extent0", - extent1Key = "extent1"; + extent1Key = "extent1", + selectedLaneKey = "lane"; var projectToSiteLinker = modelAssociations.generateLinker("Project", "Site"); var siteToProjectLinker = modelAssociations.generateLinker("Site", "Project"); - var updateLocationSearch = _.throttle(function (newExtent) { + var updateLocationSearch = _.throttle(function (newExtent, category) { //console.debug(...newExtent); $location.replace(); $location.search({ - [$scope.filterType]: $routeParams[$scope.filterType], - [extent0Key]: +newExtent[0], - [extent1Key]: +newExtent[1] + [$scope.filterType]: $routeParams[$scope.filterType], + [extent0Key]: +newExtent[0], + [extent1Key]: +newExtent[1], + [selectedLaneKey]: category }); }, 250); @@ -194,11 +196,11 @@ angular startOffsetSeconds ); }, - extentUpdated(newExtent) { + extentUpdated(newExtent, category) { //console.debug(...newExtent); // if value has changed, update the search for deep linkingness if (newExtent) { - updateLocationSearch(newExtent); + updateLocationSearch(newExtent, category); } } }, @@ -206,7 +208,7 @@ angular availableResolutions: [0.02, 0.04, 0.08, 0.16, 0.2, 0.4, 0.6, 1, 2, 4, 6, 12, 24, 60], visualizationTileHeight: 256, visualizationYMax: 11025, - initialExtent: parameters.initialExtent + initialSelection: parameters.initialSelection }; $scope.getLegendClass = function (site) { @@ -272,19 +274,24 @@ angular $scope.ids = ids; - var initialExtent = null; + var initialSelection = null; if ($routeParams.hasOwnProperty(extent0Key) && - $routeParams.hasOwnProperty(extent1Key)) { - initialExtent = [ - new Date(Number($routeParams[extent0Key])), - new Date(Number($routeParams[extent1Key])) - ]; + $routeParams.hasOwnProperty(extent1Key) && + $routeParams.hasOwnProperty(selectedLaneKey) + ) { + initialSelection = { + category: Number($routeParams[selectedLaneKey]), + extent: [ + new Date(Number($routeParams[extent0Key])), + new Date(Number($routeParams[extent1Key])) + ] + }; } return { error: $scope.errorState, ids, - initialExtent, + initialSelection, projectFirst: hasProjectId }; }