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 Reply Children