From dcc2402b9a337aec5193feac2fb79b9cbb4388a7 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Tue, 17 Mar 2015 00:17:04 +0700 Subject: [PATCH] SAC done --- app/scripts/src/app.jsx | 4 +- app/scripts/src/charts/stacked_area_chart.jsx | 51 ++++++++++++------- app/styles/charts.css | 2 +- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/app/scripts/src/app.jsx b/app/scripts/src/app.jsx index 9202250..3b4ee80 100644 --- a/app/scripts/src/app.jsx +++ b/app/scripts/src/app.jsx @@ -273,13 +273,13 @@ var WeekIntervalSelector = React.createClass({ var weeksBefore = _(this.state.weeks) .filter(function(week) { - return week <= to; + return week < to; }) .reverse() .value(); var weeksAfter = _(this.state.weeks) .filter(function(week) { - return week >= from; + return week > from; }) .reverse() .value(); diff --git a/app/scripts/src/charts/stacked_area_chart.jsx b/app/scripts/src/charts/stacked_area_chart.jsx index 5600e53..100659b 100644 --- a/app/scripts/src/charts/stacked_area_chart.jsx +++ b/app/scripts/src/charts/stacked_area_chart.jsx @@ -64,10 +64,10 @@ var StackedAreaChart = React.createClass({ } }, - handleClick: function(point) { + handleClick: function(item) { var params = {org: this.getParams().org}; - params[this.state.item] = point.item; - this.transitionTo(this.state.item, params); + params[this.state.item] = item; + this.transitionTo(this.state.item, params, this.getQuery()); }, handleFocusIn: function(i) { @@ -83,6 +83,13 @@ var StackedAreaChart = React.createClass({ handleNewData: function() { // Group commits by items var weeksList = _(this.state.rawData).pluck('week').uniq().sort().reverse().take(this.maxWeeks).value(); + if (weeksList.length < 2) { + this.setState({ + weeks: [], + state: 'newPoints' + }); + return; + } var counts = _.reduce(this.state.rawData, function(res, el) { if (weeksList.indexOf(el.week) === -1) { @@ -152,18 +159,6 @@ var StackedAreaChart = React.createClass({ return _.map(points, function(point, i) { point.x = i/(len-1)*maxWidth; point.y = maxHeight - point.point; - - if (point.x < 10) { // Radius - point.x = 10 - } else if (point.x > maxWidth - 10) { - point.x = maxWidth - 10; - } - if (point.y < 10) { - point.y = 10; - } else if (point.y > maxHeight - 10) { - point.y = maxHeight - 10; - } - return point; }); }, @@ -233,12 +228,30 @@ var StackedAreaChart = React.createClass({ if (dot.val === 0) { return null; } + + var maxWidth = this.state.canvasWidth, + maxHeight = this.height, + radius = 10, + x = dot.x, + y = dot.y; + + if (x < radius) { + x = radius + } else if (x > maxWidth - radius) { + x = maxWidth - radius; + } + if (y < radius) { + y = radius; + } else if (y > maxHeight - radius) { + y = maxHeight - radius; + } + return ( ); }.bind(this); @@ -254,7 +267,9 @@ var StackedAreaChart = React.createClass({
  • + onMouseOut={this.handleFocusOut.bind(this, i)} + onClick={this.handleClick.bind(this, item)} + >
    {item}
  • diff --git a/app/styles/charts.css b/app/styles/charts.css index ba916e2..b75e40c 100644 --- a/app/styles/charts.css +++ b/app/styles/charts.css @@ -58,7 +58,7 @@ .sachart-container .legend li { display: inline-block; padding: 10px 15px 0 0; - cursor: default; + cursor: pointer; } .sachart-container.focused .path {