Dsc Charthtm

<object id=chrtSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 _

style="width:100%;height:340"></object> <object id=dsc1 classid=CLSID:0002E530-0000-0000-C000-000000000046> _ </object>

<SCRIPT Language="VBScnpt"> Sub Window OnLoad()

Dim strConnection Dim strSQL Dim c

Dim rstdef

' Set the connection for the DataSource control strConnection="Provider=Microsoft.Jet.0leDB.4.0; data source=" & "C:\Program Files\Microsoft 0ffice\0ffice\Samples\Northwind.mdb" dscl.ConnectionString = strConnection

' Define the SQL query string to obtain the data strSQL = "SELECT Categories.CategoryName, Sum(od.Quantity) AS [Total

Quantity] " strSQL = strSQL & "FROM Categories " strSQL = strSQL & "INNER JOIN (Products " strSQL = strSQL & "INNER JOIN [order Details] as od " strSQL = strSQL & "ON Products.ProductID = od.ProductID) " strSQL = strSQL & "ON Categories.CategoryID = Products.CategoryID " strSQL = strSQL & "GROUP BY Categories.CategoryName;"

' Add a new Recordset definition to the DataSource control Set rstdef = dsc1.RecordsetDefs.AddNew(strSQL, dscl.Constants. dscCommandText)

' Get constants for the Chart component Set c = chrtSpacel.Constants

' Bind the chart space to the recordset definition in the ' DataSource control With chrtSpacel .DataSource = dscl

.DataMember = rstdef.Name

' Create a new chart with CategoryName field for Categories ' and Total Quantity field for Values .Charts.Add

.Charts(0).Type = c.chChartTypeBarClustered .Charts(0).SetData c.chDimCategories, 0, "CategoryName" .Charts(0).SetData c.chDimValues, 0, "Total Quantity" .Charts(0).Axes(c.chAxisPositionBottom).Numberformat = "#,##0" .Charts(0).PlotArea.Interior.Color = "yellow" End With End Sub </SCRIPT> </B0DY>

0 0

Post a comment