Skip to content

Commit

Permalink
(fix) no longer tries animates line chart with no data
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeleusin committed May 11, 2014
1 parent 15b8ca4 commit 7fac220
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/angular-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,20 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
* [last description]
* @type {[type]}
*/
var last = linedata[linedata.length - 1].values;
var totalLength = path.node().getTotalLength() + getX(last[last.length - 1].x);

path.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(1500)
.ease("linear")
.attr("stroke-dashoffset", 0)
.attr("d", function(d) { return line(d.values) });
if (linedata.length > 0) {
var last = linedata[linedata.length - 1].values;
if (last.length > 0) {
var totalLength = path.node().getTotalLength() + getX(last[last.length - 1].x);

path.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(1500)
.ease("linear")
.attr("stroke-dashoffset", 0)
.attr("d", function(d) { return line(d.values); });
}
}

/**
* Add points
Expand Down

0 comments on commit 7fac220

Please sign in to comment.