Skip to content

Commit

Permalink
Merge pull request #472 from visdesignlab/450-451-spacing
Browse files Browse the repository at this point in the history
Fix plot width calculation, expand accessibility statement
  • Loading branch information
NateLanza authored Feb 11, 2025
2 parents 7296943 + 24a469d commit 5adb356
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/components/AccessiblityStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const AccessibilityStatement = ({ open, close, data }: Props) => {
const hiddenSets = provenance.getState().allSets.filter((set: Column) => !visibleSets.includes(set.name));

return (
<Dialog open={open} onClose={close} sx={{ padding: '20px' }}>
<Dialog open={open} onClose={close} sx={{ padding: '20px' }} fullWidth maxWidth="lg">
<Box sx={{ padding: '20px' }}>
<Typography variant="h4" component="h4">UpSet 2 Accessibility Statement</Typography>
<p>
Expand Down
3 changes: 3 additions & 0 deletions packages/upset/src/atoms/config/visibleAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { selector } from 'recoil';

import { upsetConfigAtom } from './upsetConfigAtoms';

/**
* The attributes that are currently visible.
*/
export const visibleAttributesSelector = selector<string[]>({
key: 'visible-attribute',
get: ({ get }) => get(upsetConfigAtom).visibleAttributes,
Expand Down
6 changes: 5 additions & 1 deletion packages/upset/src/atoms/dimensionsAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ ReturnType<typeof calculateDimensions>
const visibleSets = get(visibleSetSelector);
const rowCount = get(rowCountSelector);
const hiddenSets = get(hiddenSetSelector);
const attributes = get(visibleAttributesSelector);
let attributes = get(visibleAttributesSelector);

const degree = attributes.includes('Degree');
attributes = attributes.filter((a) => a !== 'Degree');

return calculateDimensions(
visibleSets.length,
hiddenSets.length,
rowCount,
attributes.length,
degree,
);
},
});
Expand Down
17 changes: 12 additions & 5 deletions packages/upset/src/dimensions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
/**
* Calculates the dimensions of the plot
* @param nVisibleSets Number of visible sets
* @param nHiddenSets Number of hidden sets
* @param nIntersections Number of intersections
* @param nAttributes Number of visible attributes, excluding Degree
* @param degree Whether to show the Degree column
* @returns The dimensions of the plot, in an object with a variety of fields
*/
export function calculateDimensions(
nVisibleSets: number = 0,
nHiddenSets: number = 0,
nIntersections: number = 0,
nAttributes: number = 0,
degree: boolean = false,
) {
const gap = 20;

Expand Down Expand Up @@ -83,11 +93,8 @@ export function calculateDimensions(
bookmarkStar.gap +
bookmarkStar.width + // Bookmark Star
bookmarkStar.gap +
degreeColumn.gap +
degreeColumn.width + // Degree Column
degreeColumn.gap + // Add margin
attribute.width + // Deviation
attribute.vGap +
(degree ? degreeColumn.width + // Degree Column
degreeColumn.gap : 0) + // Add margin
(attribute.vGap + attribute.width) * nAttributes, // Show all attributes
totalHeight: set.size.height + set.label.height,
};
Expand Down

0 comments on commit 5adb356

Please sign in to comment.