Updates:
Status: WontFix
Comment #1 on issue 1977 by
gra...@google.com: Charting event listiners
https://code.google.com/p/google-visualization-api-issues/issues/detail?id=1977
Hi Paul,
While I admit that the semantics of the 'select' event aren't exactly
intuitive, they are fairly straightforward. You can think of it as much
like the 'onchange' event of a text box or <select> tag: even if the result
of the change is that the text box ends up with no content, the event is
still fired.
It seems like for your use case, you should be using the 'click' event
(which admittedly isn't supported for Material Charts, but should be).
Here's an example of that to get you started (although I didn't implement
any drilldown functionality):
http://jsfiddle.net/78rp1pcy/
Furthermore, I'd like to know more about your usage of 'select' for
drilldown. If you have one chart div where you replace the chart with the
new drilled down chart, then you shouldn't have a problem with using
the 'select' event, since the user would click on chart 1, have it be
replaced with chart 2, then the user would click the 'back' button, and
chart 1 would be redrawn without any selection; if this is not what
happens, you could explicitly clear the selection for the chart so that it
is drawn cleanly.
The other possibility is that you have multiple chart divs: one where you
can click one one chart and a new chart will appear with the drilled down
information. But if this is the case, then I'm not entirely sure what you
expect to happen when the user clicks on the same thing in the first chart.
Let's say the user selected row 0, and you showed a second chart; at this
point both charts would be visible, with chart 2 having the state
of "drilled down into row 0". Now, when the user deselects row 0, either
the state of the second chart shouldn't change at all, or it should
disappear.
Since it doesn't appear that you're using the selection of the chart for
anything more than a signal that the user clicked on it, you could actually
just clear the selection in your 'select' handler. This way, the user will
never be deselecting something, since no selection will ever be remembered
beyond what you need to drilldown.
I suppose it's not unreasonable to ask for a 'deselect' event, but your
statement about being able to map both select and deselect to the same
function is not accurate. Since the current behavior of the 'select' event
is to fire even when a user deselects something, and we both came to the
conclusion that we can't break existing use of the 'select' event, you
would wind up with that function being called twice: once for the 'select'
event and another time for the 'deselect' event. This would likely cause
more issues than it will solve.
For these reasons, I'm going to close this Issue as "WontFix". If none of
these solutions work for you or you require further clarification, please
post back and we can discuss this issue further.
- Sergey