officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-chartview-648dd45f.md
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
bool VaryColors { get; set; }
Property VaryColors As Boolean
| Type | Description |
|---|---|
| Boolean |
true , if the same-series data markers are displayed in varied colors; otherwise, false.
|
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.
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.
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;
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.
// 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
// 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
// Specify that each data point in the series has a different color.
chart.Views[0].VaryColors = true;
' 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
' 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
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
See Also