Skip to content

Commit

Permalink
Merge pull request #1044 from knod/refactor-1
Browse files Browse the repository at this point in the history
Moves chart utils to charts
  • Loading branch information
knod committed Dec 9, 2018
2 parents 60f82f0 + ecf3967 commit cd4f395
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const PROGRAM_CHART_VALUES = {
const BENEFIT_CHART_VALUES = {
earned: {
name: `Earned`,
color: `rgb(136, 187, 236)`,
Expand All @@ -18,4 +18,4 @@ const PROGRAM_CHART_VALUES = {
},
};

export { PROGRAM_CHART_VALUES };
export { BENEFIT_CHART_VALUES };
8 changes: 4 additions & 4 deletions src/forms/output/BenefitsLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ import {

// LOGIC
import { timescaleMultipliers } from '../../utils/convert-by-timescale';
import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import { getChartData } from './getChartData';
import { toFancyMoneyStr } from './chartFormatting';
import {
formatMoneyWithK,
textFromTranslatedElement,
} from './chartStringTransformers';
import { zoom } from './zoom';

// DATA
import { PROGRAM_CHART_VALUES } from '../../utils/charts/PROGRAM_CHART_VALUES';
import { BENEFIT_CHART_VALUES } from './BENEFIT_CHART_VALUES';


// Graphs get things in monthly values, so we'll convert from there
let multipliers = timescaleMultipliers.fromMonthly,
// Each graph controls its own scaling
limits = PROGRAM_CHART_VALUES.limits;
limits = BENEFIT_CHART_VALUES.limits;

/** Graph of each benefit as household income changes. Uses Highchart lib.
* @class
Expand Down
4 changes: 2 additions & 2 deletions src/forms/output/ResourcesColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {

// LOGIC
import { timescaleMultipliers } from '../../utils/convert-by-timescale';
import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import { getChartData } from './getChartData';
import { toFancyMoneyStr } from './chartFormatting';
import {
formatMoneyWithK,
textFromTranslatedElement,
Expand Down
8 changes: 4 additions & 4 deletions src/forms/output/StackedResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ import {

// LOGIC
import { timescaleMultipliers } from '../../utils/convert-by-timescale';
import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import { getChartData } from './getChartData';
import { toFancyMoneyStr } from './chartFormatting';
import {
formatMoneyWithK,
textFromTranslatedElement,
} from './chartStringTransformers';
import { zoom } from './zoom';

// DATA
import { PROGRAM_CHART_VALUES } from '../../utils/charts/PROGRAM_CHART_VALUES';
import { BENEFIT_CHART_VALUES } from './BENEFIT_CHART_VALUES';


// Graphs get things in monthly values, so we'll convert from there
let multipliers = timescaleMultipliers.fromMonthly,
// Each graph controls its own scaling
limits = PROGRAM_CHART_VALUES.limits;
limits = BENEFIT_CHART_VALUES.limits;


// Still @todo
Expand Down
10 changes: 5 additions & 5 deletions src/forms/output/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

// DATA
// Colors and text for parts of the chart
import { PROGRAM_CHART_VALUES } from '../../utils/charts/PROGRAM_CHART_VALUES';
import { BENEFIT_CHART_VALUES } from './BENEFIT_CHART_VALUES';

// DATA MANIPULATION
import { cloneDeep } from 'lodash';
Expand Down Expand Up @@ -65,8 +65,8 @@ let totalLastItemsOfArraysInObject = function (accumulated) {
* accumulate values.
*
* @example
* // In PROGRAM_CHART_VALUES.js
* let PROGRAM_CHART_VALUES = {
* // In BENEFIT_CHART_VALUES.js
* let BENEFIT_CHART_VALUES = {
* benefit1: { name: "B1" },
* benefit2: { name: "B2" },
* };
Expand Down Expand Up @@ -99,7 +99,7 @@ let totalLastItemsOfArraysInObject = function (accumulated) {
* // }
*
* Unfortunately, stll relies on an outside value -
* PROGRAM_CHART_VALUES.
* BENEFIT_CHART_VALUES.
*
* @typedef {object} benefit
* @property {string} label Name to be displayed for the benefit
Expand Down Expand Up @@ -136,7 +136,7 @@ let fillInMoneyValues = (keys, sourceObject, index) => {
moneyValues.earned = amount;
} else {
moneyValues.benefits.push({
label: PROGRAM_CHART_VALUES[ itemKey ].name,
label: BENEFIT_CHART_VALUES[ itemKey ].name,
amount: amount,
});
// Add up all benefits (we're not including earned income)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import { PROGRAM_CHART_VALUES } from '../../utils/charts/PROGRAM_CHART_VALUES';
import { BENEFIT_CHART_VALUES } from './BENEFIT_CHART_VALUES';

// LOGIC
import { applyAndPushBenefits } from '../../programs/applyAndPushBenefits';
Expand Down Expand Up @@ -72,7 +72,7 @@ const getChartData = function (incomes, multiplier, client, activeBenefitsInOrde
// Return in the same order as it was asked for
for (let benefiti = 0; benefiti < benefits.length; benefiti++) {
let benefitName = benefits[ benefiti ],
graphFrosting = PROGRAM_CHART_VALUES[ benefitName ];
graphFrosting = BENEFIT_CHART_VALUES[ benefitName ];

// All the graph info for that benefit
benefitDatasets.push({
Expand Down

0 comments on commit cd4f395

Please sign in to comment.