Skip to content

Commit

Permalink
population styling
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhappy committed Mar 2, 2020
1 parent 3b0e26e commit 67e5403
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class App extends Component {
sillyData: [],
lastUpdate: "Updating...",
mode: "Light",
version: "v0.2-beta"
version: "v0.2-dev"
};

loadData = async () => {
Expand Down Expand Up @@ -102,7 +102,9 @@ class App extends Component {
/>
<Route
path="/pop"
render={props => <Population popData={this.state.popData} />}
render={props => (
<Population popData={this.state.popData} single={true} />
)}
/>
<Route
path="/silly"
Expand Down
22 changes: 13 additions & 9 deletions src/components/Population.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ import { Doughnut } from "react-chartjs-2";
import AnimatedNumber from "react-animated-number";

class Population extends Component {
getPopulationData(arg) {
getTotalPopulationData(arg) {
// first we need to get the data
const { popData } = this.props;
// if we're still loading, slap a huge loading for everything
if (popData.totalPopulation === undefined) {
return 0;
}

// send total pop if it's total
if (arg === "total") {
return popData.totalPopulation;
}

// send the district's data
return popData.populationByDistrict[arg];
return popData.totalPopulation;
}

getPopulationChartData() {
Expand Down Expand Up @@ -113,13 +107,22 @@ class Population extends Component {
formatValue = value => value.toFixed(0);
duration = 500;

styling() {
switch (this.props.single) {
case true:
return 135;
default:
return 130;
}
}

render() {
return (
<div>
<h1>Current Population</h1>
<h4>
<AnimatedNumber
value={this.getPopulationData("total")}
value={this.getTotalPopulationData()}
formatValue={this.formatValue}
duration={this.duration}
/>{" "}
Expand All @@ -135,6 +138,7 @@ class Population extends Component {
boxWidth: 20
}
}}
height={this.styling()}
options={{
tooltips: {
mode: "nearest",
Expand Down

0 comments on commit 67e5403

Please sign in to comment.