Skip to content

Commit

Permalink
do not draw undefined points for lineChart. Closes dc-js#330
Browse files Browse the repository at this point in the history
  • Loading branch information
jrideout committed Oct 10, 2013
1 parent 26fe7d3 commit 0688648
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,7 @@ dc.lineChart = function (parent, chartGroup) {
layers.each(function (d, i) {
var layer = d3.select(this);
var points = layer.datum().points;
if (_defined) points = points.filter(_defined);

var g = tooltips.select("g." + TOOLTIP_G_CLASS + "._" + i);
if (g.empty()) g = tooltips.append("g").attr("class", TOOLTIP_G_CLASS + " _" + i);
Expand Down
2 changes: 1 addition & 1 deletion dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/line-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ dc.lineChart = function (parent, chartGroup) {
layers.each(function (d, i) {
var layer = d3.select(this);
var points = layer.datum().points;
if (_defined) points = points.filter(_defined);

var g = tooltips.select("g." + TOOLTIP_G_CLASS + "._" + i);
if (g.empty()) g = tooltips.append("g").attr("class", TOOLTIP_G_CLASS + " _" + i);
Expand Down
22 changes: 22 additions & 0 deletions test/line-chart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,28 @@ suite.addBatch({
}
});

suite.addBatch({
'defined hides undefined points': {
topic: function () {
var chart = buildChart("chart-defeined");
chart.defined(function(d) { return d.x.valueOf() != 1339311600000;});
chart.brushOn(false);
chart.render();
return chart;
},
'path should be broken where not defined': function (chart) {
assert.notEqual(chart.select("path.line").attr("d").indexOf("M",1),-1);
},
'dots should not be drawn on undefined points': function (chart) {
assert.equal(chart.selectAll(".dot").size(),5);
},
teardown: function (topic) {
resetAllFilters();
resetBody();
}
}
});

suite.addBatch({
'horizontal grid lines drawing': {
topic: function () {
Expand Down
1 change: 1 addition & 0 deletions web/js/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,7 @@ dc.lineChart = function (parent, chartGroup) {
layers.each(function (d, i) {
var layer = d3.select(this);
var points = layer.datum().points;
if (_defined) points = points.filter(_defined);

var g = tooltips.select("g." + TOOLTIP_G_CLASS + "._" + i);
if (g.empty()) g = tooltips.append("g").attr("class", TOOLTIP_G_CLASS + " _" + i);
Expand Down

0 comments on commit 0688648

Please sign in to comment.