Created
June 5, 2023 14:29
-
-
Save ashl1/d04ab99aa49271a5d610567109ca852b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "react-dom"; | |
import { LineChart, Line, XAxis, YAxis, ReferenceLine } from "recharts"; | |
const styles = { | |
fontFamily: "sans-serif", | |
textAlign: "center" | |
}; | |
const data = []; | |
const mid = 3; | |
for (let i = 0; i < 7; i++) { | |
data.push({ | |
year: 2000 + i, | |
value: i <= mid ? 3 * i + 50 : null, | |
value2: i >= mid ? i : null | |
}); | |
} | |
const App = () => ( | |
<div style={styles}> | |
<LineChart | |
width={500} | |
height={300} | |
data={data} | |
margin={{ top: 5, right: 20, bottom: 5, left: 0 }} | |
> | |
<Line type="monotone" dataKey="value" stroke="#8884d8" dot={false} /> | |
<Line type="monotone" dataKey="value2" stroke="#8884d8" dot={false} /> | |
<XAxis dataKey="year" /> | |
<YAxis /> | |
</LineChart> | |
</div> | |
); | |
render(<App />, document.getElementById("root")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment