Skip to content
Open
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
9 changes: 0 additions & 9 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion assets/core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/core/oecd/DonorFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const init = (className) => {
*
* const chart = window.echarts.init(chartNode);
*/
const csv = 'https://raw.githubusercontent.com/devinit/di-website-data/main/2022/rh-and-fp-dropdowns.csv';
const csv = 'https://raw.githubusercontent.com/devinit/di-website-data/main/2024/rh-and-fp-dropdowns.csv';
fetchCSVData(csv).then((data) => {
const filterWrapper = addFilterWrapper(chartNode);
const countryFilter = addFilter({
Expand Down
33 changes: 25 additions & 8 deletions src/core/oecd/TableThree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,43 @@ import { render } from 'react-dom';
import { TableOne } from '../../components/TableOne/TableOne';
import { filterDataByCountry, filterDataByPurpose, formatNumber } from '../../utils/data';
import { addFilter, addFilterWrapper } from '../../widgets/filters';
import { ALTERNATIVE_PURPOSE_TO_FILTER_BY, CHANNEL_FIELD, COUNTRY_FIELD, DEFAULT_COUNTRY, PURPOSE_FIELD, VALUE_FIELD } from '../../utils/constants';
import {
ALTERNATIVE_PURPOSE_TO_FILTER_BY,
CHANNEL_FIELD,
COUNTRY_FIELD,
DEFAULT_COUNTRY,
PURPOSE_FIELD,
VALUE_FIELD,
} from '../../utils/constants';

const sumChannelData = (countryData) => {
const yearData = countryData.filter((item) => item['year'] === '2020');
const yearData = countryData.filter((item) => item['year'] === '2022');

return yearData.reduce((acc, data) => {
return {...acc, [data[CHANNEL_FIELD]]: (parseFloat(acc[data[CHANNEL_FIELD]] || 0) + parseFloat(data[VALUE_FIELD] || 0)).toFixed(1) }
return {
...acc,
[data[CHANNEL_FIELD]]: (parseFloat(acc[data[CHANNEL_FIELD]] || 0) + parseFloat(data[VALUE_FIELD] || 0)).toFixed(
1,
),
};
}, {});
};

const getRows = (tableData) => {
const sum = Object.keys(tableData).reduce((_sum, key) => formatNumber(_sum + formatNumber(Number(tableData[key]) || 0)), 0);
const sum = Object.keys(tableData).reduce(
(_sum, key) => formatNumber(_sum + formatNumber(Number(tableData[key]) || 0)),
0,
);

return Object.keys(tableData).map((dataKey) => {
return [dataKey, tableData[dataKey], (((tableData[dataKey]/sum)*100).toFixed(1) || 0)];
}).concat([['Total', sum, '100%']]);
return Object.keys(tableData)
.map((dataKey) => {
return [dataKey, tableData[dataKey], ((tableData[dataKey] / sum) * 100).toFixed(1) || 0];
})
.concat([['Total', sum, '100%']]);
};

const renderTable = (data, country, purpose, tableNode) => {
const rowHeader = ['Channel', '2020', '% Total'];
const rowHeader = ['Channel', '2022', '% Total'];
const countryData = filterDataByPurpose(
filterDataByCountry(data, country, COUNTRY_FIELD),
purpose || 'Reproductive health care and family planning',
Expand Down
10 changes: 5 additions & 5 deletions src/core/oecd/TableTwo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getGroupedData = (countryData) => {
for (let count = 0; count < countryData.length; count++) {
if (iteratorData.length >= 1) {
let maxRow = iteratorData.reduce((prev, current) => {
if (Number(prev['2021']) < Number(current['2021'])) {
if (Number(prev['2022']) < Number(current['2022'])) {
return current;
} else {
return prev;
Expand All @@ -29,7 +29,7 @@ const getGroupedData = (countryData) => {
for (let count = 0; count < 10; count++) {
if (iteratorData.length >= 1) {
let maxRow = iteratorData.reduce((prev, current) => {
if (Number(prev['2021']) < Number(current['2021'])) {
if (Number(prev['2022']) < Number(current['2022'])) {
return current;
} else {
return prev;
Expand All @@ -55,11 +55,11 @@ const sortedDataRows = (data) => {
fullRows.push([
i + 1,
data[i].recipient_name,
formatNumber(Number(data[i]['2017']), NO_DATA),
formatNumber(Number(data[i]['2018']), NO_DATA),
formatNumber(Number(data[i]['2019']), NO_DATA),
formatNumber(Number(data[i]['2020']), NO_DATA),
formatNumber(Number(data[i]['2021']), NO_DATA),
formatNumber(Number(data[i]['2022']), NO_DATA),
]);
}
}
Expand All @@ -71,11 +71,11 @@ const sortedDataRows = (data) => {
fullRows.push([
i + 1,
data[i].recipient_name,
formatNumber(Number(data[i]['2017']), NO_DATA),
formatNumber(Number(data[i]['2018']), NO_DATA),
formatNumber(Number(data[i]['2019']), NO_DATA),
formatNumber(Number(data[i]['2020']), NO_DATA),
formatNumber(Number(data[i]['2021']), NO_DATA),
formatNumber(Number(data[i]['2022']), NO_DATA),
]);
}
}
Expand All @@ -93,7 +93,7 @@ const getUnsortedDataRow = (data, years) => {
};

const renderTable = (data, country, purpose, tableNode) => {
const YEARS = [2017, 2021];
const YEARS = [2018, 2022];
const yearRange = YEARS[1] - YEARS[0] + 1;
const count = [];
for (const key of Array(yearRange).keys()) {
Expand Down
27 changes: 21 additions & 6 deletions src/core/oecd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@ import { fetchCoreData } from '../../utils/data';
// Your Code Goes Here i.e. functions

const init = () => {
fetchCoreData([
{ url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2022/RH_and_FP_Purpose_code_trends_chart_OECD.csv', state: 'dataOne' },
{ url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2022/donor_by_recip_2019.csv', state: 'dataTwo' },
{ url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2022/RH_FP_aid_type_OECD.csv', state: 'odaAidType' },
{ url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2022/RH_FP_channels_OECD.csv', state: 'odaChannels' },
], { country: 'United States' });
fetchCoreData(
[
{
url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2024/RH_and_FP_Purpose_code_trends_chart_OECD.csv',
state: 'dataOne',
},
{
url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2024/donor_by_recip_2019.csv',
state: 'dataTwo',
},
{
url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2024/RH_FP_aid_type_OECD.csv',
state: 'odaAidType',
},
{
url: 'https://raw.githubusercontent.com/devinit/di-website-data/main/2024/RH_FP_channels_OECD.csv',
state: 'odaChannels',
},
],
{ country: 'United States' },
);
initDonorFilter('dicharts--donor-selector');
initTableOne('dicharts--table-one');
initBarChartOne('dicharts--chart-one');
Expand Down
24 changes: 12 additions & 12 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h3 class="type-l type-l--trailer">Donor Selector</h3>
<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">
Table: ODA to reproductive health care and family planning, 2012−2021
Table: ODA to reproductive health care and family planning, 2013−2022
</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
Expand All @@ -65,7 +65,7 @@ <h3 class="type-l type-l--trailer">
<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">
Chart: ODA to reproductive health care and family planning, 2012−2021
Chart: ODA to reproductive health care and family planning, 2013−2022
</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
Expand All @@ -85,7 +85,7 @@ <h3 class="type-l type-l--trailer">

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Chart: ODA by aid type, 2017−2021</h3>
<h3 class="type-l type-l--trailer">Chart: ODA by aid type, 2018−2022</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--chart-two"></div>
Expand All @@ -104,7 +104,7 @@ <h3 class="type-l type-l--trailer">Chart: ODA by aid type, 2017−2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor, 2017−2021</h3>
<h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor, 2018−2022</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--table-two"></div>
Expand All @@ -123,7 +123,7 @@ <h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: ODA by aid type, 2021</h3>
<h3 class="type-l type-l--trailer">Table: ODA by aid type, 2022</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--table-three"></div>
Expand All @@ -142,7 +142,7 @@ <h3 class="type-l type-l--trailer">Table: ODA by aid type, 2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: ODA by channel of delivery, 2021</h3>
<h3 class="type-l type-l--trailer">Table: ODA by channel of delivery, 2022</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--table-four"></div>
Expand All @@ -161,7 +161,7 @@ <h3 class="type-l type-l--trailer">Table: ODA by channel of delivery, 2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Chart: ODA by channel of delivery, 2021</h3>
<h3 class="type-l type-l--trailer">Chart: ODA by channel of delivery, 2022</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--chart-three"></div>
Expand Down Expand Up @@ -204,7 +204,7 @@ <h3 class="type-l type-l--trailer">IATI Donor Selector</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: Total trends, 2019–2021</h3>
<h3 class="type-l type-l--trailer">Table: Total trends, 2019–2023</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<!-- CODE TO COPY STARTS HERE {% endcomment %} -->
Expand All @@ -226,7 +226,7 @@ <h3 class="type-l type-l--trailer">Table: Total trends, 2019–2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Chart: Total trends, 2019–2021</h3>
<h3 class="type-l type-l--trailer">Chart: Total trends, 2019–2023</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--chart-one-iati"></div>
Expand All @@ -245,7 +245,7 @@ <h3 class="type-l type-l--trailer">Chart: Total trends, 2019–2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Chart: Aid type, 2019–2021</h3>
<h3 class="type-l type-l--trailer">Chart: Aid type, 2019–2023</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--chart-two-iati"></div>
Expand All @@ -264,7 +264,7 @@ <h3 class="type-l type-l--trailer">Chart: Aid type, 2019–2021</h3>

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor, 2019–2021</h3>
<h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor, 2019–2023</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--table-two-iati"></div>
Expand All @@ -283,7 +283,7 @@ <h3 class="type-l type-l--trailer">Table: Largest recipients by individual donor

<section class="section">
<div class="row row--narrow">
<h3 class="type-l type-l--trailer">Table: Aid type, 2019–2021</h3>
<h3 class="type-l type-l--trailer">Table: Aid type, 2019–2023</h3>
<div class="chart-container chart-container--full">
<div class="charts__chart">
<div class="dicharts--table-three-iati"></div>
Expand Down
6 changes: 3 additions & 3 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const ALTERNATIVE_PURPOSE_TO_FILTER_BY = [
];
export const VALUE_FIELD = 'usd_disbursement_deflated';
export const CHANNEL_FIELD = 'oecd_aggregated_channel';
export const YEARS = [2012, 2021];
export const YEARSsmall = [2017, 2021];
export const YEARsingle = 2021;
export const YEARS = [2013, 2022];
export const YEARSsmall = [2018, 2022];
export const YEARsingle = 2022;
export const NO_DATA = 0;
export const AIDTYPE_FIELD = 'aid_type_di_name';
export const VALUE_FIELD_AIDTYPE = 'usd_disbursement_deflated_Sum';