Since the TeeChart VCL version is widely used in a variety of development environments and is well recognized, the Spanish Steema Software SL company developed TeeChart Pro ActiveX in October 1997. It is undoubtedly good news for the B/S development model. Since it only needs to be installed on the server side, the client does not need to install other software. Statistical graphics can be displayed using a general browser. Therefore, once it is launched, it has once again gained great popularity. welcome.
Next, we will introduce the common properties and applications of TeeChart Pro V5 ActiveX components based on ASP technology.
Let's first look at an example of a two-dimensional bar chart using the TeeChart component to display "quarterly sales":
<HTML><BODY>
<%'-----------TeeChartEg.asp---- --------------------
Set TChart1 = CreateObject("TeeChart.TChart")
TChart1.Header.Text(0)="Quarterly Sales Statistics"
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
%>
<img src="MyChart.jpg">
</BODY></HTML>
1) Same as other ASP components The usage method is the same, first create the object.
Set TChart1 = CreateObject("TeeChart.TChart")
2) Use its properties to display a static statistical graph.
TChart1.Header.Text(0)="Quarterly Sales Statistics"
...
TChart1.Series(0).Add 210, "3rd Quarter",&HFACE87
TChart1.Series(0).Add 280, "4th Quarter",16777215
3 ) Generate statistical graphics file
TChart1.Export.SaveToJPEGFile server.mappath("MyChart.jpg"),False,JPEGBestQuality,100,TChart1.Width, TChart1.Height
4) Release the object
Set TChart1 = nothing
Many attributes of the object class in the above example These are all default values, and we can add settings according to specific circumstances. The following is a detailed introduction to other common properties of the TeeChart component (listed in the form of program comments)
<HTML> <HEAD><TITLE>Introduction to the property methods of the TeeChart object</TITLE></HEAD>
<BODY>
<%
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 "Quarterly Sales Statistics" 'Chart title, the method can also be in the form of TChart1.Header.Text(0)="title"
TChart1.Header.Font.Size = 22 'Title font size
TChart1.Header.Font.Bold = True 'Whether the title font is
boldTChart1 .Header.Font.Italic = True ' Whether the title font is italic
TChart1.Panel.MarginLeft = 3 ' The left margin of the chart
TChart1.Panel.Gradient.Visible = True ' Whether there is a background color
TChart1.Panel.Gradient.StartColor = &HB3DEF ' The bottom of the chart Color start color
TChart1.Panel.Gradient.EndColor = &HFACE87 ' Chart background color end color
TChart1.Panel.BevelWidth = 0 ' Canvas indentation width
TChart1.AddSeries(0) ' The way to display graphics, the value range is 1 ~ 39
TChart1.Aspect.View3D = False ' False represents 2D graphics, True represents 3D graphics
TChart1.Aspect.Chart3DPercent = 10 ' If it is a 3D graphics, it represents its inclination
TChart1.Aspect.Zoom = 100 ' Graphic display ratio
TChart1.Aspect.Orthogonal = TRUE 'Whether the 3D chart is rotated sideways
TChart1.Aspect.Rotation = -20 'If the chart is rotated sideways, the horizontal rotation angle is -360~360
TChart1.Aspect.Elevation = 0 'If the chart is rotated sideways, rotate front and back Angle -360~360
TChart1.Aspect.Perspective = 0 ' 3D graphics centripetal aggregation degree
TChart1.Aspect.Chart3DPercent = 20 ' 3D graphics thickness 1~100
TChart1.Walls.Bottom.Size = 5 ' If it is a 3D graphic, it indicates its Abscissa thickness
TChart1.Walls.Bottom.Color = RGB(35,70,128) ' Base color
TChart1.Walls.Bottom.Transparent = True ' If it is a 3D graphic, whether the base is transparent TChart1.Walls.Back.Pen.Visible = True ' Parameter Whether the coordinate border is displayed
TChart1.Walls.Left.Size = 5 ' If it is a 3D graphic, it indicates its ordinate thickness
TChart1.Walls.Left.Color = 8454143 ' The ordinate color
TChart1.Walls.Left.Transparent = True ' If it is a 3D graphic , whether the ordinate wall is transparent
TChart1.Legend.Visible = True ' Whether to display the legend
TChart1.Legend.VertSpacing = 9 ' The height of the legend frame
TChart1.Legend.DividingLines.Visible = False ' Whether there are spacing lines between legends
'TChart1.Series(0 ).Clear
'TChart1.Series(0).ColorEachPoint = True
'TChart1.Series(0).Add 180,"1 Quarter",RGB(35,70,128) ' Staticly add display data to the chart, the parameters are numerical values in order ,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 coordinate axis is 3D transparent, whether to display the inner wall
TChart1.Axis.DrawAxesBeforeSeries = False ' Whether the grid is displayed in front of the graph
TChart1.Axis.Left.Title.Caption = "Output value (unit: 10,000 yuan)" ' Vertical axis title
TChart1.Axis.Left.Title.Font.Bold = True ' Vertical axis title whether to bold
TChart1.Axis.Left.Title.Font.Size = 9 ' Vertical axis title size
TChart1.Axis.Left.Title.Visible = True ' Whether to display the vertical axis name
TChart1.Axis.Left.Labels.Angle = 90 ' Vertical axis font tilt angle
TChart1.Axis.Left.GridPen.Visible = True ' Whether the abscissa parameter axis displays
TChart1.Axis.Bottom.Title.Caption = "Time Axis" ' Whether the abscissa axis title
TChart1.Axis.Bottom.Title.Font.Bold = True ' Whether the abscissa axis title is bold
TChart1.Axis .Bottom.Title.Font.Size= 9 'Abscissa axis title size
TChart1.Axis.Bottom.Labels.Angle = 0 'Abscissa font tilt angle 0~360
TChart1.Axis.Bottom.GridPen.Visible = True ' Parameter vertical Whether the coordinate axis displays
TChart1.Footer.Text.Add "Chart lower title" 'The lower title of the chart
TChart1.Footer.Font.Size = 11 'The font size of the lower title
TChart1.Footer.Font.Bold = True 'Whether the font of the lower title is Bold
TChart1.Footer.Font.Italic = False 'Whether the lower title font is italic
TChart1.Export.SaveToJPEGFile server.mappath("MyChart.jpg"),False,JPEGBestQuality, 100, TChart1.Width, TChart1.Height 'Export storage
Set TChart1 = nothing
%>
for the MyChart.jpg file
<img src="MyChart.jpg"></BODY></HTML>
Note: 1. The properties of the graphic display mode of TChart1.AddSeries(0) are worth studying. Those who are interested Readers can test it from 0 to 39 to find their ideal display method.
2. For color references, three representation methods of RGB are used, for example: RGB(255,255,255) = &HFFFFFF = 16777215. The specific conversion method is not explained.
3. The properties of True and False can be represented by 1 and 0 instead.
For the addition of group graphs, here is an example of displaying two groups of data.
<%Set TChart1 = CreateObject("TeeChart.TChart")
TChart1.Header.Text(0)="Quarterly Sales Volume"'Title
TChart1.AddSeries(1)
TChart1.AddSeries(1)
TChart1.Series(0).Add 180 , "Quarter 1",RGB(255,255,255)
TChart1.Series(1).Add 240, "Quarter 1",255
TChart1.Series(0).Add 280, "Quarter 2",RGB(255,255,255)
TChart1.Series(1 ).Add 200, "2nd Quarter",255
TChart1.Series(0).Add 150, "3rd Quarter",RGB(255,255,255)
TChart1.Series(1).Add 320, "3rd Quarter",255
TChart1.Series( 0).Add 360, "4 Quarters",RGB(255,255,255)
TChart1.Series(1).Add 200, "4 Quarters",255
TChart1.Series(0).Marks.Visible = True ' Whether to display the data title
TChart1. Series(0).Marks.Style = 0 'Data display style 0~9, 0 is numerical value, 1 is percentage...
TChart1.Series(1).Marks.Style=0
TChart1.Export.SaveToJPEGFile server.mappath("MyChart .jpg"),False,JPEGBestQuality,100,TChart1.Width, TChart1.Height
Set TChart1 = nothing
%>
The above two examples statically generate statistical results and then display them. However, in actual work, more dynamic statistical data display is read from the existing database. Below we give an example of using ADO to directly connect to the Access database and dynamically display the results. The database is (test.mdb), and the two columns of the table are colname and colvalue. They are 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)="Quarterly Sales Volume"'Title
TChart1.AddSeries(0)'The style value of the displayed graphics is 1~39, see below
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 results, randomly 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
%> <img src="MyChart .jpg">
The above three examples are all displayed after generating static JPG image files. If there is no value in saving the browsing results, we can use PNG (Portable Network Graphics) to display them.
<% Dim ChartType, OutputStream, ViewType
Set Chart1 = CreateObject("TeeChart.TChart")
Chart1.AddSeries(0)
Chart1.Series(0).FillSampleValues 20 ' Randomly 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 it will be helpful to everyone. A free trial version of Teechart Pro ActiveX can be downloaded from http://www.steema.com/download/Downloadindex.htm . For code examples of combining TeeChart with Asp, please refer to http://www.steema.com/products/teechart/asp/ASPHome.htm .