INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

COM and Automation

How to use Office Web Components to create a chart. by mgagnon
Posted: 9 Mar 03 (Edited 10 Mar 03)

The following creates a Jpeg picture of a chart you can use in your application on forms, in reports etc... This example sends the chart to the Internet Explorer.
This requires Microsoft's Office Web Components. (http://office.microsoft.com/downloads/2002/owc10.aspx).


Local i
Store 0 To i
Dimension laLabels[3]
Dimension laData[3]
Dimension laData2[3]
Create Cursor final (pic m)
Create Cursor sales (Name c(20),total1 N(10),total2 N(10))
Insert Into sales (Name,total1,total2) Values ("Total sales Mike",1000,2000)
Insert Into sales (Name,total1,total2) Values ("Total sales Frank",2550,2500)
Insert Into sales (Name,total1,total2) Values ("Total sales Fred",1292,500)
Go Top
Do While !Eof()
    i = i +1
    laLabels[i]=sales.Name
    laData[i]=sales.total1
    laData2[i]=sales.total2
    Select sales
    Skip
Enddo
loChartSpace = Createobject("OWC10.ChartSpace")
oConst = loChartSpace.Constants
loGraph = loChartSpace.Charts.Add()
loGraph.Type =47
loGraph.HasLegend = .T.
loGraph.PlotArea.Interior.Color="Pink"
loChartSpace.HasChartSpaceTitle = .T.
loChartSpace.ChartSpaceTitle.Caption = "Monthly Sales for My Company Inc."
loChartSpace.ChartSpaceTitle.Font.Bold = .T.
loGraph.SeriesCollection.Add()
loGraph.SeriesCollection(0).Caption = "Sales of widgets #1"
loGraph.SeriesCollection(0).SetData(oConst.chDimCategories, oConst.chDataLiteral, @laLabels)
loGraph.SeriesCollection(0).SetData(oConst.chDimValues, oConst.chDataLiteral, @laData)
loGraph.SeriesCollection.Add()
loGraph.SeriesCollection(1).Caption = "Sales of widgets #2"
loGraph.SeriesCollection(1).SetData(oConst.chDimValues, oConst.chDataLiteral, @laData2)
lcFile = Sys(2023) + "\" + Sys(2015) + ".jpg"
loChartSpace.ExportPicture(lcFile, "jpg",800,600)
oBrowser = CREATEOBJECT("internetexplorer.application")
oBrowser.navigate(lcFile)
oBrowser.visible = .t.


P.S. Some of this code was partially written by Rick Strahl.

Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close