Wrong color is shown in the legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Wrong color is shown in the legend

Post by qcrnd » Thu May 27, 2010 1:43 pm

Hi ,

I have a problem -when some of my series are not active and I set the legend CheckBoxes property to be false.
In this case the colors of the legends are wrong.

Steps:
1.This is my chart :
1.JPG
1.JPG (31.24 KiB) Viewed 42717 times
2.I change some of the series to be not active :
2.JPG
2.JPG (31.16 KiB) Viewed 42676 times
3.I chnge the property of the legend to be CheckBoxes = false :
3.JPG
3.JPG (27.72 KiB) Viewed 42655 times
Please advice .

Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Wrong color is shown in the legend

Post by Sandra » Fri May 28, 2010 10:30 am

Hello gcrnd,

I couldn't reproduce your problem using next simple code:

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            for (int i = 0; i < 6; i++)
            {
                new Steema.TeeChart.Styles.Line(tChart1.Chart);
                tChart1[i].FillSampleValues();
                tChart1[i].XValues.DateTime = true;
            }
            tChart1.Legend.CheckBoxes = true;
}
Please, modify previous code because we can reproduce your problem exactly here.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Wrong color is shown in the legend

Post by Yeray » Fri May 28, 2010 10:57 am

Hi qcrnd,

I've reproduced the problem hiding some series and hiding the checkboxes so I've added it to the defect list to be fixed in future releases (TF02014918):

Code: Select all

            tChart1.Aspect.View3D = false;
            for (int i = 0; i < 3; i++)
            {
                new Steema.TeeChart.Styles.Line(tChart1.Chart);
                tChart1[i].FillSampleValues();
            }
            tChart1.Legend.CheckBoxes = true;

            tChart1[0].Active = false;

            tChart1.Draw();
            tChart1.Legend.CheckBoxes = false;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Sun May 30, 2010 6:15 am

Do you have any workaround that I can use until we get the fix in future versions?

Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Wrong color is shown in the legend

Post by Sandra » Mon May 31, 2010 9:24 am

Hello gcrnd,

I have found a workaround using GetLengeText Event and it works fine here with last version of TeeChart .Net. Please, could you check if next code works as you want?

Code: Select all

       private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            for (int i = 0; i < 3; i++)
            {
                new Steema.TeeChart.Styles.Line(tChart1.Chart);
                tChart1[i].FillSampleValues();
            }
            tChart1.Legend.CheckBoxes = true;
            tChart1[0].Active = false;
            tChart1.Draw();
            tChart1.Legend.CheckBoxes = false;
            tChart1.GetLegendText += new Steema.TeeChart.GetLegendTextEventHandler(tChart1_GetLegendText);  
        }
        void tChart1_GetLegendText(object sender, Steema.TeeChart.GetLegendTextEventArgs e)
        {
            foreach (Steema.TeeChart.Styles.Line s in tChart1.Series)
            {
                if (s.Active)
                {
                    if (e.Text == s.Title)
                    {
                        tChart1.Legend.Items[e.Index].Text = s.Title;
                    }
                }
              
            }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Mon May 31, 2010 1:11 pm

Hi ,

I tried to use the workaround , but it delete the legend and the colors in the chart.
When the checkboxes = true I see :
1.JPG
1.JPG (21.88 KiB) Viewed 42594 times
When the checkboxes = false I see :
2.JPG
2.JPG (16.72 KiB) Viewed 42591 times
I want to see the legend text and the legend color
Please advice.
Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Wrong color is shown in the legend

Post by Sandra » Tue Jun 01, 2010 8:36 am

Hello gcrnd,

I couldn't reproduce your problem here using last version of TeeChart.Net. Please, could you send us a simple project, because we can see the problem here? Also, could you say what version of TeeChart .Net you are using?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Tue Jun 01, 2010 3:29 pm

Hi Sandra ,

My version is 3.5.3425.20244
I tried to create a small example - and it seems to work partially - since on resize of the chart - the legend begins to be corrupted.
I tried to add the event and the method to our code ,and the legend looks corrupted , like the images that i send you - I think that this is related to size of the chart .
I also tried to compare between the legend properties of the example and the chart in my code - and all properties were the same.
Could you please explain to me what exactly the event "GetLegendText" and the method "ChartGetLegendText" supposed to do ? This may help us to understand why it is not working properly :

private void ChartGetLegendText(object sender, GetLegendTextEventArgs e)
{
foreach (Series series in Chart.Series)
{
if (series.Active)
{
if (e.Text == series.Title)
{
Chart.Legend.Items[e.Index].Text = series.Title;
}
}
}

Thanks
Kety

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Wrong color is shown in the legend

Post by Sandra » Wed Jun 02, 2010 9:56 am

Hello Kety,
Could you please explain to me what exactly the event "GetLegendText" and the method "ChartGetLegendText" supposed to do? This may help us to understand why it is not working properly:
GetLegenText is event that you can use basically to change text for each items of legend. I have made other example, because I found that my previous code doesn't work correctly for each case. Please, check next example works as you want.

Code: Select all

  private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            for (int i = 0; i < 6; i++)
            {
                new Steema.TeeChart.Styles.Line(tChart1.Chart);
                tChart1[i].FillSampleValues();
            }
            
            tChart1.Draw();
            tChart1.GetLegendText += new Steema.TeeChart.GetLegendTextEventHandler(tChart1_GetLegendText);
            tChart1.Draw();
        }
        void tChart1_GetLegendText(object sender, Steema.TeeChart.GetLegendTextEventArgs e)
        {
            foreach (Steema.TeeChart.Styles.Line s in tChart1.Series)
            {
                if (s.Active)
                {
                    if (e.Text == s.Title)
                    {
                        tChart1.Legend.Items[e.Index].Text = s.Title;
                    }
                }
                else if (!s.Active && tChart1.Legend.CheckBoxes)
                {
                    if (e.Text == s.Title)
                    {
                        tChart1.Legend.Items[e.Index].Text = s.Title;
                    }
                }
            }
        }
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

            tChart1.Legend.CheckBoxes = checkBox1.Checked;
}
On the other hand, I recommend that update last version 3.5.3700.30574/5 you could download it in this link and check if it works as you want. Also, I have checked previous code with last version 4 of TeeChart .Net and works fine.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Wed Jun 02, 2010 5:39 pm

hi sandrs,

I can not upgrade my version we are a week before code freeze.
I used you example without the method :
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
tChart1.Legend.CheckBoxes = checkBox1.Checked;
}

Since I didn't know to which event to link it.

And I still have the same problem - I see only the checkboxes without the label.
Please advice.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Wrong color is shown in the legend

Post by Sandra » Thu Jun 03, 2010 11:11 am

Hello gcrnd,

Finally, I could reproduce your problem, and I have added it in bug report list [TF02014931]. We will try to fix it for next maintenence releases of TeeChart .Net.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Thu Jun 03, 2010 1:15 pm

Hi Sandra,

So , I return to me previous request ...
Do you have any workaround that I can use until the fix in the future versions ?

Thanks
Kety

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Wrong color is shown in the legend

Post by Narcís » Thu Jun 03, 2010 1:24 pm

Hello Kety,

Sandra already suggested a workaround which involved using latest TeeChart for .NET v3 build available. If you can't update your TeeChart version the only solution I can think of is drawing your own custom legend as in the example Christopher Ireland posted on this thread.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Re: Wrong color is shown in the legend

Post by qcrnd » Thu Jun 03, 2010 2:00 pm

Hi ,

I didn't understand you answer my version is 3.5 - newer than v3, and the workaround that she gave me didn't work also in the example,since she was able to reproduce the problem also...

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Wrong color is shown in the legend

Post by Narcís » Thu Jun 03, 2010 5:42 pm

Hello,
I didn't understand you answer my version is 3.5 - newer than v3,
I'm sorry if I didn't explain myself clearly enough. As you can see here, build 3.5.3700.30574/5 is the latest version available of TeeChart for .NET v3. A TeeChart for .NET v3.5 doesn't exist, version following up TeeChart for .NET v3 is TeeChart for .NET v2010.
and the workaround that she gave me didn't work also in the example,since she was able to reproduce the problem also...
In that case the only solution I can think of is using drawing your own legend as I told in my previous reply.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply