Skip to content

Commit e619ad4

Browse files
authored
Merge pull request #3433 from Vizzuality/fix/sentences-feedback
Updates dynamic sentences and defaults
2 parents a8a7736 + 3a4b21e commit e619ad4

File tree

10 files changed

+23
-21
lines changed

10 files changed

+23
-21
lines changed

app/javascript/components/widgets/widgets/climate/emissions/initial-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export default {
99
colors: 'emissions',
1010
sentences: {
1111
positive:
12-
'In {location}, the land-use change and forestry sector is a {type} of CO\u2082, emitting an average of {value} of emissions from {startYear} to {endYear}. This represents {percentage} of {location_alt} total greenhouse gas emissions over the same period.',
12+
'In {location}, the land-use change and forestry sector is a {type} of CO\u2082, emitting an average of {value} from {startYear} to {endYear}. This represents {percentage} of {location_alt} total greenhouse gas emissions over the same period.',
1313
negative:
14-
'In {location}, the land-use change and forestry sector is a {type} of CO\u2082, sequestering an average of {value} of emissions from {startYear} to {endYear}. This represents an offset of {percentage} of {location_alt} total greenhouse gas emissions over the same period.'
14+
'In {location}, the land-use change and forestry sector is a {type} of CO\u2082, sequestering an average of {value} from {startYear} to {endYear}. This represents an offset of {percentage} of {location_alt} total greenhouse gas emissions over the same period.'
1515
}
1616
},
1717
enabled: true

app/javascript/components/widgets/widgets/forest-change/fao-deforest/initial-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export const initialState = {
1717
globalHuman:
1818
'According to the FAO, the {location} rate of deforestation in {year} was {rate}, of which {human} was due to human activity.',
1919
initial:
20-
'According to the FAO the rate of deforestation in {location} was {rate}, in {year}.',
20+
'According to the FAO, the rate of deforestation in {location} was {rate} in {year}.',
2121
humanDeforest:
22-
'According to the FAO the rate of deforestation in {location} was {rate} in {year}, of which {human} was due to human activity.',
22+
'According to the FAO, the rate of deforestation in {location} was {rate} in {year}, of which {human} was due to human activity.',
2323
noDeforest: 'No deforestation data in {location}.'
2424
}
2525
},

app/javascript/components/widgets/widgets/forest-change/fao-reforest/initial-state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const initialState = {
1515
globalInitial:
1616
'According to the FAO, the {location} rate of reforestation in {year} was {rate}.',
1717
initial:
18-
'According to the FAO the rate of reforestation in {location} was {rate}, in {year}',
18+
'According to the FAO, the rate of reforestation in {location} was {rate} in {year}',
1919
noReforest: 'No reforestation data in {location}.'
2020
}
2121
},

app/javascript/components/widgets/widgets/forest-change/glad-ranked/selectors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const getSentence = createSelector(
114114
topPercent: `${format('.2r')(topCount)}%`,
115115
topRegions: percentileLength,
116116
location: currentLabel,
117-
indicator: `${indicator ? `${indicator.label.toLowerCase()} in ` : ''}`
117+
indicator: `${indicator ? `${indicator.label.toLowerCase()}` : ''}`
118118
};
119119
const sentence = percentileLength === 1 ? oneRegion : initial;
120120
return { sentence, params };

app/javascript/components/widgets/widgets/forest-change/tree-cover-gain/initial-state.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export default {
22
title: 'Tree cover gain',
33
config: {
44
size: 'small',
5-
forestTypes: ['plantations'],
65
landCategories: ['wdpa', 'landmark', 'mining'],
76
units: ['ha', '%'],
87
categories: ['summary', 'forest-change'],
@@ -39,7 +38,7 @@ export default {
3938
settings: {
4039
threshold: 50,
4140
unit: '%',
42-
extentYear: 2010,
41+
extentYear: 2000,
4342
layers: ['forestgain']
4443
},
4544
enabled: true

app/javascript/components/widgets/widgets/forest-change/tree-loss/initial-state.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ export const initialState = {
2323
},
2424
sentences: {
2525
initial:
26-
'From {startYear} and {endYear}, {location} lost {loss} of tree cover, equivalent to a {percent} decrease since {extentYear} and {emissions} of CO\u2082 emissions.',
26+
'From {startYear} to {endYear}, {location} lost {loss} of tree cover, equivalent to a {percent} decrease since {extentYear} and {emissions} of CO\u2082 emissions.',
2727
withIndicator:
28-
'From {startYear} and {endYear}, {location} lost {loss} of tree cover in {indicator}, equivalent to a {percent} decrease since {extentYear} and {emissions} of CO\u2082 emissions.',
28+
'From {startYear} to {endYear}, {location} lost {loss} of tree cover in {indicator}, equivalent to a {percent} decrease since {extentYear} and {emissions} of CO\u2082 emissions.',
2929
noLoss:
30-
'From {startYear} and {endYear}, {location} lost {loss} of tree cover.',
30+
'From {startYear} to {endYear}, {location} lost {loss} of tree cover.',
3131
noLossWithIndicator:
32-
'From {startYear} and {endYear}, {location} lost {loss} of tree cover in {indicator}.'
32+
'From {startYear} to {endYear}, {location} lost {loss} of tree cover in {indicator}.'
3333
}
3434
},
3535
settings: {

app/javascript/components/widgets/widgets/land-cover/fao-cover/initial-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export const initialState = {
1212
colors: 'extent',
1313
sentences: {
1414
globalInitial:
15-
'FAO data from 2015 shows that there was {extent} of forest {location}, with Primary forest occupying {primaryPercent} of land area.',
15+
'FAO data from 2015 shows that there was {extent} of forest {location}, with primary forest occupying {primaryPercent} of land area.',
1616
globalNoPrimary:
1717
'FAO data from 2015 shows that there was {extent} of forest {location}, which occupies {primaryPercent} of the country.',
1818
initial:
19-
'FAO data from 2015 shows that {location} contains {extent} of forest, with Primary forest occupying {primaryPercent} of the country.',
19+
'FAO data from 2015 shows that {location} contains {extent} of forest, with primary forest occupying {primaryPercent} of the country.',
2020
noPrimary:
2121
'FAO data from 2015 shows that {location} contains {extent} of forest, which occupies {primaryPercent} of the country.'
2222
}

app/javascript/components/widgets/widgets/land-cover/tree-cover-plantations/initial-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
title: 'Plantations extent',
2+
title: 'Plantations in',
33
config: {
44
size: 'small',
55
categories: ['land-cover'],
@@ -18,7 +18,7 @@ export default {
1818
singleSpecies:
1919
'In {location}, {firstSpecies} represent the largest plantation area by {type}, spanning {extent} and {percent} of land area.',
2020
initialTypes:
21-
'In {location}, the largest plantation area by type are {topType}, spanning {extent} and {percent} of land area.'
21+
'In {location}, the largest plantation area by type is {topType}, spanning {extent} and {percent} of land area.'
2222
}
2323
},
2424
settings: {

app/javascript/components/widgets/widgets/land-cover/tree-cover-ranked/initial-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default {
1616
},
1717
sentences: {
1818
initial:
19-
'As of {extentYear}, {location} represented {percentage} of global tree cover.',
19+
"As of {extentYear}, {location} had {extent} of tree cover, equivalent to {landPercentage} of it's land area and {globalPercentage} of global tree cover.",
2020
withInd:
21-
'As of {extentYear}, {location} represented {percentage} of global tree cover in {indicator}.'
21+
"As of {extentYear}, {location} had {extent} of tree cover, equivalent to {landPercentage} of it's land area and {globalPercentage} of global tree cover in {indicator}."
2222
}
2323
},
2424
settings: {

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,18 @@ export const getSentence = createSelector(
9494
const locationData =
9595
currentLocation && data.find(l => l.id === currentLocation.value);
9696
const extent = locationData && locationData.extent;
97-
const areaPercent = 100 * extent / sumBy(rawData, 'extent') || 0;
97+
const landPercent = 100 * extent / locationData.area || 0;
98+
const globalPercent = 100 * extent / sumBy(rawData, 'extent') || 0;
9899

99100
const params = {
100101
extentYear: settings.extentYear,
101102
location: currentLocation.label,
102103
extent: `${extent ? format('.3s')(extent) : '0'}ha`,
103104
indicator: indicator && indicator.value.toLowerCase(),
104-
percentage:
105-
areaPercent >= 0.1 ? `${format('.2r')(areaPercent)}%` : '<0.1%'
105+
landPercentage:
106+
landPercent >= 0.1 ? `${format('.2r')(landPercent)}%` : '<0.1%',
107+
globalPercentage:
108+
globalPercent >= 0.1 ? `${format('.2r')(globalPercent)}%` : '<0.1%'
106109
};
107110

108111
const sentence = indicator ? withInd : initial;

0 commit comments

Comments
 (0)