Change Axes Label text at runtime

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
else
Newbie
Newbie
Posts: 17
Joined: Fri May 21, 2004 4:00 am
Location: Germany
Contact:

Change Axes Label text at runtime

Post by else » Fri Sep 24, 2004 11:41 am

Hi,

I want to change the text of an axes label at runtime, but it doesn't work.
If I design the chart with the Chart Editor and set the text of the Label it wortks.
But if I set the text at runtime with
WebChart1.Chart.Axes.Left.Labels.Text = "Test";
it doesn't work. The text which I set in designer is shown.

What did I wrong?

Else

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Sep 27, 2004 9:54 am

Hi Else,

you can enter the labels using :

WebChart1.Chart.Series[0].Labels[0] = "Label0";

else
Newbie
Newbie
Posts: 17
Joined: Fri May 21, 2004 4:00 am
Location: Germany
Contact:

Post by else » Mon Sep 27, 2004 11:03 am

Hi Pep,

it doesn't work.
I want the labels in the chart like the labels in chart "Gantt Series" in the TeeChart Gallery.
The names of machines which data are shown in the chart should shown on the left axis.

Thanks,
Else
Pep wrote:Hi Else,

you can enter the labels using :

WebChart1.Chart.Series[0].Labels[0] = "Label0";

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Sep 27, 2004 12:58 pm

Hi.

If you're using Gantt series then left axis will be (is) populated with point labels, as long as axis label style is set to text:

Code: Select all

      tChart1.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;

If you're using different series type, then the best solution is to manually define vertical axis labels. The following code should do the trick:

Code: Select all

      points1.Add(1.5, 10, "1st point");
      points1.Add(2.5, 3, "2nd point");
      points1.Add(3.0, 7, "3rd point");
      points1.Add(3.2, 6, "4th point");
      // show x values on horizontal axis
      points1.GetHorizAxis.Labels.Style = Steema.TeeChart.AxisLabelStyle.Value;

      // define custom labels for vertical axis
      Steema.TeeChart.AxisLabelsItems labels = points1.GetVertAxis.Labels.Items;
      labels.Clear();
      for (int i=0; i<points1.Count ;i++)
        labels.Add(points1.YValues[i],points1.Labels[i]);        
Marjan Slatinek,
http://www.steema.com

else
Newbie
Newbie
Posts: 17
Joined: Fri May 21, 2004 4:00 am
Location: Germany
Contact:

Post by else » Mon Sep 27, 2004 1:40 pm

Hi,

thanks, but it's already not running.
I work with lines in my chart. the yValue in the whole line the same, only the xValue changes. The xAxis is in DateTimeFormat. And if there are more lines, I want to name them by a label.
I try it as you told me. Now the yAxis is okay (the names are shown) but the XAxis shows the value I set in Line.Add(1,20,"Text"); Every label in the xAXis shows "Text". BUt I want to show the dateTime.

Thanks,
Else
Marjan wrote:Hi.

If you're using Gantt series then left axis will be (is) populated with point labels, as long as axis label style is set to text:

Code: Select all

      tChart1.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;

If you're using different series type, then the best solution is to manually define vertical axis labels. The following code should do the trick:

Code: Select all

      points1.Add(1.5, 10, "1st point");
      points1.Add(2.5, 3, "2nd point");
      points1.Add(3.0, 7, "3rd point");
      points1.Add(3.2, 6, "4th point");
      // show x values on horizontal axis
      points1.GetHorizAxis.Labels.Style = Steema.TeeChart.AxisLabelStyle.Value;

      // define custom labels for vertical axis
      Steema.TeeChart.AxisLabelsItems labels = points1.GetVertAxis.Labels.Items;
      labels.Clear();
      for (int i=0; i<points1.Count ;i++)
        labels.Add(points1.YValues[i],points1.Labels[i]);        

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Sep 28, 2004 5:48 am

Hi Else,
I work with lines in my chart. the yValue in the whole line the same, only the xValue changes. The xAxis is in DateTimeFormat. And if there are more lines, I want to name them by a label.
I try it as you told me. Now the yAxis is okay (the names are shown) but the XAxis shows the value I set in Line.Add(1,20,"Text"); Every label in the xAXis shows "Text". BUt I want to show the dateTime.
Set:

Code: Select all

tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Auto;
If you want to show your datatime labels, do not add any text to the 'String text' parameter of the Series.Add() method, e.g.

Code: Select all

Line.Add(1,20,""); 
If you want to show text rather than the datetime labels then add the text to the 'String text' parameter of the Series.Add() method, e.g.

Code: Select all

Line.Add(1,20,"Text"); 
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply