|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
import format from 'date-fns/format';
|
|
import format from 'date-fns/format';
|
|
|
import { LineChart, XAxis, YAxis, Line, CartesianGrid } from 'recharts';
|
|
import { LineChart, XAxis, YAxis, Line, CartesianGrid } from 'recharts';
|
|
|
|
|
|
|
|
-import { Cases, Country, Data } from '../types';
|
|
|
|
|
|
|
+import { DataSource, Country, Data } from '../types';
|
|
|
import { getCases } from '../utils/get-cases';
|
|
import { getCases } from '../utils/get-cases';
|
|
|
import { processCases } from '../utils/regression';
|
|
import { processCases } from '../utils/regression';
|
|
|
|
|
|
|
@@ -22,12 +22,15 @@ const dateTickFormatter = (date: Date): string => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const GraphCases: React.FC<Props> = ({ country }) => {
|
|
const GraphCases: React.FC<Props> = ({ country }) => {
|
|
|
- const cases = React.useMemo<Cases>(() => getCases(country), [country]);
|
|
|
|
|
- const data = React.useMemo<Data>(() => processCases(cases), [cases]);
|
|
|
|
|
|
|
+ const dataSource = React.useMemo<DataSource>(() => getCases(country), [country]);
|
|
|
|
|
+ const data = React.useMemo<Data>(() => processCases(dataSource.cases), [dataSource.cases]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
<h3>Country: {country.toUpperCase()}</h3>
|
|
<h3>Country: {country.toUpperCase()}</h3>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ Source: <a href={dataSource.source}>{dataSource.source}</a>
|
|
|
|
|
+ </p>
|
|
|
<LineChart width={640} height={480} data={data} margin={margin}>
|
|
<LineChart width={640} height={480} data={data} margin={margin}>
|
|
|
<XAxis
|
|
<XAxis
|
|
|
dataKey="xValue"
|
|
dataKey="xValue"
|