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

How to display date in different date format

3 Answers 219 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 25 Nov 2008, 10:02 PM
Hi,

I am designing Gantt chart and I would like to display dates in custom format eg.  Jan-08, Feb-08, Mar-08. I  understood we need to convert date value in OA format.

I have couple questions:

1) How do I display date in custom format as I described above.
2) How do I manage lablestep property on axis as days in month varies for every month and there cannot be same step for eg. 30 to  
    lable for every month as I want it.
 
Appreciate all your help.

Thanks,
Amit

3 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 28 Nov 2008, 11:26 AM
Hi Amit,

Let me see if I understand this correctly. You want to format series data labels to MMM-YY format? If so, I am afraid this is not possible using the default label format property.

A work-around would be to manually format the label string and cycle through all series items and change the labels yourself.

We apologize for the inconvenience.

Kind regards,
Vladimir Milev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Amit
Top achievements
Rank 1
answered on 01 Dec 2008, 08:23 PM
Dear Admin,

I have solved the proble of my first question. The solution was as below.

TimeLineChart.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.

ChartValueFormat.ShortDate;

 

TimeLineChart.PlotArea.YAxis.Appearance.CustomFormat =

"MMM-yy";

For my second question, I solved it partially as below:

on my Y-axis, I want to display the value as Jan-08, Feb-08 and so on...what I am doing is using labelstep by 31 and displaying only month and year as

 

TimeLineChart.PlotArea.YAxis.AddRange(StartDay, EndDay, 1);

TimeLineChart.PlotArea.YAxis.LabelStep = 31;

It solved the purpose of displaying the label in the format I want. But label doesn't display at the beginning of everymonth as label step is 31 and thats not correct for every month as some months have 30 days and Feb has less than that. so value displayed on series is not very precise but little varies in proportion with axis. 

I am not sure if we can do anything with lablestep which step thru accurately when actual month ends and not every 31 days. If is there any workaround, will appreciate your answer.

0
Accepted
Vladimir Milev
Telerik team
answered on 04 Dec 2008, 08:15 AM
Hello Amit,

You have pretty much nailed the reason label step behaves this way yourself. Actually, the reading on the axis is precise and the reason you are getting different dates is simply because months are of different length. Since the idea of the labelstep feature is to show labels at precise intervals equal to its value and months vary in length you are bound to get such results. There is no work-around possible for this.

You may, however, consider displaying the month name only - this will produce more consistent results if you use a step of 30 and pick a mid-month date like 15th. You will be able to get Janury, February, March etc... lined up on the axis.

Best wishes,
Vladimir Milev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
Amit
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Amit
Top achievements
Rank 1
Share this question
or