Page 1 of 1

Custom axis labels

Posted: Wed May 06, 2009 2:27 pm
by 9339785
Hi,
I have a question concerning axis labels : is it possible to keep default axis labels when adding a custom one with the routine

Code: Select all

NewAxisItem := Chart.DepthAxis.Items.Add(0.0)
thanks
Franck

Posted: Wed May 06, 2009 3:22 pm
by yeray
Hi Franck,

I've tried it and forcing a chart draw before adding the new axis labels, the default labels list isn't overwritten:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TSurfaceSeries.Create(self));
  Chart1[0].FillSampleValues(10);

  Chart1.Chart3DPercent := 100;
  Chart1.Axes.Depth.Visible := true;

  Chart1.Draw;

  Chart1.Axes.Depth.Items.Add(5.5);
end;

Posted: Thu May 07, 2009 7:23 am
by 9339785
In my case, default axis labels are hidden as soon as I had a custom one.

You could reproduce it with the example Axes->Labels->CustomLabels in Tee7New.exe

Franck

NB: I'm working with TeeChart v7.07 (source v7.12)

Posted: Thu May 07, 2009 8:14 am
by yeray
Hi Franck,

Here is the code of the Custom Labels demo with two little changes that makes the default labels also visible:
- Chart1.Draw to force the default labels to be drawn before adding the custom ones.
- Commented the line Chart1.Axes.Left.Items.Clear in AddCustomLabels method for not to clean the labels.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.AddSeries(TLineSeries.Create(self));
  Chart1[0].AddArray([200,0,123,300,260,-100,650,400]);

  Chart1.Draw;

  AddCustomLabels;
end;

Procedure TForm1.AddCustomLabels;
begin
  with Chart1.Axes.Left do
  begin
//    Items.Clear;  // remove all custom labels

    // add custom labels

    Items.Add(123,'Hello').Font.Size:=16;

    Items.Add(466,'Good'#13'Bye').Transparent:=False;

    Items.Add(300);

    with Items.Add(-100) do
    begin
      Transparent:=False;
      Transparency:=50;
      Color:=clBlue;
    end;
  end;
end;
Another possibility could be drawing the default labels, save them in an array at OnGetAxisLabels event, and then clean all the labels and add the desired ones as custom labels.

Posted: Thu May 07, 2009 9:43 am
by 9339785
Your first possibility does not work on my side :(
You are working with TeeChart v8.xx ?

The second works ... but it is not very practical

Franck

Posted: Thu May 07, 2009 10:44 am
by yeray
Hi Franck,

Yes, excuse me. I was making tests with TeeChart 8.04 and I've just seen that with v7 the easiest solutions doesn't work. So with v7 I can only think in the saving to table solution.

If you find problems implementing it, please don't hesitate to let us know.

Posted: Thu May 07, 2009 11:59 am
by 9339785
thanks for your help
Franck