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

Label Formatter with DateTimeContinuousAxis

1 Answer 32 Views
This is a migrated thread and some comments may be shown as answers.
Maxence
Top achievements
Rank 1
Maxence asked on 28 Dec 2017, 01:15 PM

How to use Label Formatter with DateTimeContinuousAxis ?

 

I've tried something like that : 

<telerikChart:RadCartesianChart.HorizontalAxis>
                <telerikChart:DateTimeContinuousAxis GapLength="0.5" LabelFormatter="{Binding DateLabelFormatter}" PlotMode="BetweenTicks" MajorStepUnit="Day" MajorStep="1" />
          </telerikChart:RadCartesianChart.HorizontalAxis>

 

with my formatter just like that :

    public class DateLabelFormatter : LabelFormatterBase<DateTime>
    {
        public override string FormatTypedValue(DateTime value)
        {
            DateTimeFormatInfo dateTimeFormats = new CultureInfo("fr-FR").DateTimeFormat;
            return value.ToString("ddd", dateTimeFormats).ToUpper();
        }
    }

 

But nothing work, please I need some help ...

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Dec 2017, 09:54 AM
Hi Maxence,

You will need to add the DateLabelFormatter to the Resources section of the ContentPage and reference it as a StaticResource instead, please check the following snippet:

           ...>
    <ContentPage.Resources>
        <ResourceDictionary>
            <local:DateLabelFormatter x:Key="DateLabelFormatter" />
        </ResourceDictionary>
    </ContentPage.Resources>
    ...

and inside the Chart definition:

<telerikChart:RadCartesianChart.HorizontalAxis>
    <telerikChart:DateTimeContinuousAxis GapLength="0.5" LabelFormatter="{StaticResource DateLabelFormatter}" PlotMode="BetweenTicks" MajorStepUnit="Day" MajorStep="1" />
</telerikChart:RadCartesianChart.HorizontalAxis>

I hope this will be helpful.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Maxence
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or