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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to redraw WPF Chart (SfChart) while dragging the series out of the range?

Platform: WPF |
Control: SfChart |
.NET Framework: 4.5

You can redraw in the predefined range for WPF Chart (SfChart) by using 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. You can change the secondary axis and values of the Minimum and Maximum properties based on the new value. 

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;
   }
}

The below image represents Initial segment position and preview dragging segment position.

LIne series before dragging in WPF Chart

The below image represents Segment redrawn after dragging.

Line series after dragging in WPF Chart

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
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

Live Chat Icon For mobile