Page 1 of 1

Axis GetPOstion() returns 0 and more

Posted: Thu Feb 17, 2011 1:07 pm
by 15053905
Hi,
I am using TeeChart pro V8.0.0.6 Version v Active x, C++.
The following code draws the chart, axis and series as expected.
The values of leftPos, bottomPos and topPos which use the axis GetPosition() function get 0 values. Why?
chartCenter, ChartWidth and canvasLeft get 0 value as well. Why?
Drawing line on the canvas with MoveTo() LineTo() using several different values of argumnets don't draw any line. Why?

Is there anything mising?
Please help me.
Thanks,
YVB

Code: Select all

	m_Chart.GetAspect().SetView3D(false);
	m_Chart.GetAxis().GetLeft().SetAutomatic(false);
	m_Chart.GetAxis().GetLeft().SetVisible(true);
	m_Chart.GetAxis().GetLeft().SetMaximum(100);
	m_Chart.GetAxis().GetLeft().SetMinimum(0);
	m_Chart.GetAxis().GetBottom().SetAutomatic(false);
	m_Chart.GetAxis().GetBottom().SetVisible(true);
	m_Chart.GetAxis().GetBottom().SetMaximum(200);
	m_Chart.GetAxis().GetBottom().SetMinimum(0);

	m_Chart.AddSeries(scFastLine);
	m_Chart.Series(0).AddXY(0.0, 0.0, NULL,RGB(255, 0, 0));
	m_Chart.Series(0).AddXY(30.0, 30.0,NULL,RGB(255, 0, 0));

	long leftPos = m_Chart.GetAxis().GetLeft().GetPosition();
	long bottomPos = m_Chart.GetAxis().GetBottom().GetPosition();
	long topPos = m_Chart.GetAxis().GetTop().GetPosition();

	long chartXCenter = m_Chart.GetCanvas().GetChartXCenter();
	long ChartWidth = m_Chart.GetChartWidth();
	long canvasLeft = m_Chart.GetCanvas().GetLeft();

	m_Chart.Repaint();

	m_Chart.GetCanvas().GetPen().SetColor(RGB(0,255,0)); 
	m_Chart.GetCanvas().MoveTo( 100, 200); 
	m_Chart.GetCanvas().LineTo( 100, 200); 

	m_Chart.Repaint();

Re: Axis GetPOstion() returns 0 and more

Posted: Fri Feb 18, 2011 1:20 pm
by 10050769
Hello yvb,
The values of leftPos, bottomPos and topPos which use the axis GetPosition() function get 0 values. Why?
chartCenter, ChartWidth and canvasLeft get 0 value as well. Why?
The leftPos,bottomPos and topPos, chartCenter,ChartWidth and canvasLeft are 0 because Chart is not painted. So you need use GetEnvironment().InternalRepaint() Chart property, before assign values to variables as do in next lines of code:

Code: Select all

m_Chart.AddSeries(scFastLine);
   m_Chart.Series(0).AddXY(0.0, 0.0, NULL,RGB(255, 0, 0));
   m_Chart.Series(0).AddXY(30.0, 30.0,NULL,RGB(255, 0, 0));
   m_Chart.GetEnvironment().InternalRepaint();
  long leftPos = m_Chart.GetAxis().GetLeft().GetPosition();
   long bottomPos = m_Chart.GetAxis().GetBottom().GetPosition();
   long topPos = m_Chart.GetAxis().GetTop().GetPosition();

   long chartXCenter = m_Chart.GetCanvas().GetChartXCenter();
   long ChartWidth = m_Chart.GetChartWidth();
   long canvasLeft = m_Chart.GetCanvas().GetLeft();
Drawing line on the canvas with MoveTo() LineTo() using several different values of argumnets don't draw any line. Why?
I recommend two thinks:
First: Don’t add the same values in MoveTo and LineTo for example you can change values of MoveTo to half
Second: Use MoveTo and LineTo in the AfterDraw event.

I hope will helps.

Thanks,

Re: Axis GetPOstion() returns 0 and more

Posted: Tue Feb 22, 2011 7:38 am
by 15053905
Hi Sandra,
Thanks. It works.
yvb

Re: Axis GetPOstion() returns 0 and more

Posted: Tue Feb 22, 2011 11:55 am
by 10050769
Hello yvb,

I am glad that it works for you :).

Thanks,