chart|web| Data | chart | Page Use chart (chart) performance data in a Web page
One of the things that you often need to do in WEB programming is to put the data that you've identified from the database (number)
Use the form of a chart (chart) to represent it in the page. Here's a quick summary of several common practices.
1. If the style of the chart requires only a column chart (bar), there is a very simple, lazy
method, that is, to use some of the tag's width property to perform. Examples are as follows:
src=http://www.163design.net/a/q/"small squares. gif" >
With this idea, if not too ugly, you simply use for loop control * Number of display number is also not
Not. ;-)
If you want to be more beautiful, you can design a good CSS, and then combine with DHTML.
A complete example of this method is shown in:
Http://www.microsoft.com/workshop/database/datavis/datavis.asp
2. Some guys like to put pictures directly in the database, so let's see how to tune them out.
(If these pictures are just graphs, I'm not straying.) ;-))
This is an example of the online Help for IIS:
Http://localhost/IIsSamples/SDK/asp/docs/CodeBrws.asp?source=/IIsSamples/SDK/asp/Database/Blob_VBScript.asp
Its core code:
<%
' The declaration is a Gif file, not an ordinary HTML
Response.Buffer = TRUE
Response.ContentType = "Image/gif"
' Even database
Set oconn = Server.CreateObject ("ADODB. Connection ")
oConn.Open "Dsn=localserver; Uid=sa; pwd=;D Atabase=pubs "
' Find a good picture
Set oRs = Oconn.execute ("Select logo from pub_info WHERE pub_id= ' 0736 '")
' Take the value to appear professional;-
Picsize = ORs ("logo"). ActualSize
Pic = ORs ("logo"). GetChunk (Picsize)
' Again, it's a GIF picture, and view source doesn't see anything.
Response.BinaryWrite Pic
Response.End
%>
Well, look at the notes, man (I don't have a good habit;-) asks: This program mypic.asp the final effect in the browser
Equivalent to Mypic.gif, I want to have words to do?
Quite simply, writing a Web page with is not over. ;-)
3. Also some of the older man, these heroes of the machine is mostly 8 CPU P III, they use the Server-side software,
Excel, for example, now makes a chart picture and then passes it to the browser in GIF format. More in the CGI master. ;-)
Let's look at a cool demo like this.
Core code:
<%
Set Excel = GetObject ("", "Excel.Application")
If err.number <> 0 Then
Response.Write ("Could not create Excel document." + err.description+ "")
Err.Clear
End If
Excel. DisplayAlerts = False
Set workbooks = Excel. Workbooks
Set wb = Workbooks. Add
Set sheets = wb. Sheets
Set wstotal = sheets. ADD (,,,-4167)
Wstotal.name = "Total_expenses"
Set range = Wstotal.range ("B1")
Range. FORMULAR1C1 = "1"
Set range = Wstotal.range ("C1")
Range. FORMULAR1C1 = "2"
Set range = Wstotal.range ("D1")
Range. FORMULAR1C1 = "3"
Wstotal.activate
Wstotal.select
Set range = Wstotal.range ("B1:d1")
Excel. Charts.add
Excel. Activechart.charttype = 51
Excel. Activechart.setsourcedata range,2
Excel. Activechart.export "D:\test\exceltest" + ". gif", "GIF"
Response.Write "%>
Real lazy people in writing this code also use Excel VBA (:-P), absolute code fast shooter,
But the efficiency of the operation----BAH! ;-)
4. Well, it's time to take a look at the professional athlete's approach----use chart control.
What kind of control is better everyone has a different opinion, (for example, some guys like Java Applets;-) And some, man.
Like to use it for the sake of simplicity, here I recommend Microsoft (;-))----
Office Web Component. ;-)
In the previous article I introduced several ways in which controls and data were combined, and we analyzed
With Excel 2000, chart control is implemented.
A. Row-by-line assignment
Excel Chart Control has two methods of assignment: An array, a string.
Array method:
code example:
----------------------------------
<object Id=chartspace1 classid=clsid:0002e500-0000-0000-c000-000000000046 style= "width:100%;height:350" > </object>
<script language=vbs>
Sub Window_onload ()
Dim categories (3), VALUES (3)
' 4 categories
Categories (0) = "White"
Categories (1) = "Bla