Chart is converting my dates

2 posts, 0 answers
  1. Lyle 3M
    Lyle 3M avatar
    2 posts
    Member since:
    May 2012

    Posted 09 Jan 2013 Link to this post

    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?

        theme: $(document).data("kendoSkin") || "default",
        dataSource: App.ChartDataSource,
        title: { text: "Energy Usage In Days", visible: false },
        seriesDefaults: { type: "line" },
          { 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" }

  2. Hristo Germanov
    Hristo Germanov avatar
    703 posts

    Posted 11 Jan 2013 Link to this post

    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.

    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!
Back to Top