categoryAxis Line Chart

4 posts, 0 answers
  1. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2015 Link to this post

    Hi

    kendo v2014.2.1008

    I am trying to implement one of your chart components and I am unable to get some of the date formats to work as required.

    Using the MVC helper, I have tried doing the following:
    CategoryAxis(axis => axis
                .Date()
                .MaxDateGroups(12)                 
                .BaseUnit(ChartAxisBaseUnit.Weeks)
                        .WeekStartDay(Model.WeekBeginningDay)
                        .Labels(labels => labels
                                    .DateFormats(formats => formats
                                        .Seconds("HH:mm:ss")
                                        .Minutes("HH:mm")
                                        .Hours("HH:mm")
                                        .Days("dd/MM")
                                        .Weeks("dd/MM")
                                        .Months("MMM yy")
                                        .Years("yyyy"))
                                  )

    If I change the base unit to Months or Years then the formats used above do work (as proven by making changes to them). The Weeks format never seems to be applied.

    Using the above, if I inspect the chart object in the developer tools console, I can see that only only some of those specified appear in the chart.options.categoryAxis.labels.dateFormats property (Weeks is not present).

    If I set .Autobind(false) and then set these on document.ready() as follows:
            var DateLabelFormats = {
                seconds: "HH:mm:ss",
                minutes: "HH:mm",
                hours: "HH:mm",
                days: "d/M",
                weeks: "d/M",
                months: "MMM 'yy",
                years: "yyyy"
            };
            var chart = $("#ProjectHoursLineChart").data("kendoChart")
            chart.options.categoryAxis.dateFormats = DateLabelFormats;
            chart.dataSource.read();

    When I inspect the chart object in the developer tools console I can see all formats are present, but still the Weeks format is not applied.

    Can anyone please tell me how I get the date formats to work as specified above (I would like to use ChartAxisBaseUnit.Fit)?

    Many thanks in advance

     

  2. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2015 in reply to Paul McNamara Link to this post

    I should add to the original post that I am loading the culture specific kendo.culture.en-GB.min.js and setting the current kendo.culture("en-GB") and expected the controls to format to those culture defaults.

    Nevertheless, this is not so and I have had to attempt to enforce the formatting.
    I also tried using chart.refresh() before datasource.read() to see if that made any difference but this did not work either.

  3. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 30 Apr 2015 in reply to Paul McNamara Link to this post

    It seems there is a bug in the MVC helper which Telerik are going to investigate. 

    The workaround is to do the following in document.ready()

    You may want to set .Autobind(false)

    var DateLabelFormats = {
                    seconds: "HH:mm:ss",
                    minutes: "HH:mm",
                    hours: "HH:mm",
                    days: "d/M",
                    weeks: "d/M",
                    months: "MMM 'yy",
                    years: "yyyy"
                };
    var chart = $("#LineChart").data("kendoChart")

    chart.options.categoryAxis.labels.dateFormats = DateLabelFormats;
    chart.refresh();
    chart.dataSource.read();

     

    Note that I had originally missed the labels property...

  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2817 posts

    Posted 01 May 2015 Link to this post

    Hi,

    Thank you for sharing this solution with the community.
    The issue should be fixed in the latest internal build (2015.1.430) as well.

    Apologies for the caused inconvenience.

    Regards,
    T. Tsonev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top