Page 1 of 1

Change Axes Label text at runtime

Posted: Fri Sep 24, 2004 11:41 am
by 8125571
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

Posted: Mon Sep 27, 2004 9:54 am
by Pep
Hi Else,

you can enter the labels using :

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

Posted: Mon Sep 27, 2004 11:03 am
by 8125571
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";

Posted: Mon Sep 27, 2004 12:58 pm
by Marjan
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]);        

Posted: Mon Sep 27, 2004 1:40 pm
by 8125571
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]);        

Posted: Tue Sep 28, 2004 5:48 am
by Chris
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");