From 0be36128cd929db0d10445120ca9261e8d3934b1 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Mon, 16 Mar 2015 19:05:39 +0700 Subject: [PATCH] SAC dots --- app/scripts/src/charts/stacked_area_chart.jsx | 117 ++++++++++++++---- 1 file changed, 95 insertions(+), 22 deletions(-) diff --git a/app/scripts/src/charts/stacked_area_chart.jsx b/app/scripts/src/charts/stacked_area_chart.jsx index b5dd23b..750016d 100644 --- a/app/scripts/src/charts/stacked_area_chart.jsx +++ b/app/scripts/src/charts/stacked_area_chart.jsx @@ -4,6 +4,22 @@ var StackedAreaChart = React.createClass({ numElements: 10, maxWeeks: 30, height: 350, + words: { + items: { + repo: 'repositories', + team: 'teams', + user: 'contributors' + }, + item: { + repo: 'repository', + team: 'team' + }, + actions: { + repo: 'which were the most attended by', + team: 'which were the most active working on', + user: 'which were the most active working on' + } + }, getInitialState: function() { return { @@ -111,12 +127,10 @@ var StackedAreaChart = React.createClass({ buildPathD: function(points) { var maxWidth = this.state.canvasWidth, - maxHeight = this.height, - maxValue = this.state.max, - len = points.length; + maxHeight = this.height; - var d = _.map(points, function(point, i) { - return 'L'+ Math.floor(i/(len-1)*maxWidth) +','+ Math.floor(maxHeight - point); + var d = _.map(this.buildDots(points), function(dot) { + return 'L'+ dot[0] +','+ dot[1]; }); d.unshift('M0,'+ maxHeight); d.push('L'+ maxWidth +','+ maxHeight +'Z'); @@ -124,6 +138,17 @@ var StackedAreaChart = React.createClass({ return d.join(' '); }, + buildDots: function(points) { + var maxWidth = this.state.canvasWidth, + maxHeight = this.height, + maxValue = this.state.max, + len = points.length; + + return _.map(points, function(point, i) { + return [Math.floor(i/(len-1)*maxWidth), Math.floor(maxHeight - point)]; + }); + }, + render: function() { var maxWidth = this.state.canvasWidth, maxHeight = this.height, @@ -138,7 +163,7 @@ var StackedAreaChart = React.createClass({ var sum = 0; var points = _.map(values, function(val) { - sum += Math.floor(val/max*maxHeight); + sum += Math.floor(val/max*maxHeight*0.96); return sum; }); @@ -171,22 +196,28 @@ var StackedAreaChart = React.createClass({ ); }.bind(this)); - var words = { - items: { - repo: 'repositories', - team: 'teams', - user: 'contributors' - }, - item: { - repo: 'repository', - team: 'team' - }, - actions: { - repo: 'which were the most attended by', - team: 'which were the most active working on', - user: 'which were the most active working on' + var dots = _.map(paths, function(pair, i) { + var item = pair[0], path = pair[1]; + var dots = this.buildDots(path); + var lastY = 0; + var renderDot = function(dot, j) { + if (lastY === dot[1]) { + return null; } - }, + lastY = dot[1]; + return ( + + ); + }; + + return dots.map(renderDot); + }.bind(this)); + + var words = this.words, who = this.getParams().repo || this.getParams().team || this.getParams().user || this.getParams().org; var params = Object.keys(this.getParams()); @@ -212,7 +243,8 @@ var StackedAreaChart = React.createClass({ - {areas.reverse()} + {areas.reverse()} + {dots}