Skip to content

Commit

Permalink
Merge pull request #311 from flacoman91/separator
Browse files Browse the repository at this point in the history
More information about link on Overview expanded row charts
  • Loading branch information
flacoman91 authored Jul 13, 2020
2 parents a052e01 + e7371ac commit 79332de
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/components/Charts/RowChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export class RowChart extends React.Component {
}

_selectFocus( element ) {
this.props.selectFocus( element, this.props.lens )
// make sure to assign a valid lens when a row is clicked
const lens = this.props.lens === 'Overview' ? 'Product' : this.props.lens
this.props.selectFocus( element, lens )
}

render() {
Expand Down
20 changes: 19 additions & 1 deletion src/components/__tests__/RowChart.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,36 @@ describe( 'component: RowChart', () => {
expect( sp ).toHaveBeenCalledTimes( 1 )
} )

it( 'calls select Focus', () => {
it( 'calls select Focus with a lens', () => {
const cb = jest.fn()
const target = shallow( <RowChart
selectFocus={ cb }
colorScheme={ [] }
title={ 'test' }
lens={ 'Boo' }
data={ [ 23, 4, 3 ] }
id={ 'foo' }
total={ 1000 }
/> )
target.instance()._selectFocus( { name: 'foo' } )
expect( cb ).toHaveBeenCalledTimes( 1 )
expect( cb ).toHaveBeenCalledWith( { name: 'foo' }, 'Boo' )
} )

it( 'calls select Focus with product lens - Overview', () => {
const cb = jest.fn()
const target = shallow( <RowChart
lens={ 'Overview' }
selectFocus={ cb }
colorScheme={ [] }
title={ 'test' }
data={ [ 23, 4, 3 ] }
id={ 'foo' }
total={ 1000 }
/> )
target.instance()._selectFocus( { name: 'foo' } )
expect( cb ).toHaveBeenCalledTimes( 1 )
expect( cb ).toHaveBeenCalledWith( { name: 'foo' }, 'Product' )
} )
} )

Expand Down
2 changes: 1 addition & 1 deletion src/reducers/__fixtures__/trendsAggsDupes.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/reducers/__fixtures__/trendsResults.jsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const trendsResults = {"activeCall":"","chartType":"line","colorMap":{"Complaints":"#ADDC91","Other":"#a2a3a4","All other products":"#a2a3a4","All other companies":"#a2a3a4","All other values":"#a2a3a4"},"error":false,"expandedTrends":[],"filterNames":["Mortgage","Credit card or prepaid card","Credit reporting, credit repair services, or other personal consumer reports","Checking or savings account","Debt collection"],"focus":"","isLoading":false,"lastDate":"2020-05-01T00:00:00.000Z","lens":"Overview","results":{"company":[],"dateRangeArea":[],"dateRangeLine":{"dataByTopic":[{"topic":"Complaints","topicName":"Complaints","dashed":false,"show":true,"dates":[{"date":"2020-01-01T00:00:00.000Z","value":0},{"date":"2020-02-01T00:00:00.000Z","value":0},{"date":"2020-03-01T00:00:00.000Z","value":106},{"date":"2020-04-01T00:00:00.000Z","value":374},{"date":"2020-05-01T00:00:00.000Z","value":52}]}]},"product":[{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Mortgage","value":185,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Conventional home mortgage","value":108,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"FHA mortgage","value":44,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"VA mortgage","value":19,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other type of mortgage","value":9,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Home equity loan or line of credit (HELOC)","value":5,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Credit card or prepaid card","value":129,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"General-purpose credit card or charge card","value":98,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Store credit card","value":23,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Government benefit card","value":6,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"General-purpose prepaid card","value":2,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Credit reporting, credit repair services, or other personal consumer reports","value":87,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit reporting","value":84,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit repair services","value":2,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other personal consumer report","value":1,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Checking or savings account","value":43,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Checking account","value":34,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Savings account","value":5,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other banking product or service","value":3,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"CD (Certificate of Deposit)","value":1,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Debt collection","value":38,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other debt","value":12,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"I do not know","value":8,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Medical debt","value":8,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Auto debt","value":4,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit card debt","value":4,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Federal student loan debt","value":1,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Private student loan debt","value":1,"parent":"Debt collection","visible":false,"width":0.4}]},"subLens":"","tooltip":false,"total":532}
export const trendsResults = {"activeCall":"","chartType":"line","colorMap":{"Complaints":"#ADDC91","Other":"#a2a3a4","All other products":"#a2a3a4","All other companies":"#a2a3a4","All other values":"#a2a3a4"},"error":false,"expandedTrends":[],"filterNames":["Mortgage","Credit card or prepaid card","Credit reporting, credit repair services, or other personal consumer reports","Checking or savings account","Debt collection"],"focus":"","isLoading":false,"lastDate":"2020-05-01T00:00:00.000Z","lens":"Overview","results":{"company":[],"dateRangeArea":[],"dateRangeLine":{"dataByTopic":[{"topic":"Complaints","topicName":"Complaints","dashed":false,"show":true,"dates":[{"date":"2020-01-01T00:00:00.000Z","value":0},{"date":"2020-02-01T00:00:00.000Z","value":0},{"date":"2020-03-01T00:00:00.000Z","value":106},{"date":"2020-04-01T00:00:00.000Z","value":374},{"date":"2020-05-01T00:00:00.000Z","value":52}]}]},"product":[{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Mortgage","value":185,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Conventional home mortgage","value":108,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"FHA mortgage","value":44,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"VA mortgage","value":19,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other type of mortgage","value":9,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Home equity loan or line of credit (HELOC)","value":5,"parent":"Mortgage","visible":false,"width":0.4},{"hasChildren":false,"isParent":false,"key":"More Information about Mortgage","name":"More Information about Mortgage","splitterText":"More Information about Mortgage","value":"","parent":"Mortgage","width":0.3,"visible":false},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Credit card or prepaid card","value":129,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"General-purpose credit card or charge card","value":98,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Store credit card","value":23,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Government benefit card","value":6,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"General-purpose prepaid card","value":2,"parent":"Credit card or prepaid card","visible":false,"width":0.4},{"hasChildren":false,"isParent":false,"key":"More Information about Credit card or prepaid card","name":"More Information about Credit card or prepaid card","splitterText":"More Information about Credit card or prepaid card","value":"","parent":"Credit card or prepaid card","width":0.3,"visible":false},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Credit reporting, credit repair services, or other personal consumer reports","value":87,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit reporting","value":84,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit repair services","value":2,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other personal consumer report","value":1,"parent":"Credit reporting, credit repair services, or other personal consumer reports","visible":false,"width":0.4},{"hasChildren":false,"isParent":false,"key":"More Information about Credit reporting, credit repair services, or other personal consumer reports","name":"More Information about Credit reporting, credit repair services, or other personal consumer reports","splitterText":"More Information about Credit reporting, credit repair services, or other personal consumer reports","value":"","parent":"Credit reporting, credit repair services, or other personal consumer reports","width":0.3,"visible":false},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Checking or savings account","value":43,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Checking account","value":34,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Savings account","value":5,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other banking product or service","value":3,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"CD (Certificate of Deposit)","value":1,"parent":"Checking or savings account","visible":false,"width":0.4},{"hasChildren":false,"isParent":false,"key":"More Information about Checking or savings account","name":"More Information about Checking or savings account","splitterText":"More Information about Checking or savings account","value":"","parent":"Checking or savings account","width":0.3,"visible":false},{"hasChildren":true,"isNotFilter":false,"isParent":true,"name":"Debt collection","value":38,"parent":false,"visible":true,"width":0.5},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Other debt","value":12,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"I do not know","value":8,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Medical debt","value":8,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Auto debt","value":4,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Credit card debt","value":4,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Federal student loan debt","value":1,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isNotFilter":false,"isParent":false,"name":"Private student loan debt","value":1,"parent":"Debt collection","visible":false,"width":0.4},{"hasChildren":false,"isParent":false,"key":"More Information about Debt collection","name":"More Information about Debt collection","splitterText":"More Information about Debt collection","value":"","parent":"Debt collection","width":0.3,"visible":false}]},"subLens":"","tooltip":false,"total":532}
30 changes: 13 additions & 17 deletions src/reducers/trends.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const defaultState = {
*/
export function processBucket( state, agg ) {
const list = []
const { expandedTrends, filterNames, lens } = state
const { expandedTrends, filterNames } = state
for ( let i = 0; i < agg.length; i++ ) {
processTrendPeriod( agg[i] )

Expand All @@ -70,22 +70,18 @@ export function processBucket( state, agg ) {
/* istanbul ignore else */
if ( item[subKeyName] && item[subKeyName].buckets ) {
const expandableBuckets = item[subKeyName].buckets

// only push expand text when a data lens is selected
if ( lens !== 'Overview' ) {
// if there's buckets we need to add a separator for rendering
const labelText = `More Information about ${ item.key }`
expandableBuckets.push( {
hasChildren: false,
isParent: false,
key: labelText,
name: labelText,
splitterText: labelText,
value: '',
parent: item.key,
width: 0.3
} )
}
// if there's buckets we need to add a separator for rendering
const labelText = `More Information about ${ item.key }`
expandableBuckets.push( {
hasChildren: false,
isParent: false,
key: labelText,
name: labelText,
splitterText: labelText,
value: '',
parent: item.key,
width: 0.3
} )

list.push( expandableBuckets )
}
Expand Down

0 comments on commit 79332de

Please sign in to comment.