diff --git a/app/scripts/src/app.jsx b/app/scripts/src/app.jsx index 3686946..9202250 100644 --- a/app/scripts/src/app.jsx +++ b/app/scripts/src/app.jsx @@ -240,31 +240,15 @@ var WeekIntervalSelector = React.createClass({ weeks.push(i); }; - var from = (this.getQuery().f ? parseInt(this.getQuery().f, 10)*100 : lastWeek - 7*weekSeconds), - to = (this.getQuery().t ? parseInt(this.getQuery().t, 10)*100 : lastWeek); - return { - from: from, - to: to, - weeks: weeks + weeks: weeks.sort() }; }, - componentDidMount: function() { - this.updateLocation(); - }, - handleChange: function(thing, e) { - var patch = {}; - patch[thing] = e.target.value; - this.setState(patch, this.updateLocation); - }, - - updateLocation: function() { - this.transitionTo(document.location.pathname, null, { - f: this.state.from/100, - t: this.state.to/100 - }); + var params = this.getQuery(); + params[thing.slice(0, 1)] = e.target.value/100; + this.transitionTo(document.location.pathname, null, params); }, formatDate: function(ts, showYear) { @@ -281,18 +265,23 @@ var WeekIntervalSelector = React.createClass({ }, render: function() { + var daySeconds = 86400, + weekSeconds = daySeconds*7, + lastWeek = this.state.weeks[this.state.weeks.length-1], + from = (this.getQuery().f ? parseInt(this.getQuery().f, 10)*100 : lastWeek - 7*weekSeconds), + to = (this.getQuery().t ? parseInt(this.getQuery().t, 10)*100 : lastWeek); + var weeksBefore = _(this.state.weeks) .filter(function(week) { - return week <= this.state.to; - }.bind(this)) - .sort() + return week <= to; + }) .reverse() .value(); var weeksAfter = _(this.state.weeks) .filter(function(week) { - return week >= this.state.from; - }.bind(this)) - .sort() + return week >= from; + }) + .reverse() .value(); var renderOption = function(ts) { @@ -303,16 +292,17 @@ var WeekIntervalSelector = React.createClass({ return (
-
- {this.formatDate(this.state.from)} - {weeksBefore.map(renderOption)}
- — -
- {this.formatDate(this.state.to)} - {weeksAfter.map(renderOption)}
diff --git a/app/scripts/src/charts/bar_chart.jsx b/app/scripts/src/charts/bar_chart.jsx index da571d4..5fc1d71 100644 --- a/app/scripts/src/charts/bar_chart.jsx +++ b/app/scripts/src/charts/bar_chart.jsx @@ -120,7 +120,7 @@ var BarChart = React.createClass({ return (
- This bar chart represents {words.items[this.state.item]} {words.actions[this.state.item]} {who} {words.item[subject]} from Mar 9 to Apr 27 + This bar chart represents {words.items[this.state.item]} {words.actions[this.state.item]} {who} {words.item[subject]}
- This stacked area chart represents {words.items[this.state.item]} {words.actions[this.state.item]} {who} {words.item[subject]} from Mar 9 to Apr 27 + This stacked area chart represents {words.items[this.state.item]} {words.actions[this.state.item]} {who} {words.item[subject]}