dongsi1954 2011-08-29 16:21
浏览 42
已采纳

Highcharts问题 - 标记基于Y轴的系列数据

I have an issue regarding highcharts...

Consider the example relation:

Data
-----
Id(pk)
Date date
Data varchar(50)

This relation contains data. It is important to note that the date is non-contiguous...i.e. data isn't entered everyday. An example table may be

Data
-----
Id       Date        Data
1     2011-08-22   SomeData
2     2011-08-29   MoreData

I present users with an HTML/jQuery interface, where data can be pulled from the database and graphed using highcharts. This works well:

http://dev.speechlink.co.uk/David/fifthiteration/dbgrapher.php

I use the following jQuery to label the x-axis:

xAxis: {
         type: 'datetime',
         maxZoom: 14 * 24 * 3600000, // fourteen days
         lineWidth: 1,
         lineColor: '#999999',
         title: {
            text: 'Date' 
         }
       }

And this is for the series:

series: [{
         type: 'spline',
         name: data.questionTitle,
         pointInterval: 24 * 3600 * 1000,
     pointStart: Date.UTC(data.year, data.month, data.day),
     data: cdata,
     lineColor:  '#f6a828',
     color: '#418ed6'
      }]

Now this works fine bar ONE problem -> all points are plotted as if they are done on successive days...This is not the case...For example, if in my table I have data submitted on the 24th and then no data until the 29th....the data on the 29th is incorrectly placed as data submitted the 25th...

This is obviously to do with this series argument:

         **pointInterval: 24 * 3600 * 1000,**

My data comes in like this:

[23rd, 24th, 25th, 29th]

Whereas it should probably be something like:

[23rd, 24th, 25th, null, null, null, 29th]

I am not sure if the above is correct syntax..thats is why I am here...how do you tell highcharts to skip a point, but keep the same pointintervals....

EDIT:

I see on highcharts you can pass data like so:

var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    xAxis: {
        type: 'datetime'
    },

    series: [{
        data: [
            [Date.UTC(2010, 0, 1), 29.9], 
            [Date.UTC(2010, 2, 1), 71.5], 
            [Date.UTC(2010, 3, 1), 106.4]
        ]
    }]
});

Is there a way to pass a php array in the correct format to the series above (i.e. with a data and associated value)..

  • 写回答

1条回答 默认 最新

  • dongpa5277 2011-08-29 16:26
    关注

    If you dont have data points for an interval then you can specify as null in the series. You can try [23rd, 24th, 25th, null, null, null, 29th] it will perfectly work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决