From 5c423eb7b313aab806f44afe60a1328ddaf26bf4 Mon Sep 17 00:00:00 2001 From: EmmaLRussell Date: Fri, 2 Aug 2024 11:18:32 +0100 Subject: [PATCH] add graphCount to redraw watches in RunPlot --- app/static/src/app/components/mixins/selectVariables.ts | 2 +- app/static/src/app/components/run/RunPlot.vue | 7 ++++++- app/static/src/app/plot.ts | 2 +- app/static/tests/unit/components/run/runPlot.test.ts | 9 ++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/static/src/app/components/mixins/selectVariables.ts b/app/static/src/app/components/mixins/selectVariables.ts index 908ca341..9873a55d 100644 --- a/app/static/src/app/components/mixins/selectVariables.ts +++ b/app/static/src/app/components/mixins/selectVariables.ts @@ -53,7 +53,7 @@ export default ( const variable = dataTransfer!.getData("variable"); const srcGraphConfig = dataTransfer!.getData("srcGraphConfig"); if (srcGraphConfig !== thisSrcGraphConfig) { - // add to this graph if necessary - do this before remove so it is not unlinked if linked variables + // add to this graph if necessary - do this before remove so, if a linked variable, it is not unlinked if (!hasHiddenVariables && !selectedVariables.value.includes(variable)) { const newVars = [...selectedVariables.value, variable]; updateSelectedVariables(graphIndex!, newVars); diff --git a/app/static/src/app/components/run/RunPlot.vue b/app/static/src/app/components/run/RunPlot.vue index e334a27a..541d639b 100644 --- a/app/static/src/app/components/run/RunPlot.vue +++ b/app/static/src/app/components/run/RunPlot.vue @@ -4,7 +4,9 @@ :placeholder-message="placeholderMessage" :end-time="endTime" :plot-data="allPlotData" - :redrawWatches="solution ? [solution, allFitData, selectedVariables, parameterSetSolutions, displayNames] : []" + :redrawWatches="solution ? + [solution, allFitData, selectedVariables, parameterSetSolutions, displayNames, graphCount] : + []" :linked-x-axis="linkedXAxis" :fit-plot="false" :graph-index="graphIndex" @@ -69,6 +71,9 @@ const allFitData = computed(() => store.getters[`fitData/${FitDataGetter.allData const selectedVariables = computed(() => props.graphConfig.selectedVariables); const placeholderMessage = computed(() => runPlaceholderMessage(selectedVariables.value, false)); +// TODO: put this in the composable in mrc-5572 +const graphCount = computed(() => store.state.graphs.config.length); + const allPlotData = (start: number, end: number, points: number): WodinPlotData => { const options = { mode: "grid", diff --git a/app/static/src/app/plot.ts b/app/static/src/app/plot.ts index 77066925..3aa3b759 100644 --- a/app/static/src/app/plot.ts +++ b/app/static/src/app/plot.ts @@ -156,7 +156,7 @@ export function allFitDataToPlotly( const variable = linkedVariables[name]; if (variable) { // If there is a linked variable, only show data if the variable is selected - if not ,render the series, - // but as transparent so that all graph x axes match + // but as transparent so that all graph x axes are consistent color = selectedVariables.includes(variable) ? paletteModel[variable] : "transparent"; } return { diff --git a/app/static/tests/unit/components/run/runPlot.test.ts b/app/static/tests/unit/components/run/runPlot.test.ts index 31445288..d92eeef6 100644 --- a/app/static/tests/unit/components/run/runPlot.test.ts +++ b/app/static/tests/unit/components/run/runPlot.test.ts @@ -153,7 +153,8 @@ describe("RunPlot", () => { mockAllFitData, selectedVariables, {}, - ["Hey", "Bye"] + ["Hey", "Bye"], + 1 ]); expect(wodinPlot.props("linkedXAxis")).toStrictEqual(linkedXAxis); @@ -292,7 +293,8 @@ describe("RunPlot", () => { mockAllFitData, selectedVariables, { Set1: mockParamSetResult1.solution, Set2: mockParamSetResult2.solution }, - ["rand1", "rand2", "rand3"] + ["rand1", "rand2", "rand3"], + 1 ]); // Generates expected plot data from model @@ -517,7 +519,8 @@ describe("RunPlot", () => { mockAllFitData, selectedVariables, {}, - ["Hey", "Bye"] + ["Hey", "Bye"], + 1 ]); // Generates expected plot data from model