Skip to content

Commit

Permalink
Merge pull request #711 from openjck/issue-104-persist-reference-point
Browse files Browse the repository at this point in the history
Fix #104: Persist reference point to URL
  • Loading branch information
openjck authored Jul 7, 2020
2 parents 95d0f8c + 294187a commit d90eac8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/explore/ProbeExplorer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import ComparisonSummary from './ComparisonSummary.svelte';
import AdHocViolin from './AdHocViolin.svelte';
import { store } from '../../state/store';
import {
explorerComparisonSmallMultiple,
overTimeTitle,
Expand Down Expand Up @@ -104,7 +106,7 @@ export let hovered = !hoverActive ? { x: data[0].label, datum: data[0] } : {};
function leftLabelForAggComparison(d, aggLevel, x) {
if (d.length === 2) {
if (aggLevel === 'build_id') return formatBuildIDToDateString(d[0].label);
else return d[0].label;
return d[0].label;
}
if (aggLevel === 'build_id') return formatBuildIDToDateString(x);
return x;
Expand All @@ -116,7 +118,19 @@ function leftPointsForAggComparison(d, pmt, dt) {
return undefined;
}
export let reference = data[data.length - 1];
// Get the reference point from the query string if possible
function getDefaultReferencePoint() {
if ($store.reference) {
const found = data.find((d) => d[aggregationLevel] === $store.reference);
if (found) return found;
}
return data[data.length - 1];
}
export let reference = getDefaultReferencePoint();
// Persist the reference point to the query string
$: store.setField('reference', aggregationLevel === 'version' ? reference.version : reference.build_id);
// This will lightly animate the reference distribution part of the violin plot.
// FIXME: for quantile plots, let's move this up a level to the view.
Expand Down
1 change: 1 addition & 0 deletions src/config/firefox-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default {
proportionMetricType: store.proportionMetricType,
activeBuckets: store.activeBuckets,
visiblePercentiles: store.visiblePercentiles,
reference: store.reference,
};
},
getParamsforDataAPI(store) {
Expand Down
1 change: 1 addition & 0 deletions src/state/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const initialState = {
activeBuckets: getFromQueryString('activeBuckets', true) || [],
applicationStatus: 'INITIALIZING', // FIXME: applicationStatus or dashboardMode, not both.
route: {},
reference: getFromQueryString('reference') || '',
};

export const store = createStore(initialState);
Expand Down

0 comments on commit d90eac8

Please sign in to comment.