| |
akkua123
Posts: 15
Score: 0
Joined: 6/21/2005
From: USA
Status: offline
|
Hi Thank you all for the previous help.I am trying to create a test dynamic chart on Web using owc10.I can create single chart for a student information table which plots "TEST' on x-axis and "SCORES" on y-axis for each student.But I could not create a "series" by using 'Seriescollection" .So that I can plot a goup of students at a time.Like if we have 3 students in the table I wish to get 3 different plots in a single chart.I could bo it in OWC11.But I am here resrticted with OWC10. The code is shown below. <%@ Language="vbscript" CodePage="65001"%> <% Response.Buffer = TRUE Response.ContentType = "text/xml" Dim sCat, objSeries sCat = Request.QueryString("Category") 'Connect to the SQL Server Northwind database. Dim conn, rs Set conn = CreateObject("ADODB.Connection") 'conn.Open "Provider=SQLOLEDB;Data Source=SQLServer;Initial Catalog=Northwind;UID=sa" conn.Open "Provider=SQLOLEDB;SERVER=TOWSQL99;UID=akumar;Pwd=asdfgh;DATABASE=test_AK" 'Execute a query that returns records based on the Category ID. Set rs = CreateObject("ADODB.Recordset") ' rs.Open "SELECT ProductName, ProductSales From [Product Sales for 1997] " & _ ' "Where CategoryName='" & sCat & "'", conn, 3 rs.Open "select student, test, score from testscore where subject='" & sCat & "' order by test", conn, 3 'Build an array for the ProductName field and an array for the ProductSales field. ReDim aStudent(rs.RecordCount - 1) ReDim aTest(rs.RecordCount - 1) ReDim aScore(rs.RecordCount - 1) Dim i, j Do While Not rs.EOF aStudent(i) = rs.Fields("student") aTest(i) = rs.Fields("test") aScore(i) = rs.Fields("score") i = i + 1 rs.MoveNext Loop 'Close the connection to the database. rs.close conn.Close Set rs= Nothing Set conn = Nothing 'Create a new bar chart. Dim ChartSpace1, Cht, c, axis Set ChartSpace1 = CreateObject("OWC10.Chartspace") Set c = Chartspace1.Constants Set cht = Chartspace1.Charts.Add ' cht.Type = c.chChartTypeBarClustered cht.Type = c.chChartTypeLineMarkers 'Add the data to the chart. cht.SetData c.chDimSeriesNames, c.chDataLiteral, "Student" cht.SetData c.chDimCategories, c.chDataLiteral, aTest cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, aScore for each axis in cht.Axes axis.HasTitle = True if axis.Type = c.chCategoryAxis then axis.Title.Caption = "Date" else axis.Title.Caption = "Size" end if next 'Format chart elements. Chartspace1.Border.Color = "Rosybrown" ChartSpace1.Border.Weight = c.owcLineWeightMedium cht.SeriesCollection(0).Interior.Color = "Rosybrown" cht.PlotArea.Interior.Color = "Wheat" 'Return the new chart's XML. Response.Write Chartspace1.XMLData Response.End %> </HTML>
_____________________________
Amaran
|
|