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

Alternative_grid_size #692

Merged
merged 2 commits into from
Jan 24, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ import { formatProportion } from '../shared/table/formatProportion';
export interface MutationsOverTimeGridProps {
data: MutationOverTimeDataMap;
colorScale: ColorScale;
maxNumberOfGridRows?: number;
}

const MAX_NUMBER_OF_GRID_ROWS = 100;
const MUTATION_CELL_WIDTH_REM = 8;

const MutationsOverTimeGrid: FunctionComponent<MutationsOverTimeGridProps> = ({ data, colorScale }) => {
const MutationsOverTimeGrid: FunctionComponent<MutationsOverTimeGridProps> = ({
data,
colorScale,
maxNumberOfGridRows,
}) => {
const currentMaxNumberOfGridRows = maxNumberOfGridRows ?? MAX_NUMBER_OF_GRID_ROWS;
const allMutations = data.getFirstAxisKeys();
const shownMutations = allMutations.slice(0, MAX_NUMBER_OF_GRID_ROWS);
const shownMutations = allMutations.slice(0, currentMaxNumberOfGridRows);

const dates = data.getSecondAxisKeys();

const gridRef = useRef<HTMLDivElement>(null);

return (
<>
{allMutations.length > MAX_NUMBER_OF_GRID_ROWS && (
{allMutations.length > currentMaxNumberOfGridRows && (
<div className='pl-2'>
Showing {MAX_NUMBER_OF_GRID_ROWS} of {allMutations.length} mutations. You can narrow the filter to
reduce the number of mutations.
Showing {currentMaxNumberOfGridRows} of {allMutations.length} mutations. You can narrow the filter
to reduce the number of mutations.
</div>
)}
{allMutations.length === 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const wastewaterMutationOverTimeSchema = z.object({
sequenceType: sequenceTypeSchema,
width: z.string(),
height: z.string(),
maxNumberOfGridRows: z.number().optional(),
});

export type WastewaterMutationsOverTimeProps = z.infer<typeof wastewaterMutationOverTimeSchema>;
Expand Down Expand Up @@ -75,6 +76,7 @@ export const WastewaterMutationsOverTimeInner: FunctionComponent<WastewaterMutat
<MutationsOverTimeTabs
mutationOverTimeDataPerLocation={mutationOverTimeDataPerLocation}
originalComponentProps={componentProps}
maxNumberOfGridRows={componentProps.maxNumberOfGridRows}
/>
);
};
Expand All @@ -87,17 +89,21 @@ type MutationOverTimeDataPerLocation = {
type MutationOverTimeTabsProps = {
mutationOverTimeDataPerLocation: MutationOverTimeDataPerLocation;
originalComponentProps: WastewaterMutationsOverTimeProps;
maxNumberOfGridRows?: number;
};

const MutationsOverTimeTabs: FunctionComponent<MutationOverTimeTabsProps> = ({
mutationOverTimeDataPerLocation,
originalComponentProps,
maxNumberOfGridRows,
}) => {
const [colorScale, setColorScale] = useState<ColorScale>({ min: 0, max: 1, color: 'indigo' });

const tabs = mutationOverTimeDataPerLocation.map(({ location, data }) => ({
title: location,
content: <MutationsOverTimeGrid data={data} colorScale={colorScale} />,
content: (
<MutationsOverTimeGrid data={data} colorScale={colorScale} maxNumberOfGridRows={maxNumberOfGridRows} />
),
}));

const toolbar = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@ export class WastewaterMutationsOverTimeComponent extends PreactLitAdapterWithGr
@property({ type: String })
height: string = '700px';

/**
* The maximum number of grid rows to display.
*
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please at least issue a follow up PR to get rid of this?

(And add the new attribute to the web component storybook - both the args and the code example in the docs)

*/
@property({ type: Number })
maxNumberOfGridRows: number = 100;

override render() {
return (
<WastewaterMutationsOverTime
lapisFilter={this.lapisFilter}
sequenceType={this.sequenceType}
width={this.width}
height={this.height}
maxNumberOfGridRows={this.maxNumberOfGridRows}
/>
);
}
Expand Down
Loading