Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Highcharts Example</title>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- var options = {
- chart: {
- renderTo: 'container',
- type: 'column',
- marginRight: 130,
- marginBottom: 25
- },
- title: {
- text: 'Project Requests',
- x: -20 //center
- },
- subtitle: {
- text: '',
- x: -20
- },
- xAxis: {
- //////////// FROM PHP data_2.php, $category
- categories: []
- },
- yAxis: {
- title: {
- text: 'Requests'
- },
- plotLines: [{
- value: 0,
- width: 1,
- color: '#808080'
- }]
- },
- tooltip: {
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'top',
- x: -10,
- y: 100,
- borderWidth: 0
- },
- //////////// FROM PHP data_2.php, $series1
- series: []
- }
- ///////////////HOW TO REPLACE JSON BY USING PHP ?//////////////////
- /////$.getJSON("data_2.php", function(json) {
- ///// options.xAxis.categories = json[0]['data'];
- ///// options.series[0] = json[1];
- ///// chart = new Highcharts.Chart(options);});
- ///////////////////////////////////////////////////////////////////
- });
- </script>
- </head>
- <body>
- <script src="http://code.highcharts.com/highcharts.js"></script>
- <script src="http://code.highcharts.com/modules/exporting.js"></script>
- <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"> </div>
- </body>
- <?php
- header("Content-Type:application/json");
- include_once "shift.php";
- list($s1,$e1,$shift) = shift_frame();
- $servername = 'localhost';
- $username = "";
- $password = "";
- $select = "SELECT EH_CELLNUM, COUNT(EH_SERIALID)";
- $table = " FROM T_EEDATA";
- $rule1 = " WHERE (EH_END_DT between ".$s1." and ".$e1.") group by EH_CELLNUM";
- $conn = mysql_connect($servername,$username,$password) or die("Connection failed: " . mysqli_connect_error());
- mysql_select_db("eedata",$conn) or die(mysql_error());
- $sql = $select.$table.$rule1;
- $query = mysql_query( $sql, $conn );
- while($row = mysql_fetch_array($query)){
- $category['data'][] = $row['EH_CELLNUM'];
- $gantries = $gantries.""".$row['EH_CELLNUM'].""".",";
- $series1['data'][] = $row['COUNT(EH_SERIALID)'];
- $insert = $insert.$row['COUNT(EH_SERIALID)'].",";
- }
- //for PHP < v5.2 to replace "json_numeric_check", manual adding up numbers
- $gantries = rtrim($gantries, ",");
- $category = "[{"name":"Cellnum","data":[".$gantries."]}]";
- $insert = rtrim($insert, ",");
- $series1 = "[{"name":"SerialID","data":[".$insert."]}]";
- //echo $category;
- //echo $series1;
- mysql_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement