Thanks it Works !!! :)

Now I was wondering if there is an example somewhere of using query to
build up a dynamic table which will supply data to this org chart. I
have done some trial and error on this. But it will be very helpful to
see a sample.

Thanks.
Ruby

On Dec 6, 3:10 pm, VizGuy <[email protected]> wrote:
> You are almost there.
> In the selection object, you get the index of the row in the data table.
> The value that you want to get is the value of the data table, in the
> selected row, and probably in the first column.
> And so you need:
> data.getValue(item.row, 0);
>
> Note that in order to use this term in the event handler, you will have to
> move the definition of 'data' out of drawChart function, to the 'global'
> scope.
>
> VizGuy
>
>
>
> On Fri, Dec 5, 2008 at 11:03 PM, Ruby <[email protected]> wrote:
>
> > Hi,
>
> > I am new to google visualization api and still have a lot to learn.
>
> > I created the following code. But dont know how can I ge the value or
> > label of these boxes er. carol and ruby.
>
> > Here is my code
>
> > * the commented alert boxes are what i was trying to get the label ,
> > but didnt work.
>
> > <html>  <head>    <script type="text/javascript" src="http://
> >www.google.com/jsapi">
> > </script>
>
> > <script type="text/javascript">
> >      google.load("visualization", "1", {packages:["orgchart"]});
>
> >              google.setOnLoadCallback(drawChart);
> >                  var orgchart;
>
> >                   function drawChart()
> >                   {
>
> >                    var data = new google.visualization.DataTable();
> >                            data.addColumn('string', 'Name');
> >                                data.addColumn('string', 'Manager');
> >                                data.addRows(6);
> >                                data.setCell(0, 0, 'Mike');
> >                                data.setCell(1, 0, 'Jim');
> >                                data.setCell(1, 1, 'Mike');
> >                                data.setCell(2, 0, 'Alice');
> >                                data.setCell(2, 1, 'Mike');
> >                                data.setCell(3, 0, 'Ruby');
> >                                data.setCell(3, 1, 'Mike');
> >                                data.setCell(4, 0, 'Bob');
> >                                data.setCell(4, 1, 'Jim');
> >                                data.setCell(5, 0, 'Carol');
> >                                data.setCell(5, 1, 'Bob');
>
> >                                orgchart  = new
> > google.visualization.OrgChart
> > (document.getElementById('chart_div'));
> >                                orgchart.draw(data, {});
>
> >  google.visualization.events.addListener(orgchart, 'select',
> > display);
> >                        }
>
> >                        function display(e)
> >                        {
> >                                 var selection = orgchart.getSelection();
>
> >                                var message = '';
> >                                for (var i = 0; i < selection.length; i++)
> >                                {
>
> >                                        alert ("Success !!!");
> >                                        var item = selection[i];
> >                                        //alert('You have item as ' + item);
> >                                        if (item.row != null)
> >                                        {      message += '{row:' + item.row
> > +'}';
> >                                //      alert ("value is "+
> > selection.getValue(rowInds[i]));
>
> >                //                       alert ("You have " +
> > item.row.label);
> >                                        }
>
> >                                }
>
> >                                if (message == '')
> >                                {   message = 'nothing';
> >                                }
>
> >                                        alert('You selected ' + message);
>
> >                        }
>
> >                           </script>
> >                 </head>
> >                  <body>
>
> >                 <div id="chart_div"></div>  </body></html>- Hide quoted 
> > text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to