Have a custom palette to be applied to the chart

Applies to: Nevron Chart for .NET

How to have a custom palette to be applied to the chart?

You can set a custom palette in order to have different colors applied to your charts. You need to apply a fill style to each individual data point that you wish to be colored in a different way that the standard fill style associated with the series. For example:

[C#]
NChart chart = nChartControl1.Charts[0];
  
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(25);
bar.FillStyles[0] = new NColorFillStyle(Color.Red);
bar.FillStyles[1] = new NColorFillStyle(Color.Green);
bar.FillStyles[2] = new NColorFillStyle(Color.Blue);
  
nChartControl1.Refresh();

[VB.NET]
Dim chart As NChart = nChartControl1.Charts(0)
  
Dim bar As NBarSeries = DirectCast(chart.Series.Add(SeriesType.Bar), NBarSeries)
bar.Values.Add(10)
bar.Values.Add(20)
bar.Values.Add(25)
bar.FillStyles(0) = New NColorFillStyle(Color.Red)
bar.FillStyles(1) = New NColorFillStyle(Color.Green)
bar.FillStyles(2) = New NColorFillStyle(Color.Blue)
  
nChartControl1.Refresh()

The above code will associate red, green and blue fill style to the first, second and third data point in a simple bar chart.

You can also use the built in Chart Editor and the predefined palettes.

Article ID: 69, Created On: 10/6/2010, Modified: 11/15/2010