Use the OWC control to implement the details of the chart function in ASP

xiaoxiao2021-03-05  22

Easily implement various chart features, such as pie chart, cluster column, and fold line diagrams, etc. in ASP. In the following code, I give a detailed method of using the pie chart, a cluster column pattern, and a line diagram. More features of OWC, attributes can participate in the msowcvba.chm help file (find yourself below the Office 2000 folder). Testowc.asp

<

DOCTYPE HTML

Public

"

- // W3C // DTD HTML 4.01 Transitional // EN

"

>

<

HTML

>

<

HEAD

>

<

Meta http

-

Equiv

=

"

Content-Type

"

Content

=

"

TEXT / HTML; Charset = GB2312

"

>

<

Title

>

Use the OWC control to implement the details of the chart function in ASP

Title

>

HEAD

>

<

Body

>

<

%

'

The following is a product sales chart.

MX1

=

"

A products, B products, C products, D products

"

'

Data project name arrays (given test data, read from database "," separation)

MX2

=

"

50, 60, 20, 80

"

'

Data project value array

Datest

=

"

2005-3-24,2005-3-25,2005-3-26,2005-3-27,2005-3-28

"

'

date

SQARXLSTR

=

"

50, 100, 20, 80, 89

"

'

Sales of A products 2005-3-24 to 2005-3-28

SQARXLSTR

=

SQARXLSTR

&

"

,

"

&

"

40, 60, 20, 90, 70

"

'

B products 2005-3-24 to 2005-3-28 sales

SQARXLSTR

=

SQARXLSTR

&

"

,

"

&

"

20, 50, 55, 25, 60

"

'

C Products 2005-3-24 to 2005-3-28 Sales

SQARXLSTR

=

SQARXLSTR

&

"

,

"

&

"

80, 20, 75, 58, 100

"

'

Sales of D products 2005-3-24 to 2005-3-28

%

>

<

Br

>

<

Center

> <

Object

id

=

"

Chartspace1

"

ClassID

=

"

CLSID: 0002E500-0000-0000-C000-000000000046

"

Style

=

"

Width: 95%; HEIGHT: 400

"

>

Object

>

Center

>

<

Br

>

<

Center

> <

Object

id

=

"

Chartspace2

"

ClassID

=

"

CLSID: 0002E500-0000-0000-C000-000000000046 "

Style

=

"

Width: 95%; HEIGHT: 400

"

>

Object

>

Center

>

<

Br

>

<

Center

> <

Object

id

=

"

Chartspace3

"

ClassID

=

"

CLSID: 0002E500-0000-0000-C000-000000000046

"

Style

=

"

Width: 95%; HEIGHT: 400

"

>

Object

>

Center

>

<

Script logage

=

"

VBScript

"

>

Sub

WINDOW_ONLOAD ()

'

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------

'

Assigning data for data

Categories

=

split

(

"

<% = Mx1%>

"

,

"

,

"

)

'

Data project name array

Values

=

split

(

"

<% = Mx2%>

"

,

"

,

"

)

'

Data project value array

Set

CHT

=

Chartspace1.Charts.add

'

Add an icon object

Set

c

=

Chartspace1.constants

'

Returns an object that allows the script user to use the named constant.

cht.type

=

C.chcharttypepie

'

Set chart type for pie chart

'

------- Set the chart title ----------------------------------------

Chartspace1.haschartspaceTitle

=

True

'

Specify the title in the chart workspace

Chartspace1.ChartSpaceTitle.caption

=

"

pie chart

"

'

Set the chart workspace title

'

Standard setting

Chartspace1.ChartSpaceTitle.Font.Bold

=

True

'

Set the chart workspace title content is bold

Chartspace1.ChartSpaceTitle.font.color

=

"

Blue

"

'

Set the color of the chart workspace title

Chartspace1.ChartSpaceTitle.Font.Ilic

=

False

'

Set whether the chart workspace title is italic

Chartspace1.ChartspaceTitle.font.name

=

"

Lishu

"

'

Set the font of the chart workspace title

Chartspace1.ChartspaceTitle.font.size

=

18

'

Set the size of the chart workspace title content (unit: lbs)

Chartspace1.ChartSpaceTitle.Font.underline

=

C.owcunderlinestylesingle

'

Set the underscore properties

'

------- Set the legend ----------------------------------------- --- cht.haslegegend

=

True

'

Specifying the legend in the chart workspace

Cht.Legend.Font.Size

=

9

'

Other related paragraphs sets to set the 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.chdataral, Values

Set

DL

=

CHT.Seriescollection

0

) .DATALABELSCOLLECTION.ADD

'

Add legend data tag

Dl.haasvalue

=

False

Dl.haspercentage

=

True

Dl.font.size

=

11

'

------------------ Cake chart (end) --------------------------- ---------------------

'

------------------ Cluster column (start) ------------------------ ----------------

Set

CHT

=

Chartspace2.Charts.add

'

Add an icon object

Set

c

=

Chartspace2.constants

'

Returns an object that allows the script user to use the named constant.

cht.type

=

C.chchartTypeColumnClustered

'

Set the chart type as a line diagram

'

------- Set the chart title ----------------------------------------

Chartspace2.haschartspaceTitle

=

True

'

Specify the title in the chart workspace

Chartspace2.ChartSpaceTitle.caption

=

"

Histogram

"

'

Set the chart workspace title

'

Standard setting

Chartspace2.ChartSpaceTitle.Font.Bold

=

True

'

Set the chart workspace title content is bold

Chartspace2.ChartSpaceTitle.Font.color

=

"

Blue

"

'

Set the color of the chart workspace title

Chartspace2.ChartSpaceTitle.Font.Ilic

=

False

'

Set whether the chart workspace title is italic

Chartspace2.ChartspaceTitle.Font.name

=

"

Lishu

"

'

Set the font of the chart workspace title

Chartspace2.ChartSpaceTitle.Font.Size

=

18

'

Set the size of the chart workspace title content (unit: lbs)

Chartspace2.ChartSpaceTitle.Font.underline

=

C.owcunderlinestylesingle

'

Set the underscore properties

CHT.SetData C.chdimcategories, C.chdataliteral, Categories

'

Horizons (Classification axes) CHT.Seriescollection

0

) .SetData C.chdimvalues, C.chdataral, Values

Set

DL

=

CHT.Seriescollection

0

) .DATALABELSCOLLECTION.ADD

'

Add legend data tag

Dl.haasvalue

=

True

Dl.haspercentage

=

False

Dl.font.size

=

9

Dl.font.color

=

"

RED "

DL.Position

=

C.chlegendPositionRight

'

Set longitudinal numerical properties

Set

Categoryaxis

=

CHT.axes (c.chaxispositionbottom) categoryaxis.font.size

=

9

'

Set classification group properties

Set

Categoryaxis

=

CHT.axes (c.chaxispositionLes) categoryaxis.font.size

=

9

'

------------------ Cluster column (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 the script user to use the named constant.

cht.type

=

C.chcharttypelinemarkers

'

Set the chart type as a line diagram

'

------- Set the chart title ----------------------------------------

Chartspace3.haschartspaceTitle

=

True

'

Specify the title in the chart workspace

Chartspace3.ChartSpaceTitle.caption

=

"

Day sales line diagram

"

'

Set the chart workspace title

'

Standard setting

Chartspace3.ChartspaceTitle.Font.Bold

=

True

'

Set the chart workspace title content is bold

Chartspace3.ChartSpaceTitle.Font.color

=

"

Blue

"

'

Set the color of the chart workspace title

Chartspace3.ChartSpaceTitle.font.italic

=

False

'

Set whether the chart workspace title is italic

Chartspace3.ChartspaceTitle.Font.name

=

"

Lishu

"

'

Set the font of the chart workspace title

Chartspace3.ChartSpaceTitle.Font.Size

=

18

'

Set the size of the chart workspace title content (unit: pound) chartspace3.ChartSpaceTitle.Font.underline

=

C.owcunderlinestylesingle

'

Set the underscore properties

'

------- Set the legend ----------------------------------------- ---

cht.haslegegend

=

True

'

Specifying the legend in the chart workspace

Cht.Legend.Font.Size

=

9

'

Other related paragraphs sets to set the 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

'

Horizontal item (classification axis)

'

Set longitudinal numerical properties

Set

Categoryaxis

=

CHT.axes (c.chaxispositionbottom) categoryaxis.font.size

=

9

'

Set classification group properties

Set

Categoryaxis

=

CHT.axes (c.chaxispositionLes) categoryaxis.font.size

=

9

Values

=

split

(

"

<% = SQARXLSTR%>

"

,

"

,

"

)

for

i

=

0

TO

Ubound

(Sparr) ValyETemp

=

"

"

for

j

=

i

*

(

Ubound

(DATEARR)

1

)

TO

(i

1

)

*

(

Ubound

(DATEARR)

1

)

-

1

'

Read data on days

Valuetemp

=

Valuetemp

&

"

,

"

&

Values ​​(j)

NEXT

Valuearr

=

split

(

MID

(ValyETemp,

2

),

"

,

"

) CHT.Seriescollection (i) .SetData C.chdimvalues, C.chdataliteral, Valuearr

Set

DL

=

Cht.seriescollection (i) .datalabelscollection.add

'

Add legend data tag

Dl.haasvalue

=

True

Dl.haspercentage

=

False

Dl.font.size

=

9

NEXT

'

------------------ Corporation map (end) --------------------------- ---------------------------------------------------------------------------------------------------------------------------------------

End Sub

Script

>

Body

>

HTML

>

Transfer from:

http://www.5iuu.com/blogview.asp?logid=1949

转载请注明原文地址:https://www.9cbs.com/read-38029.html

New Post(0)