开发者

Highcharts Issue - Labelling Y-Axis Based Series Data

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 t开发者_如何学运维he 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)..


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜