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 Chart Object (IChart)

The Chart object represents a single chart in a Charts collection.

To create a Chart object, use Charts.Add, as in the following example.

Set Chart = charts.add(1,3,3,0,15,7)

Chart Properties Chart Methods
Chart Properties
AutoScale*

If AutoScale is set to True, Excel will automatically resize a chart's text when the chart is resized. If AutoScale is set to False, Excel will not automatically scale a chart's text.


[VBScript]
Property AutoScale As Boolean (read/write)
				
		
Example


[VBScript]

'--- Create an instance of ExcelWriter and add a new 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, 10)

'--- Enable AutoScale for the chart
MyChart.AutoScale = True


Top

BopPopGapSize*

Sets or returns the size of the gap between,

Note: Excel 95 does not support this feature.

By default, BopPopGapSize is set to 50% of the width of the second pie, or of the bar.


[VBScript]
Property BopPopGapSize As Integer (read/write)
				
	
Example


[VBScript]

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

'--- Set BopPopGapSize to 100% the width of the second pie
MyChart.BopPopGapSize = 100


Top

BopPopSecondPieSize*

Sets or returns the size of the second pie in a pie of pie chart. By default, BopPopSecondPieSize is set to 50% of the first pie.


[VBScript]
Property BopPopSecondPieSize As Integer (read/write)

		

Note: Excel 95 does not support this feature.

Example


[VBScript]

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

'--- Set BopPopSecondPieSize to 75% of the size of the first pie
MyChart.BopPopSecondPieSize = 75


Top

BopPopSplitType*

Sets or returns how data will be split in the bar of a bar of pie chart, or second pie of a pie of pie chart. Use BopPopSplitType in conjunction with BopPopSplitValue. Assign BopPopSplitType by name or number, according to the following table.

NameNumber  Definition
saxlsBopPopPosition  0    The bar or second pie will contain the chart's last n data points, where n is the value assigned to BopPopSplitValue.
saxlsBopPopValue  1    The bar or second pie will contain all data points with values less than n, where n is the value assigned to BopPopSplitValue.
saxlsBopPopPercent  2    The bar or second pie will contain data points with values less than n% of the total data series in the chart, where n is the value assigned to BopPopSplitValue.
saxlsBopPopCustom  3    The bar or second pie is customizable. To customize, drag data points between plot areas.

Note: Excel 95 does not support this feature.


[VBScript]
Property BopPopSplitType As ASXBopPopSplitType (read/write)
Example: The following will generate a pie of pie chart, with the second pie containing all data points that equal less than 40% of the total data series.


[VBScript]

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

'--- Set BopPopSplitType to saxlsBopPopPercent
MyChart.BopPopSplitType = saxlsBopPopPercent
MyChart.BopPopSplitValue = 40


Top

BopPopSplitValue*

Sets or returns a value that determines which of a chart's data points will be included in the bar of a bar of pie chart, or second pie of a pie of pie chart. BopPopSplitValue represents a data point value, data point position, or data point percentage, depending on the value of BopPopSplitType.

If BopPopSplitType = BopPopSplitValue represents
saxlsBopPopPosition          The number of last data points that will be included in the bar or second pie. For example, if BopPopSplitValue is set to 3, the bar or second pie will contain the last 3 data points in the pie's data series.
saxlsBopPopValueThe value of a data point. Only data points with values less than this value will be included in the bar or second pie. For example, if BopPopSplitValue is set to 15, the bar or second pie will contain all data points with values less than 15.
saxlsBopPopPercentA data point's percentage value. Only data points with a percentage less than this value will be included in the bar or second pie. For example, if BopPopSplitValue is set to 40, the bar or second pie will contain all data points with percentage values less than 40%.

Note: Excel 95 does not support this feature.


[VBScript]
Property BopPopSplitValue As Integer (read/write)
				
		
Example: The following will generate a pie of pie chart, with the second pie containing all data points that equal less than 40% of the total data series.


[VBScript]

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

'--- Set BopPopSplitType to saxlsBopPopPercent
MyChart.BopPopSplitType = saxlsBopPopPercent
MyChart.BopPopSplitValue = 40


Top

CategoryAxis

Returns an Axis object, representing the chart's X axis. The properties of CategoryAxis are, AxisCrossesMidCategory, AxisLine, LabelFont, LabelPosition, MajorGridline, MajorIncrement, MajorTickType, MinorGridline, MinorIncrement, MinorTickType, Number, Title, ValuesInReverseOrder, Wall3D, and Wall3DBorder.


[VBScript]
Property CategoryAxis As IAxis (read-only)
				
		
Example


[VBScript]

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

'--- The CategoryAxis property is an IAxis interface that you can
'--- use to adjust the properties of the chart's category axis
'--- Set the axis title
MyChart.CategoryAxis.Title = "Category Axis Title"


Top

ChartArea

Returns a ChartFrame object, representing the chart area in the worksheet. ChartArea is the area defined by
Charts.Add, that is, the entire area within the worksheet assigned to the chart. The properties of ChartArea are, Area, Border, HasShadow, Height, Text, TextFont, TextHorizontalAlignment, TextRotationAngle, TextVerticalAlignment, Width, X, and Y.


[VBScript]
Property ChartArea As IChartFrame (read-only)
				
		

The following example demonstrates applying a shadow effect to the ChartArea border and adjusting its height and width

Example


[VBScript]

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

'--- The ChartArea property is an IChartFrame interface that you can
'--- use to adjust the properties of the chart's frame
'--- Adjust the height and width of the chart's frame
'--- Apply shadowing to the border
MyChart.ChartArea.HasShadow = True
MyChart.ChartArea.Width = 10
MyChart.ChartArea.Height = 10


Top

DataTable*

Returns a ChartFrame object, representing a chart's data table. The properties of DataTable are, Area, Border, HasShadow, Height, Text, TextFont, TextHorizontalAlignment, TextRotationAngle, TextVerticalAlignment, Width, X, and Y.

Note: Excel 95 does not support this feature.

The following example demonstrates applying a horizontal stripe pattern to a chart's data table.


[VBScript]
Property DataTable As IChartFrame (read-only)
				
		
Example


[VBScript]

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

'--- First, enable the data table for the chart
MyChart.ShowDataTable = True

'--- The DataTable property is an IChartFrame interface that you can
'--- use to adjust the properties of the chart's data table
'--- Adjust the height and width of the data table
'--- Apply shadowing to the border
MyChart.DataTable.HasShadow = True
MyChart.DataTable.Width = 10
MyChart.DataTable.Height = 10


See also, ShowDataTable.

Top

DataTableHasHorizontalBorders*

When set to True, the chart's data table will display horizontal grid lines. DataTableHasHorizontalBorders is set to True by default.


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

		
Example


[VBScript]

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

'--- First, show the data tabke
MyChart.ShowDataTable = True

'--- Set DataTableHasHorizontalBorders to False to hide
'--- horizontal borders in the data table
MyChart.DataTableHasHorizontalBorders = False


See also, ShowDataTable. Note: Excel 95 does not support this feature.

Top

DataTableHasVerticalBorders*

When set to True, the chart's data table will display vertical grid lines. DataTableHasVerticalBorders is set to True by default. To hide vertical grid lines, use,


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

		
Example


[VBScript]

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

'--- First, show the data tabke
MyChart.ShowDataTable = True

'--- Set DataTableHasVerticalBorders to False to hide
'--- vertical borders in the data table
MyChart.DataTableHasVerticalBorders = False


See also, ShowDataTable. Note: Excel 95 does not support this feature.

Top

DataTableShowsSeriesKeys*

When set to True, the chart's data table will include legend keys next to the series titles. DataTableShowsSeriesKeys is set to True by default. To hide legend keys, use,


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

		
Example


[VBScript]

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

'--- First, show the data tabke
MyChart.ShowDataTable = True

'--- Set DataTableShowsSeriesKeys to False to hide
'--- legend keys next to the series titles
MyChart.DataTableShowsSeriesKeys = False


See also, ShowDataTable. Note: Excel 95 does not support this feature.

Top

FillSurfaceArea

Determines whether the surface area of a Surface chart (type 5), will be filled or appear transparent. FillSurfaceArea is set to 1 (enabled) by default. To display a transparent surface area, set FillSurfaceArea to 0.


[VBScript]
Property FillSurfaceArea As Long (read/write)
				
		
Example


[VBScript]

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

'--- For a surface chart, set FillSurfaceArea to 0 to get
'--- a transparent surface area
MyChart.FillSurfaceArea = 0


Top

Legend

Returns a ChartFrame object, representing the chart legend. The properties of Legend are, Area, Border, HasShadow, Height, Text, TextFont, TextHorizontalAlignment, TextRotationAngle, TextVerticalAlignment, and Width.

The following example demonstrates applying a horizontal stripe pattern to the legend box.


[VBScript]
Property Title As IChartFrame (read-only)
				
		
Example


[VBScript]

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

'--- The Legend property returns a IChartFrame interface that
'--- you can use to adjust the properties of the legend
'--- Set the height and width of the chart's legend
MyChart.Legend.Height = 10
MyChart.Legend.Width = 10


Top

LegendLocation

Determines the position of the legend in relation to the chart's plot area. LegendLocation has six possible values. Assign LegendLocation by name or number, according to the following table.

saxlsObjectBottom0
saxlsObjectCorner1
saxlsObjectTop2
saxlsObjectRight (default)3
saxlsObjectLeft4
saxlsObjectNotDocked7

Note: LegendLocation and the pair of Chartframe properties Height and Width are mutually exclusive. Use either LegendLocation or Height and Width.

The following will display the legend to the left of the chart's plot area.


[VBScript]
Property LegendLocation As ASXObjectLocation (read/write)
				
		
Example


[VBScript]

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

'--- Set the location of the chart's legend to the left
MyChart.LegendLocation = saxlsObjectLeft


Top

LegendVertical

Displays the legend vertically, when set to True. LegendVertical is set to True by default. To display the legend
horizontally, set LegendVertical to False, as follows.


[VBScript]
Property LegendVertical 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)

'--- LegendVertical is True by default.  
'--- Set it to False to display the legend horizontally
MyChart.LegendVertical = False


Top

PlotArea

Returns a ChartFrame object, representing the chart's plot area, that is, the area of the chart itself. The properties of PlotArea are, Area, Border, HasShadow, Height, Text, TextFont, TextHorizontalAlignment, TextRotationAngle, TextVerticalAlignment, Width, X, and Y.

The following example applies a diagonal stripe pattern to the plot area.


[VBScript]
Property PlotArea As IChartFrame (read-only)
				
		
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)

'--- The PlotArea property returns an IChartFrame interface that
'--- you can use to adjust the properties of the chart's plot area
'--- Set the height, width, and shadowing of the plot area
MyChart.PlotArea.Height = 10
MyChart.PlotArea.Width = 10
MyChart.PlotArea.HasShadow = True


Top

RectangularCorner

Determines whether the chart area will be sharp-cornered or round-cornered. By default, RectangularCorner is set to 0, and chart area corners are angular. For round corners, set RectangularCorner to 1, as follows.


[VBScript]
Property RectangularCorner As Long (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 RectangularCorner to 1 to get round corners on the chart
MyChart.RectangularCorner = 1



Top

SecondaryCategoryAxis V5
Syntax
[VBScript] Property SecondaryCategoryAxis As IAxis (read-only)
Description

SecondaryCategoryAxis returns an Axis object, representing a chart's secondary X axis.

The properties of SecondaryCategoryAxis are, AxisCrossesMidCategory, AxisLine, LabelFont, LabelPosition, MajorGridline, MajorIncrement, MajorTickType, MinorGridline, MinorIncrement, MinorTickType, Number, Title, ValuesInReverseOrder, Wall3D, and Wall3DBorder.

Example

[VBScript]

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

'--- SecondaryCategoryAxis returns an IAxis interface
'--- for the second category axis of a saxlsColumnLine2AxesChart
Set SecondAxis = MyChart.SecondaryCategoryAxis


Top

SecondaryValueAxis V5
Syntax
		
[VBScript]
Property SecondaryValueAxis As IAxis (read-only)

	
Description

SecondaryValueAxis returns an Axis object, representing the chart's secondary Y axis.

The properties of SecondaryValueAxis are, AxisLine, CategoryAxisCrossMaxValue, CategoryCrossingValue, LabelFont, LabelPosition, LogarithmicScale, MajorGridline, MajorIncrement, MajorTickType, MaxValue, MinorGridline, MinorIncrement, MinorTickType, MinValue, Number, Title, ValuesInReverseOrder, Wall3D, and Wall3DBorder.

By default, for a chart's secondary value axis, CategoryAxisCrossMaxValue is set to true, and the secondary value axis will cross the category axis at the maximum category value.

Example


[VBScript]

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

'--- SecondaryValueAxis returns an IAxis interface
'--- for the second value axis of a saxlsColumnLine2AxesChart
Set SecondValueAxis = MyChart.SecondaryValueAxis


Top

SeriesCollection

Returns a SeriesCollection object representing the set of data series in the chart. The methods and properties of SeriesCollection are, Add, CategoryData, and Item.


[VBScript]
Property SeriesCollection As ISeriesCollection (read-only)

Example


[VBScript]

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

'--- SeriesCollection returns an ISeriesCollection interface
'--- After creating a chart, use the SeriesCollection property
'--- to add one or more data series
'--- Chart's data will be based on values in A1:B10
Set MySeries = MyChart.SeriesCollection.Add("A1:B10",,1)
'--- Chart's Category Data (Y axis) will be based on D1:D2
MyChart.SeriesCollection.CategoryData = "D1:D2"


Top

ShowDataTable*

When set to True, will display a data table in place of the category axis' tick mark labels, in some chart types. A data table displays the data from which the chart was generated.

Note: Excel 95 does not support this feature.

Example

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

		
Example


[VBScript]

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

'--- First, enable the data table for the chart
MyChart.ShowDataTable = True

'--- The DataTable property is an IChartFrame interface that you can
'--- use to adjust the properties of the chart's data table
'--- Adjust the height and width of the data table
'--- Apply shadowing to the border
MyChart.DataTable.HasShadow = True
MyChart.DataTable.Width = 10
MyChart.DataTable.Height = 10


Top

ShowHorizontal

When set to True, will display columns horizontally, that is, will convert a column chart to a bar chart. ShowHorizontal is False by default. To set ShowHorizontal to True, use,


[VBScript]
Property ShowHorizontal 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 ShowHorizontal=True to display columns horizontally
MyChart.ShowHorizontal = True


Top

ShowLegend

When set to True, displays the chart legend. When set to False, hides the chart legend. ShowLegend is True by default. To set ShowLegend to False, use,


[VBScript]
Property ShowLegend 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 ShowLegend = False to hide the legend 
'--- (legend is visible by default)
MyChart.ShowLegend = True


Top

ShowValueAsPercent

When set to True, displays ValueAxis values as percents. ShowValueAsPercent is False by default.


[VBScript]
Property ShowValueAsPercent 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)

'--- Display value axis values as percents insted of the actual values
MyChart.ShowValuesAsPercent = True


Top

SizeOfCenterHole*

Sets or retrieves the size of the center hole of a doughnut chart. By default, SizeOfCenterHole is set to 20% of the doughnut size. The following example demonstrates setting the hole size to 50%.


[VBScript]
Property SizeOfCenterHole As Integer (read/write)

		
Example


[VBScript]

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

'--- For a Doughnut chart, set the percentage size of the center hole
MyChart.SizeOfCenterHole = 50


Top

SliceDistanceFromCenter

For exploded pie charts. Sets or returns the distance of slices from the chart's center. SliceDistanceFromCenter is set to 20 by default. The following will set SliceDistanceFromCenter to 100.


[VBScript]
Property SliceDistanceFromCenter As Integer (read/write)

		
Example


[VBScript]

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

'--- For an Exploded Pie chart, set the 
'--- distance of the slices from center
MyChart.SliceDistanceFromCenter = 100


Top

SpaceBetweenBars

Sets or retrieves the space between data series bars. SpaceBetweenBars is 0 by default. The following example demonstrates setting SpaceBetweenBars to 50.


[VBScript]
Property SpaceBetweenBars As Integer (read/write)

		
Example


[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new 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 the spece between bars of the chart's data series
MyChart.SpaceBetweenBars = 50


Top

SpaceBetweenCategories

Sets or retrieves the space between categories in column and bar charts.


[VBScript]
Property SpaceBetweenCategories As Integer (read/write)

		
Example


[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new 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 the spece between categoties to 50
MyChart.SpaceBetweenCategories = 50


Top

StackDisplayedValues

Stacks series values, when set to True.


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

		
Example


[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new 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 this property to True to stack series values
MyChart.StackDisplayValues = True


Top

Subtype

Returns the chart's subtype code. For a list of chart subtypes and their codes, see Chart Codes.

The following example demonstrates retrieving a chart's subtype code.


[VBScript]
Property SubType As Integer (read-only)

		
Example


[VBScript]

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

'--- Get the numeric value representing the chart's sub-type
'--- Refer to the chart codes to determine the type
ChartSubType = MyChart.SubType


Top

Title

Returns a ChartFrame object, representing the chart's title. The properties of Title are, Area, Border, HasShadow, Height, Text, TextFont, TextHorizontalAlignment, TextRotationAngle, TextVerticalAlignment, Width, X, and Y.

The following example demonstrates applying a horizontal stripe pattern to the title frame.


[VBScript]
Property Title As IChartFrame (read-only)

		
Example


[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new 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)

'--- Title returns an IChartFrame interface that
'--- can be used to format the chart's title area
'--- Set the chart title and apply a horizontal stripe pattern
MyChart.Title.Text = "My Chart Title"
MyChart.Title.Area.Pattern = 5


Top

Type

Returns the chart's type code. For a list of chart types and their codes, see Chart Codes.

The following example demonstrates retrieving a chart's type code.


[VBScript]
Property Type As ASXChartType (read-only)

		
Example


[VBScript]

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

'--- Get a numeric value representing the chart type
ChartType = MyChart.Type
Response.Write "The chart type is: " & ChartType


Top

ValueAxis

Returns an Axis object, representing the chart's Y axis. The properties of ValueAxis are, AxisLine, CategoryAxisCrossMaxValue, CategoryCrossingValue, LabelFont, LabelPosition, LogarithmicScale, MajorGridline, MajorIncrement, MajorTickType, MaxValue, MinorGridline, MinorIncrement, MinorTickType, MinValue, Number, Title, ValuesInReverseOrder, Wall3D, and Wall3DBorder.

The following example demonstrates setting a title for the value axis.


[VBScript]
Property ValueAxis As IAxis (read-only)

		
Example


[VBScript]

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

'--- ValueAxis returns an IAxis interface that represents the value axis
Set ValAxis = MyChart.ValueAxis


Top

View3D

Returns a 3DProperties object representing the properties of a three-dimensional chart. The properties of View3D are, ChartDepth, DistanceFromEyeToChart, ElevationAngle, PlotVolumeHeight, RotationAngle, SeriesGapDepth, Show3D, Stack3DColumns, UseAutoScaling, UsePerspectiveTransform, and ZAxis.

To set a View3D object, use,


[VBScript]
Property View3D As I3DProperties (read-only)

		
Example


[VBScript]

'--- Create an instance of ExcelWriter and 
'--- create a new 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)

'--- Get an I3DProperties interface for the chart
'--- to control the 3D characteristics of the chart
'--- Enable 3D by setting Show3D=True
MyChart.View3D.Show3D = True


Top

*This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree.


Chart Methods
Move

Moves the chart to a specified location. Move takes four parameters that determine the new position of the chart in the worksheet:

chart.move UpperLeftColumn, UpperLeftRow, LowerRightColumn, LowerRightRow

To re-position your chart at upper-left corner J9 and lower-right corner V16, use,


[VBScript]
Sub Move(UpperLeftColumn As Long, _
UpperLeftRow As Long, _
LowerRightColumn As Long, _
LowerRightRow As Long)

		
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)

'--- You can use the Move method to move or resize a chart
'--- to a new location in the worksheet
'--- Move the chart's upper left corner from 
'--- cell B2 to cell D10 (col 4, row 10)
MyChart.Move 4, 10, 30, 30


Top

SetChartType

Sets the chart's type and subtype. SetChartType takes two parameters:


[VBScript]
Sub SetChartType(Type As ASXChartType, Subtype As Integer)

		

Consult Chart Codes to select ChartType (pie, column, etc.) and SubType.

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)

'--- Convert clustered column chart to a 3D Pie chart
MyChart.SetChartType saxlsPieChart, 1


Top

*This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree.


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.