How to make use of click event (google pie chart) in a second script

84 views
Skip to first unread message

Olaf

unread,
Apr 27, 2013, 2:55:38 AM4/27/13
to google-visua...@googlegroups.com
Hi all,

I use the Google pie chart. I generate the script from a server java class and let it show in a browser. I have a different java script that contains a function. My question is: How can I call this function from my generated Google pie chart script:

 +       "var options = {'title':'Content Type', "
                 +                      "'width':800, "
                 +                      "'height':600,"
                 +                        "'chartArea.left':'50%',colors:['red','#706464','#E9DCDC','#3D0808','black']}; "
                 +       "var chart = new google.visualization.PieChart(document.getElementById('Formular')); "
                 +       "function selectHandler() { "
                 +         "var selectedItem = chart.getSelection()[0]; "
                 +         "if (selectedItem) { "
                 +           "var auswahl = data.getValue(selectedItem.row, 0); "
                 +           "alert('The user selected ' + auswahl); " <---------------------------------------------------------------------------Works perfect!
                 //+             "suSo.push('{\"Funktion\":\"antworten\",\"Text\":\"type\",\"Wert\":auswahl}');" <-------------------Causes the pie chart not to show up when enabled?
                 +         "} "
                 +       "} "
                 +       "google.visualization.events.addListener(chart, 'select', selectHandler); "   
                 +       "chart.draw(data, options); "
                 +     "} "
                 +   "</script> ";

I only started to use the GPC. So this might be a newbee question.

Thank you in advance
Olaf   

asgallant

unread,
Apr 27, 2013, 9:47:56 AM4/27/13
to google-visua...@googlegroups.com
Open the page in Chrome and view the developer's console (ctrl+shift+j to open).  What error message(s) do you see?

Also, if you need help debugging, posting a link to the page or a copy of the code as seen by a browser (after it has been rendered by the server, open the page and view the source to get it) is most helpful to us.

Olaf Resch

unread,
Apr 27, 2013, 11:22:49 AM4/27/13
to google-visua...@googlegroups.com
Hi, thank you for your help. I managed to workaround the problem by integrating the chart api functions in my main script. BW Olaf


2013/4/27 asgallant <drew_g...@abtassoc.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/nUkrjN_jEAQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages