From 0216f8879440ce73d90a9e58cc5eac68240e9fdd Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Fri, 29 Oct 2021 12:19:15 -0400 Subject: add static data for 2020-2021 school year --- src/History.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/History.js (limited to 'src/History.js') diff --git a/src/History.js b/src/History.js new file mode 100644 index 0000000..7425b61 --- /dev/null +++ b/src/History.js @@ -0,0 +1,82 @@ +import { React, PureComponent } from "react"; +import { DateTime } from "luxon"; +import { + BarChart, + Bar, + LineChart, + Line, + CartesianGrid, + XAxis, + YAxis, + Tooltip, + ResponsiveContainer, + Label, +} from "recharts"; +import GoatCounter from "./GoatCounter"; + +const History = (props) => { + const offset = DateTime.fromSQL(props.data[0].date, { zone: "UTC" }).setZone(DateTime.local().zoneName).toSeconds(); + const data = props.data.map((d) => { + return { + value: d.value, + date: DateTime.fromSQL(d.date, { zone: "UTC" }).setZone(DateTime.local().zoneName).toSeconds(), + }; + }); + + return ( + <> +

{props.name}

+ + + + } + height={90} + /> + + + + + + ); +}; + +class CustomizedAxisTick extends PureComponent { + render() { + const { x, y, payload } = this.props; + + 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 History; -- cgit v1.2.3