We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How use TimeSpan Axe

Thread ID:





118373 Mar 3,2015 07:08 PM UTC Mar 5,2015 04:58 AM UTC WPF 3
Tags: Chart
Asked On March 3, 2015 07:08 PM UTC

HI all,

I am new on syncfusion products and I met some trouble with syncfusion chart control.
I am pretty sure it's pretty easy but i don't figure out.

I try to make a column chart with a category primary axis and a timespan secondary axis but I get a InvalidCastException: Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.

Code below :


<chart:SfChart x:Name="columnChart" AreaBorderBrush="#8e8e8e" Background="White" Grid.Row="0">
                    <TextBlock FontSize="22"   Foreground="Black" FontFamily="Segoe UI">Time spend by application</TextBlock>
                    <chart:CategoryAxis  Header="Applications" Foreground="Black"  FontSize="20" LabelTemplate="{StaticResource labelTemplate}"/>
                    <chart:TimeSpanAxis  FontSize="20" Minimum="0" Maximum="500" Interval="50"   Header="Time (in Min)" Foreground="Black" LabelTemplate="{StaticResource labelTemplate}"/>
                <chart:ColumnSeries EnableAnimation="True" Palette="Metro" ItemsSource="{Binding ApplicationTime}"  XBindingPath="ApplicationName" YBindingPath="Time" Label="Sneakers sold" chart:ChartTooltip.EnableAnimation="true" ShowTooltip="True"> ...

View Model :

public class ViewModel
        public ObservableCollection<Model> ApplicationTime { get; set; }

        public ViewModel()
            ApplicationTime = new ObservableCollection<Model>();
            ApplicationTime.Add(new Model { ApplicationName = "Visual Studio 2013", Time = new TimeSpan(1,40,30)});

Model :

    public class Model
        public TimeSpan Time { get; set; }
        public string ApplicationName { get; set; }

Maybe I have to herit System.TimeSpan class to implements IConvertible (to convert it to double) ?


Sheik Syed Abthaheer M [Syncfusion]
Replied On March 4, 2015 05:43 AM UTC

Dear Customer,

Thanks for using Syncfusion products.

At present we are not having TimeSpanAxis support for chart secondary axis. However we have meet your requirement in workaround by converting TimeSpan value to double. Please find the sample in the below location.

Sample: TimeSpan_Sample.zip

Please let us know if have any queries.


Replied On March 4, 2015 12:56 PM UTC

Thank you very much. It works as expected.

Sheik Syed Abthaheer M [Syncfusion]
Replied On March 5, 2015 04:58 AM UTC

Dear Customer,

Thanks for your update.

Please let us know if you need any further assistance on this.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon