Format the value (HH:mm:ss) on the top of the bars

2 posts, 0 answers
  1. Luka
    Luka avatar
    7 posts
    Member since:
    Mar 2013

    Posted 05 Apr 2013 Link to this post

    I have the WPF:

    <telerik:RadChart x:Name="reasonChart" ItemsSource="{Binding ReasonChart, Mode=TwoWay}">
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping LegendLabel="Devices">
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:BarSeriesDefinition></telerik:BarSeriesDefinition>
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="Label" FieldName="Value"></telerik:ItemMapping>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Value"></telerik:ItemMapping>
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="Label"/>
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>

    Instead of the Value for the Label I would like to format the seconds in the HH:mm:ss format! See the image attached!
    Excepted result:
    120s => 00:02:00
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 09 Apr 2013 Link to this post

    Hi Luka,

    You can introduce a Label property to your data item class like this: 
    public string Label
    {
        get
        {
            return TimeSpan.FromSeconds(this.Value).ToString();
        }
    }
    and then bind the series item labels to it: 
    <telerik:ItemMapping DataPointMember="Label" FieldName="Label"/>

    I hope this helps.
     
    All the best,
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top