diff --git a/app/scripts/app.jsx b/app/scripts/app.jsx index 2f15def..68639dc 100644 --- a/app/scripts/app.jsx +++ b/app/scripts/app.jsx @@ -80,7 +80,8 @@ var TeamStats = React.createClass({ render: function(){ return (
- +
); } @@ -102,7 +103,7 @@ var RepoStats = React.createClass({ render: function(){ return (
- +
); } diff --git a/app/scripts/charts.jsx b/app/scripts/charts.jsx index ea6011e..e98e091 100644 --- a/app/scripts/charts.jsx +++ b/app/scripts/charts.jsx @@ -21,7 +21,7 @@ var BarChart = React.createClass({ this.fetchData(); }, - onFilter: function(thing, i) { + handleFilter: function(thing, i) { if (thing === 'item' && this.props.items[i] !== this.state.item) { this.setState({ item: this.props.items[i] @@ -33,6 +33,12 @@ var BarChart = React.createClass({ } }, + handleClick: function(point) { + var params = {org: this.getParams().org}; + params[this.state.item] = point.item; + this.transitionTo(this.state.item, params); + }, + fetchData: function() { $.get(this.props.api, this.apiParams(), function(res){ this.setState({ @@ -95,11 +101,11 @@ var BarChart = React.createClass({ + onChange={this.handleFilter.bind(this, 'item')} /> + onChange={this.handleFilter.bind(this, 'sort')} /> {this.state.points.map(this.renderBar)} @@ -119,13 +125,12 @@ var BarChart = React.createClass({ offset = -min/max2*maxWidth, x = (min >= 0 ? 0 : offset - (val >= 0 ? 0 : width)), y = this.y(i); - // console.log(point.item, {val: val, max: max, x: x, y: y, width: width}) return ( - + onClick={this.handleClick.bind(this, point)} /> ); } }); @@ -133,13 +138,9 @@ var BarChart = React.createClass({ var Bar = React.createClass({ mixins: [Router.Navigation], - handleClick: function(e) { - this.transitionTo(this.props.link + this.props.point.item); - }, - render: function() { - var val = this.props.point[this.props.metric], - item = this.props.point.item, + var val = this.props.value, + item = this.props.item, offset = this.props.offset, width = this.props.width, label = item + ': ' + val, @@ -168,8 +169,8 @@ var Bar = React.createClass({ } return ( - - +