Page 1 of 2

Wrong color is shown in the legend

Posted: Thu May 27, 2010 1:43 pm
by 9092401
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 42742 times
2.I change some of the series to be not active :
2.JPG
2.JPG (31.16 KiB) Viewed 42701 times
3.I chnge the property of the legend to be CheckBoxes = false :
3.JPG
3.JPG (27.72 KiB) Viewed 42680 times
Please advice .

Thanks

Re: Wrong color is shown in the legend

Posted: Fri May 28, 2010 10:30 am
by 10050769
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,

Re: Wrong color is shown in the legend

Posted: Fri May 28, 2010 10:57 am
by yeray
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;

Re: Wrong color is shown in the legend

Posted: Sun May 30, 2010 6:15 am
by 9092401
Do you have any workaround that I can use until we get the fix in future versions?

Thanks

Re: Wrong color is shown in the legend

Posted: Mon May 31, 2010 9:24 am
by 10050769
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,

Re: Wrong color is shown in the legend

Posted: Mon May 31, 2010 1:11 pm
by 9092401
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 42619 times
When the checkboxes = false I see :
2.JPG
2.JPG (16.72 KiB) Viewed 42616 times
I want to see the legend text and the legend color
Please advice.
Thanks

Re: Wrong color is shown in the legend

Posted: Tue Jun 01, 2010 8:36 am
by 10050769
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,

Re: Wrong color is shown in the legend

Posted: Tue Jun 01, 2010 3:29 pm
by 9092401
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

Re: Wrong color is shown in the legend

Posted: Wed Jun 02, 2010 9:56 am
by 10050769
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,

Re: Wrong color is shown in the legend

Posted: Wed Jun 02, 2010 5:39 pm
by 9092401
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.

Re: Wrong color is shown in the legend

Posted: Thu Jun 03, 2010 11:11 am
by 10050769
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,

Re: Wrong color is shown in the legend

Posted: Thu Jun 03, 2010 1:15 pm
by 9092401
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

Re: Wrong color is shown in the legend

Posted: Thu Jun 03, 2010 1:24 pm
by narcis
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.

Re: Wrong color is shown in the legend

Posted: Thu Jun 03, 2010 2:00 pm
by 9092401
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...

Re: Wrong color is shown in the legend

Posted: Thu Jun 03, 2010 5:42 pm
by narcis
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.