|
@@ -0,0 +1,33 @@
|
|
|
|
|
+import React from 'react';
|
|
|
|
|
+import { LineChart, XAxis, Line, CartesianGrid } from 'recharts';
|
|
|
|
|
+
|
|
|
|
|
+import { Cases, Country } from '../types';
|
|
|
|
|
+import { getCases } from '../utils/get-cases';
|
|
|
|
|
+
|
|
|
|
|
+type Props = {
|
|
|
|
|
+ country: Country;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const margin = {
|
|
|
|
|
+ top: 0,
|
|
|
|
|
+ right: 0,
|
|
|
|
|
+ bottom: 0,
|
|
|
|
|
+ left: 0,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const GraphCases: React.FC<Props> = ({ country }) => {
|
|
|
|
|
+ const cases = React.useMemo<Cases>(() => getCases(country), [country]);
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h3>Country: {country.toUpperCase()}</h3>
|
|
|
|
|
+ <LineChart width={640} height={480} data={cases} margin={margin}>
|
|
|
|
|
+ <XAxis dataKey="date" />
|
|
|
|
|
+ <CartesianGrid stroke="#f5f5f5" />
|
|
|
|
|
+ <Line type="monotone" dataKey="value" stroke="#000" yAxisId={0} />
|
|
|
|
|
+ </LineChart>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+export default GraphCases;
|