Highcharts 时间轴yAxis格式(含分钟):仅秒

Highcharts 时间轴yAxis格式(含分钟):仅秒,highcharts,Highcharts,我想画出一个游泳运动员在几次比赛中的比赛时间 对于系列数据,我使用php代码: $datetime1=date('Y, m, d', strtotime($performances['PERF_DATE']."-1 month")); $datetime2='Date.UTC('.$datetime1.')'; $chrono=strtotime($performances['PERF_DATE']); $data[] = "[$datetime2, $chrono]"; xAxis时间表用

我想画出一个游泳运动员在几次比赛中的比赛时间

对于系列数据,我使用php代码:

$datetime1=date('Y, m, d', strtotime($performances['PERF_DATE']."-1 month")); 
$datetime2='Date.UTC('.$datetime1.')';
$chrono=strtotime($performances['PERF_DATE']);
$data[] = "[$datetime2, $chrono]";
xAxis时间表用于游泳比赛日期:

xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: { 
        day: '%d/%m/%Y'}
yAxis时间线用于比赛时间:

yAxis: {
         title : { text :'chronos'},
         type: 'datetime', //y-axis will be in milliseconds
         dateTimeLabelFormats: { //force all formats to be minute:second
         second: '%M:%S',
         minute: '%M:%S'
            },
            min: 0
             }
xAxis时间轴工作得非常好。 但是yAxis有一个格式问题:我不能用mm:ss格式显示时间

我使用的是mysql 5.6.4,比赛时间(PERF_TIME)存储在type TIME(2)列中,即包括2分之一秒。 比赛日期(PERF_DATE)存储在type datetime列中

例如,php生成的表中的$performances['PERF_DATE']将显示:00:01:33.91。 但在高图表中,在yAxis上,该值将为16.Jan,在绘图标签上,该值将显示为1371333600。我想那是微秒。 我假设我需要在$chrono=strotime($performances['PERF_DATE'])上应用正确的时间格式函数; 有人能帮我吗?
非常感谢。

能否显示您的
数据输出?对我来说,它工作得很好,请参阅:确保y值也是以毫秒为单位的时间戳

    $('#container').highcharts({

        chart: {
            type: 'column'
        },

        xAxis: {
            type: 'datetime'
        },

        yAxis: {
            type: 'datetime'
        },


        series: [{
            name: 'Temperatures',
            pointStart: new Date().getTime(),
            pointInterval: 24 * 3600 * 1000, 
            data: [1.5 * 60 * 1000,1.2 * 60 * 1000,2.5 * 60 * 1000,1.9 * 60 * 1000,],
        }]

    }); 

您能显示您的
数据
输出吗?对我来说,它工作得很好,请参阅:确保y值也是以毫秒为单位的时间戳

    $('#container').highcharts({

        chart: {
            type: 'column'
        },

        xAxis: {
            type: 'datetime'
        },

        yAxis: {
            type: 'datetime'
        },


        series: [{
            name: 'Temperatures',
            pointStart: new Date().getTime(),
            pointInterval: 24 * 3600 * 1000, 
            data: [1.5 * 60 * 1000,1.2 * 60 * 1000,2.5 * 60 * 1000,1.9 * 60 * 1000,],
        }]

    }); 

很抱歉,我之前确实回答了,但我的答案没有被系统保存下来——显然有8小时的停电时间,作者无法回答自己的问题

我想出来了: 我的时间在mysql中格式为hh:mm:ss.00。我认为有一个函数可以轻松地将mysql时间格式转换为毫秒格式,但显然没有。 因此,我使用以下代码手动将时间“分解”为毫秒:

extract($performances); 
 //converts date from 2012-01-10 (mysql date format) to the format Highcharts understands 2012, 1, 10
$datetime1=date('Y, m, d', strtotime($performances['PERF_DATE']."-1 month"));

//getting the date into the required format for pushing the Data into the Series
$datetime2='Date.UTC('.$datetime1.')'; 

// value is in format hh:mm:ss.00
$chrono1=$performances['PERF_TIME']; 

// explodes value in mn, sec and microseconds
sscanf($chrono1,"%d:%d:%d.%d",$hours,$minutes,$seconds,$milliseconds);

// calculate total of milliseconds
$chrono=$seconds * 1000 + $minutes * 60 * 1000 + $milliseconds * 10;

$data[] = "[$datetime2, $chrono]";
也许有更干净的方法?但我现在可以将$data输入Highcharts,而且效果非常好


谢谢。

抱歉,我之前确实回答了,但我的答案没有被系统保存下来——显然,有8小时的停电时间,作者无法回答自己的问题

我想出来了: 我的时间在mysql中格式为hh:mm:ss.00。我认为有一个函数可以轻松地将mysql时间格式转换为毫秒格式,但显然没有。 因此,我使用以下代码手动将时间“分解”为毫秒:

extract($performances); 
 //converts date from 2012-01-10 (mysql date format) to the format Highcharts understands 2012, 1, 10
$datetime1=date('Y, m, d', strtotime($performances['PERF_DATE']."-1 month"));

//getting the date into the required format for pushing the Data into the Series
$datetime2='Date.UTC('.$datetime1.')'; 

// value is in format hh:mm:ss.00
$chrono1=$performances['PERF_TIME']; 

// explodes value in mn, sec and microseconds
sscanf($chrono1,"%d:%d:%d.%d",$hours,$minutes,$seconds,$milliseconds);

// calculate total of milliseconds
$chrono=$seconds * 1000 + $minutes * 60 * 1000 + $milliseconds * 10;

$data[] = "[$datetime2, $chrono]";
也许有更干净的方法?但我现在可以将$data输入Highcharts,而且效果非常好


谢谢。

mysql的数据输出是hh:mm:ss.00我的意思是数据输出,例如,
系列:[{data:}]
和下面的内容(使用
console.log()
告诉我们Highcharts传递了什么)-示例就足够了。更新了JSFIDLE,其中工具提示显示格式化的时间值:mysql的数据输出是hh:mm:ss.00I是指数据输出,例如,您对
系列:[{data:}]
有什么内容,以及下面有什么内容(使用
控制台.log()
并告诉我们传递给Highcharts的内容)-示例就足够了。更新的JSFIDLE,其中工具提示显示格式化的时间值: