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

Lagt til zoom-knapp i linediagram i sykehusprofil #3762

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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 @@ -4,14 +4,16 @@ import {
IndicatorLinechartParams,
} from "../../../charts/IndicatorLinechart";
import { LineStyles } from "qmongjs";
import { ThemeProvider, Box, Typography } from "@mui/material";
import { ThemeProvider, Box, Typography, Stack, Button } from "@mui/material";
import { ChipSelection } from "../../ChipSelection";
import {
LinePlotLegend,
ItemBox,
lineChartTheme,
} from "../..//HospitalProfile";
import { formatUnitNameIfNational } from "../../../helpers/functions/formatUnitNameIfNational";
import ZoomInIcon from "@mui/icons-material/ZoomIn";
import ZoomOutIcon from "@mui/icons-material/ZoomOut";

type HospitalProfileLinePlotProps = {
unitFullName: string;
Expand All @@ -36,6 +38,10 @@ export const HospitalProfileLinePlot = (
textMargin,
} = props;

// States
const [normalise, setNormalise] = useState<boolean>(true);
const [zoomIn, setZoomIn] = useState<boolean>(false);

// Set the line plot width to fill the available space
const [plotWidth, setPlotWidth] = useState(null);

Expand Down Expand Up @@ -84,26 +90,19 @@ export const HospitalProfileLinePlot = (
fontWeight: 500,
fontFamily: "Arial",
},
yAxisText: "Antall indikatorer",
yAxisText: normalise ? "Andel" : "Antall indikatorer",
xTicksFont: { fontFamily: "Arial", fontSize: 16, fontWeight: 500 },
yTicksFont: { fontFamily: "Arial", fontSize: 14, fontWeight: 500 },
startYear: lastYear - pastYears,
endYear: lastYear,
yMin: 0,
normalise: true,
yMax: normalise && !zoomIn ? 1 : undefined,
normalise: normalise,
useToolTip: true,
};

// State logic for normalising the line plot
const [normalise, setNormalise] = useState(indicatorParams.normalise);

indicatorParams.normalise = normalise;

if (normalise) {
indicatorParams.yAxisText = "Andel";
} else {
indicatorParams.yAxisText = "Antall indikatorer";
}
const zoomButtonicon = zoomIn ? <ZoomOutIcon /> : <ZoomInIcon />;
const zoomButtonText = zoomIn ? "Zoom ut" : "Zoom inn";

return (
<ItemBox sx={{ overflow: "auto" }}>
Expand All @@ -116,18 +115,35 @@ export const HospitalProfileLinePlot = (
lastYear}
</b>
</Typography>
<ChipSelection
leftChipLabel="Vis andel"
rightChipLabel="Vis Antall"
leftChipHelpText=""
rightChipHelpText=""
hoverBoxOffset={[20, 20]}
hoverBoxPlacement="top"
hoverBoxMaxWidth={400}
state={normalise}
stateSetter={setNormalise}
trueChip="left"
/>
<Stack
direction="row"
justifyContent="space-between"
alignItems="center"
>
<ChipSelection
leftChipLabel="Vis andel"
rightChipLabel="Vis Antall"
leftChipHelpText=""
rightChipHelpText=""
hoverBoxOffset={[20, 20]}
hoverBoxPlacement="top"
hoverBoxMaxWidth={400}
state={normalise}
stateSetter={setNormalise}
trueChip="left"
/>
<Button
disabled={!normalise}
variant="outlined"
startIcon={zoomButtonicon}
sx={{ height: "3rem", marginRight: "4rem" }}
onClick={() => {
setZoomIn(!zoomIn);
}}
>
{zoomButtonText}
</Button>
</Stack>
<div style={{ margin: textMargin }}>
<Typography variant="body1">
{"Grafen gir en oversikt over kvalitetsindikatorer fra de nasjonale medisinske kvalitetsregistrene for " +
Expand Down