private void SliderValueChanged(object sender, ValueChangedEventArgs e)
{
Random r = new Random();
double newVal = 5 + r.Next(40); // here we obtain real bar value
int index = (int)e.NewValue; // determine needed bar
if (index > 4)
return;
Color c = Color.LightGreen;
if (newVal < 20)
c = Color.Black;
else if (newVal > 40)
c = Color.LightSkyBlue;
series.ColorModel.CustomBrushes[index] = c; // <------ here I try to use new color
datas[index].YValue = newVal;
}
But it doesn't work. Can you advise, how to do it correctly?
Thanks,
Vadim.
P.S. I maid a little sample to explain my question.
Update. I can achive needed results with the next code modification (bold), it looks like some kind of brushes cashing is used.
private void SliderValueChanged(object sender, ValueChangedEventArgs e)
{
Random r = new Random();
double newVal = 5 + r.Next(40);
int index = (int)e.NewValue;
if (index > 4)
return;
Color c = Color.LightGreen;
if (newVal < 20)
c = Color.Black;
else if (newVal > 40)
c = Color.LightSkyBlue;
var list = (from col in chart.Series[0].ColorModel.CustomBrushes select col).ToList();
list[index] = c;
series.ColorModel.CustomBrushes = list;
datas[index].YValue = newVal;
}
But it seems to be very expencive to make new list every time. Maybe, better way exists?
Hello, Parthiban.
Thank you for the information! This topic can be closed.