Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Graph Wizard
Message
From
08/12/2000 03:19:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/12/2000 06:55:11
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00450291
Message ID:
00450725
Views:
34
>Hi all,
>
>Is there any graph wizard for VFP6.0 that I can use that will actually count records in a table. The graph wizard that comes with VFP6.0 does not let me do this .eg. a count of all students form a student table whose nationality is Irish,American,English .etc.
>
>Does anybody have code that will do this, I don't want to have to buy a product off the shelf to do this.
>
>Any replies ???
>
>Regards
>Aidan

Aidan,
You prepare the data for Graph with an SQL and then call graph wizard or programmatically graph it. If you want extra functions like count, sum, avg in graph part then use pivot and Excel. IMHO if you have a chance to use Excel prefer it over Graph.
Here is a sample that would count and graph with MSGraph :
*** set the LOCALEID to English
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)				&& We will be sending instructions in English

* Part of xlChartType constants
#Define xlBubble3DEffect			87
#Define xlColumnClustered  51
#Define xlBarClustered  57
#Define xlCategory  1

#Define TABULATE CHR(9)
#Define CRLF CHR(13)+CHR(10)

Select country,cnt(*) as 'Count' from customer group by country into cursor crsGraph
Wait window nowait "Filling cell values..."
MCGDATA = ""
nCols = fcount()
For ix = 1 to nCols
  MCGDATA = MCGDATA + iif(empty(MCGDATA),"",TABULATE)+field(ix)
Endfor
MCGDATA = MCGDATA + CRLF
Scan
  For ix = 1 to nCols
    MCGDATA = MCGDATA + iif(ix=1,"",TABULATE)+nvl(transform(evaluate(field(ix))),"")
  Endfor
  MCGDATA = MCGDATA + CRLF
Endscan
* Data prepare *

Create cursor testgen (graphtest g)
Append blank
Append general graphtest class MSGraph.Chart.5 data MCGDATA

oForm = createobject("Form")
With oForm
  .height = 450
  .width = 650
  .show
  .closable = .f.
  .addobject("myGraph","OleBoundControl")
  .addobject("myQuit1","myQuit")
  .addobject("myChanger1","myPlotChanger")
  With .myGraph
    .height = oForm.height - 20
    .width = oForm.width
    .left = 0
    .top = 20
    .ControlSource = "testgen.graphtest"
    Wait window nowait "Plotting..."
    .ChartType=xlColumnClustered
    .object.application.plotby = 2 && Columns
    .haslegend = .F.
*!*	    with .Legend.Font
*!*	    	.Bold = .f.
*!*	    	.Size = 8
*!*	    endwith
    With .Axes(xlCategory).TickLabels
      With .Font
        .Name = "Arial"
        .FontStyle = "Normal"
        .Size = 8
      Endwith
      .Offset = 50
      .Orientation = 90
    Endwith
    .visible=.T.
  Endwith
  .myQuit1.visible = .t.
  .myChanger1.visible = .t.
Endwith
Wait clear
**** 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=150
  Top=0
  AutoSize = .T.
  Caption="Change plotby"
  Procedure click
  With thisform.myGraph.object.application
    .plotby = iif(.plotby=1,2,1)
  Endwith
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
Reply
Map
View

Click here to load this message in the networking platform