Skip to content

Commit

Permalink
Merge pull request #1038 from knod/code-style-13
Browse files Browse the repository at this point in the history
Cleans /src/utils/charts. #1018
  • Loading branch information
knod committed Dec 6, 2018
2 parents c7fb641 + 9527b0f commit e8f3666
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/utils/charts/PROGRAM_CHART_VALUES.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

const PROGRAM_CHART_VALUES = {
earned: {
name: 'Earned',
color: 'rgb(136, 187, 236)',
name: `Earned`,
color: `rgb(136, 187, 236)`,
},
snap: {
name: 'SNAP',
color: 'rgba(101, 47, 138, 1)',
name: `SNAP`,
color: `rgba(101, 47, 138, 1)`,
},
section8: {
name: 'Section 8 Housing',
color: 'rgba(206, 203, 61, 1)',
name: `Section 8 Housing`,
color: `rgba(206, 203, 61, 1)`,
},
limits: {
max: 100000 / 12, // monthly amount
Expand Down
10 changes: 4 additions & 6 deletions src/utils/charts/chartFormatting.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import _ from 'lodash';

/** Helper functions to format vlaues
/** Helper functions to format values for charts
* @module
* @todo Use language of the app in money formatters
*/

const toFancyMoneyStr = function (toFormat) {
return toFormat.toLocaleString('en-US', { style: 'currency',currency: 'USD' }).replace('.00','');
return toFormat.toLocaleString(`en-US`, { style: `currency`,currency: `USD` }).replace(`.00`,``);
};

const formatAxis = function (label) {
/* Adds 1,000s separators to graph axes */
return label.toLocaleString('en-US');
return label.toLocaleString(`en-US`);
};

const formatLabel = function(tooltipItem, data) {
/* From https://github.com/chartjs/Chart.js/issues/2386 */
return data.datasets[ tooltipItem.datasetIndex ].label
+ ': ' + toFancyMoneyStr(tooltipItem.yLabel);
+ `: ` + toFancyMoneyStr(tooltipItem.yLabel);
};

const formatBenefitLinesTitle = function (tooltipItems, data) {
Expand All @@ -33,7 +32,6 @@ const formatStackedTitle = function(tooltipItems, data) {
};


// For use by react-chartjs-2
export {
toFancyMoneyStr,
formatAxis,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/charts/getChartData.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const getChartData = function (incomes, multiplier, client, activeBenefitsInOrde
// Adjust money amount to correct time interval (weekly, monthly, or yearly)
for (let benefiti = 0; benefiti < benefits.length; benefiti++) {
let benefitName = benefits[ benefiti ],
val = allData[ benefitName ][ incomei ] * multiplier;
val = allData[ benefitName ][ incomei ] * multiplier;
allData[ benefitName ][ incomei ] = val;
} // end for all active benefits
} // end for all incomes
} // ends for all active benefits
} // ends for all incomes

// Return in the same order as it was asked for
for (let benefiti = 0; benefiti < benefits.length; benefiti++) {
Expand All @@ -85,7 +85,7 @@ const getChartData = function (incomes, multiplier, client, activeBenefitsInOrde
}

return benefitDatasets;
}; // End getChartData()
}; // Ends getChartData()


export { getChartData };

0 comments on commit e8f3666

Please sign in to comment.