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

Global Land Cover Widget: fix pie chart #3492

Merged
merged 4 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
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
Expand Up @@ -5,8 +5,8 @@ export default {
config: {
size: 'small',
categories: ['land-cover'],
admins: ['country', 'region', 'subRegion'],
selectors: ['years'],
admins: ['country', 'region'],
selectors: [],
years: [2015],
type: 'plantations',
metaKey: 'widget_global_land_cover',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export const parseData = createSelector(
const dataParsed = dataMerged.filter(el => el.value !== 0).map(el => ({
...el,
percentage: 100 * el.value / total,
area_ha: el.value * 300 * 300 / 1e4,
value: el.value * 300 * 300 / 1e4,
color: colors.categories[el.label]
}));
return sortByKey(dataParsed.filter(d => d !== null), 'area_ha', true);
return sortByKey(dataParsed.filter(d => d !== null), 'value', true);
}
);

Expand All @@ -57,12 +57,12 @@ export const getSentence = createSelector(
if (isEmpty(data) || !sentences) return null;
const { initial } = sentences;
const { year } = settings;
const { label, area_ha } = data[0];
const { label, value } = data[0];
const params = {
location: currentLabel,
year,
category: label,
extent: `${format('.3s')(area_ha)}ha`
extent: `${format('.3s')(value)}ha`
};
return {
sentence: initial,
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/services/forest-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const CARTO_REQUEST_URL = `${process.env.CARTO_API}/sql?q=`;

const SQL_QUERIES = {
extent:
"SELECT SUM({extentYear}) as value, SUM(area_gadm28) as total_area FROM data WHERE {location} thresh = {threshold} AND polyname = '{indicator}'",
"SELECT SUM({extentYear}) as value, SUM(area_gadm28) as total_area FROM data WHERE {location} AND thresh = {threshold} AND polyname = '{indicator}'",
plantationsExtent:
"SELECT SUM(area_poly_aoi) AS plantation_extent, {admin} AS region, {bound} AS label FROM data WHERE {location} thresh = 0 AND polyname = 'plantations' GROUP BY {type} ORDER BY plantation_extent DESC",
multiRegionExtent:
Expand Down