-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
clickable bar charts not clickable if not dc.units.ordinal #168
Comments
If you turn brush off, the bars will become clickable however you won't be able to use the brush this way. One solution is to create another brushable clone to allow user to select a range to filter, similar to what NASDAQ example was doing. |
Thanks. Maybe I misunderstood. I do have the brush turned off, but I still cannot attach a click handler to individual bars of the chart. It seemed that lines 2203-2204 of dc.js was preventing clickability because the _chart.isOrdinal() check was failing since my xUnits are d3.time.days.
I was assuming I could do:
|
Err.. my bad =) in a rush of replying this I forgot I decided not to implement clicking for non-ordinal bar chart since the range selection is deemed more useful. Yet, you can easily attach the clicking handler using a renderlet, try this: chart.renderlet(function(_chart){
_chart.selectAll("rect.bar").on("click", _chart.onClick);
}); |
Ah! That's perfect, thank you very much. |
hi Nick, |
For double clicking you can simply attach a listener to dbclick event: chart.renderlet(function(_chart){
_chart.selectAll("rect.bar").on("dbclick", function(e){...});
}); Range selection currently does not work with ordinal bar chart however I am thinking of implementing it using the new multi-filter capability. |
Thanks for your reply Nick... Sorry..... i meant multi-select ... i agree that the flexibility of range select-ing on ordinal types would be a good addition, |
It should (be able to) support multi-selection if it does not already. If it does not, please feel free to create a feature request for it (should be a trivial change to make it work) |
The proposed solution to this problem (using renderlet and chart.onClick) does not work with current development version of dc.js (2.0.0-alpha.2). .on("click", _chart.onClick) produces Uncaught TypeError: Cannot read property 'isFiltered' of undefined at dc.js:710. |
Hi @emiguevara, I just saw your comment here. I haven't tried this, but I think you'd have to define your own Here is a more recent conversation: It's too bad that you have to customize dc.js just to get such basic functionality! |
So, it appears that the reason (And using the base's I am fixing this in 2.0.0-beta.4 |
fixes the common complaint that it's hard to add click-bar behavior to charts with quantitative scales, e.g. #168
Hey @gordonwoodhull , Much thanks. |
Hi @anmolkoul, that would be request #657. I think you can do it by adding a custom click event, but I haven't tried it myself. |
To make a bar in a bar chart clickable the xUnits on the bar chart needs to be of type dc.units.ordinal.
I have a bar chart which uses xUnits(d3.time.days). It's 'ordinal' but not dc.units.ordinal. I'd really like to make this chart clickable, but the current implementation doesn't allow me to.
The text was updated successfully, but these errors were encountered: