Skip to content

Commit

Permalink
Remove box and whisker and standard deviation bar graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
TyHil committed Apr 16, 2023
1 parent fd6f85b commit 75fd661
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 48 deletions.
2 changes: 2 additions & 0 deletions components/graph/BarGraph/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function BarGraph(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
/>
);
}
Expand All @@ -30,6 +31,7 @@ export function BarGraph(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
/>
);
}
4 changes: 4 additions & 0 deletions components/graph/BoxGraph/BoxGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export function BoxGraph(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
8 changes: 8 additions & 0 deletions components/graph/GraphChoice/GraphChoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></BarGraph>
);
}
Expand All @@ -34,6 +35,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></LineGraph>
);
}
Expand All @@ -44,6 +46,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></BoxGraph>
);
}
Expand All @@ -54,6 +57,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></VerticalBarGraph>
);
}
Expand All @@ -64,6 +68,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></HorizontalBarGraph>
);
}
Expand All @@ -73,6 +78,7 @@ export function GraphChoice(props: GraphProps) {
xaxisLabels={props.xaxisLabels}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></RadarChart>
);
}
Expand All @@ -81,6 +87,7 @@ export function GraphChoice(props: GraphProps) {
<RadialBarChart
series={props.series}
title={props.title}
subtitle={props.subtitle}
></RadialBarChart>
);
}
Expand All @@ -91,6 +98,7 @@ export function GraphChoice(props: GraphProps) {
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
subtitle={props.subtitle}
></BarGraph>
);
}
Expand Down
4 changes: 4 additions & 0 deletions components/graph/HorizontalBarGraph/HorizontalBarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export function HorizontalBarGraph(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
4 changes: 4 additions & 0 deletions components/graph/LineGraph/LineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function LineGraph(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
4 changes: 4 additions & 0 deletions components/graph/RadarChart/RadarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function RadarChart(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
4 changes: 4 additions & 0 deletions components/graph/RadialBarChart/RadialBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export function RadialBarChart(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
4 changes: 4 additions & 0 deletions components/graph/VerticalBarGraph/VerticalBarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function VerticalBarGraph(props: GraphProps) {
text: props.title,
align: 'left',
},
subtitle: {
text: props.subtitle,
align: 'left',
},
noData: {
text: 'Please select a class to add',
align: 'center',
Expand Down
1 change: 1 addition & 0 deletions modules/GraphProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type GraphProps = {
yaxisFormatter?: (val: number) => string;
series: any[];
title: string;
subtitle?: string;
labels?: string[];
};
export default GraphProps;
62 changes: 14 additions & 48 deletions pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ export const Dashboard: NextPage = () => {

let newDat: gradesType[] = [];
let newStudentTotals = [-1, -1, -1];
let newAverageDat: gradesType[] = [];
let newStdevDat: gradesType[] = [];
for (let i = 0; i < partialGradesData.length; i++) {
const total: number = partialGradesData[i].data.reduce(
(accumulator, currentValue) => accumulator + currentValue,
Expand All @@ -309,41 +311,23 @@ export const Dashboard: NextPage = () => {
name: partialGradesData[i].name,
data: normalized,
};
}
setGradesData(newDat);
setStudentTotals(newStudentTotals);

let newGPADat: gradesType[] = [];
let newAverageDat: gradesType[] = [];
let newStdevDat: gradesType[] = [];
for (let i = 0; i < partialGradesData.length; i++) {
const GPALookup = [
4, 4, 3.67, 3.33, 3, 2.67, 2.33, 2, 1.67, 1.33, 1, 0.67, 0,
];
let GPAGrades: number[] = [];
for (let j = 0; j < partialGradesData[i].data.length - 1; j++) {
GPAGrades = GPAGrades.concat(
Array(partialGradesData[i].data[j]).fill(GPALookup[j]),
);
}
newGPADat.push({ name: partialGradesData[i].name, data: GPAGrades });
const mean =
GPAGrades.reduce((partialSum, a) => partialSum + a, 0) /
GPAGrades.length;
GPALookup.reduce(
(accumulator, currentValue, index) =>
accumulator + currentValue * partialGradesData[i].data[index],
0,
) / total;
newAverageDat.push({
name: partialGradesData[i].name,
data: [mean],
});
const stdev = Math.sqrt(
GPAGrades.reduce((partialSum, a) => partialSum + (a - mean) ** 2, 0) /
GPAGrades.length,
);
newStdevDat.push({
name: partialGradesData[i].name,
data: [stdev],
});
}
setGPAData(newGPADat);
setGradesData(newDat);
setStudentTotals(newStudentTotals);
setAverageData(newAverageDat);
setStdevData(newStdevDat);
}, [fullGradesData, startingSession, endingSession]);
Expand Down Expand Up @@ -439,32 +423,14 @@ export const Dashboard: NextPage = () => {
</Card>
<Card className="h-96 p-4 m-4">
<GraphChoice
form="BoxWhisker"
title="GPA Box and Whisker"
form="Vertical"
title="GPA Averages"
subtitle="Excluding dropped grades"
xaxisLabels={['Average']}
yaxisFormatter={(value) => Number(value).toFixed(2)}
series={GPAData}
series={averageData}
/>
</Card>
<div className="grid grid-cols-1 md:grid-cols-2">
<Card className="h-96 p-4 m-4">
<GraphChoice
form="Vertical"
title="GPA Averages"
xaxisLabels={['Average']}
yaxisFormatter={(value) => Number(value).toFixed(2)}
series={averageData}
/>
</Card>
<Card className="h-96 p-4 m-4">
<GraphChoice
form="Vertical"
title="GPA Standard Deviations"
xaxisLabels={['Standard Deviation']}
yaxisFormatter={(value) => Number(value).toFixed(2)}
series={stdevData}
/>
</Card>
</div>
</div>
</>
);
Expand Down

0 comments on commit 75fd661

Please sign in to comment.