import { LineChart, XAxis, YAxis, Line, Tooltip, Legend } from "recharts"; import { timeFormat } from "d3-time-format"; interface ToolTipProps { active?: boolean, payload?: object, }; const defaultProps = { active: false, payload: {}, }; interface ChartProps { data: number, color: string, unit: string, dataCollections?: [], } function CustomizedTooltip(props: ToolTipProps) { const { active, payload, unit } = props; if (active && payload && payload[0]) { const time = payload[0].payload ? timeFormat("%I:%M")(new Date(payload[0].payload.time)) : ""; return (

{time} {payload[0].payload.value} {unit}

); } return null; } CustomizedTooltip.defaultProps = defaultProps; export default function Chart({ data, color, unit, dataCollections }: ChartProps) { const timeFormatter = (tick: string) => { return timeFormat("%I:%M")(new Date(tick)); }; if (dataCollections) { var ticks = dataCollections[0]?.data.map(function (collection) { return collection?.time; }) } else { var ticks = data.map(function (item) { return item?.time; }); } return ( } /> {dataCollections?.map((s) => ( ))} ); }