Chart Event

25 views
Skip to first unread message

JosePlaza

unread,
Oct 23, 2018, 12:49:29 PM10/23/18
to Google Visualization API
I want to know how to display a new chart after clicking on data of another chart.

For example: 

If I have a barchart display the amount of food Jose - Maria - Adam ate, I want to be able to click on Jose's name and have a new chart displaying the types of food that he ate. Same thing for Maria and Adam.
------------------------------------------------------
Demo:
------------------------------------------------------
Bar Chart - Who ate the most?
      
   0          
   0          0            
   0          0             0
   0          0             0
Jose     Maria     Adam
------------------------------------------------------
>>>>> Click on Jose
------------------------------------------------------
Bar Chart - What did he eat?

            0                                      0
            0                    0                0
            0                    0                0
Slices of Pizza     HotDogs     Wings
------------------------------------------------------

Anyone has an idea on how to do this?

Thanks for your help.

Shawn Hughes

unread,
Oct 23, 2018, 5:21:02 PM10/23/18
to Google Visualization API
Below is what I did using JQuery.

        google.visualization.events.addListener(chart, 'select', selectHandler);

        function selectHandler() {
            var selectedItem = chart.getSelection()[0];
            if (selectedItem) {
                var value1 = data.getValue(selectedItem.row, 4);
                var value2 = data.getValue(selectedItem.row, 5);
                $("#div1").load("chart1.asp?str1=" + value1 + "&str2=" + value2);    
                $("#div2").load("chart2.asp?str1=" + value1 + "&str2=" + value2);    
Reply all
Reply to author
Forward
0 new messages