我在 X 轴上获取格式为 18:30:00.000 的时间而不是日期,如何在 X 轴上显示日期?我将日期插入为 varchar 并采用这种格式 2015-04-01入库。 然后我使用这个查询来获取:
$sql = "SELECT TRIM(TRAILING '.000000' from UNIX_TIMESTAMP(date)*1000) as unixdate,".$type." from h_stats where category='Hits' order by unixdate asc";
并创建日期格式为 highcharts 的 CSV 文件。我使用下面的 jquery 属性使用 highcharts 在 X 轴上显示日期。但我不明白。
$('#hits').highcharts('StockChart', {
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
second: '%Y-%m-%d<br/>%H:%M:%S',
minute: '%Y-%m-%d<br/>%H:%M',
hour: '%Y-%m-%d<br/>%H:%M',
day: '%Y<br/>%m-%d',
week: '%Y<br/>%m-%d',
month: '%Y-%m',
year: '%Y'
}
},
最佳答案
我猜你使用PHP连接数据库,所以更好的是从数据库获取数据并转换为json。然后将其在 jaascript 中加载到 highcharts。在SO中,你会发现很多类似的主题。
关于jquery - x 轴上显示时间,而不是 highstock 中显示日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29619249/