I am trying to figure out Teechart control and graph canvas of all four corners in client coordinate.
Does anyone know Teechart API that return a canvas coordinate for all four corner?
Thank you
I am trying to figure out Teechart control and graph canvas of all four corners in client coordinate.
Does anyone know Teechart API that return a canvas coordinate for all four corner?
Thank you
To determine the position of chart in the Window Form you can use the .Left
and .Top
Chart properties. In the same way, you can get the TChart
Corners using the ChartRect
. Please take a look to the code below:
// CDraggingDlg message handlers
BOOL CDraggingDlg::OnInitDialog()
{
….
CDialog::OnInitDialog();
// Extra initialization
m_ctrlChart.RemoveAllSeries();
m_ctrlChart.GetAspect().SetView3D(false);
m_ctrlChart.AddSeries(scLine);
m_ctrlChart.Series(0).FillSampleValues(100);
return TRUE;
}
std::string text;
void CDraggingDlg::OnAfterDrawTChart()
{
// Draw a white circle around the clicked pyramid...
CTeeRect r = m_ctrlChart.GetGetChartRect();
long recwidth, recheight, posLeft, posTop;
int BottomLCornerX,BottomLCornerY, BottomRCornerX, BottomRCornerY, TopLCornerX, TopLCornerY, TopRCornerX, TopRCornerY;
std::string s1, s2, s3;
//Get Width
recwidth = (r.GetRight()- r.GetLeft());
recheight = (r.GetBottom()-r.GetTop());
//GetPosition
posLeft = m_ctrlChart.GetLeft();
posTop = m_ctrlChart.GetTop();
//CalculateCorners
BottomLCornerX = r.GetLeft();
BottomLCornerY = r.GetBottom();
BottomRCornerX = r.GetRight();
BottomRCornerY = r.GetBottom();
TopLCornerX = r.GetLeft();
TopLCornerY = r.GetTop();
TopRCornerX = r.GetRight;
TopRCornerY = r.GetTop();
//Visualization Values
s1 = "Position Chart :" + std::to_string(posLeft) + "," + std::to_string(posTop);
s2 = "Chart Rect Positons: Left " + std::to_string(r.GetLeft()) + " Top " + std::to_string(r.GetTop()) + " Right " + std::to_string(r.GetRight()) + " Bottom " + std::to_string(r.GetBottom());
s3 = "Chart Rect Corners: BottomLeft " + std::to_string(BottomLCornerX) + "," + std::to_string(BottomLCornerY) + " BottomRight " + std::to_string(BottomRCornerX) + "," +
std::to_string(BottomRCornerY) + "\n TopLeft " + std::to_string(TopLCornerX) + "," + std::to_string(TopLCornerY) + " TopRight " + std::to_string(TopRCornerX) + "," + std::to_string(TopRCornerY);
text = s1 + "\n" + s2 +"\n"+s3 ;
}
void CDraggingDlg::OnButton1()
{MessageBox(text.c_str()); }