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 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c