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>