Talking about the Application of Teechart Components in ASP
Since the Teechart VCL version is widely used in a variety of development environments and well-recognized, STEEMA SOFTWARE SL has developed Teechart Pro ActiveX in October 1997. For the development mode of B / S is undoubtedly a good news, because it only needs to be installed on the server side, the client does not need to install additional software, as long as you use a universal browser to display the statistics graphics, the city is even more Welcome.
Below we combine ASP technology to introduce the usual properties and applications of Teechart Pro V5 ActiveX components.
Let's first look at the two-dimensional histogram example of the TEECHART component to display the "quarter sales" situation:
<% '----------- Teecharteg.asp ------------------------
Set tchart1 = createObject ("teechart.tchart")
TCHART1.HEADER.TEXT (0) = "Statistics of Sales Quarter"
TCHART1.ADDSeries (1)
TCHART1.ASPECT.VIEW3D = 0
TCHART1.SERIES (0) .clear
TCHART1.SERIES (0) .add 180, "1 quarter", RGB (35, 70, 128)
Tchart1.series (0) .add 240, "2 quarter", RGB (255, 80, 128)
Tchart1.series (0) .add 210, "3 Quarter", & HFACE87
Tchart1.series (0) .add 280, "4 Quarter", 16777215
Tchart1.export.savetojpegfile server.mappath ("MyChart.jpg"), False, JPEGBestQuality, 100, Tchart1.Width, Tchart1.height
Set tchart1 = nothing
%>
Body> html>
1) The same way as the ASP other components is the same, first create an object.
Set tchart1 = createObject ("teechart.tchart")
2) Use its attribute to display a static statistical graphic.
TCHART1.HEADER.TEXT (0) = "Statistics of Sales Quarter"
......
Tchart1.series (0) .add 210, "3 Quarter", & HFACE87
Tchart1.series (0) .add 280, "4 Quarter", 16777215
3) Generate a statistical graphic file
Tchart1.export.savetojpegfile server.mappath ("MyChart.jpg"), False, JPEGBestQuality, 100, Tchart1.Width, Tchart1.height
4) Release the object
Set tchart1 = nothing
Many properties of the object class in the above example are default, we can add settings based on the specific situation. Let's take a detailed introduction to other common attributes of the Teechart component (listed in the form of program comments)
<%
Set tchart1 = createObject ("teechart.tchart") tChart1.height = 440 'The height of the entire chart
TCHART1.WIDTH = 500 'The width of the entire chart
'Tchart1.header.text.clear
'TChart1.Header.Text.add "Quarter Sales Survey"' chart title, the way TCHART1.HEADER.TEXT (0) = "Title" form
TCHART1.HEADER.FONT.SIZE = 22 'Title Font Size
TCHART1.HEADER.FONT.BOLD = TRUE 'The title font is bold
Tchart1.Header.font.italic = true '标题 字否 体
TCHART1.PANEL.MARGINLINLINLINLINLINLINLINLINLINLINEFT = 3 'Chart left margin
TCHART1.PANEL.GRADIENT.Visible = True 'Is there a background
TCHART1.PANEL.GRADIENT.STARTCOLOR = & HB3DEF 'Chart color start color
TCHART1.PANEL.GRADIENT.EndColor = & HFACE87 'Chart color end color
TCHART1.PANEL.BEVELWIDTH = 0 'Canvas to indent the amplitude
TCHART1.Addseries (0) 'Shows the way the graphics, the value range is 1 ~ 39
TCHART1.ASPECT.VIEW3D = false 'false represents 2D graphics, true representation 3D graphics
TCHART1.ASPECT.CHART3DPERCENT = 10 'If it is 3D graphics, it indicates its inclination.
TCHART1.ASPECT.ZOOM = 100 'graphic display ratio
TCHART1.ASPECT.ORTHOGONAL = True '3d chart
TCHART1.ASPECT.ROTATION = -20 'If the chart is a side turn, the horizontal side turn angle -360 ~ 360
TCHART1.ASPECT.ELEVATION = 0 'If the chart is a side turn, the front and rear side turn angles - 360 ~ 360
TCHART1.ASPECT.PERSPECTIVE = 0 '3D graphics level aggregation level
TCHART1.ASPECT.CHART3DPERCENT = 20 '3D graphics thickness 1 ~ 100
TCHART1.WALLS.BOTTOM.SIZE = 5 'If it is a 3D graphic, it indicates that its horizontal thickness
TCHART1.WALLS.BOTTOM.COLOR = RGB (35, 70, 128) 'Base Color
TCHART1.WALLS.BOTTOM.TRANSPARENT = true 'is 3D graphics, the base is transparent TCHART1.WALLS.BACK.PEN.Visible = true' Participation Border Shows TCHART1.WALLS.LEFT.SIZE = 5 'If it is 3D graphics, Hand sitting thickness
TCHART1.WALLS.LEFT.COLOR = 8454143 'Longitudinal coordinate color
TCHART1.WALLS.LEFT.TRANSPARENT = true 'is a 3D graphic, whether the ordinate wall is transparent
TCHART1.LGEND.Visible = true 'Whether to display the legend
TCHART1.LEGEND.VERTSPACING = 9 'Legend Frame Height
TCHART1.DIVIDINGLINGLINGLINES.Visible = false 'legendary interval
'Tchart1.series (0) .clear
'Tchart1.series (0) .ColoreachPoint = true
'Tchart1.series (0) .ADD 180, "1 quarter", RGB (35, 70, 128)' Static to add display data in the chart, parameter is numerical size, name, color
'Tchart1.series (0) .add 240, "2 Quarter", 255
'Tchart1.series (0) .add 210, "3 Quarter", & HFace87
Tchart1.series (0) .add 280, "4 Quarter", 16777215
TCHART1.AXIS.DEPTH.Visibl E = false 'When the axle is 3D transparent, whether the inner wall is displayed
TCHART1.AXIS.DRAWAXESBEFORESERIES = FALSE 'The grid is displayed before the map
TCHART1.AXIS.LEFT.TITLE.CAPTION = "Value (unit: 10,000 yuan)" 'longitudinal axis heading
TCHART1.AXIS.LEFT.TITLE.FONT.BOLD = TRUE 'Whether the longitudinal shaft title is bold
TCHART1.AXIS.LEFT.TITLE.FONT.SIZE = 9 'Longitudinal shaft header size
TCHART1.AXIS.LEFT.TITLE.Visible = true 'Whether to display a set of ordinate
Tchart1.Axis.Labels.angle = 90 'longitudinal status tilt angle
TCHART1.AXIS.LEFT.GRIDPEN.Visible = True 'Is the abscissa parameter shaft display
TCHART1.AXIS.BOTTOM.TITLE.CAPTION = "Timeline" 'horizontal shaft title
TCHART1.AXIS.BOTTOM.TILE.FONT.BOLD = True 'Is the horizontal shaft header?
TCHART1.AXIS.BOTTOM.TILE.FONT.SIZE = 9 'horizontal shaft header size
TCHART1.AXIS.BOTTOM.LABELS.ANGLE = 0 'abscissive font tilt angle 0 ~ 360tchart1.axis.bottom.gridpen.visible = True' Biographical axis display
TCHART1.FOOTER.TEXT.ADD "under the title" under the chart
TCHART1.FOOTER.FONT.SIZE = 11 'under the title font size
Tchart1.footer.font.bold = true 'under the title font is bold
Tchart1.footer.font.italic = false 'Is the title font for a bevel?
Tchart1.export.savetojpegfile server.mappath ("mychart.jpg"), False, JPEGBESTQUAL, 100, TCHART1.WIDTH, TCHART1.HEIGHT 'Export Store is a MyChart.jpg file
Set tchart1 = nothing
%>
Body> html>
Note: 1. TCHART1.Addseries (0) The property of the graphic display method is worth researching. Interested readers can test from 0 to 39 to find their ideal display.
2. For reference color, the RGB three methods, for example: RGB (255,255,255) = & HFFFFFF = 16777215. The specific conversion method is not described.
3. The property is TRUE and FALSE that can be used instead of 1 and 0.
For the addition of the group map, the following is listed in the following examples of the two sets of data.
<% Set tchart1 = createObject ("teechart.tchart")
TCHART1.HEADER.TEXT (0) = "Quarter Sales" 'Title
TCHART1.ADDSeries (1)
TCHART1.ADDSeries (1)
Tchart1.series (0) .add 180, "1 quarter", RGB (255, 255, 255)
Tchart1.series (1) .add 240, "1 quarter", 255
TCHART1.SERIES (0) .add 280, "2 Quarter", RGB (255, 255, 255)
TCHART1.SERIES (1) .add 200, "2 Quarter", 255
TCHART1.SERIES (0) .add 150, "3 Quarter", RGB (255, 255, 255)
TCHART1.SERIES (1) .add 320, "3 Quarter", 255
TCHART1.SERIES (0) .add 360, "4 Quarter", RGB (255, 255, 255)
TCHART1.SERIES (1) .add 200, "4 Quarter", 255
TCHART1.SERIES (0) .MARKS.Visible = true 'Displays data title
TCHART1.SERIES (0) .MARKS.Style = 0 'Data Display style 0 ~ 9, 0 is numerical, 1 is% ...
TCHART1.SERIES (1) .MARKS.Style = 0
Tchart1.Export.savetojpegfile server.mappath ("mychart.jpg"), False, JPEGBESTQUAL, 100, TCHART1.WIDTH, TCHART1.HEIGHTSET TCHART1 = Nothing
%>
The above two examples are static production statistics, and then display. However, in actual work, more is displayed from the existing databases to read dynamic statistics. Let's take an example of using ADO directly connecting access to Access databases, dynamically displaying results. The database is (TEST.MDB), two columns of tables are colname, colvalue. The Month Name and the corresponding statistical data colname (January, February, ...), Colvalue (103, 210, ...):
<% DIM OUTPUTSTREAM
Set tchart1 = createObject ("teechart.tchart")
TCHART1.HEADER.TEXT (0) = "Quarter Sales" 'Title
TCHART1.Addseries (0) 'The value of the display graph is 1 ~ 39
Set
Conn
= Server.createObject ("AdoDb.Connection")
SET RST = Server.createObject ("AdoDb.Recordset")
Conn.open "Driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("zcw.mdb")
strsql = "SELECT * from test"
Rst.Open Strsql, CONN, 1, 1
IF RST.Recordcount> 0 THEN
TCHART1.SERIES (0) .datasource = RST
Tchart1.series (0) .Labelssource = "colname"
TCHART1.SERIES (0). Yvalues.valuesource = "colvalue"
Else
Tchart1.series (0) .fillsamplevalues (12)
TCHART1.HEADER.TEXT (0) = "No result, random display data"
END IF
TCHART1.SERIES (0) .MARKS.Visible = TRUE
TCHART1.SERIES (0) .MARKS.Style = 4
Tchart1.export.savetojpegfile server.mappath ("MyChart.jpg"), False, JPEGBestQuality, 100, Tchart1.Width, Tchart1.height
Set tchart1 = nothing
Rst.Close
Set
Conn
= Nothing
%>
The above three instances are displayed after generating a static JPG image file. If the value is not saved for the browsing result, we can use the PNG (Portable Network Graphics) mode.
<% DIM ChartType, OutputStream, ViewType
Set Chart1 = CreateObject ("Teechart.tchart") Chart1.addSeries (0)
Chart1.series (0) .fillsamplevalues 20 'Random Generate Data
OutputStream = chart1.export.aspng.savetostream
Set chart1 = Nothing
Response.binaryWrite OutputStream
%>
The above is a brief introduction to the combination of Teechart component attributes and ASP technology, I hope to help everyone. Teechart Pro Activex Free Trial Version can be downloaded from http://www.steema.com/download/download/download/download. Code examples of Teechart and ASP can be found at http://www.steema.com/products/teechart/asp/asphome.htm. If you have any opinions or opinions on this article, please contact Zcwmxn@sina.com.cn.