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 to redraw the chart while dragging the series out of the range?

Platform: WinRT |
Control: SfChart |
Published Date: March 4, 2016 |
Last Revised Date: June 27, 2019 |
.NET Framework: 4.5

Description:

The chart series can be dragged out of the boundary range, i.e., the Minimum and Maximum values that are not defined for the axis. This article describes how to drag the series with explicit minimum and maximum values.

Solution

The chart can be redrawn in the predefined range by using the DragEnd event, which is used to add the functionalities after dragging. In the DragEnd event, you can get the new position and axis value where the segment is dragged.

Based on the new value, you can change the secondary axis and values of the Minimum and Maximum properties.

XAML

<chart:SfChart>
    <chart:SfChart.PrimaryAxis>
         <chart:CategoryAxis x:Name="axis1" />
    </chart:SfChart.PrimaryAxis>
    <chart:SfChart.SecondaryAxis>
         <chart:NumericalAxis x:Name="sec_axis" Minimum="10" Maximum="350" RangePadding="Round" Interval="50" />
         </chart:SfChart.SecondaryAxis>
    <chart:LineSeries XBindingPath="Product" YBindingPath="Price" DragEnd="LineSeries_DragEnd" ItemsSource="{Binding Products}" EnableDragTooltip="True" EnableSegmentDragging="True" >
    </chart:LineSeries>
</chart:SfChart>

C#

private void LineSeries_DragEnd(object sender, Syncfusion.UI.Xaml.Charts.ChartDragEndEventArgs e)
  {
            if(e.NewYValue<sec_axis.Minimum)
            {
                sec_axis.Minimum = e.NewYValue;
            }
            else if(e.NewYValue>sec_axis.Maximum)
            {
                sec_axis.Maximum = e.NewYValue;
            }
  }

Output

LIne series before dragging in WPF

Figure 1: Initial segment position and preview dragging segment position.

Line series after dragging in WPF

Figure 2: Segment redrawn after dragging.

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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