<%@ language=vbscript %> <% '利用数据库中的数据生成线图。 '根据4个不同的值分别生成4条线。 '在X轴上显示星期的名称。
Response.Expires = 0 Response.Buffer = true Response.Clear
'利用下面的语句创建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
'关闭数据库连接 RS.Close DBConn.Close
'下面设置组件属性 '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格式发送到浏览器 Response.ContentType = "image/gif" Response.BinaryWrite Chart.GIFLine Response.End %>
|