Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes data issue with fao pie chart #3421

Merged
merged 1 commit into from
May 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createSelector } from 'reselect';
import isEmpty from 'lodash/isEmpty';
import { format } from 'd3-format';
import { getColorPalette } from 'utils/data';

// get list data
const getData = state => state.data || null;
Expand All @@ -16,31 +15,39 @@ export const parseData = createSelector(
if (isEmpty(data)) return null;
const {
area_ha,
extent,
planted_forest,
forest_primary,
forest_regenerated
} = data;
const colorRange = getColorPalette(colors.ramp, 3);
const nonForest =
area_ha - (forest_regenerated + forest_primary + planted_forest);
const colorRange = colors.ramp;
const otherCover =
extent - (forest_regenerated + forest_primary + planted_forest);
const nonForest = area_ha - extent;
return [
{
label: 'Naturally regenerated Forest',
label: 'Naturally Regenerated Forest',
value: forest_regenerated,
percentage: forest_regenerated / area_ha * 100,
color: colorRange[0]
color: colorRange[1]
},
{
label: 'Primary Forest',
value: forest_primary,
percentage: forest_primary / area_ha * 100,
color: colorRange[1]
color: colorRange[2]
},
{
label: 'Planted Forest',
value: planted_forest,
percentage: planted_forest / area_ha * 100,
color: colorRange[2]
color: colorRange[4]
},
{
label: 'Other Tree Cover',
value: otherCover,
percentage: otherCover / area_ha * 100,
color: colorRange[6]
},
{
label: 'Non-Forest',
Expand Down