1

I have a simple DC.js bar chart. I have it set up so you can click on an element and it gets filtered. This is standard behavior. It remains lit up, and the others go dark. You can then select other elements and have them added to the filter.

I'm looking for a way to replicate that functionality without clicking on the element. So like, i click a link outside the chart and the chart acts like I just clicked on some element.

Has anyone seen this done before?

Thanks,

Edit:

The reason I'm trying to do this is for accessibility. There's no way for keyboard users to interact as far as I can tell.

rbristow
  • 183
  • 2
  • 15
  • 1
    What's with the downvote? Looks like a good question to me. – Gordon Aug 08 '14 at 20:29
  • If you put some code it would be much clearer what you actually want. Also, you probably will get a concrete answer like that. Like this, it's too vague... – Belphegor Aug 10 '14 at 14:21

1 Answers1

1

A hacky way to do it is to use chart.select to get a d3 selection of the element you want, and then fire an artificial click event as described here:

How to invoke "click" event programmatically in d3?

A better way is to do what the base chart onClick does:

_chart.filter(filter);
_chart.redrawGroup();

https://github.com/dc-js/dc.js/blob/master/src/base-mixin.js#L610

where filter is the key you want to filter on.

Community
  • 1
  • 1
Gordon
  • 19,811
  • 4
  • 36
  • 74