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 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛