Back to Devexpress

ChartView.VaryColors Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-chartview-648dd45f.md

latest5.8 KB
Original Source

ChartView.VaryColors Property

Gets or sets a value indicating whether each data marker in the series should have a different color.

Namespace : DevExpress.Spreadsheet.Charts

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
bool VaryColors { get; set; }
vb
Property VaryColors As Boolean

Property Value

TypeDescription
Boolean

true , if the same-series data markers are displayed in varied colors; otherwise, false.

|

Remarks

By default, the slices in a pie or doughnut chart are varied, but you can turn this option off by setting the VaryColors property to false. As a result, the slices will be displayed as a single color instead of varied colors.

Example

The example below demonstrates how to create a clustered column chart and automatically apply a different color to each data marker representing a data point on the chart. To vary colors of the same-series data markers point by point, set the ChartView.VaryColors property to true.

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"];

// Specify that each data point in the series has a different color.
chart.Views[0].VaryColors = true;
// 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")

' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
' Hide the legend.
chart.Legend.Visible = False

The following code snippets (auto-collected from DevExpress Examples) contain references to the VaryColors 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.

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/TitlesActions.cs#L33

csharp
// Specify that each data point in the series has a different color.
chart.Views[0].VaryColors = true;

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/TitlesActions.cs#L26

csharp
// Specify that each data point in the series has a different color.
chart.Views[0].VaryColors = true;

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/TitlesActions.cs#L26

csharp
// Specify that each data point in the series has a different color.
chart.Views[0].VaryColors = true;

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/TitlesActions.vb#L31

vb
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/TitlesActions.vb#L30

vb
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/TitlesActions.vb#L29

vb
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True

See Also

ChartView Interface

ChartView Members

DevExpress.Spreadsheet.Charts Namespace