FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Draw line on TGraph
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Draw line on TGraph
Posted: 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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Draw line on TGraph
Posted: Sat Oct 15, 2011 01:57 AM

Can you try drawing line in the bPainted codeblock ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Draw line on TGraph
Posted: Sat Oct 15, 2011 01: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Draw line on TGraph
Posted: Sat Oct 15, 2011 02:24 PM
Rao,

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

Code (fw): Select all Collapse
   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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion