Page 1 of 1

Unable to change the bar color

Posted: Tue Sep 07, 2010 2:36 am
by 15655558
Hi,

I have created a bar chart using TeeChart.

I am able to change the bar color using the following code:

series.Color = Color.Red

However, the bar color cannot be changed using the above code when the bar value is changing at the same time.

The above code is working fine in TeeChart v2005, but fail to work in TeeChart v2010.

Please help.

Thanks.

Re: Unable to change the bar color

Posted: Tue Sep 07, 2010 4:30 pm
by yeray
Hi mcpang,

I'm not sure about what do you mean with "at the same time". Are you using threads? Could you please send us a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.

Re: Unable to change the bar color

Posted: Wed Sep 08, 2010 3:28 am
by 15655558
Yes, there is a thread to update the bar value.

I have done more debugging, and noticed the following:

The thread updates the bar value in 100ms interval.
For testing purpose, I changed the code to update the bar value at a longer interval (such as 5 secs), and I am able to change the bar color.

I didn't encounter this problem in TeeChartv2.

Re: Unable to change the bar color

Posted: Wed Sep 08, 2010 2:00 pm
by narcis
Hi mcpang,

Can you please attach a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Re: Unable to change the bar color

Posted: Thu Sep 09, 2010 3:29 am
by 15655558
Hi,

Attached is simple test application to illustrate the problem.

I also noticed that if I commented off this line of code, it works.

series.Colors.Add(series.Color);

Thanks.

Re: Unable to change the bar color

Posted: Fri Sep 10, 2010 11:45 am
by yeray
Hi mcpang,

As you can see here,
Narcis wrote:if you populate a Pie series with a specific color for each slice it will prevail over series' color
What you could do is to clear the Colors list to use the series' color again:

Code: Select all

series1.Colors.Clear();

Re: Unable to change the bar color

Posted: Tue Sep 14, 2010 1:22 am
by 15655558
Sorry, can you elaborate on what you have mentioned in the previous post regarding on the solution?

Thanks.

Re: Unable to change the bar color

Posted: Tue Sep 14, 2010 11:26 am
by 10050769
Hello mcpang,

I think Yeray suggested you do is that you clean series list colors before change series color to red in click_button event:

Code: Select all

private void button1_Click(object sender, EventArgs e)
        {
            series1.Colors.Clear();
            series1.Color = Color.Red;
            
        }
So if you use previous code, you solve your problem and you don't need remove or comment next line of code:

Code: Select all

 series.Colors.Add(series.Color);
I hope will helps.

Thanks,