stuff
This commit is contained in:
parent
0123c59b1a
commit
4696e7c651
1 changed files with 31 additions and 43 deletions
70
page.php
70
page.php
|
@ -18,16 +18,15 @@
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$hostTypes = array();
|
$hostType = array();
|
||||||
|
|
||||||
// Sets sql charset to utf-8
|
// Sets sql charset to utf-8
|
||||||
$mysqli->set_charset("utf8");
|
$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)){
|
while($row = mysqli_fetch_row($result)){
|
||||||
// puts the value for COUNT(HostType) into $num{i}, so $num0, $num1, $num2, etc.
|
// 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;
|
$i = $i + 1;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -40,51 +39,42 @@
|
||||||
// Set a callback to run when the Google Visualization API is loaded.
|
// Set a callback to run when the Google Visualization API is loaded.
|
||||||
google.setOnLoadCallback(drawChart);
|
google.setOnLoadCallback(drawChart);
|
||||||
|
|
||||||
|
/* THE ISSUE IS SOMEWHERE BETWEEN HERE...
|
||||||
|
|
||||||
// Callback that creates and populates a data table,
|
// Callback that creates and populates a data table,
|
||||||
// instantiates the pie chart, passes in the data and
|
// instantiates the pie chart, passes in the data and
|
||||||
// draws it.
|
// draws it.
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
|
|
||||||
// Create the data table.
|
// Create the data table.
|
||||||
var data = new google.visualization.DataTable();
|
var data = new google.visualization.DataTable();
|
||||||
data.addColumn('string', 'hostType');
|
data.addColumn('string', 'hostType');
|
||||||
data.addColumn('number', 'hostTypeCount');
|
data.addColumn('number', 'hostTypeCount');
|
||||||
data.addRows([
|
data.addRows([
|
||||||
['CIT', <?php echo $hostTypes[0]; ?>],
|
['CIT', <?php echo $hostType[0]; ?>],
|
||||||
['DEV', <?php echo $hostTypes[1]; ?>],
|
['DEV', <?php echo $hostType[1]; ?>],
|
||||||
['DR', <?php echo $hostTypes[2]; ?>],
|
['DR', <?php echo $hostType[2]; ?>],
|
||||||
['OAT', <?php echo $hostTypes[3]; ?>],
|
['OAT', <?php echo $hostType[3]; ?>],
|
||||||
['PROD', <?php echo $hostTypes[4]; ?>],
|
['PROD', <?php echo $hostType[4]; ?>],
|
||||||
['SIT', <?php echo $hostTypes[5]; ?>],
|
['SIT', <?php echo $hostType[5]; ?>],
|
||||||
['UAT', <?php echo $hostTypes[6]; ?>],
|
['UAT', <?php echo $hostType[6]; ?>],
|
||||||
['UNCLASSIFIED', <?php echo $hostTypes[7]; ?>];
|
['UNCLASSIFIED', <?php echo $hostType[7]; ?>];
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Set chart options
|
// Set chart options
|
||||||
var options = {'title':'Distro Proportions Among Servers',
|
var options = {'title':'Types of Servers',
|
||||||
'width':400,
|
'width':400,
|
||||||
'height':300};
|
'height':300};
|
||||||
|
|
||||||
// Instantiate and draw our chart, passing in some options.
|
// Instantiate and draw our chart, passing in some options.
|
||||||
var pie_chart = new google.visualization.PieChart(document.getElementById('pie_chart'));
|
var pie_chart = new google.visualization.PieChart(document.getElementById('pie_chart'));
|
||||||
var bar_chart = new google.visualization.BarChart(document.getElementById('bar_chart'));
|
var bar_chart = new google.visualization.BarChart(document.getElementById('bar_chart'));
|
||||||
|
|
||||||
// The select handler. Call the chart's getSelection() method
|
pie_chart.draw(data, options);
|
||||||
function selectHandler() {
|
bar_chart.draw(data, options);
|
||||||
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
|
...AND HERE */
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -93,7 +83,5 @@
|
||||||
<div id="pie_chart" style="display: inline; float: left;"></div>
|
<div id="pie_chart" style="display: inline; float: left;"></div>
|
||||||
<!--Div that will hold the bar chart-->
|
<!--Div that will hold the bar chart-->
|
||||||
<div id="bar_chart" style="display: inline; float: left;"></div>
|
<div id="bar_chart" style="display: inline; float: left;"></div>
|
||||||
<!--Div that will hold the Sankey chart-->
|
|
||||||
<div id="Sankey_chart" style="display: inline; float: left;"></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Reference in a new issue