Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
NumericXAxis Labels
posted

How do you get the double values to show up as dates on the NumericXAxis?

Currently I have double values like 40402.5 showing on the axis. I have tried a few different Label Settings, but nothing so far has worked.

 

  • 7305
    Suggested Answer
    posted

    You can use IValueConverter to convert tickmark value into DateTime value:

    //  In code or can be done in XAML as well

     

     

     

    DataPoint

     

    dp1 = new DataPoint();

    dp1.ChartParameters.Add(ChartParameterType.ValueX,(DateTime)Convert.ToDateTime(date.Convert(null, typeof(DateTime), 633011240000000000, System.Globalization.CultureInfo.CurrentCulture)));

    dp1.ChartParameters.Add(ChartParameterType.ValueY, 5);

     

    //  IValueConverter:

    long ticks = System.Convert.ToInt64(parameter);

    DateTime temp = new DateTime(ticks);

    return temp.ToShortDateString();

    Let me know if you have any question.

    Sam