Page 1 of 1

Labels on top of CandleSeries !!

Posted: Mon Jan 16, 2006 2:45 am
by 9236155
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

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