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.
Unfortunately, activation email could not send to your email. Please try again.

dasharray in sfchart

Thread ID:





132087 Aug 13,2017 06:37 AM Aug 16,2017 12:08 AM WPF 3
Tags: SfChart
Asked On August 13, 2017 06:37 AM

how to display dash-line series in sfchart using code behind?

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On August 14, 2017 05:03 AM

Hi Rex, 
Thanks for contacting Syncfusion Support. 
1)With FastLineSeries 
We can display dash-line series by setting the StrokeDashArray property of FastLineSeries and it can be set as shown in the below code snippet, 
  FastLineSeries series1 = new FastLineSeries() 
       StrokeDashArray = new DoubleCollection() { 2, 2 }, 
       Interior = new SolidColorBrush(Colors.Blue)      
2) With FastLineBitmapSeries 
This requirement can also be achieved by using FastLineBitmapSeries with its StrokeDashArray property  
  FastLineBitmapSeries series2 = new FastLineBitmapSeries() 
          StrokeDashArray = new DoubleCollection() { 3, 2 }, 
          Interior = new SolidColorBrush(Colors.Black) 
3) With LineSeries 
We can achieve your requirement (dash- line series) by using the CustomTemplate property for LineSeries and it can be set as shown in the below code snippet, 
            FrameworkElementFactory lineFactory = new  
            lineFactory.SetValue(Line.StrokeDashArrayProperty, new DoubleCollection() {  
                                        3, 2 }); 
            lineFactory.SetValue(Line.StrokeProperty, new Binding() { Path = new  
            lineFactory.SetValue(Line.StrokeThicknessProperty, new Binding() { Path =  
                                        new PropertyPath("StrokeThickness") }); 
            lineFactory.SetValue(Line.X1Property, new Binding() { Path = new  
            lineFactory.SetValue(Line.X2Property, new Binding() { Path = new  
            lineFactory.SetValue(Line.Y1Property, new Binding() { Path = new  
            lineFactory.SetValue(Line.Y2Property, new Binding() { Path = new  
            LineSeries series3 = new LineSeries() 
                Interior = new SolidColorBrush(Colors.Purple), 
                CustomTemplate = new DataTemplate() { VisualTree = lineFactory } 
Please find the output screenshot, 

The demo sample can be downloaded from below link, 

Replied On August 15, 2017 06:45 AM

many tnx Devi.

Durgadevi Selvaraj [Syncfusion]
Replied On August 16, 2017 12:08 AM

Hi Rex, 
Please let us know if your need any further assistance. 
Durgadevi S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.