Skip to content

Commit

Permalink
add graphCount to redraw watches in RunPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Aug 2, 2024
1 parent dd701f1 commit 5c423eb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/static/src/app/components/mixins/selectVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion app/static/src/app/components/run/RunPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions app/static/tests/unit/components/run/runPlot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ describe("RunPlot", () => {
mockAllFitData,
selectedVariables,
{},
["Hey", "Bye"]
["Hey", "Bye"],
1
]);
expect(wodinPlot.props("linkedXAxis")).toStrictEqual(linkedXAxis);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -517,7 +519,8 @@ describe("RunPlot", () => {
mockAllFitData,
selectedVariables,
{},
["Hey", "Bye"]
["Hey", "Bye"],
1
]);

// Generates expected plot data from model
Expand Down

0 comments on commit 5c423eb

Please sign in to comment.