Hi,
i currently set custom colors to my BarSeries:
C#series[i].View.Color = newColor;
Every bar is painted using two colors due to gradient painting-style of the bars. But i can only change the primary color, resulting to wrong gradient painting. I expected a possibility to recalculate the second color or to simply set the second color to a self defined one. But unfortunately i did not figure out an easy way.
C#series[i].View.Color2 = newColor;
Please see the rightmost bar in the attached screenshot. It seems that a second color for gradient style is used from the original color before changed to the custom color. To correct this, i use the CustomDrawSeriesPoint event to manipulate the Color2:
C#private void chartControl1_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e)
{
BarDrawOptions drawOptions = e.SeriesDrawOptions as BarDrawOptions;
if (drawOptions == null)
return;
// Get the fill options for the series point.
drawOptions.FillStyle.FillMode = FillMode.Gradient;
RectangleGradientFillOptions options = drawOptions.FillStyle.Options as RectangleGradientFillOptions;
if (options == null)
{
return;
}
Color color2 = drawOptions.Color;
byte R = (byte)((float)color2.R / 1.5f);
byte G = (byte)((float)color2.G / 1.5f);
byte B = (byte)((float)color2.B / 1.5f);
options.Color2 = Color.FromArgb(R, G, B);
}
After that, i get nice bars, but there is one problem left. The legend is still showing wrong colors like before using the event. Can anybody help? Best regards from Germany,
Timo
PS: Why is it so sophisticated to simply change some colors?