How to Draw Lines

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Newbie
Newbie
Posts: 27
Joined: Wed Nov 09, 2022 12:00 am

How to Draw Lines

Post by » Thu Aug 17, 2023 8:06 am

I want to draw 2 lines using the following code。

Code: Select all

	int nLeft=Chart->ChartRect.Left;
	int nRight=Chart->ChartRect.Right;
	int nTop=Chart->ChartRect.Top;
	int nBottom=Chart->ChartRect.Bottom;
	Chart->Canvas->Pen->Width = 3;
	Chart->Canvas->DoHorizLine(nLeft, nRight, 10);
	Chart->Canvas->DoVertLine(10, nTop, nBottom); 
But I don't know how to obtain the pixel value where the (0,0) point is located。
How to obtain the pixel value where the (0,0) point is located, using c++builder???
Attachments
666.png
666.png (11.42 KiB) Viewed 10604 times

Marc
Site Admin
Site Admin
Posts: 1217
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: How to Draw Lines

Post by Marc » Thu Aug 17, 2023 11:00 am

Hello,

This example code would plot a line from the Chart's 0,0 location to 5,5:

Code: Select all

procedure TForm4.Chart1AfterDraw(Sender: TObject);
var x0,y0,x1,y1 : Integer;
begin
  if Series1.Count>5 then
  Begin
    x0 :=  Chart1.Axes.Bottom.CalcXPosValue(0);
    y0 :=  Chart1.Axes.Left.CalcYPosValue(0);
    x1 :=  Chart1.Axes.Bottom.CalcXPosValue(5);
    y1 :=  Chart1.Axes.Left.CalcYPosValue(5);
    Chart1.Canvas.MoveTo(x0,y0);
    Chart1.Canvas.LineTo(x1,y1);
  End;
end;
There are similar methods available in the Series itself.
See:
https://www.steema.com/docs/teechart/vc ... rial13.htm

Regards,
Marc Meumann
Steema Support

Post Reply