【问题标题】:Time display at x axis instead of date display in highstock在 x 轴上显示时间,而不是在 highstock 中显示日期
【发布时间】:2015-06-19 14:02:58
【问题描述】:

我在 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'
    }
}, 

【问题讨论】:

    标签: jquery mysql date highcharts highstock


    【解决方案1】:

    我猜你使用PHP连接数据库,所以最好从数据库中获取数据并转换为json。然后在 jaascript 中将其加载到 highcharts。在 SO 中,你会发现很多类似的话题。

    【讨论】:

    • 是的,我已转换为 highcharts 日期格式。现在可以正常使用了,谢谢
    猜你喜欢
    • 1970-01-01
    • 2021-08-21
    • 2016-02-16
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多