Skip to content

Commit

Permalink
Set is loading for chart container skeleton from hurumap-ui CodeForAf…
Browse files Browse the repository at this point in the history
  • Loading branch information
karimkawambwa committed Aug 21, 2019
1 parent 224b883 commit 066c436
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/pages/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ function Profile({
} = useContext(AppContext);
const head2head = Boolean(geoId && comparisonGeoId);
const [activeTab, setActiveTab] = useState('All');
const [chartData, setChartsData] = useState({});
const [chartData, setChartsData] = useState({
isLoading: true
});
const [profiles, setProfiles] = useState({
profile: {},
parentProfile: {},
Expand Down Expand Up @@ -131,6 +133,7 @@ query charts($geoCode: String!, $geoLevel: String!) {
}

setChartsData({
isLoading: false,
profileVisualsData,
comparisonVisualsData
});
Expand Down Expand Up @@ -267,8 +270,9 @@ query charts($geoCode: String!, $geoLevel: String!) {
/* data is not missing */
!v.find(
x =>
!chartData.profileVisualsData ||
chartData.profileVisualsData[x.id].nodes.length === 0
(!chartData.profileVisualsData ||
chartData.profileVisualsData[x.id].nodes.length === 0) &&
!chartData.isLoading
)
)
.map(chart => (
Expand All @@ -280,6 +284,7 @@ query charts($geoCode: String!, $geoLevel: String!) {
}
>
<ChartContainer
loading={chartData.isLoading}
overflowX={
chart.visuals.find(visual => visual.type === 'pie')
? 'visible'
Expand All @@ -297,16 +302,17 @@ query charts($geoCode: String!, $geoLevel: String!) {
title={chart.title}
subtitle={chart.subtitle}
>
{chart.visuals.map(
visual =>
profiles.loaded &&
ChartFactory.build(
visual,
chartData.profileVisualsData,
chartData.comparisonVisualsData,
profiles
)
)}
{!chartData.isLoading &&
chart.visuals.map(
visual =>
profiles.loaded &&
ChartFactory.build(
visual,
chartData.profileVisualsData,
chartData.comparisonVisualsData,
profiles
)
)}
</ChartContainer>
</Grid>
))}
Expand Down

0 comments on commit 066c436

Please sign in to comment.