Skip to content

Commit 8955584

Browse files
authored
Merge pull request #3448 from Vizzuality/feature/consistent-colours
Standardised extent pallet
2 parents 5f5c000 + fc350fe commit 8955584

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

app/javascript/components/widgets/widgets/land-cover/fao-cover/selectors.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const parseData = createSelector(
2020
forest_primary,
2121
forest_regenerated
2222
} = data;
23-
const colorRange = colors.ramp;
2423
const otherCover =
2524
extent - (forest_regenerated + forest_primary + planted_forest);
2625
const nonForest = area_ha - extent;
@@ -29,25 +28,25 @@ export const parseData = createSelector(
2928
label: 'Naturally Regenerated Forest',
3029
value: forest_regenerated,
3130
percentage: forest_regenerated / area_ha * 100,
32-
color: colorRange[1]
31+
color: colors.naturalForest
3332
},
3433
{
3534
label: 'Primary Forest',
3635
value: forest_primary || 0,
3736
percentage: forest_primary / area_ha * 100 || 0,
38-
color: colorRange[2]
37+
color: colors.primaryForest
3938
},
4039
{
4140
label: 'Planted Forest',
4241
value: planted_forest || 0,
4342
percentage: planted_forest / area_ha * 100 || 0,
44-
color: colorRange[4]
43+
color: colors.plantedForest
4544
},
4645
{
4746
label: 'Other Tree Cover',
4847
value: otherCover > 0 ? otherCover : 0,
4948
percentage: otherCover / area_ha * 100,
50-
color: colorRange[6]
49+
color: colors.otherCover
5150
},
5251
{
5352
label: 'Non-Forest',

app/javascript/components/widgets/widgets/land-cover/intact-tree-cover/selectors.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createSelector } from 'reselect';
22
import isEmpty from 'lodash/isEmpty';
3-
import { getColorPalette } from 'utils/data';
43
import { format } from 'd3-format';
54

65
// get list data
@@ -17,18 +16,17 @@ export const parseData = createSelector(
1716
(data, settings, colors) => {
1817
if (isEmpty(data)) return null;
1918
const { totalArea, totalExtent, extent } = data;
20-
const colorRange = getColorPalette(colors.ramp, 2);
2119
const parsedData = [
2220
{
2321
label: 'Intact Forest',
2422
value: extent,
25-
color: colorRange[0],
23+
color: colors.intactForest,
2624
percentage: extent / totalArea * 100
2725
},
2826
{
2927
label: 'Other Tree Cover',
3028
value: totalExtent - extent,
31-
color: colorRange[1],
29+
color: colors.otherCover,
3230
percentage: (totalExtent - extent) / totalArea * 100
3331
},
3432
{

app/javascript/components/widgets/widgets/land-cover/primary-forest/selectors.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createSelector } from 'reselect';
22
import isEmpty from 'lodash/isEmpty';
3-
import { getColorPalette } from 'utils/data';
43
import { format } from 'd3-format';
54

65
// get list data
@@ -17,19 +16,18 @@ export const parseData = createSelector(
1716
(data, settings, colors) => {
1817
if (isEmpty(data)) return null;
1918
const { totalArea, totalExtent, extent } = data;
20-
const colorRange = getColorPalette(colors.ramp, 2);
2119
const secondaryExtent = totalExtent - extent < 0 ? 0 : totalExtent - extent;
2220
const parsedData = [
2321
{
2422
label: 'Primary Forest',
2523
value: extent,
26-
color: colorRange[0],
24+
color: colors.primaryForest,
2725
percentage: extent / totalArea * 100
2826
},
2927
{
3028
label: 'Other Tree Cover',
3129
value: secondaryExtent,
32-
color: colorRange[1],
30+
color: colors.otherCover,
3331
percentage: secondaryExtent / totalArea * 100
3432
},
3533
{

app/javascript/components/widgets/widgets/land-cover/tree-cover/selectors.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createSelector } from 'reselect';
22
import isEmpty from 'lodash/isEmpty';
3-
import { getColorPalette } from 'utils/data';
43
import { format } from 'd3-format';
54

65
// get list data
@@ -22,12 +21,11 @@ export const parseData = createSelector(
2221
const hasPlantations =
2322
(currentLabel !== 'global' && isEmpty(whitelist)) ||
2423
whitelist.indexOf('plantations') > -1;
25-
const colorRange = getColorPalette(colors.ramp, hasPlantations ? 2 : 1);
2624
const parsedData = [
2725
{
2826
label: hasPlantations && !indicator ? 'Natural Forest' : 'Tree cover',
2927
value: cover - plantations,
30-
color: colorRange[0],
28+
color: colors.naturalForest,
3129
percentage: (cover - plantations) / totalArea * 100
3230
},
3331
{
@@ -41,7 +39,7 @@ export const parseData = createSelector(
4139
parsedData.splice(1, 0, {
4240
label: 'Plantations',
4341
value: plantations,
44-
color: colorRange[1],
42+
color: colors.plantedForest,
4543
percentage: plantations / totalArea * 100
4644
});
4745
}

app/javascript/data/colors.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"extent": {
33
"main": "#a0c746",
4-
"ramp": ["#364a08", "#506917", "#6b8729", "#84a637", "#a0c746", "#b8d86d", "#c7e67c", "#d2f189", "#dff7a6"],
4+
"ramp": ["#364a08", "#42590E", "#506917", "#6b8729", "#84a637", "#a0c746", "#b8d86d", "#c7e67c", "#d2f189", "#dff7a6"],
5+
"naturalForest": "#506917",
6+
"intactForest": "#6b8729",
7+
"primaryForest": "#84a637",
8+
"plantedForest": "#a0c746",
9+
"otherCover": "#c7e67c",
510
"nonForest": "#e7e5a4"
611
},
712
"loss": {

0 commit comments

Comments
 (0)