-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from cartologic/development
Fix COVID-19 statistics graphs not shown
- Loading branch information
Showing
3 changed files
with
49 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,65 @@ | ||
import React, { Component } from "react"; | ||
import axois from "axios"; | ||
import React, { useState, useEffect } from "react"; | ||
import axios from "axios"; | ||
import Loader from "react-loader-spinner"; | ||
import BarChart from "./BarChart/BarChart"; | ||
import classes from "./BarChartViewer.module.css"; | ||
import config from "../../configurations/config.json"; | ||
|
||
class BarChartViewer extends Component { | ||
constructor(props) { | ||
super(props); | ||
const BarChartViewer = props => { | ||
const [saudiData, setSaudiData] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
this.state = { | ||
saudiData: [], | ||
loading: true, | ||
useEffect(() => { | ||
const requestParams = { | ||
srsName: "EPSG:3857", | ||
outputFormat: "json", | ||
service: "WFS", | ||
srs: "EPSG:3857", | ||
request: "GetFeature", | ||
version: "1.0.0" | ||
}; | ||
} | ||
const { covidHostedView } = config && config.layersNames; | ||
|
||
componentDidMount() { | ||
axois | ||
.get( | ||
"http://mapsaudi.com/geoserver/ows?srsName=EPSG%3A3857&outputFormat=json&service=WFS&srs=EPSG%3A3857&request=GetFeature&typename=geonode%3Ahostedview&version=1.0.0" | ||
) | ||
.then((response) => { | ||
this.setState({ | ||
saudiData: response.data.features, | ||
loading: false, | ||
}); | ||
axios | ||
.get(`${config.SiteURL}/geoserver/ows`, { | ||
params: { | ||
...requestParams, | ||
typename: covidHostedView | ||
} | ||
}) | ||
.then(response => { | ||
setSaudiData(response.data.features); | ||
setLoading(false); | ||
}); | ||
} | ||
}, []); | ||
|
||
render() { | ||
const { saudiData, loading } = this.state; | ||
return ( | ||
<div className={classes.BarChartLayout}> | ||
{!loading ? ( | ||
return ( | ||
<div className={classes.BarChartLayout}> | ||
{ | ||
!loading ? ( | ||
<div className={classes.BarChart}> | ||
<BarChart | ||
data={saudiData} | ||
regionName={this.props.regionName} | ||
caseType="Confirmed" | ||
regionName={props.regionName} | ||
caseType="confirmed" | ||
/> | ||
<BarChart | ||
data={saudiData} | ||
regionName={this.props.regionName} | ||
caseType="Deaths" | ||
regionName={props.regionName} | ||
caseType="deaths" | ||
/> | ||
<BarChart | ||
data={saudiData} | ||
regionName={this.props.regionName} | ||
caseType="Tested" | ||
regionName={props.regionName} | ||
caseType="tested" | ||
/> | ||
</div> | ||
) : ( | ||
<Loader type="Oval" color="#4BAE53" height={50} width={50} /> | ||
)} | ||
</div> | ||
); | ||
} | ||
} | ||
) | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BarChartViewer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters