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

Chart date formats depending on baseUnit and Globalisation?

7 Answers 867 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 2
Igor asked on 24 Oct 2012, 07:29 PM
Hi!
I need to show my own format for category axis with the Date values.
i able to do that by specifying format:

categoryAxis: { labels: { rotation: -90, format: 'dd MM yyyy' } }

but i also have allowed user to change baseUnit property for the chart interactively, like it represented in the example http://demos.kendoui.com/dataviz/line-charts/date-axis.html
 
by default i have baseUnit value set to "months". anyway, on the category axis label i have always the same format as it was given
(dd MM yyyy). 

how can i provide format depending on the baseUnit value (e.g. for "months" i need format: "MM yyyy", for "days" - "dd MM", etc)?

p.s. the globalisation as a possible solution did not work for me. based on this: http://docs.kendoui.com/getting-started/framework/globalization/definecultureinfo i was not able to change formatting on the chart (and chart is not depending on that for some reasons: http://docs.kendoui.com/getting-started/framework/globalization/overview#widgets-that-depend-on-culture-info). so #2 questions is: how to apply globalisation for charts?

7 Answers, 1 is accepted

Sort by
0
Igor
Top achievements
Rank 2
answered on 26 Oct 2012, 06:15 AM
anyone please??
i still unable to solve it :(
0
Accepted
Igor
Top achievements
Rank 2
answered on 27 Oct 2012, 05:20 AM
finally i solved it by using this code:

categoryAxis: {
                  labels:
                      {
                          rotation: -90,
                          dateFormats:
                              {
                                  minutes: "HH:mm",
                                  hours: "HH:mm",
                                  days: "dd/MM",
                                  months: "MMM 'yy",
                                  years: "yyyy"
                              }
                      }, type: "Date", field: "Date", baseUnit: "months"
              }
0
osman
Top achievements
Rank 1
answered on 04 Jun 2013, 12:39 PM
how can i put different plot bands for each series ? a and b 

series: [{
name:"a",
type: "line",
data: [0.12762026843613,0.074445799930289,0.051466313585417,0.017728479526192,0.0011143506621862,0.0082959602505941,0.026745267782156,0.019458825291431,0.017666868863876,0.017092082111437,0.011608384149052,0.0065201835176499,0.004421453538218,0.010505036630037,0.012308118592408,0.010346048650291] },{
name:"b",
type: "line",
data: [0.3090348363746,0.19095852213315,0.075481586402266,0.010372204635964,0.00088406799762799,0.0048533160509829,0.011445506815686,0.0084266493597264,0.0069378355912022,0.006063734115347,0.0049154651638251,0.0028565070017462,0.0024460858669129,0.0050479242979243,0.0053070102521474,0.005090310902052] }];
0
Robert
Top achievements
Rank 1
answered on 13 Feb 2014, 10:27 PM
Thank you this post was very helpful.
0
Attila
Top achievements
Rank 2
answered on 01 Mar 2018, 07:03 AM

Thanks, this was helpful. Using widget looks like this for me:

.CategoryAxis(axis => axis.Date().BaseUnit(ChartAxisBaseUnit.Days).Labels(x => x.DateFormats(d => d.Days("MMM. dd")))

0
Dimo
Top achievements
Rank 1
answered on 18 Oct 2020, 08:43 PM

>>>.CategoryAxis(axis => axis.Date().BaseUnit(ChartAxisBaseUnit.Days).Labels(x => x.DateFormats(d => d.Days("MMM. dd")))

How this could be converted in format for PHP widget?

0
Alex Hajigeorgieva
Telerik team
answered on 21 Oct 2020, 01:58 PM

Hi, Dimo,

The equivalent for the PHP Chart wrapper is available in the API reference with a example here:

https://docs.telerik.com/kendo-ui/api/php/Kendo/Dataviz/UI/ChartCategoryAxisItemLabels#dateformats

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Charts
Asked by
Igor
Top achievements
Rank 2
Answers by
Igor
Top achievements
Rank 2
osman
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Attila
Top achievements
Rank 2
Dimo
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or