Skip to content

Instantly share code, notes, and snippets.

@BK1031
Created July 10, 2024 21:28
Show Gist options
  • Save BK1031/6694281037532e3ba56cd8ba1ff3c71d to your computer and use it in GitHub Desktop.
Save BK1031/6694281037532e3ba56cd8ba1ff3c71d to your computer and use it in GitHub Desktop.
racecar_analytics chart component
import {
LineChart,
Line,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
} from "recharts";
const Chart = () => {
return (
<div className="mx-2 text-center">
<h4 className="my-2">Motor RPM</h4>
<ResponsiveContainer width="100%" height={250}>
<LineChart
width={500}
height={300}
data={ecuData}
>
<CartesianGrid strokeDasharray="4 3" stroke="#343434" />
<XAxis
dataKey="created_at"
stroke="white"
tick={{ fill: "gray" }}
tickFormatter={(timestamp) =>
new Date(timestamp).toLocaleTimeString()
}
/>
<YAxis
stroke="white"
tick={{ fill: "gray" }}
domain={["dataMin", "dataMax"]}
allowDataOverflow={true}
/>
<Tooltip />
<Line
type="monotone"
dataKey="motor_rpm"
stroke="#820DDF"
strokeWidth={2}
isAnimationActive={false}
animateNewValues={false}
/>
</LineChart>
</ResponsiveContainer>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment