Create TimeLine

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Eic
Newbie
Newbie
Posts: 5
Joined: Fri Mar 24, 2017 12:00 am

Create TimeLine

Post by Eic » Mon Apr 09, 2018 3:34 pm

Hello,

I'm trying to create a "timeline" chart with this code :

Code: Select all

void __fastcall TFormGraphiqueHelper::btnTimeLineClick(TObject *Sender)
{
	int i;
	TDateTime tmpDate;
	TVolumeSeries *serie = new TVolumeSeries(Chart1);
	Chart1->View3D = false;
	Chart1->OnAfterDraw = ChartTmpAfterDraw;
	Chart1->View3DWalls = false;
	Chart1->Legend->Visible = false;
	tmpDate = Now();
	Chart1->AddSeries(serie);

	serie->Marks->Visible = true;
	serie->XValues->DateTime = true;

	for (i = 0; i <= 9; i++)
	{
		serie->AddXY(tmpDate, 10*((i % 3) + 1), tmpDate.FormatString("dd/mm/yy") + "\r\nwith number " + IntToStr(i));
		tmpDate += random(9);
	}

	Chart1->Axes->Left->SetMinMax(0, 40);
	Chart1->Axes->Left->Visible = false;

	Chart1->Axes->Bottom->Grid->Visible = false;
	Chart1->Axes->Bottom->Labels = false;
	Chart1->Axes->Bottom->Increment = 1;
	Chart1->Axes->Bottom->MinimumOffset = 50;
	Chart1->Axes->Bottom->MaximumOffset = 50;
	Chart1->Axes->Bottom->Axis->Color = clGreen;
	Chart1->Axes->Bottom->Axis->Width = 18;
	Chart1->Axes->Bottom->Axis->EndStyle = esRound;
}

void __fastcall TFormGraphiqueHelper::ChartTmpAfterDraw(TObject *Sender)
{
	TChart *chart = static_cast<TChart*>(Sender);
	TTrianglePoints3D triangle;
	TTriangleColors3D triangleCouleur;
	int iHauteurAxe = Chart1->Axes->Bottom->Axis->Width;

	int iPosX = chart->Width;
	int iPosY = chart->LeftAxis->CalcYPosValue(0) + (iHauteurAxe / 2);

	triangle[0].x = iPosX - iHauteurAxe;
	triangle[0].y = iPosY - iHauteurAxe / 2 - 5;
	triangle[1].x = triangle[0].x;
	triangle[1].y = iPosY + iHauteurAxe / 2 + 5;
	triangle[2].x = iPosX;
	triangle[2].y = iPosY;
	triangleCouleur[0] = triangleCouleur[1] = triangleCouleur[2] = clYellow;//chart->Axes->Bottom->Axis->Color;

	chart->Canvas->Pen->Visible = false;
	chart->Canvas->Triangle3D(triangle, triangleCouleur);
}
I don't know how to position the yellow arrow at the end of the bottom axis.
How to know the position of the max of the axis, in pixel?
Image

Thanks for your help.

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

Re: Create TimeLine

Post by Yeray » Tue Apr 10, 2018 11:06 am

Hello,

Try using the bottom axis IEndPos property. Ie:

Code: Select all

uses TeCanvas;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var triangle: TTrianglePoints3D;
    triangleCouleur: TTriangleColors3D;
begin
  triangle[0].x := Chart1.Axes.Bottom.IEndPos;
  triangle[0].y := Chart1.Axes.Bottom.PosAxis - 5;
  triangle[1].x := triangle[0].x;
  triangle[1].y := triangle[0].y + 10;
  triangle[2].x := triangle[0].x + 10;
  triangle[2].y := Chart1.Axes.Bottom.PosAxis;

  triangleCouleur[0]:=clYellow;
  triangleCouleur[1]:=clYellow;
  triangleCouleur[2]:=clYellow;

  Chart1.Canvas.Triangle3D(triangle, triangleCouleur);
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

Eic
Newbie
Newbie
Posts: 5
Joined: Fri Mar 24, 2017 12:00 am

Re: Create TimeLine

Post by Eic » Tue Apr 10, 2018 1:55 pm

Its' perfect.

Thank you.

Post Reply