We help IT Professionals succeed at work.

Displaying an MSChart object

tinklerj
tinklerj asked
on
Is there a way to show an MSChart object on an Active Server Page?  MSDN suggests embedding in a Picture object but then I see no way of rendering that, eg as GIF or JPG file.
Comment
Watch Question

Commented:
embed the object control on the page as you would any active x control
Here is the code for the MSOffice 2000 MSChart Control ...
(MSCHRT20.OCX)
ALL OF THE STRANGE TEXT IN THE MIDDLE IS ACTUALLY THE DATA AND PROPERTIES -- JUST COPY AND PASTE THIS IN YOUR ASP PAGE

<OBJECT id=MSChart1 style="LEFT: 0px; WIDTH: 319px; TOP: 0px; HEIGHT: 121px" classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D"

width=319
height=121 VIEWASTEXT></OBJECT>

Commented:
sorry - here is a MSDN on how to populate the chart above it dynamically

Option Explicit


' Be sure to set a reference to the Microsoft ActiveX Data
' Objects 2.0 Library.


Private rsProducts As New ADODB.Recordset
Private cn As New ADODB.Connection

Private Sub Form_Load()
   Dim strQuery  ' SQL query string.

   ' First change the path to a valid path for your machine.
   cn.ConnectionString = _
   "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
   "C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb" ' <-Change this path.

   ' Open the connection.
   cn.Open
   
   ' Create a query that retrieves only four fields.
   strQuery = "SELECT ProductName, UnitPrice, " & _
   "UnitsInStock, UnitsOnOrder FROM Products WHERE SupplierID = 1"
   ' Open the recordset.
   rsProducts.Open strQuery, cn, adOpenKeyset
   ' Set the DataSource to the recordset.
   With MSChart1
      .ShowLegend = True
      Set .DataSource = rsProducts
   End With
End Sub

Explore More ContentExplore courses, solutions, and other research materials related to this topic.