Trigger overlay on interactive google chart

I am creating a custom legend for my Google pie chart because I need a little more control.

I would like my legend to interact with the graphics in exactly the same way as by default. I can add listeners to legend strings that select the appropriate fragment, for example:

myChart.setSelection([{row: selectedIdx]); 

This causes the selection of the slice, as if I clicked a fragment, i.e. it displays a hard line a few pixels from the slice.

That is all right, but I really want to replicate the mouse cursor, i.e. just “highlight” the slice.

I thought the diagram could listen on the mouse, and then examine the event to determine which slice to select, so I connected an onmouseover listener to it. It seemed right, because when I went over a piece of the pie, I even went through:

 Object {row: 1, column: null} 

In my legend string listener, I then called the hover and passed in the same case:

 google.visualization.events.trigger(myChart, 'onmouseover', {row: selectedIndex, column: null}); 

But that did not work. I also tried to explicitly create a JS object, and also use parseInt for the selected index. In the Firefox debugger, both things (the actual cursor hover, the legend trigger) looked exactly the same from the listener's point of view, but only the actual mouse hover caused fragment selection.

Which leaves me at a standstill. Does anyone have an idea how to do this? Ideally, I'm looking for something like:

 var slice = myChart.getSlice(someIndex); slice.setHighlighted(); 

thanks

+4
source share
1 answer

I am afraid this is not possible on Google Charts. However, you can write code to explode a slice rather than highlight it. It does the same from an IMO user perspective.

0
source

All Articles