Skip to content

Commit

Permalink
Mereg master
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKalach committed Apr 3, 2020
2 parents 4139a2b + 38ccb08 commit 6667a5f
Show file tree
Hide file tree
Showing 14 changed files with 1,255 additions and 984 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ Following people have also contributed to this project:
- [miikkajs](https://github.com/valstu/korona-info/pulls/miikkajs) (infection predictions)
- [albacoretuna](https://github.com/albacoretuna) (translation logic + translations to en/fa)
- [jonijuup](https://github.com/jonijuup) (translations)
- [villesau](https://github.com/villesau) (filter chart by healthcare district, code quality)
- [villesau](https://github.com/villesau) (filter chart by healthcare district, bubble chart, code quality)
- [nghitrum](https://github.com/nghitrum) (bug fixes)
- [msillanpaa](https://github.com/msillanpaa) (content fixes)
- [csaavedra](https://github.com/csaavedra) (translation fixes)
- [petetnt](https://github.com/petetnt) (UI fixes)

## License

Expand Down
143 changes: 143 additions & 0 deletions components/BubbleChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { useState, useContext } from 'react';
import styled from '@emotion/styled';
import {
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
ScatterChart,
ZAxis,
Scatter
} from 'recharts';
import { Box, Button, ButtonGroup } from '@chakra-ui/core';

import _ from 'lodash';

import Block from '../components/Block';
import { UserContext } from '../pages/_app';
import { InfectionDevelopmentDataItem } from '../utils/chartDataHelper';
import { GroupedData } from '../pages';
import { format, utcToZonedTime } from 'date-fns-tz';

const TooltipWrapper = styled.div`
border: 1px solid rgba(102, 119, 136, 0.15);
background-color: #fff;
padding: 1rem;
`;

const BubbleChart = ({ data }: { data: GroupedData }) => {
const [chartScale, setChartScale] = useState<'cumulative' | 'daily'>('daily');
const { t } = useContext(UserContext);
return (
<Box width={['100%', '100%', '100%', '100%', 1 / 2]} p={3}>
<Block
title={t('accumulation by healthcare district')}
>
<ButtonGroup
spacing={0}
alignSelf="center"
display="flex"
justifyContent="center"
marginTop="-15px"
>
<Button
size="xs"
fontFamily="Space Grotesk Regular"
px={3}
letterSpacing="1px"
borderRadius="4px 0px 0px 4px"
borderWidth="0px"
isActive={chartScale === 'cumulative'}
onClick={() => setChartScale('cumulative')}
>
{t('cumulative')}
</Button>
<Button
size="xs"
fontFamily="Space Grotesk Regular"
px={3}
letterSpacing="1px"
borderRadius="0px 4px 4px 0px"
borderWidth="0px"
isActive={chartScale === 'daily'}
onClick={() => setChartScale('daily')}
>
{t('daily')}
</Button>
</ButtonGroup>
<Box p={5}>
{_.map(data, (district, key) => {
return (
<ResponsiveContainer key={key} width={'100%'} height={25}>
<ScatterChart
margin={{
top: 0,
right: 0,
bottom: -17,
left: 0
}}
>
<XAxis
type="category"
dataKey="date"
interval={0}
tick={false}
axisLine={false}
tickLine={false}
/>
<YAxis
type="number"
dataKey="y"
name={key}
height={0}
interval={0}
tick={false}
tickLine={false}
axisLine={false}
label={{ value: key === 'all' ? t('total') : key, position: 'insideLeft' }}
/>
<ZAxis
type="number"
name="infections"
dataKey={
chartScale === 'daily' ? 'infectionsDaily' : 'infections'
}
range={[0, 350]}
// @ts-ignore
domain={[0, chartScale === 'daily' ? 50 : 350]}
/>
<Tooltip
cursor={false}
wrapperStyle={{ zIndex: 100 }}
isAnimationActive={false}
content={(props: any) => (props.payload[0] &&
<TooltipWrapper role='tooltip'>
<h5>{format(
// @ts-ignore
utcToZonedTime(props.payload[0].value, 'Europe/Helsinki'),
'd.M.yyyy'
)}</h5>
<p className="label">{t('cases')}: {props.payload[2].value}</p>
</TooltipWrapper>
)}
/>
<Scatter
data={district.timeSeries.infectionDevelopmentData30Days.map(
(data: InfectionDevelopmentDataItem) => ({
...data,
y: 0
})
)}
fill="#f3858d"
/>
</ScatterChart>
</ResponsiveContainer>
);
})}
</Box>
</Block>
</Box>
);
};

export default BubbleChart;
98 changes: 1 addition & 97 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,102 +18,6 @@ const Header: React.FC = () => {
const { t } = useContext(UserContext);
return (
<Fragment>
<Head>
<link
rel="apple-touch-icon-precomposed"
sizes="57x57"
href="/images/apple-touch-icon-57x57.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="114x114"
href="/images/apple-touch-icon-114x114.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="72x72"
href="/images/apple-touch-icon-72x72.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="144x144"
href="/images/apple-touch-icon-144x144.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="60x60"
href="/images/apple-touch-icon-60x60.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="120x120"
href="/images/apple-touch-icon-120x120.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="76x76"
href="/images/apple-touch-icon-76x76.png"
/>
<link
rel="apple-touch-icon-precomposed"
sizes="152x152"
href="/images/apple-touch-icon-152x152.png"
/>
<link
rel="icon"
type="image/png"
href="/images/favicon-196x196.png"
sizes="196x196"
/>
<link
rel="icon"
type="image/png"
href="/images/favicon-96x96.png"
sizes="96x96"
/>
<link
rel="icon"
type="image/png"
href="/images/favicon-32x32.png"
sizes="32x32"
/>
<link
rel="icon"
type="image/png"
href="/images/favicon-16x16.png"
sizes="16x16"
/>
<link
rel="icon"
type="image/png"
href="/images/favicon-128.png"
sizes="128x128"
/>
<meta name="application-name" content="korona.kans.io" />
<meta name="msapplication-TileColor" content="#000000" />
<meta
name="msapplication-TileImage"
content="/images/mstile-144x144.png"
/>
<meta
name="msapplication-square70x70logo"
content="/images/mstile-70x70.png"
/>
<meta
name="msapplication-square150x150logo"
content="/images/mstile-150x150.png"
/>
<meta
name="msapplication-wide310x150logo"
content="/images/mstile-310x150.png"
/>
<meta
name="msapplication-square310x310logo"
content="/images/mstile-310x310.png"
/>
<meta name="apple-mobile-web-app-title" content="korona.kans.io" />
<meta name="apple-mobile-web-app-capable" content="yes" />
</Head>
<LanguageMenu />
<Box
p={[2, 4, 5]}
Expand All @@ -122,7 +26,7 @@ const Header: React.FC = () => {
>
<img
src="/images/corona-virus-small.png"
style={{ marginBottom: 0, marginLeft: 'auto', marginRight: 'auto', width: 90, borderWidth: 0 }}
style={{ marginBottom: 0, marginTop: 5, marginLeft: 'auto', marginRight: 'auto', width: 90, borderWidth: 0 }}
title="CDC/ Alissa Eckert, MS; Dan Higgins, MAM / Public domain"
alt="Kuvituskuva koronaviruksesta"
/>
Expand Down
16 changes: 2 additions & 14 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { ThemeProvider, theme, CSSReset } from '@chakra-ui/core';
import { Children } from 'react';

const customTheme = {
...theme,
fonts: {
...theme.fonts,
heading: 'Space Grotesk Regular, sans-serif',
body: 'Space Grotesk Regular, sans-serif',
mono: 'Space Mono, Menlo, monospace',
}
};


const Index: React.FC = props => (
<ThemeProvider theme={customTheme}>
<CSSReset />
<div style={{ flex: 1 }}>{props.children}</div>
</ThemeProvider>
<div style={{ flex: 1 }}>{props.children}</div>
);

export default Index;
2 changes: 1 addition & 1 deletion components/NetworkGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const NetworkGraph = ({ data }) => {
width: 2,
smooth: true,
},
height: "600px",
height: "468px",
nodes: {
// shape: "dot",
size: 30,
Expand Down
24 changes: 0 additions & 24 deletions components/TableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ export const infectionColumns = [
return value;
}
},
{
Header: 'Id',
accessor: 'id',
Cell: ({ cell }: any) => {
return `#0${cell.value}`;
}
},
{
Header: 'Päiväys',
accessor: 'date',
Expand All @@ -25,22 +18,5 @@ export const infectionColumns = [
{
Header: 'Sair.hoitopiiri',
accessor: 'healthCareDistrict'
},
{
Header: 'Maa',
accessor: 'infectionSourceCountry'
},
{
Header: 'Tartunnan lähde',
accessor: 'infectionSource',
Cell: ({ cell: { value } }: any) => {
if (value === 'unknown') {
return 'Ei tiedossa';
}
if (value === 'related to earlier') {
return 'Liittyy aiempaan';
}
return `#0${value}`;
}
}
];
Loading

0 comments on commit 6667a5f

Please sign in to comment.