X-Axis Time zone issue

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
SenSeo
Newbie
Newbie
Posts: 71
Joined: Wed Mar 09, 2016 12:00 am

X-Axis Time zone issue

Post by SenSeo » Thu Apr 28, 2016 9:00 am

Hello,

We are facing problem with the x-axis date time increment value. When the x axes increment time value is less than or equal to 1 hour the time value same for all the time zones.

Below is the example code for the increment value(<=1 hour),

Code: Select all

var Chart1;
function draw() {
    Chart1 = new Tee.Chart("canvas");
    var series1, series2, series3;
    series1 = Chart1.addSeries(new Tee.Line());
    series2 = Chart1.addSeries(new Tee.Line());
    series3 = Chart1.addSeries(new Tee.Line());
    series1.title = "Descricao do teste 1";
    series2.title = "Descricao do teste 2";
    series3.title = "Descricao do teste 3";
    var startDate, tmp, values1, values2, values3;
    //startDate = new Date(2014,12,4,14,30,53);
    startDate = new Date(2000, 1, 1, 0, 0, 0);
    values1 = [0.54881, 0.42365, 0.96366, 0.56804, 0.02022, 0.97862, 0.11827, 0.52185, 0.45615];
    values2 = [0.59284, 0.62356, 0.27266, 0.39278, 0.36824, 0.47361, 0.72063, 0.10591, 0.21655];
    values3 = [0.71519, 0.64589, 0.38344, 0.92560, 0.83262, 0.79916, 0.63992, 0.41466, 0.56843];
    series1.data.values.length = values1.length;
    series2.data.values.length = values2.length;
    series3.data.values.length = values3.length;
    series1.data.values = values1;
    series2.data.values = values2;
    series3.data.values = values3;
    series1.data.x = new Array(values1.length);
    series2.data.x = new Array(values2.length);
    series3.data.x = new Array(values3.length);
    for (i = 0; i < values1.length; i++) {
        tmp = new Date(startDate.getTime() + i * 1800000);
        series1.data.x[i] = tmp;
        series2.data.x[i] = tmp;
        series3.data.x[i] = tmp;
    }
    Chart1.axes.bottom.labels.dateFormat = "shortTime";
    [b]Chart1.axes.bottom.increment = series1.data.x[1] - series1.data.x[0];[/b]
    Chart1.draw();
}
Please refer the attachment for the <= 1 hour output.

But, if the x axes increment time value is greater than 1 hour the x axis value is dynamically changing based on the time zones.

To check the time zone issue please use the below code for the increment and change the time zone in your system.
Chart1.axes.bottom.increment = series1.data.x[2] - series1.data.x[0];

Please refer the attachment for the x-axis time zone error.
Attachments
X-Axis1Hour.jpg
X-Axis1Hour.jpg (141.89 KiB) Viewed 10884 times

SenSeo
Newbie
Newbie
Posts: 71
Joined: Wed Mar 09, 2016 12:00 am

Re: X-Axis Time zone issue

Post by SenSeo » Thu Apr 28, 2016 9:02 am

Please refer the attachment for the time zone issue.
Attachments
TimeZoneError.png
TimeZoneError.png (108.03 KiB) Viewed 10852 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: X-Axis Time zone issue

Post by Yeray » Fri Apr 29, 2016 3:35 pm

Hello,

If I understand it correctly, the problem is that when you change the timezone for your system, this changes the timezone for your browser and then the Date you create, without specifying a timezone, is created for the current timezone. So 12PM is always 12PM because you set and get it using the same timezone.
Try setting the dates with UTC timezone:
http://stackoverflow.com/questions/2083 ... javascript
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply