Home Forums Chart Support Chart Integration Issue

Chart Integration Issue

Viewing 2 posts - 1 through 2 (of 2 total)
  • #23520

    tbr

    Hello Admin

    Following my query
    I develop with xampp php and PostgresSql, NOT SHOWING RESULT ON PAGE

    my DATABASE
    CREATE TABLE abc
    (
    scountdate timestamp with time zone,
    scount integer
    )
    Databse Value –
    scountdate scount
    “2015-12-20 00:00:00+05:30”; 15
    “2015-12-29 00:00:00+05:30”; 10
    ————————————
    index.php
    ———

    $connection = pg_connect("host=localhost  dbname=pharmabbsr25072018 user=postgres password=postgres")  or die("couldn't make a connection.");
    $sql = "SELECT scountdate, scount FROM abc";
    $result = pg_query($connection,$sql) or die ("Couldn't execute query");
    $totRow = pg_num_rows($result);
    $dataPoints1 = array();
    $dataPoints2 = array();
    $dataPoints3 = array();
    $dataPoints4 = array();
    if ($totRow > 0) {
    	while($row = pg_fetch_array($result)) {
    		$dataPoints1[] = array("x" => (strtotime($row[0])*1000), "y" => $row[1]);
            $dataPoints2[] = array("x" => (strtotime($row[0])*1000), "y" => $row[1]);
            $dataPoints3[] = array("x" => (strtotime($row[0])*1000), "y" => $row[1]);
            $dataPoints4[] = array("x" => (strtotime($row[0])*1000), "y" => $row[1]);
    	}
    }
    
    <html>
    <head>
    <script>
    window.onload = function () {
    
    var chart = new CanvasJS.Chart("chartContainer", {
    animationEnabled: true,
    theme: "light2", // "light1", "light2", "dark1", "dark2"
    title:{
    text: "Date on Axis X"
    },
    axisX:{      
    valueFormatString: "DD-MMM",
    intervalType: "hour",
    interval: 6
    },
    data: [
        {
            type: "column",
            xValueType: "dateTime",
            dataPoints:  <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK) ?>
        },
        {
            //type: "spline",
            type: "column",
            xValueType: "dateTime",
            dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
        },
        {
            //type: "spline",
            type: "column",
            xValueType: "dateTime",
            dataPoints: <?php echo json_encode($dataPoints3, JSON_NUMERIC_CHECK); ?>
        },
        {
            //type: "spline",
            type: "column",
            xValueType: "dateTime",
            dataPoints: <?php echo json_encode($dataPoints4, JSON_NUMERIC_CHECK); ?>
        },
    ]
    });
    chart.render();
    }
    
    </script>
    </head>
    <body>
    <div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
    <script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
    </body>
    </html>
    #23528

    @tbr,

    It seems to be working fine with PostgreSQL. Please take a look at sample project.

    Bitnami provides WAPP Stack to work with PHP and PostgreSQL. I would suggest you to try WAPP over XAMPP for PostgreSQL.

    If you are still facing any issue, please share the sample project along with sample database over Google-Drive or Onedrive, so that we can run it locally at our end, understand your use-case properly and help you out.


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.