Skip to content

Commit

Permalink
Merge branch 'fix-key-value-health-bar' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagorra committed Jan 30, 2019
2 parents 2676d82 + fd57fd0 commit 088224f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const healthColorScheme = [
'#f44336',
'#dddddd',
];
const identity = x => x;

const valueSelector = x => x.value;
const keySelector = x => x.key;

export default class Field extends React.PureComponent {
static propTypes = propTypes;
Expand All @@ -44,7 +46,21 @@ export default class Field extends React.PureComponent {
const invalidCount = data.filter(x => x.invalid).length;
const emptyCount = data.filter(x => x.empty).length;
const totalCount = data.length;
return [totalCount - emptyCount - invalidCount, invalidCount, emptyCount];

return [
{
key: 'valid',
value: totalCount - emptyCount - invalidCount,
},
{
key: 'invalid',
value: invalidCount,
},
{
key: 'empty',
value: emptyCount,
},
];
});


Expand Down Expand Up @@ -116,8 +132,8 @@ export default class Field extends React.PureComponent {
<HealthBar
className={styles.healthBar}
data={healthStatusData}
valueSelector={identity}
keySelector={identity}
valueSelector={valueSelector}
keySelector={keySelector}
colorScheme={healthColorScheme}
enlargeOnHover={false}
hideLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const propTypes = {
className: PropTypes.string,
sheet: PropTypes.shape({
fields: PropTypes.array,
data: PropTypes.array,
data: PropTypes.object,
options: PropTypes.object,
}),
onClick: PropTypes.func.isRequired,
Expand Down
5 changes: 2 additions & 3 deletions src/components/other/TabularBook/TabularSheet/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const healthColorScheme = [
'#dddddd',
];

const healthBarValueSelector = x => x;
const healthBarKeySelector = (x, i) => `${x}-${i}`;
const healthBarValueSelector = x => x.value;
const healthBarKeySelector = x => x.key;

export default class Header extends React.PureComponent {
static propTypes = {
Expand Down Expand Up @@ -139,7 +139,6 @@ export default class Header extends React.PureComponent {
<HealthBar
data={statusData}
valueSelector={healthBarValueSelector}
labelSelector={undefined}
keySelector={healthBarKeySelector}
className={styles.healthBar}
hideLabel
Expand Down
15 changes: 14 additions & 1 deletion src/components/other/TabularBook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,20 @@ const transformSheet = (sheet) => {
const emptyCount = value.filter(x => x.empty).length;
const totalCount = value.length;
return {
healthBar: [totalCount - emptyCount - invalidCount, invalidCount, emptyCount],
healthBar: [
{
key: 'valid',
value: totalCount - emptyCount - invalidCount,
},
{
key: 'invalid',
value: invalidCount,
},
{
key: 'empty',
value: emptyCount,
},
],
};
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/viz/DataSeries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class DataSeries extends React.PureComponent {
[GRAPH.geo]: {
component: GeoViz,
rendererParams: () => {
const { value: { geodata } } = this.props;
const { value: { geodata = {} } } = this.props;
const { regions } = geodata;

return {
Expand Down

0 comments on commit 088224f

Please sign in to comment.