Axis GetPOstion() returns 0 and more

TeeChart for ActiveX, COM and ASP
Post Reply
yvb
Newbie
Newbie
Posts: 18
Joined: Mon Jul 13, 2009 12:00 am

Axis GetPOstion() returns 0 and more

Post by yvb » Thu Feb 17, 2011 1:07 pm

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();

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Axis GetPOstion() returns 0 and more

Post by Sandra » Fri Feb 18, 2011 1:20 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

yvb
Newbie
Newbie
Posts: 18
Joined: Mon Jul 13, 2009 12:00 am

Re: Axis GetPOstion() returns 0 and more

Post by yvb » Tue Feb 22, 2011 7:38 am

Hi Sandra,
Thanks. It works.
yvb

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Axis GetPOstion() returns 0 and more

Post by Sandra » Tue Feb 22, 2011 11:55 am

Hello yvb,

I am glad that it works for you :).

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply