This doesn't directly answer your question, but I spent a week trying to find the right solution for generating and using graphs with VFP. I ended up using the OWC - Office Web Components supplied by Microsoft to generate standalone images. It works reliably and fast. Let me know if you need samples. Robert Bradley
I hesitate to post this much code in a thread, but I think all of this would be helpful and give you a good headstart.
Essentially, you have an open table/cursor where the first column is assumed to be the labels and the second column is assumed to be the value. As you'll note, I've kludged in support for a second value column, but haven't gotten around to expanding it and making it more flexible.
An example select statement that could be used to feed the graph:
[tt]select State, count(*) from MyTable group by State[/tt]
The result will be a GIF file. Many of the parameters are optional (such as image size), so its fairly simple to use.
------------
[tt]* -- makes a chart using the currently open table/cursor
* -- the first column should be the X-axis labels,
* -- and the rest of the columns should be the Y-axis values
if empty(alias())
wait window "No table/alias open in current work area" timeout 200
return .F.
endif
if reccount() = 0
wait window "No records in alias" timeout 200
return .F.
endif
if empty(cChartType)
cChartType = "BAR"
else
cChartType = upper(cChartType)
endif
if empty(nWidthPixels)
nWidthPixels = 500
endif
if empty(nHeightPixels)
nHeightPixels = 300
endif
if empty(nValueColumns)
nValueColumns = 1
endif
* -- put the contents into an array
dimension aLabels(reccount())
dimension aValues(reccount())
go top
for i = 1 to reccount()
aLabels(i) = alltrim(evaluate(field(1)))
aValues(i) = evaluate((field(2)))
skip
endfor
if nValueColumns = 2
dimension aLabels2(reccount())
dimension aValues2(reccount())
go top
for i = 1 to reccount()
aLabels2(i) = alltrim(evaluate(field(1)))
aValues2(i) = evaluate((field(3)))
skip
endfor
endif
if empty(cCaption)
cCaption = "Graph"
endif
if empty(cOutFile)
cOutFile = "chart.gif"
endif
* -- Create a Chart Object
oChart = CreateObject("OWC.Chart"
if vartype(oChart) <> "O"
wait window "Could not create OWC object" timeout 30
return .F.
endif
lLegend = .F.
* -- determine graph type
do case
case cChartType == "COLUMN CLUSTERED"
cGraphType = oChart.Constants.chChartTypeColumnClustered
case cChartType == "COLUMN STACKED"
cGraphType = oChart.Constants.chChartTypeColumnStacked
case cChartType == "AREA"
cGraphType = oChart.Constants.chChartTypeArea
case cChartType == "AREA STACKED"
cGraphType = oChart.Constants.chChartTypeAreaStacked
lLegend = .T.
case cChartType == "PIE"
cGraphType = oChart.Constants.chChartTypePie
lLegend = .T.
case cChartType == "PIE EXPLODED"
cGraphType = oChart.Constants.chChartTypePieExploded
lLegend = .T.
case cChartType == "PIE PERCENT"
cGraphType = oChart.Constants.chChartTypePie
lLegend = .T.
case cChartType == "LINE"
cGraphType = oChart.Constants.chChartTypeLine
case cChartType == "DOUGHNUT"
cGraphType = oChart.Constants.chChartTypeDoughnut
case cChartType == "BUBBLE"
cGraphType = oChart.Constants.chChartBubble
otherwise
cGraphType = oChart.Constants.chChartTypeColumnClustered
endcase
If you guys try it and it works for you, I'll FAQ it for posterity.
I generate a couple dozen reports automatically each night. I use VFP to do the data collection and analysis, and spit out HTML with links to the generated GIF graphs.
Keep in mind that OWC has a lot more capabilities than just the little part I'm exploiting here. You can find some help files by searching on your computer for files named MSOWC*.CHM. Robert Bradley
Robert,
I see that you generate a man reports automatically each night. You use VFP to do the data collection and analysis, and spit out HTML with links to the generated GIF graphs.
I ask you a question? Can I make a graf of the totals of the collections that are taken up each sunday in chruch?
Or the averages of Baptisms or wedding per month over a period of ten years? I can see the tremendous advantage of a graf.
I will be anxious to hear your response. Johnjames...
I searched my computer for MSOWL and found several .dlls and an .sll (whatever that is), but no help files. These were all in Microsoft Office 10 directories. Should I look in some other help file? Dave Dardinger
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.