Skip to content

Commit

Permalink
Fix the rounding issue for population in country page and add source …
Browse files Browse the repository at this point in the history
…for SDG tracker
  • Loading branch information
mustafasaifee42 committed Jan 25, 2024
1 parent a694245 commit b7886f3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/AboutPage/CountryAboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ export function CountryAboutPage(props: Props) {
Located in {countryTaxonomy['Group 2']}
{isDataAvailable(countryData, 'Population, total') ? (
<>
&nbsp;and with a population of&nbsp;
&nbsp;and with a population of approximately&nbsp;
<span className='bold'>
{format('.2s')(
{format('.3s')(
GetDataValueAndYear(countryData, 'Population, total')
.value,
).replace('G', 'B')}
</span>
&nbsp;inhabitants
&nbsp;inhabitants (
{GetDataValueAndYear(countryData, 'Population, total').year})
</>
) : null}
.&nbsp;
Expand All @@ -115,7 +116,7 @@ export function CountryAboutPage(props: Props) {
{countryTaxonomy['Country or Area']}
&nbsp;had a GDP of&nbsp;
<span className='bold'>
{format('.2s')(
{format('.3s')(
GetDataValueAndYear(
countryData,
'GDP per capita, PPP (current international $)',
Expand Down
4 changes: 2 additions & 2 deletions src/CountryPage/SDGDataExplorer/LineChart/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function Graph(props: Props) {
? Math.abs(data.values[indx].value) < 1
? data.values[indx].value
: data.values[indx].value > 1000
? format('.2s')(data.values[indx].value).replace('G', 'B')
? format('.3s')(data.values[indx].value).replace('G', 'B')
: format('.3s')(data.values[indx].value)
: data.values[indx].value,
label: data.values[indx].label,
Expand Down Expand Up @@ -199,7 +199,7 @@ export function Graph(props: Props) {
? d.value.toFixed(3)
: d.value.toFixed(2)
: Math.abs(d.value) > 1000
? format('.2s')(d.value).replace('G', 'B')
? format('.3s')(d.value).replace('G', 'B')
: format('.3s')(d.value)
: d.value}
</text>
Expand Down
16 changes: 15 additions & 1 deletion src/CountryPage/SDGTracker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@ export function SDGTracker(props: Props) {
return (
<div>
{countryData && statuses ? (
<SDGTrackerViz targetStatuses={statuses.targetStatus} />
<>
<SDGTrackerViz targetStatuses={statuses.targetStatus} />
<p
className='undp-typography small-font italics'
style={{ textAlign: 'center' }}
>
For more information on the data and methodology visit:{' '}
<a
href={`https://sdgdiagnostics.data.undp.org/${countryId}/sdg-trends`}
className='undp-style'
>
SDG Push Diagnostics
</a>
</p>
</>
) : (
<div className='undp-loader-container undp-container'>
<div className='undp-loader' />
Expand Down
2 changes: 1 addition & 1 deletion src/KeyInsights/Components/AnimatedParticleChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function ParticleColumnChart(props: ColumnProps) {
);
const notesList = years.map(
(el, i) =>
`${el}: ${format('.2s')(dataList[i]).replace('G', 'B')}${
`${el}: ${format('.3s')(dataList[i]).replace('G', 'B')}${
suffix || ''
}`,
);
Expand Down
6 changes: 3 additions & 3 deletions src/KeyInsights/Components/GHGGraph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function Graph(props: Props) {
fontWeight: 'bold',
}}
>
{format('.2s')(
{format('.3s')(
data.yearlyData[data.yearlyData.findIndex(d => d.year === 1990)]
.value,
)}{' '}
Expand All @@ -137,7 +137,7 @@ export function Graph(props: Props) {
fontWeight: 'bold',
}}
>
{format('.2s')(data.yearlyData[data.yearlyData.length - 1].value)}{' '}
{format('.3s')(data.yearlyData[data.yearlyData.length - 1].value)}{' '}
{svgWidth < 640 ? 'Mil T' : 'Million T'}
</text>
<polygon
Expand Down Expand Up @@ -224,7 +224,7 @@ export function Graph(props: Props) {
fontWeight: 'bold',
}}
>
{format('.2s')(
{format('.3s')(
(data.yearlyData[data.yearlyData.length - 1].value -
data.yearlyData[data.yearlyData.findIndex(d => d.year === 1990)]
.value) /
Expand Down
4 changes: 2 additions & 2 deletions src/KeyInsights/PovertyAndInequalityKeyInsights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ export function PovertyAndInequalityKeyInsights() {
backgroundColor={['var(--gray-300)', 'var(--gray-300)']}
color={['#006EB5', '#006EB5']}
notes={[
`${format('.2s')(0.1 * 7876931987).replace(
`${format('.3s')(0.1 * 7876931987).replace(
'M',
' Million',
)} People (top 10%)`,
`${format('.2s')(0.9 * 7876931987).replace(
`${format('.3s')(0.9 * 7876931987).replace(
'G',
' Billion',
)} People (bottom 90%)`,
Expand Down

0 comments on commit b7886f3

Please sign in to comment.