Skip to content

Commit

Permalink
Merge pull request #205 from flatironinstitute/hists-show-more
Browse files Browse the repository at this point in the history
Add button to show more histogram plots
  • Loading branch information
WardBrian authored Aug 6, 2024
2 parents 77d1665 + fef2fd1 commit 26a269c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
38 changes: 27 additions & 11 deletions gui/src/app/SamplerOutputView/HistsView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ResponsiveGrid from "@SpComponents/ResponsiveGrid";
import SequenceHistogramWidget from "@SpComponents/SequenceHistogramWidget";
import { FunctionComponent, useMemo } from "react";
import { Button } from "@mui/material";
import { FunctionComponent, useMemo, useState } from "react";

type HistsViewProps = {
draws: number[][];
Expand All @@ -18,17 +19,32 @@ const HistsView: FunctionComponent<HistsViewProps> = ({
const namesWithSuffix = paramNames.filter((name) => name.endsWith("__"));
return [...names, ...namesWithSuffix];
}, [paramNames]);
const [abbreviatedToNumPlots, setAbbreviatedToNumPlots] =
useState<number>(30);
return (
<ResponsiveGrid>
{paramNamesResorted.map((paramName) => (
<SequenceHistogramWidget
key={paramName}
histData={draws[paramNames.indexOf(paramName)]}
title={paramName}
variableName={paramName}
/>
))}
</ResponsiveGrid>
<>
<ResponsiveGrid>
{paramNamesResorted.slice(0, abbreviatedToNumPlots).map((paramName) => (
<SequenceHistogramWidget
key={paramName}
histData={draws[paramNames.indexOf(paramName)]}
title={paramName}
variableName={paramName}
/>
))}
</ResponsiveGrid>
{abbreviatedToNumPlots < paramNamesResorted.length && (
<div className="PlotAbbreviationToggle">
<Button
onClick={() => {
setAbbreviatedToNumPlots((x) => x + 30);
}}
>
Show more
</Button>
</div>
)}
</>
);
};

Expand Down
7 changes: 7 additions & 0 deletions gui/src/localStyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ span.EditorTitle {
padding: 5px;
}

/* Histograms */

.PlotAbbreviationToggle {
background: white;
padding: 5px;
}

/* Trace Plots */
.TracePlotsView {
}
Expand Down

0 comments on commit 26a269c

Please sign in to comment.