From 4696e7c6519e66b665047147d2f822cad638c9fb Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Fri, 5 Dec 2014 00:56:52 +0000 Subject: [PATCH] stuff --- page.php | 74 ++++++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/page.php b/page.php index e151a02..b3a146d 100644 --- a/page.php +++ b/page.php @@ -18,16 +18,15 @@ $i = 0; - $hostTypes = array(); + $hostType = array(); // Sets sql charset to utf-8 $mysqli->set_charset("utf8"); - $result = mysqli_query($mysqli, "SELECT HostType, COUNT(HostType) AS \"Num\" FROM serverlist GROUP BY HostType;"); - + $result = mysqli_query($mysqli, 'SELECT COUNT(HostType) AS "Num" FROM serverlist GROUP BY HostType;'); while($row = mysqli_fetch_row($result)){ // puts the value for COUNT(HostType) into $num{i}, so $num0, $num1, $num2, etc. - $hostType[$i] = $row[1]; + $hostType[$i] = $row[0]; $i = $i + 1; } ?> @@ -39,52 +38,43 @@ // 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. function drawChart() { - // Create the data table. - var data = new google.visualization.DataTable(); - data.addColumn('string', 'hostType'); - data.addColumn('number', 'hostTypeCount'); - data.addRows([ - ['CIT', ], - ['DEV', ], - ['DR', ], - ['OAT', ], - ['PROD', ], - ['SIT', ], - ['UAT', ], - ['UNCLASSIFIED', ]; - ]); + // Create the data table. + var data = new google.visualization.DataTable(); + data.addColumn('string', 'hostType'); + data.addColumn('number', 'hostTypeCount'); + data.addRows([ + ['CIT', ], + ['DEV', ], + ['DR', ], + ['OAT', ], + ['PROD', ], + ['SIT', ], + ['UAT', ], + ['UNCLASSIFIED', ]; + ]); - // Set chart options - var options = {'title':'Distro Proportions Among Servers', - 'width':400, - 'height':300}; + // Set chart options + var options = {'title':'Types of Servers', + 'width':400, + 'height':300}; - // 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')); + // 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 distro = data.getValue(selectedItem.row, 0); - alert('The user selected ' + hostType); - } - } - - // 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); + pie_chart.draw(data, options); + bar_chart.draw(data, options); } + + ...AND HERE */ @@ -93,7 +83,5 @@
- -