Show code in...     

  

 

Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


The SeriesCollection Object (ISeriesCollection)

The SeriesCollection object represents the set of all data series in a single chart.

To create a SeriesCollection object, use,

Set SeriesCollection = chart.seriescollection

SeriesCollection Methods and Properties

SeriesCollection Methods and Properties
Add

Adds a series to a chart. Add takes two parameters:


[VBScript]
Function Add(Area As String, _
[After = -1], _
[Vertical As Long]) As ISeries

		

The parameter Area specifies the values from which to plot the data series. Area may be a range of cells (such as, "a1:c3"), or a sequence of values (such as,"{5,7,9}"). The optional parameter Vertical specifies whether to plot the series from a range of cell values by row or by column. When Vertical is set to 0, ExcelWriter will plot the series by row. When Vertical is set to 1, ExcelWriter will plot the series by column. The default value of Vertical is 0.

Note: If you specify the optional parameter Vertical, include two commas between Area and Vertical, for a second parameter not used in the current version.

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Add a Series to the collection.  The data will be 
'--- from the range A1:C3.
MyChart.SeriesCollection.Add "A1:C3", , 0

'--- You can also add a Series by specifying the values in code
MyChart.SeriesCollection.Add "{1,2,3,4}", , 0


Top

CategoryData

Specifies the range of Category Axis (x axis) values. CategoryData may be assigned as a range of cells (such as, "a1:c3"), or as a sequence of values (such as,"{5,7,9}").

Signature:


[VBScript]
Property CategoryData As String (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Add a Series to the collection.  The data will be 
'--- from the range A1:C3.
MyChart.SeriesCollection.Add "A1:C3", , 0

'--- Now set the Category Data (X axis)
'--- You can also set CategoryData with explicit
'--- values in code: CategoryData = "{April,May,June}"
MyChart.SeriesCollection.CategoryData = "A1:A3"


Top

Item

Represents a single series in a SeriesCollection. Item is the default property of SeriesCollection, so SeriesCollection(1) is equivalent to Charts.Item(1).

Signature:

	
[VBScript]
In VBScript, this is the default property 
for the SeriesCollection object.

Property Item(Index) As ISeries

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart, SeriesOne, SeriesTwo
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Use the default Item property to get 
'--- individual ISeries objects
'--- from the SeriesCollection.  This collection is 1-based
Set SeriesOne = MyChart.SeriesCollection(1)
Set SeriesTwo = MyChart.SeriesCollection(2)


Top

LabelShowActualValue

When set to True, the chart will include series labels displaying actual Y values. LabelShowActualValue is False by default. To set LabelShowActualValue to True, use,


[VBScript]
Property LabelShowActualValue As Boolean (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Set LabelShowActualValue to True to show series Y values
MyChart.SeriesCollection.LabelShowActualValues = True


Top

LabelShowCategoryAndValueAsPercent

Property of a Pie chart. When set to True, the chart will include series labels displaying actual category (X) values, and Y values as percents. LabelShowCategoryAndValueAsPercent is False by default.


[VBScript]
Property LabelShowCategoryAndValueAsPercent As Boolean (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Set LabelShowCategoryAndValueAsPercent to True 
'--- to show values as percentages
MyChart.SeriesCollection.LabelShowCategoryAndValueAsPercent = True


Top

LabelShowCategoryLabel

When set to True, the chart will include series labels displaying actual category values. LabelShowCategoryLabel is False by default.


[VBScript]
Property LabelShowCategoryLabel As Boolean (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new clustered column chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0,2,2,10,20)

'--- Set LabelShowCategoryLabel to True 
'--- to include series value labels
MyChart.SeriesCollection.LabelShowCategoryLabel = True


Top

LabelShowValueAsPercent

Property of a Pie chart. When set to True, the chart will include labels displaying Y values as percents. LabelShowValueAsPercent is False by default.


[VBScript]
Property LabelShowValueAsPercent As Boolean (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new pie chart
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsPieChart, _
			0,2,2,10,20)

'--- For a Pie chart, set LabelShowValueAsPercent to True 
'--- to ishow values as percentages of the whole
MyChart.SeriesCollection.LabelShowValueAsPercent = True


Top



Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


Copyright © 2005, SoftArtisans, Inc.