Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new boolean property on linechart to toggle mouseover dots #735

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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