Skip to content

Commit

Permalink
feat: responsive container for application graph
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuan-zhou committed Nov 26, 2021
1 parent fcbad99 commit 16eb3be
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions src/features/Stats/StatsApplicationsGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import { Box } from '@rebass/grid';
import { IStatsApplications } from '../../config';

import {
ResponsiveContainer,
LineChart,
Line,
XAxis,
Expand All @@ -22,29 +24,31 @@ const StatsApplicationsGraph: React.FC<IStatsApplicationsGraph> = (props) => {

// cannot use ResponsiveContainer since parent has no width and height
return (
<LineChart
width={700}
height={300}
data={applications}
margin={{
top: 5,
right: 30,
left: 20,
bottom: 5
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="date" />
<YAxis />
<Tooltip />
<Legend />
<Line
type="monotone"
dataKey="applications"
stroke="#8884d8"
activeDot={{ r: 8 }}
/>
</LineChart>
<Box width={1} alignSelf={'center'}>
<ResponsiveContainer width="100%" height={300}>
<LineChart
data={applications}
margin={{
top: 5,
right: 30,
left: 20,
bottom: 5
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="date" />
<YAxis />
<Tooltip />
<Legend />
<Line
type="monotone"
dataKey="applications"
stroke="#8884d8"
activeDot={{ r: 8 }}
/>
</LineChart>
</ResponsiveContainer>
</Box>
);
}

Expand Down

0 comments on commit 16eb3be

Please sign in to comment.