Skip to content

Commit

Permalink
fix getter
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Nov 6, 2024
1 parent 15c8fc1 commit 9b5c429
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/static/src/store/graphs/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export const getters: GraphsGetters & GetterTree<GraphsState, AppState> = {
},
[GraphsGetter.legendWidth]: (_, graphsGetters): number => {
// Heuristic for setting graph legend width based on string length of longest variable name
const longestVar = graphsGetters[GraphsGetter.allSelectedVariables].sort((a: string, b: string) =>
a.length < b.length ? 1 : -1
)[0];
return longestVar.length * LEGEND_WIDTH_PER_CHAR + LEGEND_LINE_PADDING;
let maxVariableLength = 0;
const variables = graphsGetters[GraphsGetter.allSelectedVariables];
for (let i = 0; i < variables.length; i++) {
maxVariableLength = Math.max(maxVariableLength, variables[i]);
}
return maxVariableLength * LEGEND_WIDTH_PER_CHAR + LEGEND_LINE_PADDING;
}
};

0 comments on commit 9b5c429

Please sign in to comment.