FusionChart不在远程主机上显示

时间:2016-01-06 13:05:28

标签: php mysql mysqli pdo fusioncharts

我使用Fusionchart和PHP mysql创建了图表,该图表在我的localhost上运行良好,但是当部署在远程/云服务器上时,它不显示图表信息,而是显示字符串"图表不支持"。远程服务器上的错误日志指示第44行上的错误,即执行查询的位置。请您使用您的知识和经验来解决此问题。我写了下面的代码

<?php
include("include/fusioncharts.php");

$hostdb = "localhost";  // MySQl host
$userdb = "root";  // MySQL username
$passdb = "";  // MySQL password
$namedb = "power_generation";  // MySQL database name

// Establish a connection to the database
$dbhandle = new mysqli($hostdb, $userdb, $passdb, $namedb);

/*Render an error message, to avoid abrupt failure, if the database   connection parameters are incorrect */
if ($dbhandle->connect_error) {
 exit("There was an error with your connection: ".$dbhandle->connect_error);
}
?>

<html>
<head>
<title>Peak Generation</title>

 <!-- You need to include the following JS file to render the chart.
When you make your own charts, make sure that the path to this JS file is correct.
Else, you will get JavaScript errors. -->

<script src="javafile/fusioncharts.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php

    // Form the SQL query that returns the top 10 most populous countries
    $strQuery = "select SUM(peak_generation) as TotOutput, pdate, plant_id FROM daily_report WHERE pdate BETWEEN '2015-05-01' AND '2015-05-30' GROUP BY pdate";

    // Execute the query, or else return the error message.
    $result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");



    // If the query returns a valid response, prepare the JSON string
    if ($result) {
        // The `$arrData` array holds the chart attributes and data
        $arrData = array(
            "chart" => array(
              "caption" => "Peak Generation",
              "paletteColors" => "#0075c2",
              "bgColor" => "#ffffff",
              "borderAlpha"=> "20",
              "canvasBorderAlpha"=> "0",
              "usePlotGradientColor"=> "0",
              "plotBorderAlpha"=> "10",
              "showXAxisLine"=> "1",
              "xAxisLineColor" => "#999999",
              "showValues" => "0",
              "divlineColor" => "#999999",
              "divLineIsDashed" => "1",
              "showAlternateHGridColor" => "0",
              "decimalPrecision" => "1",
               "formatNumberScale" => "0"

            )
        );

        $arrData["data"] = array();

// Push the data into the array
        while($row = mysqli_fetch_array($result)) {
        array_push($arrData["data"], array(
            "label" => $row["pdate"],
            "value" => $row["TotOutput"],
            "link" => "testcode.php?daily_report=". $row["pdate"]
            )
        );
        }

        /*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */

        $jsonEncodedData = json_encode($arrData);

        $columnChart = new FusionCharts("Column3D", "myFirstChart" , 1000, 500, "chart", "json", $jsonEncodedData);

        // Render the chart
        $columnChart->render();

        // Close the database connection
        $dbhandle->close();
    }

  ?>


   </head>

   <body>
  <div id="container">
  <div id="chart"><!-- Fusion Charts will render here--></div>

  </div>
  </body>

 </html>

0 个答案:

没有答案