Connecting Google Chart(Gauge chart) to MySQL Database

  • 0

    I am working on Gauge visualization using google chart library,PHP,MySQL (Gauge chart with Real time Updation) I wrote the code in PHP and connecting to MySQL database to use elapsed table in database for generating Gauge chart. It works well for Pie-chart,bar-chart, column chart, Line-chart but it's not working with Gauge-chart. It doesn't shows the Gauge chart in output. I think there is problem in format of Gauge.Can any one please help with this problem. Here My code is as follows:

    // Load the Visualization API and the package.
    google.charts.load('current', {'packages':['corechart']});

    // Set a callback to run when the Google Visualization API is loaded.


    function drawChart() {
    var data;
    var options = {
    width: 400,
    height: 120,
    redFrom: 90,
    redTo: 100,
    yellowFrom: 75,
    yellowTo: 90,
    minorTicks: 5
    var chart = new google.visualization.Gauge(document.getElementById('image_div'));
    function refreshData() {
    var json = $.ajax({url:'imagebar.php',dataType: 'json', async: false}).responseText;
    data = google.visualization.arrayToDataTable(json);
    chart.draw(data, options);
    setInterval(refreshData, 1000);
    and My imagebar.php code is as follows: imagebar.php
    $sql = "SELECT wonum, DATEDIFF(dt_on,dt_off) AS elapsedday from elapsed;";
    echo $wonum, $elapsedaday;

    $query = mysql_query($sql);
    while($result = mysql_fetch_array($query))
    $MDHAdata[] = array($result['wonum'],(int)$result['elapsedday']);

    I doesn't shows the Gauge chart in output. Can anyone please help with this problem. I think problem is with Format

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.