<%@ language=vbscript %> <% '利用數(shù)據(jù)庫中的數(shù)據(jù)生成線圖。 '根據(jù)4個不同的值分別生成4條線。 '在X軸上顯示星期的名稱。 Response.Expires = 0 Response.Buffer = true Response.Clear '利用下面的語句創(chuàng)建chart對象,版本不同會有所差異。 'Set Chart = Server.CreateObject("csDrawGraph.Draw") Set Chart = Server.CreateObject("csDrawGraphTrial.Draw") ConnectionString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & _ Server.Mappath("data.mdb") Set DBConn = Server.CreateObject("ADODB.Connection") DBConn.Open ConnectionString Set RS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM Table1 ORDER BY Day" RS.Open SQL, DBConn While Not RS.Eof Chart.AddPoint CInt(RS("Day")), CInt(RS("Red")), "ff0000", "Red" Chart.AddPoint CInt(RS("Day")), CInt(RS("Blue")), "0000ff", "Blue" Chart.AddPoint CInt(RS("Day")), CInt(RS("Green")), "00ff00", "Green" Chart.AddPoint CInt(RS("Day")), CInt(RS("Yellow")), "ffff00", "Yellow" Chart.AddXValue CInt(RS("Day")), RS("DayName") RS.MoveNext Wend '關(guān)閉數(shù)據(jù)庫連接 RS.Close DBConn.Close '下面設(shè)置組件屬性 'X軸坐標從1開始而不是0。(XOffset = 1)
Chart.Title = "All the combined results" Chart.TitleX = 100 Chart.YAxisText = "Total for each day" Chart.OriginY = 220 Chart.XOffset = 1 Chart.XTop = 7 Chart.XGrad = 1 Chart.UseXAxisLabels = true Chart.LineWidth = 2 Chart.PointSize = 3 Chart.PointStyle = 1 '最后圖片以GIF格式發(fā)送到瀏覽器 Response.ContentType = "image/gif" Response.BinaryWrite Chart.GIFLine Response.End %>
|