From 78bd93280bd2828e9afe3332b4b83eda194ac1f4 Mon Sep 17 00:00:00 2001 From: knod Date: Sun, 2 Dec 2018 07:26:31 -0500 Subject: [PATCH] Cleans /src/utils/charts. #1018 --- src/utils/charts/PROGRAM_CHART_VALUES.js | 12 ++++++------ src/utils/charts/chartFormatting.js | 10 ++++------ src/utils/charts/getChartData.js | 8 ++++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/utils/charts/PROGRAM_CHART_VALUES.js b/src/utils/charts/PROGRAM_CHART_VALUES.js index 7deb4af2..457996be 100644 --- a/src/utils/charts/PROGRAM_CHART_VALUES.js +++ b/src/utils/charts/PROGRAM_CHART_VALUES.js @@ -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 diff --git a/src/utils/charts/chartFormatting.js b/src/utils/charts/chartFormatting.js index ddfff89c..09aa642b 100644 --- a/src/utils/charts/chartFormatting.js +++ b/src/utils/charts/chartFormatting.js @@ -1,23 +1,22 @@ import _ from 'lodash'; -/** Helper functions to format vlaues +/** Helper functions to format vlaues 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) { @@ -33,7 +32,6 @@ const formatStackedTitle = function(tooltipItems, data) { }; -// For use by react-chartjs-2 export { toFancyMoneyStr, formatAxis, diff --git a/src/utils/charts/getChartData.js b/src/utils/charts/getChartData.js index 94ba0d31..976e5161 100644 --- a/src/utils/charts/getChartData.js +++ b/src/utils/charts/getChartData.js @@ -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++) { @@ -85,7 +85,7 @@ const getChartData = function (incomes, multiplier, client, activeBenefitsInOrde } return benefitDatasets; -}; // End getChartData() +}; // Ends getChartData() export { getChartData };