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
945
ValueOverlay bound by CategoryDateTimeXAxis
posted

Would like to place a vertical line at a certain datetime value against the CategoryDateTimeXAxis

So far no luck...

GetScaledValue does not return anything reasonable

Xaml:

<ig:ValueOverlay Axis="{Binding ElementName=xmXAxis}" Thickness="1" Brush="Red">

  <ig:ValueOverlay.Value>

   <MultiBinding Converter="{StaticResource DateTimeConverter}">

      <Binding Path="DateValue"/>

      <Binding ElementName="xmXAxis"/>

   MultiBinding>

  ig:ValueOverlay.Value>

 ig:ValueOverlay> 

 

Codebehind

 

public class DateTimeConverter : IMultiValueConverter

{

    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)

        {

      if (values[0] != null && values[0] is DateTime)

            {

                  var axis = values[1] as CategoryDateTimeXAxis;

                 if (axis != null)

                 {

                       //return ((DateTime)values[0]).Ticks;

           var chart = axis.SeriesViewer;

                       return axis.GetScaledValue(((DateTime)values[0]).Ticks, chart.WindowRect, chart.ViewportRect);

                }

            }

      return null;

        }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)

        {

              throw new NotImplementedException();

        }

    }

 

Thanks

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into and I can suggest you use the CategoryDateTimeXAxis’ GetUnscaledValue instead of the GetScaledValue method. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

Children