Page 1 of 1

Chart::DrawLine?

Posted: Wed Mar 10, 2010 4:32 pm
by 14049593
Hello,

I am completely new to TeeChart and am attempting to add a vertical line using Chart::DrawLine() in a Visual C++ application compiled under Visual Studio 2008. Sample code appears below.

The series that I've added to the chart plots just fine, but I can't get the lines to appear at all. Breakpoints show my OnAfterDraw() routine is getting called. Any thoughts?

Thanks for your help...

- Ted

Code: Select all

	private: System::Void MyChart_OnAfterDraw(System::Object^  sender, System::EventArgs^  e)
			{
				int middle = (chart->Axis->Bottom->StartPosition + chart->Axis->Bottom->EndPosition) / 2;
				chart->Canvas->DrawLine(middle, chart->Axis->Left->StartPosition, middle, chart->Axis->Left->EndPosition);
				chart->Canvas->DrawLine(10, 22, 16, 45);
			}


Re: Chart::DrawLine?

Posted: Thu Mar 11, 2010 4:05 pm
by yeray
Hi Ted,

Try the IStartPos and IEndPos instead of StartPosition and EndPosition (the seconds are percentages).

Code: Select all

int middle = (axTChart1->Axis->Bottom->IStartPos + axTChart1->Axis->Bottom->IEndPos) / 2;
axTChart1->Canvas->DrawLine(middle, axTChart1->Axis->Left->IStartPos, middle, axTChart1->Axis->Left->IEndPos);