windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-a52fe850.md
Gets or sets the name of the palette currently used to draw the chart’s series.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.UI.dll
NuGet Package : DevExpress.Win.Charts
public string PaletteName { get; set; }
Public Property PaletteName As String
| Type | Description |
|---|---|
| String |
A String value which represents the palette name.
|
Use the ChartControl.IndicatorsPaletteName property to define the palette used for indicators.
For more information, see Appearance Customization.
This example demonstrates how to customize a chart’s appearance at runtime, via the ChartControl.AppearanceName, ChartControl.PaletteName and ChartControl.PaletteBaseColorNumber properties.
Note that you can define a separate palette for painting all indicators available in your chart, via the ChartControl.IndicatorsPaletteName property.
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
private void Form1_Load(object sender, EventArgs e) {
// Create an empty chart.
ChartControl barChart = new ChartControl();
// Create a series and add points to it.
Series series1 = new Series("Bar Series", ViewType.Bar);
series1.Points.Add(new SeriesPoint("A", new double[] { 10 }));
series1.Points.Add(new SeriesPoint("B", new double[] { 12 }));
series1.Points.Add(new SeriesPoint("C", new double[] { 14 }));
series1.Points.Add(new SeriesPoint("D", new double[] { 17 }));
// Create an indicator (e.g. Regression Line),
// and add it to the series' collection.
RegressionLine myLine = new RegressionLine(ValueLevel.Value);
((SideBySideBarSeriesView)series1.View).Indicators.Add(myLine);
// Add the series to the chart.
barChart.Series.Add(series1);
// Define the chart's appearance and palette.
barChart.AppearanceName = "Dark";
barChart.PaletteName = "Opulent";
barChart.PaletteBaseColorNumber = 5;
// Define a separate palette for the chart's indicators.
barChart.IndicatorsPaletteName = "Default";
// Add the chart to the form.
barChart.Dock = DockStyle.Fill;
this.Controls.Add(barChart);
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load
' Create an empty chart.
Dim barChart As New ChartControl()
' Create a series and add points to it.
Dim series1 As New Series("Bar Series", ViewType.Bar)
series1.Points.Add(New SeriesPoint("A", New Double() { 10 }))
series1.Points.Add(New SeriesPoint("B", New Double() { 12 }))
series1.Points.Add(New SeriesPoint("C", New Double() { 14 }))
series1.Points.Add(New SeriesPoint("D", New Double() { 17 }))
' Create an indicator (e.g. Regression Line),
' and add it to the series' collection.
Dim myLine As New RegressionLine(ValueLevel.Value)
CType(series1.View, SideBySideBarSeriesView).Indicators.Add(myLine)
' Add the series to the chart.
barChart.Series.Add(series1)
' Define the chart's appearance and palette.
barChart.AppearanceName = "Dark"
barChart.PaletteName = "Opulent"
barChart.PaletteBaseColorNumber = 5
' Define a separate palette for the chart's indicators.
barChart.IndicatorsPaletteName = "Default"
' Add the chart to the form.
barChart.Dock = DockStyle.Fill
Me.Controls.Add(barChart)
End Sub
You can also apply a custom palette to a chart:
ChartControl.PaletteName property.The following example shows how to create a palette, register and apply it to a chart:
// Create a palette.
Palette palette = new Palette("Custom Palette");
palette.Add(Color.Yellow);
palette.Add(Color.Red);
palette.Add(Color.Green);
// Register the palette.
chartControl1.PaletteRepository.RegisterPalette(palette);
// Assign the palette to the chart.
chartControl1.PaletteName = "Custom Palette";
' Create a palette.
Dim palette As Palette = New Palette("Custom Palette")
palette.Add(Color.Yellow)
palette.Add(Color.Red)
palette.Add(Color.Green)
' Register the palette.
chartControl1.PaletteRepository.RegisterPalette(palette)
' Assign the palette to the chart.
chartControl1.PaletteName = "Custom Palette"
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PaletteName 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.
int seriesIndex = chartControl.Series.IndexOf(series);
string paletteName = chartControl.PaletteName;
Palette currentPalette = chartControl.PaletteRepository[paletteName];
Dim seriesIndex As Integer = chartControl.Series.IndexOf(series)
Dim paletteName As String = chartControl.PaletteName
Dim currentPalette As Palette = chartControl.PaletteRepository(paletteName)
See Also