Skip to content

This sample demonstrate how to customize the axis grid lines in WPF chart

Notifications You must be signed in to change notification settings

SyncfusionExamples/How-to-customize-the-axis-grid-lines-in-WPF-chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

How-to-customize-the-axis-grid-lines-in-WPF-chart

This sample demonstrate how to customize the axis grid lines in WPF chart.

The WPF Chart provides support to customize the axis grid lines with the help of the MajorGridLineStyle, MinorGridLineStyle, MajorTickLineStyle, and MinorTickLineStyle properties of the chart axis.

These properties are of type "Style," which means you can customize the axis grid lines by changing the value of line properties such as Stroke, StrokeThickness, and StrokeDashArray.

For example, you can set the stroke color of the major grid lines to green and the stroke thickness to 2, like this:

[XAML]

<chart:NumericalAxis>
    <chart:NumericalAxis.MajorGridLineStyle>
        <Style TargetType="Line">
            <Setter Property="StrokeThickness" Value="2"/>
            <Setter Property="Stroke" Value="Green"/>
        </Style>
    </chart:NumericalAxis.MajorGridLineStyle>
</chart:NumericalAxis>

You can also use the StrokeDashArray property to set the line style to a dashed pattern like this:

[XAML]

<chart:NumericalAxis>
    <chart:NumericalAxis.MinorGridLineStyle>
        <Style TargetType="Line">
            <Setter Property="StrokeThickness" Value="1"/>
            <Setter Property="Stroke" Value="Blue"/>
            <Setter Property="StrokeDashArray" Value="3,3"/>
        </Style>
    </chart:NumericalAxis.MinorGridLineStyle>
</chart:NumericalAxis>

Output:

Customize the axis grid lines in WPF Chart

Troubleshooting

Path too long exception

If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages