I have a Highstock graph and I've got the data from a MySQL database like is shown in this example.
The date field is a MySQL timestamp. When I situate the cursor over a value, only the year is shown instead of (Day, month day, year).
Any idea about why only the year is shown?
I'm using Codeigniter framework and the server side code looks like:
$sql = "SELECT UNIX_TIMESTAMP(sop_date)*1000 AS sop_date, sop_price
FROM share
INNER JOIN share_operation
ON share_operation.sop_idsha = share.sha_id
INNER JOIN share_operation_type
ON share_operation_type.sot_id = share_operation.sop_idsot";
$params = array($sha_idcon, $sha_idwal);
$query = $this->db->query($sql, $params);
if ($query->num_rows() > 0) {
$data = array();
foreach ($query->result() as $i => $row) {
$data[] = "[$row->sop_date, $row->sop_price]";
}
return ($data);
}
Client side:
$(document).ready(function() {
Highcharts.setOptions({
lang: {
months: ['Gener', 'Febrer', 'Març', 'Abril', 'Maig', 'Juny',
'Juliol', 'Agost', 'Setembre', 'Octubre', 'Novembre', 'Desembre'],
weekdays: ['Dilluns', 'Dimarts', 'Dimecres', 'Dijous', 'Divendres', 'Dissabte', 'Diumenge'],
rangeSelectorFrom: 'Des de',
rangeSelectorTo: 'Fins'
}
});
window.chart = new Highcharts.StockChart({
chart : {
renderTo : 'graphic'
},
rangeSelector : {
selected : 1
},
title : {
text : 'Xisco'
},
xAxis : {
maxZoom : 14 * 24 * 3600000 // fourteen days
},
series : [{
name : 'Xisco',
data : [<?php echo join($data, ',') ?>],
tooltip: {
yDecimals: 2
}
}]
});
});