Custom axis labels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
franckgar
Advanced
Posts: 109
Joined: Thu Nov 04, 2004 5:00 am

Custom axis labels

Post by franckgar » Wed May 06, 2009 2:27 pm

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

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

Post by Yeray » Wed May 06, 2009 3:22 pm

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;
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

franckgar
Advanced
Posts: 109
Joined: Thu Nov 04, 2004 5:00 am

Post by franckgar » Thu May 07, 2009 7:23 am

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)

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

Post by Yeray » Thu May 07, 2009 8:14 am

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.
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

franckgar
Advanced
Posts: 109
Joined: Thu Nov 04, 2004 5:00 am

Post by franckgar » Thu May 07, 2009 9:43 am

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

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

Post by Yeray » Thu May 07, 2009 10:44 am

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.
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

franckgar
Advanced
Posts: 109
Joined: Thu Nov 04, 2004 5:00 am

Post by franckgar » Thu May 07, 2009 11:59 am

thanks for your help
Franck

Post Reply