*** set the LOCALEID to English >>>nlLocaleId=sys(3004) && Save local id >>>=sys(3006,1033) && We will be sending instructions in English >>> >>>#Define xl3DColumnStacked 55 >>>#Define xlColumnStacked 52 >>> >>>#Define TABULATE CHR(9) >>>#Define CRLF CHR(13)+CHR(10) >>> >>>Dimension Groups[5] >>>Groups[1] = 'Sports' >>>Groups[2] = 'News' >>>Groups[3] = 'Magazine' >>>Groups[4] = 'Music' >>>Groups[5] = 'Discovery' >>>Rand(-1) >>>Create cursor test (GroupName c(10), Gender c(6), Counted i) >>>For ix = 1 to 300 >>> Insert into test ; >>> values ; >>> (Groups[int(rand()*100)%5+1], iif(int(rand()*100)%2=1,'Male','Female'),int(rand()*100)) >>>Endfor >>>Select GroupName, Gender, sum(Counted) as Total ; >>> from test ; >>> group by 1,2 ; >>> into cursor crsGraph nofilter >>> >>>Select GroupName, sum(Total) as SumTot ; >>> from crsGraph ; >>> group by 1 ; >>> into cursor crsGrpSum nofilter >>>Select max(SumTot) from crsGrpSum into array arrP100 && 100% >>> >>>Create cursor crsXTab (GroupName c(10),Female b(2), Male b(2)) >>>Select distinct GroupName from crsGraph into array arrGroups >>>For ix=1 to alen(arrGroups,1) >>> Select * from crsGraph where GroupName = arrGroups[ix,1] into cursor crsTemp >>> m.GroupName = arrGroups[ix,1] >>> Scan >>> Store Total to ('m.'+Gender) >>> Endscan >>> Insert into crsXTab from memvar >>> * Insert % representation >>> m.Multiplier = arrP100/(m.Female+m.Male) >>> m.Female = m.Multiplier*m.Female >>> m.Male = m.Multiplier*m.Male >>> Insert into crsXTab from memvar >>>Endfor >>>Select crsXTab >>>lcTempFile = sys(2015)+'.tmp' >>>Copy to (lcTempFile) type CSV >>>lcData = chrtran(FileToStr(lcTempFile),',',TABULATE) >>>Erase (lcTempFile) >>> >>>Create cursor testgen (graphtest g) >>>Append blank >>>Append general graphtest class MSGraph.Chart.5 data lcData >>> >>>oForm = createobject("myForm") >>>With oForm >>> .height = 400 >>> .width = 600 >>> .addobject("myGraph","OleBoundControl") >>> With .myGraph >>> .height = oForm.height - 50 >>> .width = oForm.width >>> .left = 0 >>> .top = 0 >>> .ControlSource = "testgen.graphtest" >>> Wait window nowait "Plotting..." >>> .haslegend = .t. >>> .ChartType=xlColumnStacked >>> .object.application.plotby = 2 >>> Wait clear >>> .visible=.T. >>> Endwith >>> .Show >>>Endwith >>>**** Set the LocaleId to the previous value >>>=sys(3006,val(nlLocaleId)) >>>Read events >>> >>>Define class myForm as Form >>> Procedure Destroy >>> Clear events >>> Endproc >>>Enddefine >>>Cetin