Home forums Using CanvasJS Getting DateTime value from mysql db to create a chart

This topic contains 1 reply, has 2 voices, and was last updated by  Indranil Deo 1 week, 5 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #21361

    d77info
    Member

    Hi
    I am querying mysql database for two values datetime (format: 2018-04-18 11:47:53) and a number values (100 … etc) to create a chart, I am trying to use the below code but its not working, is there any other way I can create this chart, sorry I am also new to php and charting

    $vsql = “SELECT Datetime, value FROM x
    $result = mysqli_query($con,$vsql);
    $dataPoints1 = array();

    while ($row = mysqli_fetch_array($result)) {
    $entry = (strtotime($row[0])*1000) .’, ‘.$row[1];
    array_push($dataPoints1, $entry);
    }
    }

    • This topic was modified 1 week, 6 days ago by  d77info.
    #21377

    Indranil Deo
    Member

    @d77info,

    Kindly download the sample PHP project from this link.

    The above sample shows how to pass dateTime from a database into Charts in PHP. A ReadMe file has been included for your convenience with all the instructions to set up the project.

    Also kindly set the xValueType: "dateTime" as timestamp values are getting assigned to the chart instead of Date objects.

    ____________
    Indranil Deo,
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.