Skip to content

Commit

Permalink
add statistics page
Browse files Browse the repository at this point in the history
Add statistics page with first set of statistics on citation trends and
simulation engines.

Also, update symbols for licenses.
  • Loading branch information
ltalirz committed Jan 18, 2021
1 parent 6f26e2e commit e1d2219
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { HashRouter as Router, Route } from 'react-router-dom';
import useStyles from './components/Dashboard/Styles';
import Table from './components/Table';
import About from './components/About';
import Statistics from './components/Statistics';
import SingleChart from './components/Chart/single';

function Copyright() {
Expand Down Expand Up @@ -97,6 +98,7 @@ export default function Dashboard() {
<Route exact path="/table" component={Table} />
<Route exact path="/charts/:code" component={SingleChart} />
<Route exact path="/about" component={About} />
<Route exact path="/stats" component={Statistics} />
{/* { </Container>} */}
</Router>
<Box pt={4}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Home() {
<Paper className={classes.paper}>
<React.Fragment>
<Title>About</Title>
<Typography component="p" variant="body1">
<Typography component="div" variant="body1">
<ReactMarkdown source={aboutMD} />
</Typography>
</React.Fragment>
Expand All @@ -47,7 +47,7 @@ export default function Home() {
<Paper className={classes.paper}>
<React.Fragment>
<Title>Acknowledgements</Title>
<Typography component="p" variant="body1">
<Typography component="div" variant="body1">
<ReactMarkdown source={acknowledgementsMD} />
</Typography>
</React.Fragment>
Expand Down
14 changes: 8 additions & 6 deletions src/components/Columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import AttachMoneyIcon from '@material-ui/icons/AttachMoney';
import SchoolIcon from '@material-ui/icons/School';
import LockOpenIcon from '@material-ui/icons/LockOpen';

import NotInterestedIcon from '@material-ui/icons/NotInterested';
//import NotInterestedIcon from '@material-ui/icons/NotInterested';
import ContactMailIcon from '@material-ui/icons/ContactMail';
import CopyrightIcon from '@material-ui/icons/Copyright';
//import CopyrightIcon from '@material-ui/icons/Copyright';
import LockIcon from '@material-ui/icons/Lock';
import NoEncryptionIcon from '@material-ui/icons/NoEncryption';

function TooltipText(tooltip, text) {
/**
Expand Down Expand Up @@ -99,13 +101,13 @@ function getColumns(data, year) {
"customBodyRenderLite": (dataIndex) => {
const x = data[dataIndex]['license'];
if (['C', 'C(S)', 'F(A)'].includes(x)) {
return TooltipText(licenses[x], [<CopyrightIcon />]);
return TooltipText(licenses[x], [<LockOpenIcon color={'action'} />]);
} else if (['C(C)'].includes(x)) {
return TooltipText(licenses[x], [<NotInterestedIcon />]);
return TooltipText(licenses[x], [<LockIcon color={'action'} />]);
} else if (['OS(P)', 'OS(CL)'].includes(x)) {
return TooltipText(licenses[x], [<LockOpenIcon color={'action'} />]);
return TooltipText(licenses[x], [<NoEncryptionIcon color={'action'} />]);
} else if (['F'].includes(x)) {
return TooltipText(licenses[x], [<span><CopyrightIcon /></span>]);
return TooltipText(licenses[x], [<span><NoEncryptionIcon color={'action'} /></span>]);
} else {
return TooltipText(licenses[x], x);
}
Expand Down
20 changes: 18 additions & 2 deletions src/components/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ import citations from '../data/citations.json'
import codes from '../data/codes.json'

function yearToRange(year) {
/**
* Transform year to year range used in citations.json
*
* E.g. 2020 => "2020-2020"
*/
return year.toString() + '-' + year.toString();
}

function rangeToYear(range) {
/**
* Transform year range used in citations.json to year
*
* E.g. "2020-2020" => 2020
*/
return parseInt(range.split('-')[0]);
}

Expand All @@ -24,6 +34,9 @@ for (const codename in codes){
}

function getData(year) {
/**
* Get data for code table for a given year.
*/
let range_key = yearToRange(year);
let citations_data = citations[range_key]['citations'];
let data = codes; //.slice();
Expand All @@ -34,12 +47,15 @@ function getData(year) {

let dataArray = [];
for (const codename in data) {
dataArray.push(data[codename]);
dataArray.push(Object.assign({}, data[codename]));
}
return dataArray;
}

function getDataChart(){
/**
* Get citation data for all codes
*/
let lines = [];
for(const codeName of CODES.slice(0,50)){
lines.push({ 'id': codeName, 'data': getCodeCitations(codeName)});
Expand All @@ -64,4 +80,4 @@ function getCodeCitations(codeName){
return line_data;
}

export {yearToRange, rangeToYear, YEARS, getData, getDataChart, getCodeCitations};
export {yearToRange, rangeToYear, YEARS, CODES, getData, getDataChart, getCodeCitations};
7 changes: 7 additions & 0 deletions src/components/Dashboard/listItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import InfoIcon from '@material-ui/icons/Info';
// import HomeIcon from '@material-ui/icons/Home';
import EqualizerIcon from '@material-ui/icons/Equalizer';
import TableChartIcon from '@material-ui/icons/TableChart';

export const mainListItems = (
Expand All @@ -20,6 +21,12 @@ export const mainListItems = (
</ListItemIcon>
<ListItemText primary="Table" />
</ListItem>
<ListItem button component={"a"} href={'#/stats'}>
<ListItemIcon>
<EqualizerIcon />
</ListItemIcon>
<ListItemText primary="Statistics" />
</ListItem>
<ListItem button component={"a"} href={'#/about'}>
<ListItemIcon>
<InfoIcon />
Expand Down
134 changes: 134 additions & 0 deletions src/components/Statistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';

import useStyles from './Dashboard/Styles';
import Title from './Dashboard/Title';
import { YEARS, getData } from './Config';
// import { Card } from '@material-ui/core';

function citationGrowth(year) {
/**
* Compute citation growth for given year with respect to previous one.
*/

const dataNew = getData(year);
const dataOld = getData(year - 1);

let data = { 'total': [], 'absoluteGrowth': [], 'relativeGrowth': [] , 'typeCounts': [] };
let delta = 0;
let codeName = '';

dataNew.forEach((dNew, index) => {
codeName = dNew['name'];
delta = dNew['citations'] - dataOld[index]['citations'];
data['absoluteGrowth'].push([codeName, delta]);
data['total'].push([codeName, dNew['citations']]);

if (dataNew[index]['citations'] < 100) {
// We require at least 100 citations for analyzing growth
data['relativeGrowth'].push([codeName, 0]);
} else {
const factor = delta / parseFloat(dataOld[index]['citations']);
data['relativeGrowth'].push([codeName, factor]);
}

// add code count to
for (const type of dNew['types']){
if (type in data['typeCounts']) {
data['typeCounts'][type] += 1;
} else {
data['typeCounts'][type] = 1;
}
}
})

data['absoluteGrowth'].sort((a, b) => {
return a[1] - b[1];
}).reverse();
data['relativeGrowth'].sort((a, b) => {
return a[1] - b[1];
}).reverse();
data['total'].sort((a, b) => {
return a[1] - b[1];
}).reverse();

return data;

}

function totalList(data) {
return (
<Typography component="div" variant="subtitle1">
<ol>
{data.map(line => <li>{line[0] + ": " + line[1] + "\n"}</li>)}
</ol>
</Typography>
);
}

function absoluteGrowthList(data) {
return (
<Typography component="div" variant="subtitle1">
<ol>
{data.map(line => <li>{line[0] + ": +" + line[1] + "\n"}</li>)}
</ol>
</Typography>
);
}

function relativeGrowthList(data) {
return (
<Typography component="div" variant="subtitle1">
<ol>
{data.map(line => <li>{line[0] + ": +" + parseInt(line[1] * 100) + "%\n"}</li>)}
</ol>
</Typography>
);
}

function typeList(data) {
return (
<Typography component="div" variant="subtitle1">
<ul>
{Object.entries(data).map(( [k,v]) => <li>{k + ": " + v + "\n"}</li>)}
</ul>
</Typography>
);
}

function Card(title, message, footnote="", size) {
const classes = useStyles();
return ([
<Grid item xs={size}>
<Paper className={classes.paper}>
<React.Fragment>
<Title>{title}</Title>
{message}
<Typography color="textSecondary" className={classes.depositContext}>
{footnote}
</Typography>
</React.Fragment>
</Paper>
</Grid>

]);
}

let CURRENT_YEAR = YEARS.slice(-1)[0];
let GROWTH = citationGrowth(CURRENT_YEAR);

export default function Home() {
return (
<Grid container spacing={3}>
{Card("Simulation engines", typeList(GROWTH['typeCounts']), "Number of simulation engines per method.", 4)}
{Card("Top cited", totalList(GROWTH['total'].slice(0, 5)),
"In " + CURRENT_YEAR +".", 4)}
{Card("Top citation growth", absoluteGrowthList(GROWTH['absoluteGrowth'].slice(0, 5)),
"In " + CURRENT_YEAR +" with respect to "+ (CURRENT_YEAR-1) + ".", 4)}
{Card("Top relative citation growth", relativeGrowthList(GROWTH['relativeGrowth'].slice(0, 5)),
"In " + CURRENT_YEAR +" with respect to "+ (CURRENT_YEAR-1) + ", considering only codes with >100 citations.",
4)}
</Grid>);
}
2 changes: 1 addition & 1 deletion src/data/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
"tags": [],
"types": [
"DFT",
"HF"
"WFM"
]
},
"LAMMPS": {
Expand Down

0 comments on commit e1d2219

Please sign in to comment.