Skip to content

Commit

Permalink
do not show linked fit data on graphs without linked variables
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Jul 31, 2024
1 parent 342c661 commit 2859341
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
9 changes: 5 additions & 4 deletions app/static/src/app/components/mixins/selectVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ export default (
const variable = dataTransfer!.getData("variable");
const srcGraphConfig = dataTransfer!.getData("srcGraphConfig");
if (srcGraphConfig !== thisSrcGraphConfig) {
if (srcGraphConfig !== "hidden") {
removeVariable(parseInt(srcGraphConfig, 10), variable);
}
// add to this graph if necessary
// add to this graph if necessary - do this before remove so it is not unlinked if linked variables
if (!hasHiddenVariables && !selectedVariables.value.includes(variable)) {
const newVars = [...selectedVariables.value, variable];
updateSelectedVariables(graphIndex!, newVars);
}

if (srcGraphConfig !== "hidden") {
removeVariable(parseInt(srcGraphConfig, 10), variable);
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/components/run/RunPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const allPlotData = (start: number, end: number, points: number): WodinPlotData
const plotOptions = { showLegend: true, includeLegendGroup: true };
const allData = [
...odinToPlotly(filterSeriesSet(result, selectedVariables.value), palette.value, plotOptions),
...allFitDataToPlotly(allFitData.value, palette.value, start, end)
...allFitDataToPlotly(allFitData.value, palette.value, start, end, props.graphConfig.selectedVariables)
];
// 2. Parameter sets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export default defineComponent({
});
if (allFitData.value) {
result.push(...allFitDataToPlotly(allFitData.value, palette.value, start, end));
result.push(
...allFitDataToPlotly(allFitData.value, palette.value, start, end, props.graphConfig.selectedVariables));
}
}
Expand Down
10 changes: 8 additions & 2 deletions app/static/src/app/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,21 @@ export function allFitDataToPlotly(
allFitData: AllFitData | null,
paletteModel: Palette,
start: number,
end: number
end: number,
selectedVariables: string[]
): WodinPlotData {
if (!allFitData) {
return [];
}
const { data, linkedVariables, timeVariable } = allFitData;
console.log("linked variables")
console.log(JSON.stringify(linkedVariables))
const filteredData = filterData(data, timeVariable, start, end);
const palette = paletteData(Object.keys(linkedVariables));
return Object.keys(linkedVariables).map((name: string) => ({
// Display column data if it is not linked OR if its linked variable is selected
const columns = Object.keys(linkedVariables)
.filter((column) => !linkedVariables[column] || selectedVariables.includes(linkedVariables[column]!));
return columns.map((name: string) => ({
name,
x: filteredData.map((row: Dict<number>) => row[timeVariable]),
y: filteredData.map((row: Dict<number>) => row[name]),
Expand Down

0 comments on commit 2859341

Please sign in to comment.