Skip to content

Commit

Permalink
fix #243
Browse files Browse the repository at this point in the history
  • Loading branch information
NickQiZhu committed Aug 22, 2013
1 parent b38722c commit 5e3223e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ dc.utils.createLegendable = function (chart, group, index, accessor) {
if (typeof chart.colors === 'function') legendable.color = chart.colors()(index);
return legendable;
};

dc.utils.safeNumber = function(n){return isNaN(n)?0:n;};
dc.events = {
current: null
};
Expand Down Expand Up @@ -2461,7 +2463,7 @@ dc.barChart = function (parent, chartGroup) {
};

function barHeight(d) {
return Math.abs(_chart.y()(d.y + d.y0) - _chart.y()(d.y0));
return dc.utils.safeNumber(Math.abs(_chart.y()(d.y + d.y0) - _chart.y()(d.y0)));
}

function renderBars(layer, d, i) {
Expand All @@ -2480,15 +2482,15 @@ dc.barChart = function (parent, chartGroup) {
.attr("x", function (d) {
var x = _chart.x()(d.x);
if (_centerBar) x -= _barWidth / 2;
return x;
return dc.utils.safeNumber(x);
})
.attr("y", function (d) {
var y = _chart.y()(d.y + d.y0);

if (d.y < 0)
y -= barHeight(d);

return y;
return dc.utils.safeNumber(y);
})
.attr("width", _barWidth)
.attr("height", function (d) {
Expand Down Expand Up @@ -2728,10 +2730,10 @@ dc.lineChart = function (parent, chartGroup) {
.append("title").text(_chart.title());

dots.attr("cx", function (d) {
return _chart.x()(d.x);
return dc.utils.safeNumber(_chart.x()(d.x));
})
.attr("cy", function (d) {
return _chart.y()(d.y + d.y0);
return dc.utils.safeNumber(_chart.y()(d.y + d.y0));
})
.select("title").text(_chart.title());

Expand Down

0 comments on commit 5e3223e

Please sign in to comment.