Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: randy requina
  Where is randy requina?
 Bohol, Philippines
 Philippines
 randy requina
 Tags
Subject: RE: Grid graph
Thread ID: 395806 Message ID: 395810 # Views: 109 # Ratings: 5
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Monday, January 20, 2014 7:53:30 AM         
   


> Hello experts,
> Any one can help me how to code a graph on the grid. Can you post the sample code guys. I attached the data below:
>
>
> I need to place the graph in the 5th column beside the Actual points earned. Thanks.
>
> Regards,
> Randy


You can use Shape objects, and put them in a Grid.Column, or in Container that you put beneath the Grid as your picture looks.

The Shape.Width would indicate something like percentage, so that you could use one of the Column.Dynamic properties if it's inside the Grid, see also the sample code pasted below.

If it's outside the Grid, Shape.Width could get determined in a place like Grid.AfterRowColChange(), which would be easy, and the Container(s) that hosts the Shape would probably need to adjust position according to resizing Forms as well as resized as well as moved Grid.Columns which can be done using BindEvent()



hth
-Stefan


LOCAL oForm as Form
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	AutoCenter = .T.
	DataSession = 2
	Width = 450

	PROCEDURE Load
		CREATE CURSOR temp (test I)
		RAND(-1)
		INSERT INTO temp VALUES ( 50 )
		LOCAL i
		FOR i = 1 TO 20
			INSERT INTO temp VALUES ( INT(RAND()*100) )
		ENDFOR
		GO TOP IN temp
	ENDPROC

	ADD OBJECT grdTest as Grid WITH ;
		ColumnCount = 2, Width = 450, Height = 250
	PROCEDURE grdTest.Init
		WITH This.Column2 as Column
			.NewObject('cntShape','GridShape')
			.cntShape.Visible = .T.
			.CurrentControl = 'cntShape'
			.DynamicFontBold = 'This.Column2.cntShape.DynamicWidth(temp.test)'
			.Sparse = .F.
			.Width = 300
		ENDWITH
	ENDPROC
ENDDEFINE

DEFINE CLASS GridShape as Container
	PROCEDURE DynamicWidth(tnPercent)
		This.shpOne.Width = This.Parent.Width / 100 * m.tnPercent
		RETURN .T.
	ENDPROC

	ADD OBJECT shpOne as Shape WITH ;
		BackColor = RGB(255,0,0), ;
		Width = 0
ENDDEFINE


ENTIRE THREAD

Grid graph Posted by randy requina @ 1/20/2014 7:32:40 AM
RE: Grid graph Posted by David Mustakim @ 1/20/2014 7:38:40 AM
RE: Grid graph Posted by randy requina @ 1/20/2014 7:51:13 AM
RE: Grid graph Posted by Stefan Wuebbe @ 1/20/2014 7:53:30 AM
RE: Grid graph Posted by randy requina @ 1/20/2014 8:43:27 AM
RE: Grid graph Posted by Stefan Wuebbe @ 1/20/2014 12:15:34 PM
RE: Grid graph Posted by randy requina @ 1/23/2014 9:43:20 AM
RE: Grid graph Posted by David Mustakim @ 1/23/2014 10:01:27 AM
RE: Grid graph Posted by Vilhelm-Ion Praisach @ 1/21/2014 9:48:19 AM
RE: Grid graph Posted by Stefan Wuebbe @ 1/21/2014 10:44:06 AM
RE: Grid graph Posted by Vilhelm-Ion Praisach @ 1/21/2014 11:06:06 AM
RE: Grid graph Posted by randy requina @ 2/22/2014 9:31:54 AM
RE: Grid graph Posted by Tore Bleken @ 1/21/2014 10:08:52 AM
RE: Grid graph Posted by Paul Gibson @ 1/21/2014 12:50:09 PM