Page 1 of 1

Problem with legend series title updation

Posted: Tue Aug 17, 2010 7:05 am
by 9641422
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();
     }

Re: Problem with legend series title updation

Posted: Tue Aug 17, 2010 9:08 am
by 10050769
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,

Re: Problem with legend series title updation

Posted: Mon Aug 23, 2010 12:15 pm
by 9641422
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.

Re: Problem with legend series title updation

Posted: Tue Aug 24, 2010 1:10 pm
by yeray
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 10171 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 10169 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),...

Re: Problem with legend series title updation

Posted: Sat Aug 28, 2010 7:50 am
by 9641422
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.

Re: Problem with legend series title updation

Posted: Tue Aug 31, 2010 8:13 am
by yeray
Hi Amol,

Could you please tell us what exact build are you using? You aren't using the latest (4.1.2010.8041), right?

Re: Problem with legend series title updation

Posted: Wed Sep 01, 2010 9:35 am
by 9641422
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.

Re: Problem with legend series title updation

Posted: Wed Sep 01, 2010 2:27 pm
by yeray
Hi Amol,

You're welcome. I glad to see it fits you needs!