# All files / src/components/Confirmed Confirmed.tsx

0% Statements 0/19
0% Branches 0/10
0% Functions 0/3
0% Lines 0/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36

     import type { FC } from 'react';
    import { useCountryCovidData, countryData, Countries } from 'src/components/Graphs';
    import Graph from 'src/components/Graphs/Graph';
    import dayjs from 'dayjs';

    export const Deaths: FC = () => {
      const result = useCountryCovidData();

      if (result.data) {
        for (const c of Object.keys(result.data)) {
          const countryCode = c as Countries;
          const country = result.data?.[countryCode];

          country.data = country.data.map((d) => ({
            ...d,
            deaths: d.y,
            y: (d.y / countryData[countryCode].population) * 100000,
          }));
        }
      }

      return (
        <Graph
          heading="Total deaths"
          yAxisLabel="Total deaths (per 100,000 people)"
          xAxisLabel="days since first reported death"
          result={result}
          labels={({ datum }) =>
            `${dayjs(datum?.x).format('DD/MM/YY')}\n deaths = ${Math.round(datum.deaths)}\n delta from day before = ${
              datum.delta
            }`
          }
        />
      );
    };