This is a migrated thread and some comments may be shown as answers.

Chart Date Time data display in specific timezone not local timezone

1 Answer 218 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 23 Mar 2017, 01:49 PM

i have a chart control that i am populating programmatically using the following options

<XAxis Type="Date" BaseUnit="Auto" >
            <TitleAppearance Text=""> </TitleAppearance>
            <LabelsAppearance DataFormatString="HH:mm"> </LabelsAppearance>
        </XAxis>

 

ScatterSeriesItem ssi1 = new ScatterSeriesItem();
ssi1.X = ConvertToJavaScriptDateTime(Convert.ToDateTime(DR[1].ToString()));
ssi1.Y = Convert.ToDecimal(DR[2].ToString());

 

private decimal ConvertToJavaScriptDateTime(DateTime fromDate)
       {
           return (decimal)fromDate.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
       }

 

and doing this the data in the chart is always displayed in local time especially the x axis, is there any way of formatting the dates so that they dont display in the local time for the browser.

 

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 28 Mar 2017, 01:09 PM
Hi Peter,

You can see a possible approach to keep a Datetime property in U"NC format on both server and client:
http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/editing/utc-time-on-both-server-and-client

The article targets MVC, but it is a general approach so you can use it in Webforms as well.

Regards,
Vessy
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Chart (HTML5)
Asked by
Peter
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or