My code does not show in the x axis the timestamp data in the firebase
Instead of showing the timestamp in the firebase which is 11:27:47, it shows 8:00:00
This is my code in array:
if (is_array($data)) {
foreach ($data as $user) {
$dataPointsx[] = array("x" => $user['Timestamp'], "y" => $user['Luminosity']);
array_push($dataPointsy, array("y" => $user['Luminosity']));
}
}
While this is the graph:
window.onload = function() {
var dataPointsy= <?php echo json_encode($dataPointsy); ?>;
var dataPointsx= <?php echo json_encode($dataPointsx); ?>;
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title: {
text: "Luminosity"
},
axisX:{
title: "Timestamp",
valueFormatString: "HH:mm:ss",
labelFormatter: function(e){
return new Date(e.value).toLocaleTimeString();
},
interval: 1
},
axisY:{
suffix: " Luminosity"
},
data: [{
type: "line",
toolTipContent: "{y} L⊙ {x}",
dataPoints: dataPointsy,
}]
});
chart.render();
}