Back to Devexpress

ChartView.GapWidth Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-chartview-1f8c84c6.md

latest6.3 KB
Original Source

ChartView.GapWidth Property

Gets or sets the space between bar or column clusters in the Bar or Column charts, or the space between the primary and secondary charts in the Pie of Pie or Bar of Pie charts.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
int GapWidth { get; set; }
vb
Property GapWidth As Integer

Property Value

TypeDescription
Int32

An integer value that is the percentage of the gap width. This value must be between 0 and 500.

|

Remarks

Use the GapWidth property to control the space between each bar or column in the Bar or Column chart with one series, or the space between each group of bars or columns if the chart has multiple series.

Utilizing this property for the Pie of Pie or Bar of Pie chart changes the space between the primary and secondary charts.

The following images demonstrate how the GapWidth property works (the charts are shown in Microsoft® Excel®)

GapWidth = 20GapWidth = 200

Example

The example below demonstrates how to create the clustered column chart and specify the space between each column using the ChartView.GapWidth property.

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask5"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:C8"]);
chart.TopLeftCell = worksheet.Cells["F2"];
chart.BottomRightCell = worksheet.Cells["L15"];

// Set the gap width between data series.
chart.Views[0].GapWidth = 33;
// Hide the legend.
chart.Legend.Visible = false;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")

' Set the gap width between data series.
chart.Views(0).GapWidth = 33
' Hide the legend.
chart.Legend.Visible = False

The following code snippets (auto-collected from DevExpress Examples) contain references to the GapWidth property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/ViewOptionsActions.cs#L95

csharp
// Set the gap width between data series.
chart.Views[0].GapWidth = 33;
// Hide the legend.

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/ViewOptionsActions.cs#L95

csharp
// Set the gap width between data series.
chart.Views[0].GapWidth = 33;
// Hide the legend.

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/ViewOptionsActions.cs#L109

csharp
// Set the gap width between data series.
chart.Views[0].GapWidth = 33;
// Hide the legend.

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/ViewOptionsActions.vb#L99

vb
' Set the gap width between data series.
chart.Views(0).GapWidth = 33
' Hide the legend.

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/ViewOptionsActions.vb#L98

vb
' Set the gap width between data series.
chart.Views(0).GapWidth = 33
' Hide the legend.

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/ViewOptionsActions.vb#L103

vb
' Set the gap width between data series.
chart.Views(0).GapWidth = 33
' Hide the legend.

See Also

ChartView Interface

ChartView Members

DevExpress.Spreadsheet.Charts Namespace