Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plot width calculation, expand accessibility statement #472

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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