Skip to content

Commit 30b5add

Browse files
authored
Merge pull request #3480 from Vizzuality/feature/remove-agriculture
feature/remove-agriculture
2 parents 7b902ec + 127ae60 commit 30b5add

File tree

1 file changed

+5
-37
lines changed
  • app/javascript/components/widgets/widgets/climate/emissions

1 file changed

+5
-37
lines changed

app/javascript/components/widgets/widgets/climate/emissions/selectors.js

+5-37
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { format } from 'd3-format';
44
import { formatNumber } from 'utils/format';
55
import { getColorPalette } from 'utils/data';
66

7-
const EMISSIONS_KEYS = [
8-
'Total including LUCF',
9-
'Land-Use Change and Forestry',
10-
'Agriculture'
11-
];
7+
const EMISSIONS_KEYS = ['Total including LUCF', 'Land-Use Change and Forestry'];
128

139
// get list data
1410
const getData = state => state.data || null;
@@ -42,14 +38,11 @@ export const parseData = createSelector([getSortedData], sortedData => {
4238
const chartData = [];
4339
data[0].emissions.forEach((item, i) => {
4440
const e1Value = item.value;
45-
const e2Value = data[1].emissions[i].value;
4641
const totalEmissions = total.emissions[i].value;
4742
chartData.push({
4843
year: item.year,
4944
e1Value,
5045
e1Percentage: e1Value / totalEmissions * 100,
51-
e2Value,
52-
e2Percentage: e2Value / totalEmissions * 100,
5346
total: totalEmissions
5447
});
5548
});
@@ -74,15 +67,6 @@ export const parseConfig = createSelector(
7467
background: false,
7568
activeDot: false,
7669
stackId: 1
77-
},
78-
e2Value: {
79-
fill: colorRange[1],
80-
stroke: colorRange[1],
81-
opacity: 1,
82-
strokeWidth: 0,
83-
background: false,
84-
activeDot: false,
85-
stackId: 1
8670
}
8771
}
8872
},
@@ -99,15 +83,8 @@ export const parseConfig = createSelector(
9983
},
10084
{
10185
key: 'e1Percentage',
102-
label: 'Agriculture',
103-
color: colorRange[0],
104-
unit: '%',
105-
unitFormat: value => format('.1f')(value)
106-
},
107-
{
108-
key: 'e2Percentage',
10986
label: 'Land-Use Change and Forestry',
110-
color: colorRange[1],
87+
color: colorRange[0],
11188
unit: '%',
11289
unitFormat: value => format('.1f')(value)
11390
}
@@ -122,18 +99,9 @@ export const getSentence = createSelector(
12299
if (!sortedData || !sortedData.data.length) return '';
123100
const { positive, negative } = sentences;
124101
const { data, total } = sortedData;
125-
const emissionsCount = data.reduce((accumulator, item) => {
126-
const accumulatorCount =
127-
typeof accumulator !== 'object'
128-
? accumulator
129-
: accumulator.emissions
130-
.map(a => a.value)
131-
.reduce((iSum, value) => iSum + value);
132-
const itemCount = item.emissions
133-
.map(a => a.value)
134-
.reduce((iSum, value) => iSum + value);
135-
return accumulatorCount + itemCount;
136-
});
102+
const emissionsCount = data[0].emissions
103+
.map(a => a.value)
104+
.reduce((iSum, value) => iSum + value);
137105
const totalEmissionsCount = total.emissions.reduce(
138106
(accumulator, item) =>
139107
(typeof accumulator !== 'object' ? accumulator : accumulator.value) +

0 commit comments

Comments
 (0)