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

Brush event isn't called #1057

Closed
ChristopheBougere opened this issue Dec 4, 2015 · 2 comments
Closed

Brush event isn't called #1057

ChristopheBougere opened this issue Dec 4, 2015 · 2 comments

Comments

@ChristopheBougere
Copy link

Hi,

I just upgrade from stable to dev (2.0 beta 22). I'm using a CompositeChart containing a stacked BarChart and a LineChart.
I would like to use the brush to select a time range (X axis is time) and process some computes on this range (means, total, ...).
With the stable version, I had some minor issues but event brush.on('brushend', function() {...}); was called.
Since the upgrade, we never enter the callback. I saw that it was quite a known issue, but it is strange that it was working before and not anymore ?
I didn't found any workaround to use brush with composite chart, do you know one ?

Thanks !

Here is one js fiddle with version 1.7, and when we use brush we can see log in console : http://jsfiddle.net/hkgytj5b/
Here is one other with version 2.0 beta 22 and nothing happen when we use brush : http://jsfiddle.net/f9bmytz9/4/

The only difference between the 2 codes is the dc.js minified and the color selector for charts (array => function).

@ChristopheBougere ChristopheBougere changed the title Brush event is'nt called Brush event isn't called Dec 4, 2015
@gordonwoodhull
Copy link
Contributor

Hi @ChristopheBougere, you have to be careful when you are using internal objects of the chart, because you usually don't want to clobber the internal event handling, or be clobbered by it, in this case.

What's happening here is that the chart itself is handling those events, and its own handlers are overwriting yours. I don't know why this wasn't an issue in 1.7.

Namespacing the events fixes this issue:

  brush.on('brushstart.foo', function() {
    console.log("brush start");
  });
  brush.on('brush.foo', function() {
    console.log("brush");
  });
  brush.on('brushend.foo', function() {
    console.log("brush end");
  });

However, there is another post-1.7 issue with brushing on composite charts, which can also be seen in your examples: the brush does not get reflected on the child charts (#878 #706 #390 #677). (I believe it works but is not displayed correctly.) There are some workarounds described on those issues, and a branch with a potential fix (but the tests aren't running clean yet).

@ChristopheBougere
Copy link
Author

Thank you @gordonwoodhull, it works :)
Actually, I didn't understood very well the working of events, that's why I removed the .custom after the event name.
For the brush on the composite chart, I'll wait for the next release including it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants