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;