Commit e2c39ec9 authored by Mike Greiling's avatar Mike Greiling

render burndown chart lines

parent dab26c55
...@@ -13,6 +13,8 @@ export default class BurndownChart { ...@@ -13,6 +13,8 @@ export default class BurndownChart {
this.chartGroup = this.canvas.append('g').attr('class', 'chart'); this.chartGroup = this.canvas.append('g').attr('class', 'chart');
this.xAxisGroup = this.chartGroup.append('g').attr('class', 'x axis'); this.xAxisGroup = this.chartGroup.append('g').attr('class', 'x axis');
this.yAxisGroup = this.chartGroup.append('g').attr('class', 'y axis'); this.yAxisGroup = this.chartGroup.append('g').attr('class', 'y axis');
this.idealLinePath = this.chartGroup.append('path').attr('class', 'ideal line');
this.actualLinePath = this.chartGroup.append('path').attr('class', 'actual line');
// parse start and due dates // parse start and due dates
this.startDate = parseDate(startDate); this.startDate = parseDate(startDate);
...@@ -52,6 +54,11 @@ export default class BurndownChart { ...@@ -52,6 +54,11 @@ export default class BurndownChart {
.tickPadding(6) .tickPadding(6)
.tickSize(4, 0); .tickSize(4, 0);
// create lines
this.line = d3.svg.line()
.x(d => this.xScale(d.date))
.y(d => this.yScale(d.value));
// render the chart // render the chart
this.render(); this.render();
} }
...@@ -70,6 +77,13 @@ export default class BurndownChart { ...@@ -70,6 +77,13 @@ export default class BurndownChart {
this.xScale.domain([this.startDate, this.xMax]); this.xScale.domain([this.startDate, this.xMax]);
this.yScale.domain([0, this.yMax]); this.yScale.domain([0, this.yMax]);
// set our ideal line data
if (this.data.length > 1) {
const idealStart = this.data[0] || { date: this.startDate, value: 0 };
const idealEnd = { date: this.xMax, value: 0 };
this.idealData = [idealStart, idealEnd];
}
this.render(); this.render();
} }
...@@ -100,5 +114,10 @@ export default class BurndownChart { ...@@ -100,5 +114,10 @@ export default class BurndownChart {
this.xAxisGroup.call(this.xAxis); this.xAxisGroup.call(this.xAxis);
this.yAxisGroup.call(this.yAxis); this.yAxisGroup.call(this.yAxis);
if (this.data != null && this.data.length > 1) {
this.actualLinePath.datum(this.data).attr('d', this.line);
this.idealLinePath.datum(this.idealData).attr('d', this.line);
}
} }
} }
...@@ -247,6 +247,7 @@ ...@@ -247,6 +247,7 @@
} }
$burndown-chart-axis-color: #aaa; $burndown-chart-axis-color: #aaa;
$burndown-chart-line-color: #2faa60;
.burndown-chart { .burndown-chart {
width: 100%; width: 100%;
...@@ -269,4 +270,18 @@ $burndown-chart-axis-color: #aaa; ...@@ -269,4 +270,18 @@ $burndown-chart-axis-color: #aaa;
shape-rendering: crispEdges; shape-rendering: crispEdges;
} }
} }
.line {
stroke-width: 2px;
fill: none;
&.actual {
stroke: $burndown-chart-line-color;
}
&.ideal {
stroke: $burndown-chart-axis-color;
stroke-dasharray: 6px 6px;
}
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment