# Chart Grid

In order to improve the readiness of the chart you may want to add grid-like visuals which support horizontal and vertical lines, associated with axis ticks and horizontal and vertical stripes for better readability. Depending on the chart that you use (RadCartesianChart or RadPolarChart) there are two types: **CartesianChartGrid** and **PolarChartGrid** that you can play with to add a decoration over the plot area.

![Telerik UI for WPF RadChartView Cartesian and polar chart grid overview](https://www.telerik.com/products/wpf/documentation/assets/51d047b6e9ccae479f810f3121cfde39/radchartview-features-grid-13.png)

## CartesianChartGrid

CartesianChartGrid shows horizontal and vertical lines and strips crossing the chart's plot area. The lines are snapped on the ticks of the axes and the strips is the area between the lines.

The grid allows you to customize its lines and strips via several properties. To use it, set the **Grid** property of RadCartesianChart to a new instance of **CartesianChartGrid**.

To **display any lines** in the grid, set the **MajorLinesVisibility** property. This is an enumeration that allows you to tell which lines to be displayed - vertical (**X**), horizontal (**Y**), both (**XY**) or **None**.

**Example 1: Setting up the grid**

```XAML
<telerik:RadCartesianChart>
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis />
    </telerik:RadCartesianChart.VerticalAxis>
    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:CategoricalAxis />
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:LineSeries>
        <telerik:LineSeries.DataPoints>
            <telerik:CategoricalDataPoint Category="A" Value="20" />
            <telerik:CategoricalDataPoint Category="B" Value="40" />
            <telerik:CategoricalDataPoint Category="C" Value="35" />
            <telerik:CategoricalDataPoint Category="D" Value="40" />
            <telerik:CategoricalDataPoint Category="E" Value="30" />
            <telerik:CategoricalDataPoint Category="F" Value="50" />
        </telerik:LineSeries.DataPoints>
    </telerik:LineSeries>
    <telerik:RadCartesianChart.Grid>
        <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
    </telerik:RadCartesianChart.Grid>
</telerik:RadCartesianChart>
```

> caption Grid lines example

![Telerik UI for WPF RadChartView Cartesian chart major grid lines](https://www.telerik.com/products/wpf/documentation/assets/42be484c9c533e3e6dd5f84e74d2073b/radchartview-features-grid-0.png)

To **display the strip lines**, set the **StripLinesVisibility** property. This is an enumeration that allows you to tell which strips to be displayed - vertical (**X**), horizontal (**Y**), both (**XY**) or **None**.

**Example 2: Enabling strip lines**

```XAML
<telerik:RadCartesianChart.Grid>
    <telerik:CartesianChartGrid MajorLinesVisibility="XY" StripLinesVisibility="XY" />
</telerik:RadCartesianChart.Grid>
```

> caption Strip lines example

![Telerik UI for WPF RadChartView Cartesian chart strip lines](https://www.telerik.com/products/wpf/documentation/assets/b5d39771f3055bac587db9905ae4bd89/radchartview-features-grid-1.png)

To **show dashed lines**, set the **MajorXLineDashArray** and **MajorYLineDashArray** properties.

**Example 3: Dashing the grid lines**

```XAML
<telerik:RadCartesianChart.Grid>
    <telerik:CartesianChartGrid MajorXLineDashArray="5 5" MajorYLineDashArray="5 5" MajorLinesVisibility="XY" />
</telerik:RadCartesianChart.Grid>
```

> caption Dash array example

![Telerik UI for WPF RadChartView Cartesian chart grid lines with a dash array](https://www.telerik.com/products/wpf/documentation/assets/564ce9644ab06cdb3063f78e795688e6/radchartview-features-grid-2.png)

To **define an interval for the grid lines** to appear, set the **MajorXLineInterval** and **MajorYLineInterval** properties.

**Example 4: Setting line interval**

```XAML
<telerik:RadCartesianChart.Grid>
    <telerik:CartesianChartGrid MajorXLineInterval="2" MajorYLineInterval="3" MajorLinesVisibility="XY" />
</telerik:RadCartesianChart.Grid>
```

> caption Line interval example

![Telerik UI for WPF RadChartView Cartesian chart grid lines with custom intervals](https://www.telerik.com/products/wpf/documentation/assets/96b443119cfd6c02135f282e231b6eb4/radchartview-features-grid-3.png)

To **change the appearance of the grid lines**, set the **MajorXLineStyle** and **MajorYLineStyle** properties.

**Example 5: Styling the grid lines**

```XAML
<telerik:RadCartesianChart.Grid>
    <telerik:CartesianChartGrid MajorLinesVisibility="XY">
        <telerik:CartesianChartGrid.MajorXLineStyle>
            <Style TargetType="Line">
                <Setter Property="Stroke" Value="#FFCE44" />
            </Style>
        </telerik:CartesianChartGrid.MajorXLineStyle>
        <telerik:CartesianChartGrid.MajorYLineStyle>
            <Style TargetType="Line">
                <Setter Property="Stroke" Value="#DD5145" />
            </Style>
        </telerik:CartesianChartGrid.MajorYLineStyle>
    </telerik:CartesianChartGrid>
</telerik:RadCartesianChart.Grid>
```

> caption Grid lines with custom colors

![Telerik UI for WPF RadChartView Cartesian chart grid lines with custom colors](https://www.telerik.com/products/wpf/documentation/assets/6d348b5c44fa34a6d87c62698aa357c3/radchartview-features-grid-4.png)

> Setting **StrokeDashArray** via the Line's Style is not supported. Use the **MajorXLineDashArray** and **MajorYLineDashArray** properties of CartesianChartGrid instead.

To **change the colors of the strip lines**, set the **XStripeBrushes** and **YStripeBrushes** properties.

**Example 6: Coloring the strip lines**

```XAML
<telerik:RadCartesianChart.Grid>
    <telerik:CartesianChartGrid StripLinesVisibility="XY">
        <telerik:CartesianChartGrid.XStripeBrushes>
            <SolidColorBrush Color="Transparent" />
            <SolidColorBrush Color="Yellow" Opacity="0.2"/>
        </telerik:CartesianChartGrid.XStripeBrushes>
        <telerik:CartesianChartGrid.YStripeBrushes>
            <SolidColorBrush Color="Red" Opacity="0.2"/>
            <SolidColorBrush Color="Green" Opacity="0.2" />
            <SolidColorBrush Color="Transparent" />
        </telerik:CartesianChartGrid.YStripeBrushes>
    </telerik:CartesianChartGrid>
</telerik:RadCartesianChart.Grid>
```

> caption Strip lines with custom colors

![Telerik UI for WPF RadChartView Cartesian chart strip lines with custom colors](https://www.telerik.com/products/wpf/documentation/assets/9327329ca8fcd1486eeb7717e52dee8d/radchartview-features-grid-5.png)

The X brushes are drawn from left to right. And the Y brushes from bottom to top.

> Keep in mind that the horizontal (Y) strip lines are drawn over the vertical (X) strip lines.

To **change the render mode of the grid lines**, set the **MajorXLinesRenderMode** and **MajorYLinesRenderMode**. This is an enumeration of type **GridLineRenderMode** and it controls what lines will get rendered.

**Example 7: Setting the grid lines render mode**

```XAML
<telerik:RadCartesianChart>
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis Visibility="Collapsed"/>
    </telerik:RadCartesianChart.VerticalAxis>
    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:CategoricalAxis />
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:LineSeries>
        <telerik:LineSeries.DataPoints>
            <telerik:CategoricalDataPoint Category="A" Value="20" />
            <telerik:CategoricalDataPoint Category="B" Value="40" />
            <telerik:CategoricalDataPoint Category="C" Value="35" />
            <telerik:CategoricalDataPoint Category="D" Value="40" />
            <telerik:CategoricalDataPoint Category="E" Value="30" />
            <telerik:CategoricalDataPoint Category="F" Value="50" />
        </telerik:LineSeries.DataPoints>
    </telerik:LineSeries>
    <telerik:RadCartesianChart.Grid>
        <telerik:CartesianChartGrid MajorLinesVisibility="X" MajorXLinesRenderMode="Inner">
            <telerik:CartesianChartGrid.MajorXLineStyle>
                <Style TargetType="Line">
                    <Setter Property="Stroke" Value="Black" />
                </Style>
            </telerik:CartesianChartGrid.MajorXLineStyle>
        </telerik:CartesianChartGrid>
    </telerik:RadCartesianChart.Grid>
</telerik:RadCartesianChart>
```

The render mode properties allow the following values.

* **First**: Only the first line is drawn.

  ![Telerik UI for WPF RadChartView grid showing only the first line](https://www.telerik.com/products/wpf/documentation/assets/1483fe925feb39f36a69cae052975733/radchartview-features-grid-6.png)

* **Inner**: All lines, except the first and last, are drawn.

  ![Telerik UI for WPF RadChartView grid showing only inner lines](https://www.telerik.com/products/wpf/documentation/assets/ad35941d14f9c417110358bc7dce2343/radchartview-features-grid-7.png)

* **FirstAndInner**: All lines, except the last, are rendered.

  ![Telerik UI for WPF RadChartView grid showing first and inner lines](https://www.telerik.com/products/wpf/documentation/assets/6686342854db5afc2c555065cce10ec0/radchartview-features-grid-8.png)

* **Last**: Only the last line is rendered.

  ![Telerik UI for WPF RadChartView grid showing only the last line](https://www.telerik.com/products/wpf/documentation/assets/72ce00de293cef580fcf7d2c9081b4b7/radchartview-features-grid-9.png)

* **FirstAndLast**: Only the first and the last lines are rendered.

  ![Telerik UI for WPF RadChartView grid showing first and last lines](https://www.telerik.com/products/wpf/documentation/assets/829ef484245fc59be2b0e66f03af0e34/radchartview-features-grid-10.png)

* **InnerAndLast**: All lines, except the first, are rendered.

  ![Telerik UI for WPF RadChartView grid showing inner and last lines](https://www.telerik.com/products/wpf/documentation/assets/9ffdf3ee5c1254d2353eb35f607f77e7/radchartview-features-grid-11.png)

* **All**: All lines are rendered. This is the **default** value.

  ![Telerik UI for WPF RadChartView grid showing all lines](https://www.telerik.com/products/wpf/documentation/assets/72c0d5f131408a047d5428b08ebb4195/radchartview-features-grid-12.png)

### PolarChartGrid

PolarChartGrid shows polar and radial lines and stripes drawn over the chart's plot area. The lines are snapped on the ticks of the axes and the stripes is the area between the lines.

The grid allows you to customize its lines and strips via several properties. To use it, set the **Grid** property of RadPolarChart to a new instance of **PolarChartGrid**.

To **display the lines** in the grid, set the **GridLineVisibility** property. This is an enumeration that allows you to tell which lines to be displayed - **Polar**, **Radial**, **Both** or **None**.

**Example 8: Setting up the polar grid**

```XAML
<telerik:RadPolarChart>
    <telerik:RadPolarChart.RadialAxis>
        <telerik:CategoricalRadialAxis />
    </telerik:RadPolarChart.RadialAxis>
    <telerik:RadPolarChart.PolarAxis>
        <telerik:PolarAxis Minimum="0" Maximum="5" />
    </telerik:RadPolarChart.PolarAxis>
    <telerik:RadarLineSeries>
        <telerik:RadarLineSeries.DataPoints>
            <telerik:CategoricalDataPoint Category="A" Value="3.2" />
            <telerik:CategoricalDataPoint Category="B" Value="3.6" />
            <telerik:CategoricalDataPoint Category="C" Value="3.8" />
            <telerik:CategoricalDataPoint Category="D" Value="4.5" />
            <telerik:CategoricalDataPoint Category="E" Value="3.5" />
            <telerik:CategoricalDataPoint Category="F" Value="3.6" />
        </telerik:RadarLineSeries.DataPoints>
    </telerik:RadarLineSeries>
    <telerik:RadPolarChart.Grid>
        <telerik:PolarChartGrid GridLineVisibility="Both" />
    </telerik:RadPolarChart.Grid>
</telerik:RadPolarChart>
```

> caption Polar grid lines example

![Telerik UI for WPF RadChartView polar chart grid lines](https://www.telerik.com/products/wpf/documentation/assets/944dd68a2d643101f4b4188f196def93/radchartview-features-grid-14.png)

To **display the strip lines**, set the **StripesVisibility** property. This is an enumeration that allows you to tell which strips to be displayed - **Polar**, **Radial**, **Both** or **None**.

**Example 9: Enabling polar strip lines**

```XAML
<telerik:RadPolarChart.Grid>
    <telerik:PolarChartGrid StripesVisibility="Radial"/>
</telerik:RadPolarChart.Grid>
```

> caption Polar strip lines example

![Telerik UI for WPF RadChartView polar chart strip lines](https://www.telerik.com/products/wpf/documentation/assets/241574c4e2c60c1461dfe689b1d44435/radchartview-features-grid-15.png)

To **show dashed lines**, set the **PolarLineDashArray** and **RadialLineDashArray** properties.

**Example 10: Dashing the polar grid lines**

```XAML
<telerik:RadPolarChart.Grid>
    <telerik:PolarChartGrid GridLineVisibility="Both" PolarLineDashArray="4 4" RadialLineDashArray="10 5"/>
</telerik:RadPolarChart.Grid>
```

> caption Dash array for the polar and radial grid lines example

![Telerik UI for WPF RadChartView polar and radial grid lines with dash arrays](https://www.telerik.com/products/wpf/documentation/assets/2f86bf55c3fda3fac2861efd1958ea5f/radchartview-features-grid-16.png)

To **change the appearance of the polar grid lines**, set the **RadialLineStyle** and **PolarLineStyle** properties.

**Example 11: Styling the polar grid lines**

```XAML
<telerik:RadPolarChart.Grid>
    <telerik:PolarChartGrid GridLineVisibility="Both">
        <telerik:PolarChartGrid.PolarLineStyle>
            <Style TargetType="Line">
                <Setter Property="Stroke" Value="OrangeRed" />
                <Setter Property="StrokeThickness" Value="3" />
            </Style>
        </telerik:PolarChartGrid.PolarLineStyle>
        <telerik:PolarChartGrid.RadialLineStyle>
            <Style TargetType="Ellipse">
                <Setter Property="Stroke" Value="OliveDrab" />
            </Style>
        </telerik:PolarChartGrid.RadialLineStyle>
    </telerik:PolarChartGrid>
</telerik:RadPolarChart.Grid>
```

> caption Polar grid lines with custom colors and thickness

![Telerik UI for WPF RadChartView polar grid lines with custom colors and thickness](https://www.telerik.com/products/wpf/documentation/assets/5425df5db28adca6088934ae371620f2/radchartview-features-grid-17.png)

> Setting **StrokeDashArray** via the Line or Ellipse's Style is not supported. Use the **PolarLineDashArray** and **RadialLineDashArray** properties of PolarChartGrid instead.

To **change the colors of the polar strip lines**, set the **PolarStripeBrushes** and **RadialStripeBrushes** properties.

**Example 12: Coloring the strip lines**

```XAML
<telerik:RadPolarChart.Grid>
    <telerik:PolarChartGrid GridLineVisibility="Both" StripesVisibility="Both">
        <telerik:PolarChartGrid.PolarStripeBrushes>
            <SolidColorBrush Color="OrangeRed" Opacity="0.4" />
            <SolidColorBrush Color="YellowGreen" Opacity="0.4" />
        </telerik:PolarChartGrid.PolarStripeBrushes>
        <telerik:PolarChartGrid.RadialStripeBrushes>
            <SolidColorBrush Color="DarkOliveGreen"  />
            <SolidColorBrush Color="YellowGreen" />
        </telerik:PolarChartGrid.RadialStripeBrushes>
    </telerik:PolarChartGrid>
</telerik:RadPolarChart.Grid>
```

> caption Strip lines with custom colors

![Telerik UI for WPF RadChartView polar and radial strip lines with custom colors](https://www.telerik.com/products/wpf/documentation/assets/f50314cfdd6b8918306fa9247b5d9038/radchartview-features-grid-18.png)

The radial strip lines are drawn from outside to inside. And the polar lines are drawn counter clockwise.

> Keep in mind that the polar strip lines are drawn over the radial strip lines.
