From 264e571b0ca34d24f4997c5864a43d4f475e14dc Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Wed, 13 Apr 2022 19:10:44 -0400 Subject: full version 2 re-write --- src/pages/Graph.css | 4 +++ src/pages/Graph.jsx | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pages/Index.css | 22 ++++++++++++ src/pages/Index.jsx | 66 ++++++++++++++++++++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 src/pages/Graph.css create mode 100644 src/pages/Graph.jsx create mode 100644 src/pages/Index.css create mode 100644 src/pages/Index.jsx (limited to 'src/pages') diff --git a/src/pages/Graph.css b/src/pages/Graph.css new file mode 100644 index 0000000..c28c8bd --- /dev/null +++ b/src/pages/Graph.css @@ -0,0 +1,4 @@ +.Title { + font-size: 2.0em; + margin-top: 24px; +} diff --git a/src/pages/Graph.jsx b/src/pages/Graph.jsx new file mode 100644 index 0000000..6754905 --- /dev/null +++ b/src/pages/Graph.jsx @@ -0,0 +1,96 @@ +import { DateTime } from "luxon"; +import { + BarChart, + Bar, + LineChart, + Line, + CartesianGrid, + XAxis, + YAxis, + Tooltip, + ReferenceLine, + ResponsiveContainer, + Label, +} from "recharts"; +import GoatCounter from "../components/GoatCounter"; +import "./Graph.css"; + +const Graph = (props) => { + const { name, response, dataKey, timeDifference } = props; + const { data, loading, error } = response; + + if (loading) { + return
; + } + + const eventStyle = { fill: "#767676" }; + + const parsed = data.map((d) => { + return { + date: DateTime.fromSQL(d["last_updated"], { zone: "UTC" }).setZone(DateTime.local().zoneName).toSeconds(), + value: d[dataKey], + }; + }); + + return ( +
+
{name}
+ 600 ? 750 : window.innerWidth * 0.9} + height={500} + margin={{ top: 15, right: 30, left: 0, bottom: 5 }} + data={parsed} + > + + + + {} + + } + height={90} + /> + + + + +
+ ); +}; + +const CustomizedAxisTick = ({ x, y, payload }) => { + return ( + + + {DateTime.fromSeconds(payload.value).toLocaleString()} + + + ); +}; + +const CustomTooltip = ({ active, payload, label }) => { + if (active) { + return ( +
+

+ {DateTime.fromSeconds(label).toLocaleString({ weekday: "long", month: "long", day: "2-digit" })} +

+

{payload[0].value}

+
+ ); + } + return null; +}; + +export default Graph; diff --git a/src/pages/Index.css b/src/pages/Index.css new file mode 100644 index 0000000..5476eb1 --- /dev/null +++ b/src/pages/Index.css @@ -0,0 +1,22 @@ +.Message { + margin-top: 24px; + font-size: 1.4em; +} + +@media screen and (max-width: 600px) { + .Message { + display: none; + } +} + +.Section .Title { + text-align: center; + font-size: 1.6em; + flex-basis: 100%; + margin-top: 48px; +} + +.Cards { + display: flex; + justify-content: center; +} diff --git a/src/pages/Index.jsx b/src/pages/Index.jsx new file mode 100644 index 0000000..3beb6fd --- /dev/null +++ b/src/pages/Index.jsx @@ -0,0 +1,66 @@ +import Card from "../components/Card"; +import GoatCounter from "../components/GoatCounter"; +import "./Index.css"; + +const Index = (props) => { + const response = props.response; + if (response.loading) { + return
Loading...
; + } + + const data = response.data; + + const latest = data[data.length - 1]; + const prior = data[data.length - (1 + props.timeDifference)]; + + return ( +
+
+
+ This dashboard has been refreshed for the new semester. Historical data from the 2020-2021 school + year is available at 2020.ritcoviddashboard.com. Data + from the Fall 2021 semester is available at{" "} + 2021.ritcoviddashboard.com. +
+
+
+
Total Positive Cases Since January 10 (First Day of Classes)
+
+ + +
+
+ +
+
New Positive Cases From Past 14 Days
+
+ + +
+
+ +
+ ); +}; + +export default Index; -- cgit v1.2.3