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);
}
How to know the position of the max of the axis, in pixel?
Thanks for your help.