Skip to content

Commit

Permalink
feat(scales): improve XYScales component
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed Apr 19, 2016
1 parent 584ff47 commit f69dc5a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/scales/XYScales.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class XYScales extends Component {
render() {
const {
data,
identityAccessor, valueAccessor,
width, height,
children
} = this.props;
Expand All @@ -21,7 +22,7 @@ class XYScales extends Component {

const yScale = d3.scale.linear()
.range([height, 0])
.domain([0, d3.max(data)])
.domain([0, d3.max(data.map(valueAccessor))])
;

return (
Expand All @@ -36,10 +37,19 @@ class XYScales extends Component {

XYScales.displayName = 'XYScales';

const { array, func, number } = PropTypes;

XYScales.propTypes = {
data: PropTypes.array.isRequired,
width: PropTypes.number,
height: PropTypes.number
data: array.isRequired,
identityAccessor: func.isRequired,
valueAccessor: func.isRequired,
width: number,
height: number
};

XYScales.defaultProps = {
identityAccessor: (d, i) => i,
valueAccessor: d => d
};


Expand Down

0 comments on commit f69dc5a

Please sign in to comment.