yvestan
Posts: 3
Joined: Wed Feb 03, 2010 4:54 pm

Datetime axis question

Hello,

Thanks to this great work !

I've little issue when I try to use datetime.

My data :

Code: Select all

<script type="text/javascript">var data_values = [[Date.UTC(2010, 1, 1, 0, 0, 0),5],[Date.UTC(2010, 1, 2, 0, 0, 0),11],[Date.UTC(2010, 1, 3, 0, 0, 0),18],[Date.UTC(2010, 1, 4, 0, 0, 0),15],[Date.UTC(2010, 1, 5, 0, 0, 0),20],[Date.UTC(2010, 1, 6, 0, 0, 0),23],[Date.UTC(2010, 1, 7, 0, 0, 0),22],[Date.UTC(2010, 1, 8, 0, 0, 0),15],[Date.UTC(2010, 1, 9, 0, 0, 0),4],[Date.UTC(2010, 1, 10, 0, 0, 0),12],[Date.UTC(2010, 1, 11, 0, 0, 0),21],[Date.UTC(2010, 1, 12, 0, 0, 0),19],[Date.UTC(2010, 1, 13, 0, 0, 0),8],[Date.UTC(2010, 1, 14, 0, 0, 0),20],[Date.UTC(2010, 1, 15, 0, 0, 0),14],[Date.UTC(2010, 1, 16, 0, 0, 0),9],[Date.UTC(2010, 1, 17, 0, 0, 0),8],[Date.UTC(2010, 1, 18, 0, 0, 0),24],[Date.UTC(2010, 1, 19, 0, 0, 0),7]];</script>
Instance of highcharts :

Code: Select all

<script type="text/javascript">
//<![CDATA[
        $(document).ready(function() {
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
            },
            title: {
                text: 'test'
            },
             xAxis: {
                  type: 'datetime',
                  title: {
                     text: null
                  }
               },
            yAxis: {
                title: {
                    text: 'Inscriptions'
                }
            },
            tooltip: {
                enabled: true,
                formatter: function() {
                    return '<b>'+ this.series.name +'<\/b><br/>le '+this.x+' : '+this.y+' inscrits';
                }
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    }
                }
            },
            series: [{
                type: 'area',
                name: 'Enseignants',
                data: data_values
            }]
        });
        });
        //]]>
        </script>
But the x axis are between 31 Jan. and 18 Feb. (see picture) ?!
Capture.png
Capture.png (27.27 KiB) Viewed 3225 times
Do you have some idea about this ?

(sorry for my bad English, french user)
torstein.honsi
Site Admin
Posts: 9215
Joined: Thu Nov 09, 2006 11:22 am
Location: Vik i Sogn, Norway

Re: Datetime axis question

In current versions the x axis will pad to the nearest tick below the start point. In the upcoming 1.2 version this is changed, so that there is an option called startOnTick that is now false by default. Additionally, you can set a minPadding to make some small space before the new value. The 1.2 version is pretty stable, so it you test your site in all browsers you can go live with it: http://www.highcharts.com/js/prerelease ... 1.2.src.js.
Torstein Hønsi
CTO, Founder
Highsoft
yvestan
Posts: 3
Joined: Wed Feb 03, 2010 4:54 pm

Re: Datetime axis question

Thank you for your answer but I don't understand how use this option to solve my problem ?!

My dates are between 01 jan. and 31 jan. but the chart x axis is between 31 jan. and 18 feb.

first date : Date.UTC(2010, 1, 1, 0, 0, 0)
last date : Date.UTC(2010, 1, 19, 0, 0, 0)

Thanks a lot for your help !
yvestan
Posts: 3
Joined: Wed Feb 03, 2010 4:54 pm

Re: Datetime axis question

Ahh ! I've find MY error ;)

On Date.UTC function, jan. = 0 and feb. = 1, Not jan. = 1 and feb. = 2

that's work fine now !

Return to “Highcharts Usage”