I am attempting to detect click on line chart datapoints.
Per this answer ( dc scatter plot binding onClick event ) I am attempting to use the pretransition event as described, but I must be missing something.
lineChart.on('pretransition', function() {
lineChart.selectAll('path.symbol').on('click', function(d) {
alert('value: ' + d);
//How would I pop-up the datapoint values?
});
});
Each chart uses different elements and classes for its diagrams. This is currently not documented, so the best bet is to go to the source.
In this case, here's the line:
var dots = g.selectAll('circle.' + DOT_CIRCLE_CLASS)
https://github.com/dc-js/dc.js/blob/f7e0a47d1246b95acbc279f14243524a0769fb84/src/line-chart.js#L279
After looking up the constant, the selector you're looking for should be circle.dot
I’ve started documenting selectors in the wiki: