Skip to content

Commit

Permalink
add new boolean property on line chart to enable/disable mouseover fo…
Browse files Browse the repository at this point in the history
…r xy axis refs and data points
  • Loading branch information
Davis Ford committed Oct 18, 2014
1 parent dcd566c commit f3cf915
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions spec/line-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ describe('dc.lineChart', function() {
});
});

describe('data point highlights and refs off', function () {
beforeEach(function () {
chart.title(function (d) { return d.value; });
chart.brushOn(false).xyTipsOn(false).render();
});
it('should not generate per data points', function () {
expect(chart.selectAll('circle.dot').size())toBe(0);
});
it('should not generate x and y refs', function () {
expect(chart.selectAll('path.xRef').size()).toBe(0);
expect(chart.selectAll('path.yRef').size()).toBe(0);
});
});

describe('data point highlights', function () {
beforeEach(function () {
chart.title(function (d) { return d.value; });
Expand Down
17 changes: 16 additions & 1 deletion src/line-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dc.lineChart = function (parent, chartGroup) {
var _tension = 0.7;
var _defined;
var _dashStyle;
var _xyTipsOn = true;

_chart.transitionDuration(500);
_chart._rangeBandPadding(1);
Expand Down Expand Up @@ -233,7 +234,7 @@ dc.lineChart = function (parent, chartGroup) {
}

function drawDots(chartBody, layers) {
if (!_chart.brushOn()) {
if (!_chart.brushOn() && _chart.xyTipsOn()) {
var tooltipListClass = TOOLTIP_G_CLASS + '-list';
var tooltips = chartBody.select('g.' + tooltipListClass);

Expand Down Expand Up @@ -338,6 +339,20 @@ dc.lineChart = function (parent, chartGroup) {
}
}

/**
#### .xyTipsOn([boolean])
Turn on/off the mouseover behavior of an individual data point which renders a circle and x/y axis
dashed lines back to each respective axis. This is ignored if the chart brush is on (`brushOn`)
Default: true
*/
_chart.xyTipsOn = function (_) {
if (!arguments.length) {
return _xyTipsOn;
}
_xyTipsOn = _;
return _chart;
};

/**
#### .dotRadius([dotRadius])
Get or set the radius (in px) for dots displayed on the data points. Default dot radius is 5.
Expand Down

0 comments on commit f3cf915

Please sign in to comment.