Labels on top of CandleSeries !!

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Satish
Newbie
Newbie
Posts: 37
Joined: Fri Mar 04, 2005 5:00 am

Labels on top of CandleSeries !!

Post by Satish » Mon Jan 16, 2006 2:45 am

I need help to write text (3-4 chars) on top of the highest point of selected candlesticks. The code stub I am using is given below (does not draw text):-

procedure TFChart01.plotcspatterns;
var i:integer;
FromPoint,ToPoint:TPoint;
begin
// Skip first 2 candles
for i:=2 to Series1.Count-1 do
begin
/Chart1.Canvas.ClipRectangle(Chart1.ChartRect);
// Series1 is TCandleSeries
ToPoint.X := Series1.CalcXPos(i);
ToPoint.Y := Series1.CalcYPosValue(Series1.HighValues.Value);
FromPoint.X := ToPoint.X;
FromPoint.Y := ToPoint.Y - 10;
Series1.ParentChart.Canvas.Pen.Color:=clRed;
Series1.ParentChart.Canvas.Pen.Style:=psSolid;
Series1.ParentChart.Canvas.Brush.Color := clLime;
Series1.ParentChart.Canvas.Brush.Style := bsSolid;
// Next two statements do not work
if i=10 then Series1.ParentChart.Canvas.TextOut(FromPoint.X,FromPoint.Y,'DJ');
Chart1.Canvas.TextOut(500,500,'DJ');
Chart1.Canvas.UnClipRectangle;
end;
end;

Will appreciate if you could let me know what I am missing in the above code. A small functioning code segment for writing text on the chart will be appreciated.

Please also let me know how to determine the minimum and maximum values assigned to a scale in case of automatic scaling of Y axis. I need to draw horizontal (pivot) lines at certain levels but have to first check that
it falls within the maximum & minimum Y scale.

Regards,

Satish


Regards,

Satish

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 Jan 16, 2006 9:20 am

Hi Satish,

To do any custom drawing in TeeChart you need to run the code in the TChart's AfterDraw event, something like:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
  i: Integer;
begin
  for i:=2 to Series1.Count-1 do
    Chart1.Canvas.TextOut(Series1.CalcXPos(i),
      Series1.CalcYPosValue(Series1.HighValues.Value[i]),'DJ');
end;
Please also let me know how to determine the minimum and maximum values assigned to a scale in case of automatic scaling of Y axis. I need to draw horizontal (pivot) lines at certain levels but have to first check that it falls within the maximum & minimum Y scale.
You can use any of the properties below, notice that each TChartValueList has a MaxValue and MinValue property.

Code: Select all

  Series1.HighValues.MaxValue
  Series1.MaxYValue
  Series1.YValues.MinValue
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