Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Added Few Charts
Browse files Browse the repository at this point in the history
  • Loading branch information
s-naveen committed Apr 6, 2020
1 parent e8d5f69 commit 4f50e48
Show file tree
Hide file tree
Showing 13 changed files with 1,171 additions and 7 deletions.
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
"homepage": "http://covid19india.github.io/",
"dependencies": {
"axios": "^0.19.2",
"chart.js": "^2.9.3",
"d3": "^5.15.0",
"d3-svg-legend": "^2.25.6",
"date-fns": "^2.11.0",
"install": "^0.13.0",
"json2csv": "^5.0.0",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
"npm": "^6.14.3",
"react": "^16.13.1",
"react-chartjs-2": "^2.9.0",
"react-dom": "^16.13.1",
"react-feather": "^2.0.3",
"react-router-dom": "^5.1.2",
Expand Down
14 changes: 7 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Navbar from './components/navbar';
import Links from './components/links';
import FAQ from './components/faq';
import Banner from './components/banner';
/* import PatientDB from './components/patientdb';*/
import DeepDive from './components/deepdive';

const history = require('history').createBrowserHistory;

Expand All @@ -26,12 +26,12 @@ function App() {
displayName: 'Home',
animationDelayForNavbar: 0.2,
},
/* {
pageLink: '/database',
view: PatientDB,
displayName: 'Patients DB',
animationDelayForNavbar: 0.3,
},*/
{
pageLink: '/deepdive',
view: DeepDive,
displayName: 'Deep Dive',
animationDelayForNavbar: 0.4,
},
{
pageLink: '/links',
view: Links,
Expand Down
49 changes: 49 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,45 @@ select {
}
}

.cards-container {
padding: 4rem;
.cards {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.card {
margin-bottom: 2em;
flex: 0 1 calc(33% - 1em);
box-shadow: rgba(#000, 0.2) 0 0 8px 0;
&:hover {
box-shadow: rgba(#000, 0.3) 0 0 8px 0;
}
height: 30rem;
.charts-header {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
.chart-title {
font-family: 'archia';
font-size: 1.5rem !important;
color: #6c757d;
font-weight: 900;
text-transform: uppercase;
padding: 20px 0 20px 0;
}

.chart-content {
height: 100%;
width: 100%;
}
}
}
}
}


@media (max-width: 769px) {
.TimeSeries,
table,
Expand Down Expand Up @@ -2254,6 +2293,16 @@ select {
}
}

.cards-container {
padding: 1rem;
.cards {
.card {
flex: 0 1 calc(100%);
}
}
}


.PatientsDB {
width: 100%;

Expand Down
130 changes: 130 additions & 0 deletions src/components/Charts/agechart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import React from 'react';
import {Bar, defaults} from 'react-chartjs-2';

function AgeChart(props) {
defaults.global.tooltips.intersect = false;
defaults.global.tooltips.mode = 'nearest';
defaults.global.tooltips.position = 'average';
defaults.global.tooltips.backgroundColor = 'rgba(255, 255, 255, 0.8)';
defaults.global.tooltips.displayColors = false;
defaults.global.tooltips.borderColor = '#c62828';
defaults.global.tooltips.borderWidth = 1;
defaults.global.tooltips.titleFontColor = '#000';
defaults.global.tooltips.bodyFontColor = '#000';
defaults.global.tooltips.caretPadding = 4;
defaults.global.tooltips.intersect = false;
defaults.global.tooltips.mode = 'nearest';
defaults.global.tooltips.position = 'nearest';

defaults.global.legend.display = true;
defaults.global.legend.position = 'bottom';

defaults.global.hover.intersect = false;

const ages = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

if (!props.data || props.data.length === 0) {
return <div></div>;
}

props.data.forEach((patient) => {
if (patient.agebracket) {
const age = parseInt(patient.agebracket);
if (age >= 0 && age <= 10) {
ages[0]++;
}
if (age > 10 && age <= 20) {
ages[1]++;
}
if (age > 20 && age <= 30) {
ages[2]++;
}
if (age > 30 && age <= 40) {
ages[3]++;
}
if (age > 40 && age <= 50) {
ages[4]++;
}
if (age > 50 && age <= 60) {
ages[5]++;
}
if (age > 60 && age <= 70) {
ages[6]++;
}
if (age > 70 && age <= 80) {
ages[7]++;
}
if (age > 80 && age <= 90) {
ages[8]++;
}
if (age > 90 && age <= 100) {
ages[9]++;
}
}
});

const chartData = {
labels: [
'0-10',
'11-20',
'21-30',
'31-40',
'41-50',
'51-60',
'61-70',
'71-80',
'81-90',
'91-100',
],
datasets: [
{
data: ages,
label: 'Cases',
backgroundColor: '#ff073a',
},
],
};

const chartOptions = {
events: ['mousemove', 'mouseout', 'touchstart', 'touchmove', 'touchend'],
responsive: true,
maintainAspectRatio: false,
legend: {
display: false,
},
layout: {
padding: {
left: 20,
right: 20,
top: 20,
bottom: 20,
},
},
scales: {
xAxes: [
{
stacked: true,
gridLines: {
color: 'rgba(0, 0, 0, 0)',
},
},
],
yAxes: [
{
stacked: true,
},
],
},
};

return (
<div className="charts-header">
<div className="chart-title">{props.title}</div>
<div className="chart-content doughnut">
<Bar data={chartData} options={chartOptions} />
</div>
</div>
);
}

export default AgeChart;

0 comments on commit 4f50e48

Please sign in to comment.