Skip to content

Commit

Permalink
changes for reusing code
Browse files Browse the repository at this point in the history
  • Loading branch information
RoxanaTorre committed May 29, 2024
1 parent c4c86a8 commit 5501c91
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 73 deletions.
9 changes: 7 additions & 2 deletions src/AppExternalDebtQuantiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { csv } from 'd3-fetch';
import { useEffect, useState } from 'react';
import { CategoryData, ChartSourceType } from './Types';
import { QuantilesLinesExternalDebt } from './RegionLineChart/index2';
import { RegionLineChartNoOptions } from './RegionLineChart/index1';
import './style.css';

function AppNetInterestQuantiles() {
Expand All @@ -29,12 +29,17 @@ function AppNetInterestQuantiles() {
return (
<div className='undp-container'>
{externalDebtQuantiles && categoriesData1 ? (
<QuantilesLinesExternalDebt
<RegionLineChartNoOptions
data={externalDebtQuantiles}
categories={categoriesData1}
title='Public and publicly guaranteed total external debt service as a
percentage of revenue'
yAxisName='Total debt service as % of revenue'
id='externalDebtQuantilesLines'
chartSource={
sourcesData.filter(d => d.graph === 'External debt quantiles')[0]
}
option='external'
/>
) : null}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/AppNetInterestQuantiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ function AppNetInterestQuantiles() {
<RegionLineChartNoOptions
data={debtNetInterest}
categories={categoriesData1}
title='General government net interest payments as percentage of revenue'
yAxisName='Net interest as % of revenue'
id='netInterestLine'
chartSource={
sourcesData.filter(
d => d.graph === 'Net interest payments to revenue',
)[0]
}
option='netInterest'
/>
) : null}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/DebtInterestBars/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function DebtInterestBars(props: Props) {
UNDPColorModule.categoricalColors.colors[0],
}}
/>
<div className='small-font'>{(periods as any)[0]}</div>
<div className='small-font'>Average {(periods as any)[0]}</div>
</div>
<div className='legend-item'>
<div
Expand All @@ -66,7 +66,7 @@ export function DebtInterestBars(props: Props) {
UNDPColorModule.categoricalColors.colors[1],
}}
/>
<div className='small-font'>{(periods as any)[1]}</div>
<div className='small-font'>Average {(periods as any)[1]}</div>
</div>
</div>
<div>
Expand Down
14 changes: 9 additions & 5 deletions src/RegionLineChart/index1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import { Graph } from './Graph';
interface Props {
data: object[];
categories: CategoryData[];
title: string;
yAxisName: string;
id: string;
chartSource: ChartSourceType;
option: string;
}

export function RegionLineChartNoOptions(props: Props) {
const { data, categories, chartSource } = props;
const { data, categories, title, yAxisName, id, chartSource, option } = props;
const [categorySelection, setCategorySelection] = useState('All developing');
return (
<>
Expand All @@ -39,17 +43,17 @@ export function RegionLineChartNoOptions(props: Props) {
<div className='flex-div flex-space-between flex-wrap'>
<div>
<h6 className='undp-typography margin-bottom-01 margin-top-03'>
General government net interest payments as percentage of revenue
{title}
</h6>
</div>
</div>
<Graph
data={data.filter(d => (d as any).Group === categorySelection)}
option='netInterest'
option={option}
svgWidth={960}
svgHeight={550}
id='netInterestLine'
yAxisName='Net interest as % of revenue'
id={id}
yAxisName={yAxisName}
/>
{chartSource?.source ? (
<p className='source'>{`Source: ${chartSource.source}`}</p>
Expand Down
64 changes: 0 additions & 64 deletions src/RegionLineChart/index2.tsx

This file was deleted.

0 comments on commit 5501c91

Please sign in to comment.