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

Chart is converting my dates

1 Answer 84 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Lyle 3M
Top achievements
Rank 1
Lyle 3M asked on 09 Jan 2013, 08:46 PM

I have a chart that is pulling data from a web service.  That data has Dates in it, and if I use that date object as a label, the chart think's it's in GMT time and then changes the hours to match the local time.  In my case, I'm in Central Time Zone, so it's 6 hours off from GMT, so it subtracts 6 hours from the ReadingDate and displays it as 6 hours off.  Is there any way to stop the label formatting from changing the datetime?

  $("#ChartContents").kendoChart({
    theme: $(document).data("kendoSkin") || "default",
    dataSource: App.ChartDataSource,
    title: { text: "Energy Usage In Days", visible: false },
    seriesDefaults: { type: "line" },
    series:
    [
      { type: "line", field: "kWh", name: App.CurrentDeviceName, axis: "WattAxis", color: "#FF9900" },
      { type: "line", field: "kWh2", name: App.CurrentDeviceName2, axis: "WattAxis", color: "#339900" },
    ],
    categoryAxis: {
      labels: { rotation: -90, dateFormats: { minutes: "HH:mm", hours: "HH:mm", days: "ddd, MMM d", months: "MMM yyyy", years: "yyyy" } },
      type: "Date",
      field: "ReadingDate",
      baseUnit: App.DayChartBaseUnit,
      majorGridLines: { visible: false }
    },
    valueAxis: [{ name: "WattAxis", title: { text: "kWh" }, min: 0, color: "#FF9900" }],
    tooltip: { visible: true, format: "{0:N0}", template: "Date: #= dataItem.DisplayDate # <br />kWh 1: #= dataItem.kWh # <br />kWh 2: #= dataItem.kWh2 #" },
    legend: { position: "bottom" }
  });


1 Answer, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 11 Jan 2013, 04:14 PM
Hi Lyle 3M,

The problem comes from that the mvc serialize date as ticks but you can try to pass your date as a string in this format:

yyyy-mm-dd HH:MM
Or you can add 6 hours to each date that you pass to the chart.

Hope this helps you.

Greetings,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Chart
Asked by
Lyle 3M
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Share this question
or