TAnnotaion

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

TAnnotaion

Post by Marius » Fri Nov 14, 2008 4:09 pm

Hi

I have a chart which has three series and three left axis (two custom ones)
The axis positions are set up as percentages so
Series 0 - Left Axis is from 0 to 60
Series 1 - Custom 0 is from 60 to 80
Series 2 - Custom 1 is from 80 to 100
percent of the chart

For each series I need to write a label in the top left corner of that part of the chart. So for for Series 0 i want label at 2,2, for Series 1 I want a label at 2,X+2 (where X is 60% of the height of the plot area) and the same for Series 2. The label position needs to update as I resize the chart.

At the moment I'm doing:

Code: Select all

  with AChart.Tools.Add(TAnnotationTool) as TAnnotationTool do begin
    Text := 'Test';
    Shape.CustomPosition := true;
    Shape.Shadow.Visible := false;
    PositionUnits := muPixels;
    Left := AChart.ChartBounds.Left + 2;
    Top  := Trunc(AChart.Height * 0.6) + 2;
  end;
But ChartBounds is the whole chart and not just the plot area. Similarly AChart.Height does not give me what I want.

How can I get at the positions I need?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Nov 14, 2008 4:21 pm

Hi Marius,

Try using axes top positions: Chart1.Axes.Left.IStartPos for left axis and Chart1.CustomAxes[CustomAxisIndex].IStartPos for custom axes.

I'd place this code in chart's OnAfterDraw event so that it's updated every time you resize, zoom, unzoom and scroll your chart. You may also need to call Chart1.Draw in OnResize, OnZoom, OnUndoZoom and OnScroll events so that chart is internally painted and the OnAfterDraw event already has updated axes positions.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

Post by Marius » Mon Nov 17, 2008 3:52 pm

Thanks. That sorts out the Top position.

But what about the "Left" position? The starting Left of my Vert axis varies with the values I plot (somtimes 200000, 210000 etc other times values like 70,80,90)

BRgds
Marius

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Nov 17, 2008 4:04 pm

Hi Marius,

In that case you can use Chart1.Axes.Left.PositionPercent. Also you may be interested in the examples my colleague Yeray made at the forums threads below:

http://www.teechart.net/support/viewtopic.php?t=6146
http://www.teechart.net/support/viewtopic.php?t=5923
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply