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 Axis Object (IAxis)

ExcelWriter includes three Axis objects: CategoryAxis, ValueAxis, and, ZAxis.

To create a CategoryAxis object, use,

set CategoryAxis = chart.categoryaxis

To create a ValueAxis object, use,

set ValueAxis = chart.valueaxis

To create a ZAxis object, use,

set ZAxis = chart.view3d.zaxis

Axis Methods and Properties

Axis Methods and Properties
AxisCrossesMidCategory

Valid only for the category axis. Determines whether category major gridlines will be between categories, or in the middle of categories. By default, AxisCrossesMidCategory is set to True and category major gridlines are between categories.

The following will display category major gridlines in the middle of a category.

Signature:

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

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set AxisCrossesMidCategory to False for the category axis
MyChart.CategoryAxis.AxisCrossesMidCategory = False


Top

AxisLine

Returns a Line object, representing the appearance of an Axis. The properties of AxisLine are LineColor, LineFormatting, LineStyle, and LineWeight.

The following demonstrates setting the color of a category axis to blue.


[VBScript]
Property AxisLine As SALine (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- The AxisLine property returns SALine
'--- Use it to format the line for the axis
'--- Set the color to red
MyChart.CategoryAxis.AxisLine.LineColor = RGB(255,0,0)


Top

CategoryAxisCrossMaxValue

Property of the ValueAxis or the SecondaryValueAxis. When set to true, the category axis will cross the value axis at its maximum value.

When CategoryAxisCrossMaxValue is a property of the value axis, it is set to false by default. When CategoryAxisCrossMaxValue is a property of the secondary value axis, it is set to true by default.

The following sets CategoryAxisCrossMaxValue to True.


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

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set CategoryAxisCrossMaxValue = True
MyChart.ValueAxis.CategoryAxisCrossMaxValue = True


Top

CategoryCrossingValue

Property of the ValueAxis. Sets or retreives the Y value at which the category axis crosses the value axis. CategoryCrossingValue is 0 by default.

The following sets the Y value at which the category axis crosses the value axis to 5.


[VBScript]
Property CategoryCrossingValue As Double (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Sets the Y value at which the category 
'--- axis crosses the value axis to 5
MyChart.ValueAxis.CategoryCrossingValue = 5


Top

LabelFont

Sets or returns a Font object, representing the label font for the specified axis.


[VBScript]
Property LabelFont As SAFont (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series, MyFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Create a new font
Set MyFont = XlwApp.CreateFont
MyFont.Name = "Tahoma"

'--- Set the font for the label
MyChart.ValueAxis.LabelFont = MyFont


Top

LabelPosition

Sets or returns the position of axis labels. The values of LabelPosition are,

Invisible Label0
Low End Of PlotArea1
High End Of PlotArea2
Next To Axis3

The following will set LabelPosition to Invisible Label.


[VBScript]
Property LabelPosition As ASXLabelPosition (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series, MyFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the label position to "next to axis"
MyChart.ValueAxis.LabelPosition = saxlsNextToAxis 


Top

LogarithmicScale

Property of the ValueAxis. When set to True, LogarithmicScale will,

The following will produce a logarithmic chart.


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

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series, MyFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Make the axis into a logarithmic scale
MyChart.ValueAxis.LogarithmicScale = True


Top

MajorGridline

Returns a Line object, representing the major gridlines of an axis. The properties of MajorGridline are LineColor, LineFormatting, LineStyle, and LineWeight.

The following sets the weight of the major gridlines on the Y axis to WideLine (see LineWeight).


[VBScript]
Property MajorGridLine As SALine (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series, MyFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Format the major grid line of the value axis
MyChart.ValueAxis.MajorGridLine.LineColor = RGB(255,0,0)


Top

MajorIncrement

Sets or returns the major unit of measurement of an axis, that is, the gap between its major gridlines and/or major ticks marks.


[VBScript]
Property MajorIncrement As Double (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the value axis's major increment to 4
MyChart.ValueAxis.MajorIncrement = 4


Top

MajorTickType

Determines the display of axis tick marks on the major gridlines. Tick marks are marks of measurement on an axis. The values of MajorTickType are,

Invisible Tick0
Inside Line Tick1
Outside Line Tick2
Cross Axis Line Tick 3

The following will display major gridline tick marks inside the value axis.


[VBScript]
Property MajorTickType As ASXTickType (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
		0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the major tick type of the value axis
MyChart.ValueAxis.MajorTickType = saxlsOutsideLineTick 


Top

MaxValue

Sets or returns the maximum value on the value axis. Note: MaxValue is a property of ValueAxis, and not of CategoryAxis or ZAxis.


[VBScript]
Property MaxValue As Double (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			 0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the max value of the value axis
MyChart.ValueAxis.MaxValue = 12


Top

MinorGridline

Returns a Line object, representing the minor gridlines of an axis. The properties of MinorGridline are LineColor, LineFormatting, LineStyle, and LineWeight.

The following sets the style of the minor gridlines on the Y axis to Dash-Dot-Dot (see LineStyle).


[VBScript]
Property MinorGridLine As SALine (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series, MyFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
		0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Format the minor grid line of the value axis
MyChart.ValueAxis.MinorGridLine.LineColor = RGB(255,0,0)


Top

MinorIncrement

Sets or returns the minor unit of measurement of an axis, that is, the gap between its minor gridlines and/or minor ticks marks.

The following sets the minor unit of the Y axis to 1.


[VBScript]
Property MinorIncrement As Double (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the value axis's minor increment to 4
MyChart.ValueAxis.MinorIncrement = 4


Top

MinorTickType

Determines the display of axis tick marks on the minor gridlines. Tick marks are marks of measurement on an axis. The values of MinorTickType are,

Invisible Tick0
Inside Line Tick1
Outside Line Tick2
Cross Axis Line Tick 3

The following will display minor gridline tick marks outside the value axis.


[VBScript]
Property MinorTickType As ASXTickType (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the minor tick type of the value axis
MyChart.ValueAxis.MinorTickType = saxlsOutsideLineTick 


Top

MinValue

Sets or returns the minimum value on the value axis. Note: MinValue is a property of ValueAxis, and not of CategoryAxis or ZAxis.

The following sets the minimum value on the value axis to 2.


[VBScript]
Property MinValue As Double (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the minimum value of the value axis
MyChart.ValueAxis.Minalue = 5


Top

Number

Sets the display format of axis values. For a complete list of Number codes, see Formatting Codes.

The following will display a chart's Y values as percentages.


[VBScript]
Property Number As Variant (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Set the display format for the axis to 0.00%
MyChart.ValueAxis.Number = 10


Top

TextRotationAngle*

Sets or returns the rotation angle of axis values. Set TextRotationAngle to a value between -90 and 90. Negative values rotate text clockwise, and positive values rotate text counterclockwise.

Example:


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

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Rotate the text 45 degrees counterclockwise
MyChart.ValueAxis.TextRotationAngle = 45


Top

Title

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

The following will display the title "Value Axis" next to the value axis.


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

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Title returns IChartFrame 
MyChart.ValueAxis.Title.Height = 10


Top

ValuesInReverseOrder

When set to True, displays axis values in reverse order.

The following will display Y values in reverse order, that is, the highest Y value will be at the chart's origin.


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

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Display the values in reverse order
MyChart.ValueAxis.ValuesInReverseOrder = True


Top

Wall3D

Returns an Area object representing the walls or floor of a three-dimensional chart.

CategoryAxis.Wall3DReturns the walls of a 3-D chart
ValueAxis.Wall3DReturns the floor of a 3-D chart

The properties of Wall3D are AreaFormatting, BackgroundColor, ForegroundColor, and Pattern.

The following sets the color of the walls of a 3-D chart to red.


[VBScript]
Property Wall3D As SAArea (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Format the floor of a 3-D chart
MyChart.ValueAxis.Wall3D.BackgroundColor = RGB(0,255,0)


Top

Wall3DBorder

Returns a Line object representing the borders of a 3-D chart's walls or floor.

CategoryAxis.Wall3DBorderReturns the borders of a 3-D chart's walls
ValueAxis.Wall3DBorderReturns the borders of a 3-D chart's floor

The properties of Wall3DBorder are LineColor, LineFormatting, LineStyle, and LineWeight.

	
[VBScript]
Property Wall3DBorder As SALine (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, Series
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Add a series to the series collection
Set Series = MyChart.SeriesCollection.Add("D2:E5", , 0)
MyChart.SeriesCollection.CategoryData = "{Monday, Tuesday}"

'--- Format the borders of the floor of a 3-D chart
MyChart.ValueAxis.Wall3DBorder.LineColor = RGB(0,0,255)


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.