Articles in this section
Category / Section

How to set the Z-Index for a scatter series in a WPF Chart (SfChart)?

3 mins read

This article explains how to adjust the visual rendering order of series in a WPF Chart (SfChart) without modifying their index position. By default, series are rendered on the chart based on their index. However, you can change their visual order by using the Canvas.ZIndex property. This property allows you to change the display position of a series in the UI, overlaying it differently without altering the actual series index.

In this example scenario, a ScatterSeries is initially positioned at the zeroth index, visually overlapping a LineSeries. By setting the Canvas.ZIndex property on the LineSeries, you can alter its rendering position to appear beneath the ScatterSeries.

 

XAML

<chart:ScatterSeries Interior="Red" ItemsSource="{Binding Products}" XBindingPath="Name" YBindingPath="Range" />
<!--Canvas.ZIndex property is used to move front or back to the series-->
<chart:LineSeries Interior="Blue" ItemsSource="{Binding Products}" XBindingPath="Name" YBindingPath="Range" Canvas.ZIndex="-1"/>

C#

ScatterSeries series1 = new ScatterSeries();
series1.ItemsSource = view.Products;
series1.XBindingPath = "Name";
series1.YBindingPath = "Range";
series1.Interior = Brushes.Red;
LineSeries series2 = new LineSeries(); series2.ItemsSource = view.Products; series2.XBindingPath = "Name"; series2.YBindingPath = "Range"; series2.Interior = Brushes.Blue;
Canvas.SetZIndex(series2, -1); chart.Series.Add(series1); chart.Series.Add(series2);

 Output

WPF Chart Series with Z Index


Conclusion

I hope you enjoyed learning about how to set the Z-Index for a scatter Series in a WPF Chart(SfChart).

You can refer to our WPF Chart’s feature tour page to know about its other groundbreaking feature representations. You can also explore our   WPF Chart documentation to understand how to present and manipulate data.


For current customers, you can check out our WPF components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our WPF Chart and other WPF components.


If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied