I'd suspect the transformation between pixel coordinates and data coordinates in the chart reference frame to be the really tricky part, since charts do quite a lot of magic behind the scene to decide what the axes scale is (and what paddings to use, which also affects the conversion).
Fixating as many chart parameters as possible (forcing a specific axis scale, extent, removing all visual aspects like the legend which may affect the positioning of the chart inside the iframe...) may help in the calculation, but it'll probably still remain a fragile process until charts start exposing more of their internals to accommodate these needs. -- R. On 21 September 2011 16:49, asgallant <[email protected]> wrote: > Better yet, put this in after you call the draw method (otherwise the chart > might not finish drawing before this is called, and jQuery could throw an > error): > > /* assumes that chart is your chart object > * hooks the 'click' event of the chart div's iframe's body element > * interpolates the mouse coordinates into chart values > * adds them to the chart and redraws the chart > */ > google.events.addListener(chart, 'ready', function () { > > $("#chart_div").find("iframe").contents().find("body").click(function( > e) { > // get X and Y coordinates in the chart > var x = e.pageX - this.offsetLeft; > var y = e.pageY - this.offsetTop; > /* > * transform coordinates into chart values > * and insert into data table object > * > * redraw the chart with new data > */ > }); > }); > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-visualization-api/-/zRTsQAAWn64J. > > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
