Issue 1977 in google-visualization-api-issues: Charting event listiners

0 views
Skip to first unread message

google-visualiz...@googlecode.com

unread,
May 8, 2015, 4:15:46 AM5/8/15
to google-visualiz...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Enhancement Priority-Low

New issue 1977 by paulmich...@gmail.com: Charting event listiners
https://code.google.com/p/google-visualization-api-issues/issues/detail?id=1977

Hi,

Been playing with google charts for a while and I have some thoughts on how
select event is handled for chart clicks.

At present the select event is fired for a selection, which in turn
highlights the area selected. The issue I see is that this same select
event is fired when you click the already selected area again.

The event is called 'select' so why is it fired when we are not selecting a
chart portion (we are actually deselecting with a second click). This
becomes even more silly when you see that selection criteria is now empty.

So we click a chart area and we fire select event, for which selected
criteria can be obtained, but clicking the same area to un-highlight it
still fires the select event with no selection criteria.

This becomes an issue when we use the selection of a chart area to do
something like drill down to further charts, you can end up in a scenario
where someone could click a chart area to drill down to other charts, go
back and decide they want to look at the drill down again, so they click
the same area..... accept this time nothing happens. To the user it looks
like the tool is not working because a deselection happened which fired
select with no criteria.

I worked around the problem above by caching the previous selection and if
a select event was fired with no criteria it used the previous selected
data.

My suggestion is to alter this with either:-

1) Always supply the select criteria even on a deselect (breaking current
usage)

2) Give an option to always force selection regardless of previous selected
status (so clicking on a selected area just reselects, again breaking
current usage)

3) Add a deselect event, that is fired when a deselection happens, exposing
the criteria of the deselected event (cleaner non breaking)

Option 3 would give the ability for users to map both select and deseelct
events to the same function in circumstances where they always need to know
what was clicked regardless of state.

thanks

Paul

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

google-visualiz...@googlecode.com

unread,
May 8, 2015, 10:06:30 AM5/8/15
to google-visualiz...@googlegroups.com
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

google-visualiz...@googlecode.com

unread,
May 8, 2015, 10:33:45 AM5/8/15
to google-visualiz...@googlegroups.com

Comment #2 on issue 1977 by paulmich...@gmail.com: Charting event listiners
https://code.google.com/p/google-visualization-api-issues/issues/detail?id=1977

Hi,

Thanks for your feedback, I totally agree that what I am actually after is
an onclick event, I will certinaly look into working this with the
mousedown example you posted.

I am at present building dashboards (having used fusion charts in the past)
but went with google charts this time as they have matured a lot so
congrats on that. My usage case gets a bit more difficult as I am using
angular too, so usage has come through the wrapper class for angular that
can be found on git hub.

I do currently have this working with a modified version of the wrapper,
but I wanted to see if I could get the deslsect looked into for more than
one reason...


My example above is the first case where I needed an onclick event, so on
clicking the chart area I could load another chart, hiding the original,
thus reverting back to the original chart means the selection is still in
place. This is where the deselection was happeneing if clicking back on the
same area. Now I have reqorked the dashboard framework a and am now loading
charts each time, replacing the original dash and caching the steps to the
drill downs rather than the dashboards themselves (this framework has a
dashboard that loads cards, the cards can have charts, clicking a chart
loads a new dash, replacing the current dash in view with the new one).

Since I have reworked the framework this issue has gone away, as the
selection is cleared on reload of the dashboard when clicking the roll up.

I still believe a deselect event could be handy, knowing when something was
deslected, but my use of it is not required now, I have implemented my
dashboard framework correctly now ;) so there is no need. I totally admit
that my use of a custom deselect using angular both being mapped to the
same function was a hack, a hack that was there due to the lack of onclick
and the need to know criteria in an onclick fashion, both now negated by
reworking the dashboard.

Again thanks for your time on this

Paul
Reply all
Reply to author
Forward
0 new messages