Problem with legend series title updation

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Problem with legend series title updation

Post by Amol » Tue Aug 17, 2010 7:05 am

Hi,
We are trying to upgrade our application from TeeChart v2 to TeeChart v4. We are facing a problem in Steema Tee Chart v4 that was working correctly in TeeChart v2.
There is a combo box containing various names of properties. On selecting any property in the combo box the legend series should display the properties name as series title. For the first time when the chart is drawn the title is shown correct as shown in ScreenShot1.jpg while the series title on the legend does not get updated with the series name as shown in ScreenShot2.jpg. Snapshots are attached for the same.


The code for the selection change is pasted below:

Code: Select all

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
 	int PropIndex = comboBox1.SelectedIndex;
	tChart1.Series[0].Clear();
        tChart1.Series[0].ShowInLegend = false;
	for(int i=0;i<5;i++)
	{
	 	switch(PropIndex)
	        {
	               case 0:
		       {
                           tChart1.Series[0].Title = "Oil Sat";
                           tChart1.Series[0].Add(oilValues[i], i, Color.Brown);
                           break;
                       }
	               case 1:
		       {
                           tChart1.Series[0].Title = "Gas Sat";
                           tChart1.Series[0].Add(gasValues[i], i, Color.Green);
                           break;
                       }	               
                       case 2:
                       {
                           tChart1.Series[0].Title = "Water Sat";
	                   tChart1.Series[0].Add(waterValues[i],i,Color.Blue);
	                   break;
                       }
	         }
	  }
          tChart1.Series[0].ShowInLegend = true;
          tChart1.Refresh();
     }
Attachments
ScreenShot2.jpg
Screen Shot for Issue
ScreenShot2.jpg (47.54 KiB) Viewed 10223 times
ScreenShot1.jpg
Screen Shot for Issue
ScreenShot1.jpg (38.66 KiB) Viewed 10224 times

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

Re: Problem with legend series title updation

Post by Sandra » Tue Aug 17, 2010 9:08 am

Hello Amol,
I couldn't reproduce your problem using last version 4 of TeeChart.Net and next code:

Code: Select all

 private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
            Random rnd = new Random();
            tChart1.Legend.Symbol.DefaultPen = false;
            tChart1.Legend.CheckBoxes = true;
            for (int i = 0; i < 5; i++)
            {
                tChart1.Series[0].Title = "Oil Sat";
                tChart1.Series[0].Add(i, rnd.Next(100), Color.Brown);
                tChart1.Legend.Symbol.Pen.Color = Color.Brown;
            }
            tChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;
            comboBox1.Items.Add("Oil Sat");
            comboBox1.Items.Add("Gas Sat");
            comboBox1.Items.Add("Water Sat");
            comboBox1.SelectedIndex = 0;
            comboBox1.SelectedIndexChanged+=new EventHandler(comboBox1_SelectedIndexChanged);

         
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int PropIndex = comboBox1.SelectedIndex;
            tChart1.Series[0].Clear();
            tChart1.Series[0].ShowInLegend = false;
            Random rnd = new Random();
            for (int i = 0; i < 5; i++)
            {
                switch (comboBox1.SelectedIndex)
                {
                    case 0:
                        {
                            tChart1.Series[0].Title = "Oil Sat";
                            tChart1.Series[0].Add(i, rnd.Next(100), Color.Brown);
                             tChart1.Legend.Symbol.Pen.Color = Color.Brown;
                            break;
                        }
                    case 1:
                        {
                            tChart1.Series[0].Title = "Gas Sat";
                            tChart1.Series[0].Add(i, rnd.Next(100), Color.Green);
                             tChart1.Legend.Symbol.Pen.Color = Color.Green;
                            break;
                        }
                    case 2:
                        {
                            tChart1.Series[0].Title = "Water Sat";
                            tChart1.Series[0].Add(i, rnd.Next(100), Color.Blue);
                            tChart1.Legend.Symbol.Pen.Color = Color.Blue;
                            break;
                        }
                }
            }
             tChart1.Series[0].ShowInLegend = true;
            tChart1.Refresh();
        }
Could you please, you can say us if previous code works fine for you?

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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Problem with legend series title updation

Post by Amol » Mon Aug 23, 2010 12:15 pm

Hi,

We tried to use your code in our sample but it also did not work for us. Therefore, we are uploading our sample project so that you can take a look at the issue. Please add the reference of Tee Chart v4.
Attachments
WindowsApplication1.7z
Sample Application
(22.33 KiB) Downloaded 518 times

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

Re: Problem with legend series title updation

Post by Yeray » Tue Aug 24, 2010 1:10 pm

Hi Amol,

Your application seems to works as expected for me here.
I've ran it in Debug mode, and I've seen that when the application starts, the line:

Code: Select all

comboBox1.SelectedIndex = 0;
makes the "comboBox1_SelectedIndexChanged" method to be executed. And I've see how the process enters to the case 0:

Code: Select all

                    case 0:
                        {
                            tChart1.Series[0].Title = "Oil Sat";
                            tChart1.Series[0].Add(i, rnd.Next(100), Color.Brown);
                            tChart1.Legend.Symbol.Pen.Color = Color.Brown;
                            break;
                        }
And when the form is shown, I can see the "Oil Sat" line:
first.png
first.png (16.96 KiB) Viewed 10165 times
And if I select "Gas Sat" in the combobox, I can see how the process goes into the "comboBox1_SelectedIndexChanged" method again, executing the case 1:

Code: Select all

                    case 1:
                        {
                            tChart1.Series[0].Title = "Gas Sat";
                            tChart1.Series[0].Add(i, rnd.Next(100), Color.Green);
                            tChart1.Legend.Symbol.Pen.Color = Color.Green;
                            break;
                        }
And the it is shown the correct chart too:
second.png
second.png (16.7 KiB) Viewed 10163 times
So, I recommend you to select Debug mode and place a BreakPoint in the beginning of the "comboBox1_SelectedIndexChanged" method to see if the application calls it correctly and check the variables, go step by step (F10),...
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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Problem with legend series title updation

Post by Amol » Sat Aug 28, 2010 7:50 am

Hi,

We are not sure if you are using TChart .Net v4 version as in the snaps posted by you we can see legends different from our v4 version of TChart .Net. The legends of TChart v4 are thicker and are denoted by a rectangle while in your TChart snaps the legends are denoted by a thin line that used to be the case with TChart v2.

Or, if you made some changes in the code then you could please let us know.

As mentioned in our first post, the problem is occuring on v4 evaulation version.
We cant convince our project manager to upgrade to TChart v4 and order for it until everything works fine.

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

Re: Problem with legend series title updation

Post by Yeray » Tue Aug 31, 2010 8:13 am

Hi Amol,

Could you please tell us what exact build are you using? You aren't using the latest (4.1.2010.8041), right?
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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Problem with legend series title updation

Post by Amol » Wed Sep 01, 2010 9:35 am

Hi Yeray,

Yes you were right. Actually we We were using an older TChart Evaluation version i.e.,4.0.2010.13055. After reading your last post, we downloaded it again and got the latest TChart version 4.1.2010.8045. The problem got resolved by using this version. Thanks a lot for your replies.

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

Re: Problem with legend series title updation

Post by Yeray » Wed Sep 01, 2010 2:27 pm

Hi Amol,

You're welcome. I glad to see it fits you needs!
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

Post Reply