Well, to make a quick fix, I just collaborated the two draw functions into one and also included the event handlers within the draw function.
That seemed to work. Although, I would like to understand why my solution above does not ^^. Best, Dan On Mar 19, 2:55 pm, p00kie <dans...@gmail.com> wrote: > I found the solution in another thread. > :)http://groups.google.com/group/google-visualization-api/browse_thread... > > However, although I have 'chart' and 'table' declared globally, > theeventlistener does not seem to work. > > This is the layout of my visualization code: > > --------------------- > > var chart, table; > > function loadXML() { > ... XML processing ... > > } > > google.load("visualization", "1", {packages:["scatterchart"]}); > google.setOnLoadCallback(drawScatPlot); > > function drawScatPlot() { > ...adding rows to ScatPlot... > chart = new google.visualization.ScatterChart(document.getElementById > ('scat_plot_div')); > chart.draw(data, {width: 600, height: 300, titleX: 'Wavelength', > titleY: 'Value', legend: 'none', pointSize: 4}); > > } > > google.load("visualization", "1", {packages:["table"]}); > google.setOnLoadCallback(drawTable); > > function drawTable() { > ..adding rows to table.. > table = new google.visualization.Table(document.getElementById > ('table_div')); > table.draw(data, {showRowNumber: true}); > > } > > google.visualization.events.addListener(chart, 'select', function() { > table.setSelection([{row: chart.getSelection()[0].row}]); > > }); > > google.visualization.events.addListener(table, 'select', function() { > chart.setSelection([{row: table.getSelect()[0].row, column: 1}]); > > }); > > ------- > > Best, > > Dan > > On Mar 19, 12:34 pm, p00kie <dans...@gmail.com> wrote: > > > VizBoy, > > > Selecting a row in the table returns: > > > [{row:100}] > > > Selecting a point in the scatplot returns: > > > [{row:100, column:1}] > > > Now how can I manipulate this to allow selections to be reflected on > > both visualizations? > > > ---- > > > Dan > > > On Mar 18, 3:38 pm, VizBoy <viz...@google.com> wrote: > > > > You are right -- if the selection format isdifferentthen such a simple > > > X.setSelection(Y.getSelection()) will not do. > > > I suggest you try and play with it, with the information I gave you in the > > > last post (from one minute ago), and if you do not succeed, post again. > > > > - VizBoy. > > > > On Wed, Mar 18, 2009 at 9:26 PM, p00kie <dans...@gmail.com> wrote: > > > > > Hi, > > > > > Further information - I would simply like a mirror-ed selection. If > > > > the user picks a row in thedatatable, it will also reflect in the > > > > scatter chart ( and vice versa ). However, I figured due to the format > > > > difference, a simpleeventhandler such as: > > > > > // When the table is selected, update the orgchart. > > > > google.visualization.events.addListener(table, 'select', function() { > > > > orgchart.setSelection(table.getSelection()); > > > > }); > > > > > // When the orgchart is selected, update the table visualization. > > > > google.visualization.events.addListener(orgchart, 'select', function() > > > > { > > > > table.setSelection(orgchart.getSelection()); > > > > }); > > > > > Would not do. > > > > > On Mar 18, 3:10 pm, p00kie <dans...@gmail.com> wrote: > > > > > Hi, > > > > > > Can you explain further in depth how to determine what kind ofdata > > > > > getSelection returns? > > > > > > On Mar 18, 2:59 pm, VizBoy <viz...@google.com> wrote: > > > > > > > Hi, > > > > > > > Aneventhandler is never between two visualizations. Aneventhandler > > > > > > always listens on one visualization. > > > > > > In the handler itself you can interact with other visualizations, by > > > > calling > > > > > > their methods, but this is entirely up to you. > > > > > > So the answer is -- yes. Question is, what exactly do you want to > > > > > > do? > > > > But in > > > > > > general, once you're in the handler, do what you want. You can get > > > > > > the > > > > > > selection from one visualization, manipulate it in whatever way you > > > > want > > > > > > using javascript and you cansetthe selection in another > > > > > > visualization > > > > in > > > > > > any way you want. > > > > > > > Hope this helps. > > > > > > > - VizBoy. > > > > > > > On Wed, Mar 18, 2009 at 7:59 PM, p00kie <dans...@gmail.com> wrote: > > > > > > > > Is it possible to have aneventhandler between these two? > > > > > > > > Even if thedatasetisdifferent.. > > > > > > > > Table: > > > > > > > data.setCell(i, 0, String(id)); > > > > > > > data.setCell(i, 1, String(pi)); > > > > > > > data.setCell(i, 2, String(ci)); > > > > > > > data.setCell(i, 3, String(dt)); > > > > > > > data.setCell(i, 4, String(lat)); > > > > > > > data.setCell(i, 5, String(lon)); > > > > > > > data.setCell(i, 6, String(wav)); > > > > > > > data.setCell(i, 7, String(name)); > > > > > > > data.setCell(i, 8, String(val)); > > > > > > > > Scatter Chart: > > > > > > > > data.setValue(i, 0, Number(wav)); > > > > > > > data.setValue(i, 1, Number(val)); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to google-visualization-api@googlegroups.com To unsubscribe from this group, send email to google-visualization-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en -~----------~----~----~----~------~----~------~--~---