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

how to set the grid color

Hi, How can I set the grid colors (major)? They do not take the color of the custom axis, so how can I set this in C#/VB.net?
Thanks.


6 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team April 27, 2017 08:31 AM UTC

Hi Theo, 
  
Thanks for contacting Syncfusion Support. 
  
We can customize the axis gridline color with the MajorGridLineStyle property of chart axis and it can be set as shown in the below code snippet, 
SfChart chart = new SfChart(); 
chart.PrimaryAxis = new NumericalAxis(); 
chart.SecondaryAxis = new NumericalAxis(); 
 
Style gridLineStyle1 = new Style(typeof(Line)); 
gridLineStyle1.Setters.Add(new Setter(Line.StrokeProperty, new  
                          SolidColorBrush(Colors.OrangeRed))); 
Style gridLineStyle2 = new Style(typeof(Line)); 
gridLineStyle2.Setters.Add(new Setter(Line.StrokeProperty, new  
                             SolidColorBrush(Colors.DeepSkyBlue))); 
 
chart.PrimaryAxis.MajorGridLineStyle = gridLineStyle1; 
chart.SecondaryAxis.MajorGridLineStyle = gridLineStyle2; 
  
Please find the output screenshot, 
 
 
  
We have prepared a simple demo sample for your reference and it can be downloaded from below link, 
  
Sample: GridLineColor 
  
Regards, 
Devi 
 






TH Theo April 28, 2017 05:42 PM UTC

Hi Devi,

Thanks....however, I can not get the style "Style(typeof(Line))" on my side. Am I missing something? Inside my development I do not have the option "line" as a type of style.
Sorry if I didn't mention but it is UWP (not sure if this is the issue).

Any ideas?

Regards


SA Santhiya Arulsamy Syncfusion Team May 1, 2017 02:49 PM UTC

Hi Theo,

Thanks for the update.

We are unable to reproduce the problem in our end. Line is the Framework element and it is under the Windows.UI.Xaml.Shapes namespace. Could you please check with your sample? If the issue still persists, then revert us the modified sample based on your application along with replication procedure to validate the issue.

Thanks,
Santhiya A


SA Santhiya Arulsamy Syncfusion Team May 1, 2017 02:51 PM UTC

Hi Theo,

Thanks for the update.

We are unable to reproduce the problem in our end. Line is the Framework element and it is under the Windows.UI.Xaml.Shapes namespace. Could you please check with your sample? If the issue still persists, then revert us the modified sample based on your application along with replication procedure to validate the issue.

Thanks,
Santhiya A


TH Theo May 1, 2017 05:59 PM UTC

Hi,

Oke, I got it...sorry...had too many problems with VS2017 to think straight (!)....I added the namespace manually, and got it - thanks!

Regards,



DA Devi Aruna Maharasi Murugan Syncfusion Team May 2, 2017 04:00 AM UTC

Hi Theo, 
  
Thanks for your update. 
  
Please let us know, if you need any further assistance on this. 
  
Regards, 
Devi 


Loader.
Live Chat Icon For mobile
Up arrow icon