Skip to content

Commit

Permalink
add country government finance story
Browse files Browse the repository at this point in the history
  • Loading branch information
epicallan committed Apr 25, 2018
1 parent 877f29b commit 2dfdb03
Show file tree
Hide file tree
Showing 2 changed files with 8,105 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/molecules/MultiLinePartition/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import MultiLinePartition, {Props} from '.';
import config from '../../visbox/localLinePartition';
const ugData = require('./testData/ug.json');
const keData = require ('./testData/ke.json');
const ngData = require ('./testData/ng.json');

const getProps = (data): Props => {
const governmentFinance = data.localGovernmentFinance;
const getProps = (data: any, financeType: string): Props => {
const governmentFinance = data[financeType];
const items: Array<{title: string, data: DH.IDomestic[], inverted?: boolean}> = [];
const revenueAndGrants = governmentFinance.revenueAndGrants as DH.IDomestic[];
const expenditure = governmentFinance.expenditure as DH.IDomestic[];
if (financeType === 'governmentFinance') {
const finance = governmentFinance.finance as DH.IDomestic[];
items.push({title: 'Finance', data: finance, inverted: false});
}
if (revenueAndGrants.length) items.push({title: 'Revenue', data: revenueAndGrants});
if (expenditure.length) items.push({title: 'Expenditure', data: expenditure, inverted: false});
return {
loading: false,
chartId: `${governmentFinance.currencyCode}-localGovmntChart`,
chartId: `${governmentFinance.currencyCode}-GovmntChart`,
config,
currencyCode: governmentFinance.currencyCode || '',
currencyUSD: governmentFinance.currencyUSD || '' ,
Expand All @@ -24,5 +29,6 @@ const getProps = (data): Props => {
};

storiesOf('MultiLine partition', module)
.add('Kampala', () => <MultiLinePartition {...getProps(ugData.data)}/>)
.add('Nairobi', () => <MultiLinePartition {...getProps(keData.data)}/>);
.add('Kampala', () => <MultiLinePartition {...getProps(ugData.data, 'localGovernmentFinance')}/>)
.add('Nairobi', () => <MultiLinePartition {...getProps(keData.data, 'localGovernmentFinance')}/>)
.add('Nigeria', () => <MultiLinePartition {...getProps(ngData.data, 'governmentFinance')}/>);
Loading

0 comments on commit 2dfdb03

Please sign in to comment.