Using OWC control to implement various statistic graphs in ASP

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >


<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>asp OWC Control to achieve a variety of statistical charts </title>

<body>
<%
' The following test is a product sales figure. NET Tutorial ' >www.111cn.net
MX1 = "A product, b product, c product, D product" ' Data item array group (give the test data, the actual use of the time from the database tutorial read "," separated)
MX2 = "50,60,20,80" Data Item value array
Datestr = "2005-3-24,2005-3-25,2005-3-26,2005-3-27,2005-3-28" ' Date
Sqarxlstr = "50,100,20,80,89" ' a product sales from 2005-3-24 to 2005-3-28
Sqarxlstr = Sqarxlstr & "," & "40,60,20,90,70" ' B products sales from 2005-3-24 to 2005-3-28
Sqarxlstr = Sqarxlstr & "," & "20,50,55,25,60" ' C products sales from 2005-3-24 to 2005-3-28
Sqarxlstr = Sqarxlstr & "," & "80,20,75,58,100" ' d products sales from 2005-3-24 to 2005-3-28
%>
<br>
<center><object id= "ChartSpace1" classid= "clsid:0002e55d-0000-0000-c000-000000000046" style= "width:95%"; height:400 "></object></center>
<br>
<center><object id= "ChartSpace2" classid= "clsid:0002e55d-0000-0000-c000-000000000046" style= "width:95%"; height:400 "></object></center>
<br>
<center><object id= "ChartSpace3" classid= "clsid:0002e55d-0000-0000-c000-000000000046" style= "width:95%"; height:400 "></object></center>

<script language= "VBScript" >
Sub Window_onload ()
'------------------pie chart-------------------------------------------------------------
' Assigning values to data
Categories = Split ("<%=MX1%>", ",") ' Data item array group
Values = Split ("<%=MX2%>", ",") ' Data Item value array

Set CHT = ChartSpace1.Charts.Add ' Add an Icon object
Set c = ChartSpace1.Constants ' Returns an object that allows script users to use named constants.
Cht. Type = C.chcharttypepie ' Set chart type as pie

'-------Set the chart title----------------------------------------
Chartspace1.haschartspacetitle = True ' Specifies that the chart workspace contains a title
ChartSpace1.ChartSpaceTitle.Caption = "pie chart" set chart workspace title content
' About font settings
ChartSpace1.ChartSpaceTitle.Font.Bold = True ' Sets whether the chart workspace header content is bold
ChartSpace1.ChartSpaceTitle.Font.Color = "Blue" sets the color of the chart workspace title
ChartSpace1.ChartSpaceTitle.Font.Italic = False ' Sets whether the chart workspace title is italic
ChartSpace1.ChartSpaceTitle.Font.Name = "XXFarEastFont-Arial" ' Sets the font for the content of the chart workspace title
ChartSpace1.ChartSpaceTitle.Font.Size = 18 ' Sets the size of the chart workspace title content (in points)
ChartSpace1.ChartSpaceTitle.Font.Underline = C.owcunderlinestylesingle ' Set underline property

'-------Set the legend--------------------------------------------
Cht. HasLegend = True ' Specifies that the chart workspace contains a legend
Cht. Legend.Font.Size = 9 ' Other settings for font items see Set Chart title section
Cht. Legend.position = C.chlegendpositionright ' Set the legend to its way

Cht. SetData c.chdimcategories, C.chdataliteral, categories
Cht. SeriesCollection (0). SetData c.chDimValues, C.chdataliteral, values

Set dl = Cht. SeriesCollection (0). Datalabelscollection.add ' Add a legend's data marker
Dl. HasValue = False
Dl. Haspercentage = True
Dl. Font.Size = 11
'------------------pie chart (end) Www.111cn.net------------------------------------------------

'------------------Clustered Column chart (start)--------------------------------------
Set cht = ChartSpace2.Charts.Add ' Add an Icon object
Set c = Chartspace2.constants ' Returns an object that allows script users to use named constants.
Cht. Type = c.chcharttypecolumnclustered ' Set chart type for line chart
'-------Set chart title----------------------------------------
Chartspace2.haschartspacetitle = True ' Specifies that the chart workspace contains a title
ChartSpace2.ChartSpaceTitle.Caption = Column chart ' Set the chart workspace title Content
' About font settings
ChartSpace2.ChartSpaceTitle.Font.Bold = True ' to set whether the chart workspace title is bold
ChartSpace2.ChartSpaceTitle.Font.Color = "Blue" sets the color of the chart workspace title
ChartSpace2.ChartSpaceTitle.Font.Italic = False ' Set whether the chart workspace title is italic
ChartSpace2.ChartSpaceTitle.Font.Name = "Arial" ' Set font for chart workspace title content
ChartSpace2.ChartSpaceTitle.Font.Size = 18 ' Sets the size of the chart workspace title content (in points)
ChartSpace2.ChartSpaceTitle.Font.Underline = C.owcunderlinestylesingle ' Set underline property

Cht. SetData c.chdimcategories, C.chdataliteral, categories ' Cross (category axis)
Cht. SeriesCollection (0). SetData c.chDimValues, C.chdataliteral, values
Set dl = Cht. SeriesCollection (0). Datalabelscollection.add ' Add a legend's data marker
Dl. HasValue = True
Dl. Haspercentage = False
Dl. Font.Size = 9
Dl. Font.Color = "Red"
Dl. Position = C.chlegendpositionright

' Set vertical numeric properties
Set Categoryaxis = cht. Axes (C.chaxispositionbottom)
CategoryAxis.Font.Size = 9
' Set category group properties
Set Categoryaxis = cht. Axes (C.chaxispositionleft)
CategoryAxis.Font.Size = 9
'------------------Clustered Column chart (end)--------------------------------------

'------------------Line chart----------------------------------------------------------
Sparr = Split ("<%=MX1%>", ",")
Datearr = Split ("<%=Datestr%>", ",")

Set CHT = ChartSpace3.Charts.Add ' Add an Icon object
Set c = Chartspace3.constants ' Returns an object that allows script users to use named constants.
Cht. Type = C.chcharttypelinemarkers ' Set chart type to line graph

'-------Set the chart title----------------------------------------
Chartspace3.haschartspacetitle = True ' Specifies that the chart workspace contains a title
ChartSpace3.ChartSpaceTitle.Caption = "Day sales line Chart" set chart workspace title content
' About font settings
ChartSpace3.ChartSpaceTitle.Font.Bold = True ' Sets whether the chart workspace header content is bold
ChartSpace3.ChartSpaceTitle.Font.Color = "Blue" sets the color of the chart workspace title
ChartSpace3.ChartSpaceTitle.Font.Italic = False ' Sets whether the chart workspace title is italic
ChartSpace3.ChartSpaceTitle.Font.Name = "XXFarEastFont-Arial" ' Sets the font for the content of the chart workspace title
ChartSpace3.ChartSpaceTitle.Font.Size = 18 ' Sets the size of the chart workspace title content (in points)
ChartSpace3.ChartSpaceTitle.Font.Underline = C.owcunderlinestylesingle ' Set underline property

'-------Set the legend--------------------------------------------
Cht. HasLegend = True ' Specifies that the chart workspace contains a legend
Cht. Legend.Font.Size = 9 ' Other settings for font items see Set Chart title section
Cht. Legend.position = C.chlegendpositionbottom ' Set the legend to its way

Cht. SetData c.chdimseriesnames, C.chdataliteral, Sparr ' series
Cht. SetData c.chdimcategories, c.chdataliteral, Datearr ' Cross (category axis)

' Set vertical numeric properties
Set Categoryaxis = cht. Axes (C.chaxispositionbottom)
CategoryAxis.Font.Size = 9

' Set category group properties
Set Categoryaxis = cht. Axes (C.chaxispositionleft)
CategoryAxis.Font.Size = 9

Values = Split ("<%=SQARXLstr%>", ",")
for i = 0 To UBound (sparr)
Valuetemp = ""
for j = i* (UBound (D Atearr) +1 to (i+1) * (UBound (Datearr) +1)-1 ' Read data by day
Valuetemp = valuetemp & ', & Values (j)
Next
Valu Earr = Split (Mid (valuetemp,2), ",")
Cht. SeriesCollection (i). SetData c.chDimValues, c.chdataliteral, Valuearr
Set dl = Cht. SeriesCollection (i). Datalabelscollection.add ' Adds a legend's data marker to the
DL. HasValue = True
dl. Haspercentage = False
dl. Font.Size = 9
Next
------------------Line chart (end)---------------------------------------------------
ending Sub
</script>
</body>

The


OWC a variety of different versions of "ClassID" as follows:
Office version             OWC version         classid
Office 2000           owc9         clsid:0002e556-0000-0000-c000-000000000046
Office xp            owc10         clsid:0002e556-0000-0000-c000-000000000046
Office 2003           owc11        clsid:0002e55d-0000-0000-c000-000000000046

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.