Reputation: 109
how do I set the time on the axis and tooltip with the time in the database?
this is my dataPLLive.php
<?php
header("Content-type: text/json");
$servername = "....";
$username = ".....";
$password = ".....";
$dbname = "...."
$conn = mysqli_connect($servername, $username, $password, $dbname);
$query = mysqli_query($conn, ("SELECT a.`JAM`, AVG(a.PacketLoss) AVG
FROM (
SELECT `JAM`,`RNC`,`IPPATH_PM` AS PHB,`VS_IPPM_FORWORD_DROPMEANS` AS PacketLoss, `VSIPPMRttMeans` AS Latency, 'IPPM'
FROM `rnc_ippm_meas`
WHERE `JAM`>= CURDATE() AND `IPPATH_PM` LIKE '%AF31%'
UNION
SELECT `JAM`,`RNC`,`IPPOOL_PM`,`VSIPPOOLIPPMForwardDrop-Means`,`VSIPPOOLIPPMRttMeans`, 'IPPOOLPM'
FROM `rnc_ippool_ippm_meas`
WHERE `JAM`>= CURDATE() AND `IPPOOL_PM` LIKE '%AF31%') a
GROUP BY a.`JAM`
LIMIT 10000"));
if (!$query) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
$arr = array();
while ($row = mysqli_fetch_assoc($query)) {
$value = $row['AVG'];
$x = strtotime($row['JAM']) * 1000;
$y = floatval($value);
$arr[] = array($x, $y);
}
echo json_encode($arr);
?>
heres the output Imgur,Big thanks if someone can solve this , Thanks
Upvotes: 0
Views: 44
Reputation: 543
You might want to try:
xAxis: {
type: 'datetime',
labels: {
format: '{value:%H:%M:%S}'
}
}
and
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x:%Y-%m-%d %H:%M:%S}<br/>{point.y:.2f}'
}
Regarding the discrepancy between the database time and the chart time, that might have to do with timezone settings in you DB. These Highchart options might help:
time: {
timezoneOffset: 5 * 60, // Positive value moves time back
useUTC : false
}
Upvotes: 1