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

Change default categoryAxis labels and other chart formaters

6 Answers 75 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 27 Dec 2013, 02:20 PM
Hi,

we are using several charts in our application. Due to internatiolaisation we want to change the label formatters for dates and other automatically rendered values.

As we don't want to edit every single chart instance by hand, we are looking for a way to set the default formatters and renderers globally.

How can we do it? Why ist it not described in the culture packages?

Thanks

6 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 31 Dec 2013, 08:49 AM
Hello Andreas,

I am afraid it is not possible to globally change the labels and other formatting options of the Chart widget.

However you can extend a widget like shown here with the options that you want and then use your own widget to initialize it with your predefined options (you can extend existing widget the same way as demonstrated to extend a Base Widget).

Or you can simply use an object literal with all predefined settings and then extend it with particular options before creating a Chart widget.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andreas
Top achievements
Rank 1
answered on 03 Jan 2014, 04:50 PM
Hey, thanks for your reply and a happy new year.

I don't really need to customize the formats, I would be happy if I could tell the labels to use the culture.de.min.js

I tried to set the culture property on the category axis's labels property, but nothing happened.

categoryAxis: {
                    field: "date",
                    baseUnit: "days",
                    labels : {
                        culture : "de",
                        step : 3
                    }
                }

It still renders as M/y which is not really german ;)
The docs say it should work: http://docs.kendoui.com/api/dataviz/chart#configuration-categoryAxis.labels.culture
0
Petur Subev
Telerik team
answered on 06 Jan 2014, 01:30 PM
Hello Andreas,

Did you add the needed culture JavaScript file?

http://docs.kendoui.com/getting-started/framework/globalization/overview

Here is an example:

http://jsbin.com/oDOkAne/2/edit


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andreas
Top achievements
Rank 1
answered on 06 Jan 2014, 02:33 PM
Yes, I do include the correct culture file.

I edited your jsbin and removed the "format" property, because I want kendo to handle the format according to the given culture.
The only thing that changes if I set the culture are the month and day names, but not the chart's formats. In my opinion, they belong to a culture because in other cultures 01/02/2014 is not the second of january 2014 :)
0
Accepted
Petur Subev
Telerik team
answered on 08 Jan 2014, 09:34 AM
Hello Andreas,

Thank you for clarifying. These formats are coded inside the chart and the order of the months / days does not depend on the current culture. Here is how the default values for the labels.dateFormats property are:

http://docs.kendoui.com/api/dataviz/chart#configuration-categoryAxis.labels.dateFormats

var DateLabelFormats = {
    seconds: "HH:mm:ss",
    minutes: "HH:mm",  
    hours: "HH:mm",    
    days: "M/d",       
    weeks: "M/d",      
    months: "MMM 'yy", 
    years: "yyyy"      
};

You can try and manually change them based on the current culture that is loaded. (kendo.culture() to get the object representing the current culture)



Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andreas
Top achievements
Rank 1
answered on 09 Jan 2014, 08:47 AM
Alright, thanks for helping me :)

It would be great if the formats, too, would make it into the culture files somewhen!
Tags
Charts
Asked by
Andreas
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or