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
145
ValueOverlay Thickness when Zooming
posted

I'm adding multiple ValueOverlays to the xamDataChart via Code Behind based on the DataContext (VM). If I zoom in to the ValueOverlays they seem to plot perfectly. When I am zoomed completely out the Overlays overlap because Thickness is not scaling correctly. The code snippet below shows what I'm trying to accomplish; I am trying to plot a Depth Zone over a Scatter Line Series. I use the average as the Value Property (middle) and the difference as the Thickness Property.

ValueOverlay overlay = new ValueOverlay();

Binding binding = new Binding("Description");
binding.Source = zone;
binding.Converter = new ZoneTitleConverter();
BindingOperations.SetBinding(overlay, Series.TitleProperty, binding);                   
overlay.Axis = LineYAxis;
overlay.ToolTip = string.Format("Zone from {0} to {1}", zone.DepthTop, zone.DepthBottom);

MultiBinding multibinding1 = new MultiBinding();
multibinding1.Converter = new AverageConverter();
multibinding1.Bindings.Add(new Binding("DepthTop") { Source = zone });
multibinding1.Bindings.Add(new Binding("DepthBottom") { Source = zone });
BindingOperations.SetBinding(overlay, ValueOverlay.ValueProperty, multibinding1);

MultiBinding multibinding2 = new MultiBinding();
multibinding2.Converter = new DifferenceConverter();
multibinding2.Bindings.Add(new Binding("DepthTop") { Source = zone });
multibinding2.Bindings.Add(new Binding("DepthBottom") { Source = zone });
BindingOperations.SetBinding(overlay, Series.ThicknessProperty, multibinding2);

Chart.Series.Add(overlay);

Parents
  • 30945
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into the functionality that you are trying to achieve and what I can suggest is binding the Thickness to the WindowRect of the XamDataChart. When you zoom in and out, the WindowRect property of the XamDataChart is updated and you can use it to see the level of the zoom. You can use the Height property of the WindowRecr to get the vertical zoom. The value of the Height is between 0 and 1 and shows the vertical zoom level. Since you are using a MultiBindig, you can add another Binding  for the WindowRect property of the XamDataChart, to the Bindings property of the MultiBinding. I have created  sample application for you, that shows how you can bind the Thickness to the XamDataChart’s WindowRect.

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    ValueOverlayThicknessBasedOnZoom.zip
Reply Children