Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 2x 4x 4x 16x 1x 3x 4x 4x 4x | import { useTheme } from "@mui/material/styles";
import { Typography } from "@mui/material";
import ReactApexChart from "react-apexcharts";
import { EXPORT_ONLY_TOOLBAR } from "@/utils/components/charts/chartExportToolbar";
const ScoreDistributionChart = ({ minimum, firstQuartile, median, thirdQuartile, maximum, mean }) => {
const theme = useTheme();
const values = [minimum, firstQuartile, median, thirdQuartile, maximum];
if (values.some((v) => typeof v !== "number" || !Number.isFinite(v))) {
return (
<Typography variant="body2" color="text.secondary">
Not enough graded submissions yet to show a distribution.
</Typography>
);
}
const hasMean = typeof mean === "number" && Number.isFinite(mean);
const options = {
chart: { type: "boxPlot", toolbar: EXPORT_ONLY_TOOLBAR },
plotOptions: {
bar: { horizontal: true, barHeight: "45%" },
boxPlot: {
colors: {
upper: theme.palette.primary.main,
lower: theme.palette.primary.light,
},
},
},
grid: { borderColor: theme.palette.divider },
xaxis: {
min: 0,
max: 100,
labels: { style: { colors: theme.palette.text.secondary } },
axisBorder: { color: theme.palette.divider },
axisTicks: { color: theme.palette.divider },
},
yaxis: { labels: { style: { colors: theme.palette.text.secondary } } },
tooltip: { theme: theme.palette.mode },
annotations: hasMean
? {
xaxis: [
{
x: mean,
borderColor: theme.palette.text.secondary,
strokeDashArray: 4,
label: {
text: `Mean ${mean.toFixed(1)}`,
orientation: "horizontal",
style: {
color: theme.palette.getContrastText(theme.palette.grey[700]),
background: theme.palette.grey[700],
fontSize: "11px",
},
},
},
],
}
: {},
};
const series = [
{
data: [{ x: "Scores", y: values }],
},
];
return <ReactApexChart options={options} series={series} type="boxPlot" height={200} />;
};
export default ScoreDistributionChart;
|