Draw line on TGraph

Draw line on TGraph

Postby James Bott » Sat Oct 15, 2011 12:05 am

I am trying to figure out how to draw a line on a graph created with TGraph. I am using the drawLine() method and have tried calling it from oGraph:bInit, oDialog:bInit, and from a button after the graph has been drawn. None of these methods results in a line.

Here is an example:

@ 0,30 button "Line" action (oGraph:drawline(0,0,600,600,CLR_RED) )

Any ideas, anyone?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Draw line on TGraph

Postby nageswaragunupudi » Sat Oct 15, 2011 1:57 am

Can you try drawing line in the bPainted codeblock ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Draw line on TGraph

Postby James Bott » Sat Oct 15, 2011 1:57 pm

Rao,

This didn't work either:

oGraph:bPainted:= {|| oGraph:drawline(0,0,6000,6000,CLR_RED) }

Actually, it doesn't look like bPainted gets called. Neither of these work either:

oGraph:bPainted:= {|| msginfo() }
oGraph:bPainted:= {|| msgbeep() }

Thanks for the idea.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Draw line on TGraph

Postby James Bott » Sat Oct 15, 2011 2:24 pm

Rao,

OK, I added this to the bottom of the Paint() method:

Code: Select all  Expand view
  if ::bPainted != nil
      eval( ::bPainted )
   endif
 

And now the line is being drawn. However, the drawLine() method is actually using window coordinates, not chart coordinates, so the line is drawn partly outside the chart.

METHOD DrawLine( nY1, nX1, nY2, nX2, nColor, lDotted )

drawLine(0,0,600,600) draws the line starting at the top left corner of the dialog not the top left corner of the chart. It seems that corrections for the coordinates of the drawLine() method are made inside the Paint() method. So, it will be a major level of effort to just draw a line using the drawLine() method.

My desire is to draw some horizontal lines across the entire length of the chart. Another option might to be to create a dummy array of data points all of the same Y value and then plot them on the chart. I would like to do this without showing the actual data points and I am not yet sure if this can be done.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests