<Object ID = chartspace1 classid = CLSID: 0002e500-0000-0000-c000-000000000046 style = "width: 100%; Height: 350"> </Object>
<Script language = "VBScript">
Sub window_onload ()
Dim categories (3), values (3)
'Get the named constant object and use it in future scripts
Set c = chartspace1.constants
'Set the title of the Chart Workspace
Chartspace1.haschartspacetitle = true
Chartspace1.chartspacetitle. Caption = "chart space title"
'Set the legend of the Chart Workspace.
Chartspace1.haschartspacelegend = true
'Legend location, where C. * is the position enumeration value. The value list is as follows:
'Chlegendpositiontop: Top
'Chlegendpositionleft: left
'Chlegendpositionright: right side
'Chlegendpositionbottom: Bottom
'Chlegendpositionautomatic: automatic
Chartspace1.chartspacelegend. Position = C. chlegendpositionright
Categories (0) = "white"
Categories (1) = "black"
Categories (2) = "Asian"
Categories (3) = "Latino"
'Add a chart to the chart workspace.
Chartspace1.charts. Add
'Add the new series to the specified chart in the Chart Workspace, as shown below
Set a = chartspace1.charts (0). seriescollection. Add
'Specify the type of the new series. C. * is the type enumeration value. The list is as follows:
'Chcharttypecombo
'Chcharttypecolumnclustered
'Chcharttypecolumnstacked
'Chcharttypecolumnstacked100
'Chcharttypebarclustered
'Chcharttypebarstacked
'Chcharttypebarstacked100
'Chcharttypeline
'Chcharttypelinemarkers
'Chcharttypelinestacked
'Chcharttypelinestackedmarkers
'Chcharttypelinestacked100
'Chcharttypelinestacked100markers
'Chcharttypesmoothline
'Chcharttypesmoothlinemarkers
'Chcharttypesmoothlinestacked
'Chcharttypesmoothlinestackedmarkers
'Chcharttypesmoothlinestacked100
'Chcharttypesmoothlinestacked100markers
'Chcharttypepie
'Chcharttypepieexploded
'Chcharttypepiestacked
'Chcharttypescattermarkers
'Chcharttypescattersmoothlinemarkers
'Chcharttypescattersmoothline
'Chcharttypescatterlinemarkers
'Chcharttypescatterline
'Chcharttypescatterlinefilled
'Chcharttypebubble
'Chcharttypebubbleline
'Chcharttypearea
'Chcharttypeareastacked
'Chcharttypeareastacked100
'Chcharttypedoughnut
'Chcharttypedoughnutexploded
'Chcharttyperadarline
'Chcharttyperadarlinemarkers
'Chcharttyperadarlinefilled
'Chcharttyperadarsmoothline
'Chcharttyperadarsmoothlinemarkers
'Chcharttypestockhlc
'Chcharttypestockohlc
'Chcharttypepolarmarkers
'Chcharttypepolarline
'Chcharttypepolarlinemarkers
'Chcharttypepolarsmoothline
'Chcharttypepolarsmoothlinemarkers
'There are 47 in total. If anyone is interested, try them one by one. I'm lazy.
The supported methods vary depending on different types. This article focuses on chcharttypecolumnclustered.
A. type = C. chcharttypecolumnclustered
Chartspace1.charts (0). seriescollection. Add
Chartspace1.charts (0). seriescollection. Add
Value (0) = 0.2
Value (1) = 0.06
Values (2) = 0.17
Value (3) = 0.13
'Set the series name, which will be displayed in the legend, the same below
Chartspace1.charts (0). seriescollection (0). Caption = "Perot"
'Set the category name, the same below
Chartspace1.charts (0). seriescollection (0). setdata C. chdimcategories, C. chdataliteral, categories
'Set the series value, the same below
Chartspace1.charts (0). seriescollection (0). setdata C. chdimvalues, C. chdataliteral, values
Value (0) = 0.38
Value (1) = 0.82
Values (2) = 0.28
Value (3) = 0.62
Chartspace1.charts (0). seriescollection (1). Caption = "Clinton"
Chartspace1.charts (0). seriescollection (1). setdata C. chdimcategories, C. chdataliteral, categories
Chartspace1.charts (0). seriescollection (1). setdata C. chdimvalues, C. chdataliteral, values
Value (0) = 0.42
Value (1) = 0.12
Values (2) = 0.55
Value (3) = 0.25
Chartspace1.charts (0). seriescollection (2). Caption = "Bush"
Chartspace1.charts (0). seriescollection (2). setdata C. chdimcategories, C. chdataliteral, categories
Chartspace1.charts (0). seriescollection (2). setdata C. chdimvalues, C. chdataliteral, values
'Set the starting point and format of the specified axis, string type
'Where C. * is an enumeration value of the axis type. The value list is as follows:
'Chaxispositionleft
'Axispositioncircular
'Chaxispositionradial
'Chaxispositionright
'Chaxispositionleft
'Axispositionbottom
'Axispositiontop
Chartspace1.charts (0). axes (C. chaxispositionleft). numberformat = "0%"
'set the primary unit of the specified axis, double type
chartspace1.charts (0 ). axes (C. chaxispositionleft ). majorunit = 0.1
end sub