Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MS Graph
Message
From
06/09/2001 10:05:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/09/2001 16:50:34
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
00552824
Message ID:
00553109
Views:
23
>I am using MSGraph to make a chart. I am using chart type 3(column). Does anyone know if it is possible to create a stacked column. If so what is the number to use in the command?

Steven,
If it's not MSGraph5 then you could use excel constants (excel97 and up). I think they exist in download area. If you can't find I can send and in the meantime to find a specific constatnt's value :
-Launch any office app (excel, word etc)
-Alt+F11
-f2
-type constant name (in combo near binoculars - by default you're there already after f2)
-enter
-Value is displayed at bottom near constant name
*** set the LOCALEID to English
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)			&& We will be sending instructions in English

#Define xl3DBarStacked  61
#Define xl3DBarStacked100  62
#Define xl3DColumnStacked  55
#Define xl3DColumnStacked100  56
#Define xlBarStacked  58
#Define xlBarStacked100  59
#Define xlColumnStacked  52
#Define xlColumnStacked100  53

#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("Form")
With oForm
  .height = 400
  .width = 600
  .show
  .closable = .f.
  .addobject("myGraph","OleBoundControl")
  .addobject("myQuit1","myQuit")
  .addobject("myChanger1","myPlotChanger")
  .addobject("myTypeChanger","cmbChartTypes")
  .addobject("Exporter","Exporter")
  With .myGraph
    .height = oForm.height - 20
    .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
  .setall('Visible',.t.)
Endwith
**** Set the LocaleId to the previous value
=sys(3006,val(nlLocaleId))

Read events

Define class myquit as commandbutton
  Left=1
  Top=0
  AutoSize = .T.
  Caption="Close"
  Procedure click
    Release all
    Clear events
  Endproc
Enddefine

Define class myPlotChanger as commandbutton
  Left=180
  Top=0
  AutoSize = .T.
  Caption="Change plotby"
  Procedure click
    With thisform.myGraph.object.application
      .plotby = iif(.plotby=1,2,1)
    Endwith
  Endproc
Enddefine

Define class cmbChartTypes as combobox
  Left=320
  Top=0
  Width = 200
  Procedure init


    With this
      .AddListItem('xl3DBarStacked',1,1)
      .AddListItem(transform(xl3DBarStacked),1,2)
      .AddListItem('xl3DBarStacked100',2,1)
      .AddListItem(transform(xl3DBarStacked100),2,2)
      .AddListItem('xl3DColumnStacked',3,1)
      .AddListItem(transform(xl3DColumnStacked),3,2)
      .AddListItem('xl3DColumnStacked100',4,1)
      .AddListItem(transform(xl3DColumnStacked100),4,2)
      .AddListItem('xlBarStacked',5,1)
      .AddListItem(transform(xlBarStacked),5,2)
      .AddListItem('xlBarStacked100',6,1)
      .AddListItem(transform(xlBarStacked100),6,2)
      .AddListItem('xlColumnStacked',7,1)
      .AddListItem(transform(xlColumnStacked),7,2)
      .AddListItem('xlColumnStacked100',8,1)
      .AddListItem(transform(xlColumnStacked100),8,2)
      .Columncount = 2
      .Columnwidths = '120,50'
    Endwith
  Endproc

  Procedure interactivechange
    With thisform.myGraph
      .ChartType = val(this.List(this.Listindex,2))
      .Setfocus
    Endwith
    This.setfocus
  Endproc

Enddefine

Define class Exporter as commandbutton
  Top =0
  Left = 70
  Caption = 'SaveAsHTML'
  Procedure click
    Thisform.myGraph.ChartArea.Copy()
    #Define wdFormatHTML 8
    oWord = createobject('Word.Application')
    With oWord
      .Documents.Add
      .Application.Selection.Paste
      lcPath = 'c:\temp\'
      lcFileName = 'myExportedGraph'
      .ActiveDocument.SaveAs(lcPath+lcFileName+'.htm', wdFormatHTML)
      .ActiveDocument.Saved = .T.
      .quit
    Endwith
    Adir(aGifFILE, lcPath+lcFileName+'_files\*.GIF')
    Wait window 'Gif file is :'+lcPath+lcFileName+'_files\'+aGifFILE[1,1]
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform