Skip to content

Commit

Permalink
Removal of growth curves from cumulative graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaiau committed Apr 17, 2020
1 parent 6936c34 commit 510c31e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 145 deletions.
100 changes: 0 additions & 100 deletions client/src/components/cumulative-graph/cumulative-graph-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,101 +18,6 @@ export default class CumulativeGraphContainer extends React.Component{
max_area_count: props.max_area_count || 30,
scale: 'log',

growth: {
label: "Doubles every 3 days",
value: 1.25992105
},
growth_options: [
{
label: "Doubles every day",
value: 2.00
},
{
label: "Doubles every 2 days",
value: 1.414213562
},
{
label: "Doubles every 3 days",
value: 1.25992105
},
{
label: "Doubles every 4 days",
value: 1.189207115
},
{
label: "Doubles every 5 days",
value: 1.148698355
},
{
label: "Doubles every 6 days",
value: 1.122462048
},
{
label: "Doubles every week",
value: 1.104089514
},
{
label: "Doubles every fortnight",
value: 1.050756639
},
{
label: "5% Daily Growth",
value: 1.05
},
{
label: "10% Daily Growth",
value: 1.1
},

{
label: "20% Daily Growth",
value: 1.2
},
{
label: "25% Daily Growth",
value: 1.25
},
{
label: "30% Daily Growth",
value: 1.3
},
{
label: "33% Daily Growth",
value: 1.33
},
{
label: "35% Daily Growth",
value: 1.35
},
{
label: "40% Daily Growth",
value: 1.4
},
{
label: "50% Daily Growth",
value: 1.5
},
{
label: "60% Daily Growth",
value: 1.6
},
{
label: "70% Daily Growth",
value: 1.7
},
{
label: "80% Daily Growth",
value: 1.8
},
{
label: "90% Daily Growth",
value: 1.9
},
{
label: "100% Daily Growth",
value: 2.0
},
]


}
Expand Down Expand Up @@ -188,16 +93,12 @@ export default class CumulativeGraphContainer extends React.Component{

accumulateFrom={this.state.accumulateFrom}
accumulateOptions={this.props.accumulateOptions}

growth={this.state.growth}
growth_options={this.state.growth_options}
show_all_areas={this.state.show_all_areas}
scaleFn={e => {this.setState({scale: e.target.value})}}
checkFn={e => this.areaChecked(e.target.value) }
clearFn={e => this.setState({checkedAreas: []})}
allFn={ (areas) => this.setState({checkedAreas: areas.map(a => a.name)})}
caseFn={e => {this.setState({accumulateFrom: e.target.value})}}
growthFn={e => this.setState({growth: this.state.growth_options.find(g => e.target.value == g.value)}) }
maxCountFn={e => this.setState({show_all_areas: ! this.state.show_all_areas})}
/>

Expand All @@ -215,7 +116,6 @@ export default class CumulativeGraphContainer extends React.Component{
accumulateFrom={this.state.accumulateFrom}
max_area_count={this.state.max_area_count}
show_all_areas={this.state.show_all_areas}
growth={this.state.growth}
areas_to_graph={this.state.checkedAreas}/>
</div>
</GraphContainer>
Expand Down
35 changes: 3 additions & 32 deletions client/src/components/cumulative-graph/cumulative-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const CumulativeGraph = ({
areas_to_graph = [],
field = 'confirmed',
max_days = 30,
growth = {
label: "Doubles every 3 days",
value: 1.25992105
},
scale="log",
accumulateFrom

Expand Down Expand Up @@ -84,24 +80,7 @@ const CumulativeGraph = ({



// Make one big array of objects
if(areas_to_graph.length > 0){
for(let i = 0; i < max_days; i++){
if(i == 0){
if(typeof ready_to_graph[i] != 'undefined')
ready_to_graph[i][growth.label] = accumulateFrom
}
else if(typeof ready_to_graph[i] != 'undefined')
ready_to_graph[i][growth.label] = (ready_to_graph[i - 1][growth.label] * growth.value).toFixed(0)

}
}
else{
ready_to_graph.push({})
for(let i = 0; i < max_days; i++){
ready_to_graph[0].num_day = i
}
}



if(areas_to_graph.length == 0) return (
Expand All @@ -123,7 +102,7 @@ const CumulativeGraph = ({
<Label value={`Days since ${accumulateFrom}th ${field == 'confirmed' ? 'case': 'death'}`} offset={5} position="bottom" />
</XAxis>
{Object.keys(ready_to_graph[0])
.filter(key => key != 'num_day' && key != growth.label)
.filter(key => key != 'num_day')
.map( (key, i) => {
return <Line
type="monotone"
Expand All @@ -135,15 +114,7 @@ const CumulativeGraph = ({
isAnimationActive={false}
/>
})
}

{
areas_to_graph.length > 0 ? (
<Line type="monotone" stroke='#aaa'
dataKey={growth.label} strokeOpacity={0.25} dot={false} strokeWidth={3} isAnimationActive={false}/>
): <></>
}

}
<Tooltip content={CumulativeGraphTooltip}/>
<Legend align="right" verticalAlign="middle" layout="vertical" iconType="square"/>

Expand Down
13 changes: 0 additions & 13 deletions client/src/components/cumulative-graph/graph-options-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const GraphOptionsSideBar = ({
scale,
accumulateFrom,
accumulateOptions,
growth,
growth_options,

scaleFn, // Callback for linear / log
caseFn,
checkFn, // Callback for country select or non
Expand Down Expand Up @@ -90,16 +87,6 @@ const GraphOptionsSideBar = ({
</div>
</div>
</div>
<div className="field ">
<label className="label">{field == 'confirmed' ? 'Case' : 'Death'} {growth.label.includes('%') ? 'daily growth' :'doubling rate'}</label>
<div className="control">
<div className="select">
<select value={growth.value} onChange={growthFn}>
{ growth_options.map( (option, i) => <option key={i} value={option.value}>{option.label}</option>) }
</select>
</div>
</div>
</div>
<div className="field">
<label className="label">
{type_of_area == 'country' ?
Expand Down

0 comments on commit 510c31e

Please sign in to comment.