Skip to content

Commit

Permalink
Added charts
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan2017 committed Jun 16, 2022
1 parent 83a6072 commit 10960a3
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 3 deletions.
190 changes: 190 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-icons": "^4.4.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"recharts": "^2.1.10",
"sass": "^1.52.3"
},
"scripts": {
Expand Down
82 changes: 82 additions & 0 deletions src/components/Chart/Chart.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import {
AreaChart,
Area,
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
} from "recharts";
import "./Chart.scss";

const data = [
{
name: "Jan",
uv: 4000,
pv: 2400,
amt: 2400,
},
{
name: "Feb",
uv: 3000,
pv: 1398,
amt: 2210,
},
{
name: "Mar",
uv: 2000,
pv: 9800,
amt: 2290,
},
{
name: "Apr",
uv: 2780,
pv: 3908,
amt: 2000,
},
{
name: "May",
uv: 1890,
pv: 4800,
amt: 2181,
},
{
name: "Jun",
uv: 2390,
pv: 3800,
amt: 2500,
},
{
name: "July",
uv: 3490,
pv: 4300,
amt: 2100,
},
];

const Chart = ({ title = "Last 6 months (Revenue)" }) => {
return (
<div className="chart-container">
<div className="chart-title">{title}</div>
<ResponsiveContainer width="100%" height="100%">
<AreaChart
width={500}
height={2000}
data={data}
margin={{
top: 10,
right: 30,
left: 0,
bottom: 0,
}}
>
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Area type="monotone" dataKey="uv" stroke="#8884d8" fill="#8884d8" />
</AreaChart>
</ResponsiveContainer>
</div>
);
};

export default Chart;
12 changes: 12 additions & 0 deletions src/components/Chart/Chart.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.chart-container {
display: flex;
flex-direction: column;
flex: 2.5;
box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.25);
padding: 2%;

.chart-title {
margin-bottom: 2%;
color: gray;
}
}
1 change: 1 addition & 0 deletions src/components/Chart/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Chart";
Loading

0 comments on commit 10960a3

Please sign in to comment.