i want to retrieve data from mysql database into bar chart using Fusion chart. but i get this error when try to debug with console log (ctrl+shift+j in chrome): index.php:212 Uncaught ReferenceError: FusionCharts is not defined
here is my code so far
<?php
include "../../koneksi.php";
//require_once __DIR__ . '/fusioncharts.php';
include "fusioncharts.php";
// Form the SQL query that returns the top 10 most populous countries
$strQuery = mysql_query("select calType, count(cal_num) as count from calequipment Group By CalType order by calType desc");
// If the query returns a valid response, prepare the JSON string
if ($strQuery) {
// The `$arrData` array holds the chart attributes and data
$arrData = array(
"chart" => array(
"caption" => "Calibration Type",
"paletteColors" => "#0075c2",
"bgColor" => "#ffffff",
"borderAlpha"=> "20",
"canvasBorderAlpha"=> "0",
"usePlotGradientColor"=> "0",
"plotBorderAlpha"=> "10",
"showXAxisLine"=> "1",
"xAxisLineColor" => "#999999",
"showValues" => "0",
"divlineColor" => "#999999",
"divLineIsDashed" => "1",
"showAlternateHGridColor" => "0"
)
);
$arrData["data"] = array();
// Push the data into the array
while($row = mysql_fetch_assoc($strQuery)) {
array_push($arrData["data"], array(
"label" => $row["calType"],
"value" => $row["count"]
)
);
}
/*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */
$jsonEncodedData = json_encode($arrData);
/*Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor.*/
$columnChart = new FusionCharts("Pie3D", "myFirstChart" , 600, 300, "chart-1", "json", $jsonEncodedData);
// Render the chart
$columnChart->render();
}
?>
the error said in line 212 and line 217. this the code :
212. <div class="panel panel-default">
217. <?php
its not make sense so i feel confused
i sure that the path includes correctly. please anyone help me. every suggestion would be appreciate thanks :)
edit: i got something different between my php file and console log file. i mean when i try to see the code in console log, the error is in this code:
<script type="text/javascript">
FusionCharts.ready(function () {
new FusionCharts({"type":"Pie3D","id":"myFirstChart","width":600,"height":300,"renderAt":"chart-1","dataFormat":"json","dataSource":{"chart":{"caption":"Calibration Type","paletteColors":"#0075c2","bgColor":"#ffffff","borderAlpha":"20","canvasBorderAlpha":"0","usePlotGradientColor":"0","plotBorderAlpha":"10","showXAxisLine":"1","xAxisLineColor":"#999999","showValues":"0","divlineColor":"#999999","divLineIsDashed":"1","showAlternateHGridColor":"0"},"data":[{"label":"Internal","value":"1"},{"label":"External","value":"2"}]}});
});
</script>
<script type="text/javascript">
FusionCharts.ready(function () {
FusionCharts("myFirstChart").render();
});
</script>
but that code is very different with my php file when i open in notepad++