Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the brush preventing dc.js barChart toolTips to appear?

I don't see why that behaviour was implemented. Any good reason ?

like image 987
Chapo Avatar asked Feb 13 '14 04:02

Chapo


2 Answers

In order to have a brushing function, a transparent rectangle that captures all mouse events has to be drawn over top of the graph. That prevents any mouse events from triggering the tooltip event handler on the main graph elements, and is the reason the dc.js API warns that leaving brushing behaviour "on" will disable all other interactive behaviour.

If you want both behaviours, consider using a focus + context layout. That example uses plain d3, but you could recreate it with dc.js. Just have two different views of the same data, one with the brush and one with the tooltips or other interactivity.

like image 143
AmeliaBR Avatar answered Nov 03 '22 17:11

AmeliaBR


You can use https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events to block 'mouseover' event for brush so that tooltips are enabled. Then on chart you can create a custom 'mousedown' event and pass it to brush to enable selection

d3.select('.chartContainer').on('mousedown', function(){
                    brush_elm = self.scrubberContent.select(".brush").node();
                    new_click_event = new Event('mousedown');
                    new_click_event.pageX = d3.event.pageX;
                    new_click_event.clientX = d3.event.clientX;
                    new_click_event.pageY = d3.event.pageY;
                    new_click_event.clientY = d3.event.clientY;
                    brush_elm.dispatchEvent(new_click_event);
                });
like image 2
Abhimanyu Nagurkar Avatar answered Nov 03 '22 19:11

Abhimanyu Nagurkar