From 23ad2584de4ed2b545024e7de45ef104a6bedfb4 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Fri, 5 Dec 2014 01:14:38 +0000 Subject: [PATCH] Waaaay the charts work, fuck semicolons mang --- page.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/page.php b/page.php index b3a146d..4fe4660 100644 --- a/page.php +++ b/page.php @@ -39,8 +39,6 @@ // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(drawChart); - /* THE ISSUE IS SOMEWHERE BETWEEN HERE... - // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and // draws it. @@ -58,9 +56,9 @@ ['PROD', ], ['SIT', ], ['UAT', ], - ['UNCLASSIFIED', ]; + ['UNCLASSIFIED', ] ]); - + // Set chart options var options = {'title':'Types of Servers', 'width':400, @@ -69,12 +67,23 @@ // Instantiate and draw our chart, passing in some options. var pie_chart = new google.visualization.PieChart(document.getElementById('pie_chart')); var bar_chart = new google.visualization.BarChart(document.getElementById('bar_chart')); + + // The select handler. Call the chart's getSelection() method + function selectHandler() { + var selectedItem = pie_chart.getSelection()[0]; + if (selectedItem) { + var hostType = data.getValue(selectedItem.row, 1); + var hostTypeNum = data.getValue(selectedItem.row, 0); + alert('There are ' + hostType + ' machines running as ' + hostTypeNum); + } + } + // Listen for the 'select' event, and call my function selectHandler() when + // the user selects something on the chart. + google.visualization.events.addListener(pie_chart, 'select', selectHandler); pie_chart.draw(data, options); bar_chart.draw(data, options); } - - ...AND HERE */