Abhijit Nathwani

Members
  • Content count

    1
  • Joined

  • Last visited

Everything posted by Abhijit Nathwani

  1. Realtime Line Graph with PHP

    Hello, I have been working with Fusion Charts for quite some time now and the product is great. I am now trying to create a Real Time Line Graph using Fusion Charts with the data to be fetched from MySQL. Following your documentation for the same, I have successfully implemented "Line Chart". However if change the chart type to "realtimeline", the chart does not load. It says "No data to display". The code: if ($resulthum) { // The `$arrData` array holds the chart attributes and data $arrDatahum = array( "chart" => array( "caption" => "Real-time stock price monitor", "subCaption" => "Harry's SuperMart", "xAxisName" => "Time", "yAxisName" => "Stock Price", "numberPrefix" => "$", "refreshinterval" => "5", "yaxisminvalue" => "35", "yaxismaxvalue" => "36", "numdisplaysets" => "10", "labeldisplay" => "rotate", "showValues" => "0", "showRealTimeValue" => "0", "theme" => "fint" ) ); $arrDatahum["data"] = array(); // Push the data into the array while($row = mysqli_fetch_array($resulthum)) { array_push($arrDatahum["data"], array( "label" => $row["timestamp"], "value" => $row["humidity"] ) ); } /*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */ $jsonEncodedDatahum = json_encode($arrDatahum); /*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.*/ $columnCharthum = new FusionCharts("realtimeline", "myFirstChart2" , 600, 330, "chart-2", "json", $jsonEncodedDatahum); // Render the chart $columnCharthum->render(); // Close the database connection $dbhandle->close(); If you could please identify the mistake I am making, it would be great. Waiting for a reply soon. Abhijit Nathwani