bmesser
Posts: 58
Joined: Sun Apr 22, 2012 12:40 pm

Fun and games with pointInterval

Hi

Please could anyone help me set the correct pointInterval for a monthly series of values that extends from 1659 to 2012. I have set the pontInterval to 3600 x 24 x 1000 x 30.5 which doesn't seem quite correct. What is the correct value for a monthly series? I have found that 3600 x 24 x 1000 x 365.25 for annual values seems to work OK.

Bruce.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Fun and games with pointInterval

Hm, how about preprocessing your data and not using pointInterval?
Something similar is described here: http://highslide.com/forum/viewtopic.ph ... 08&p=25788
Paweł Fus
Highcharts Developer
bmesser
Posts: 58
Joined: Sun Apr 22, 2012 12:40 pm

Re: Fun and games with pointInterval

Hi Fusher

Thanks for your reply - I've looked at the topic you pointed to me at for a solution and tried the example:

Code: Select all

var data = [3,2,5,3,5,6,2,3,1];
var month = 4; // the first month 
$.map(data, function(value) {
   return [Date.UTC(2010, month++, 1), value];
});
Which when I run and debug in Aptana Studio gives me [3,2,5,3,5,6,2,3,1] so it does nothing!

When I look at the jQuery API for Map (http://api.jquery.com/jQuery.map/) I notice that in the comments people are saying that map returns a flat array and not multi-dimensional one. In fact one comment says that to get a multi-dimensional array you need to do this:

Code: Select all

var arr = [1,2,3,4];
$.map(arr, function(value, index) {
return [[index, value]];
});
Returns: [[0, 1], [1, 2], [2, 3], [3, 4]]

I tried this example and in the debugger it returns [1,2,3,4] so also fails to do anything!
I know this forum is not a Javascript tutorial but the solution you suggest doesn't work can you try it or am I going mad.

Bruce.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Fun and games with pointInterval

I mean something like this: http://jsfiddle.net/Fusher/fnK92/ ;)
Paweł Fus
Highcharts Developer
bmesser
Posts: 58
Joined: Sun Apr 22, 2012 12:40 pm

Re: Fun and games with pointInterval

Hi Fusher

Thanks for your example which I have now implemented and works fine.

The problem was the example you first pointed me at viewtopic.php?f=9&t=5408&p=25788 was wrong...

Code: Select all

var data = [3,2,5,3,5,6,2,3,1];
var month = 4; // the first month 
$.map(data, function(value) {
   return [Date.UTC(2010, month++, 1), value];
});
and yours worked fine.

Code: Select all

var data = [3,2,5,3,5,6,2,3,1];
var month = 4; // the first month
data = $.map(data, function(value) {
    return {
        x: Date.UTC(2000, month++, 1), 
        y: value
    };
});
Bruce.

Return to “Highcharts Usage”