Function Reference

_XLChart_AxisSet

Set the properties of the selected axis.

#Include <ExcelChart.au3>
_XLChart_AxisSet($oObject[, $vMinimumScale = Default[, $vMaximumScale = Default[, $iDisplayUnit = Default[, $iDisplayUnitCustom = Default[, $vDisplayUnitLabel = Default]]]]])

 

Parameters

$oObject Object of an axis to set the properties
$vMinimumScale Optional: Sets the minimum value on the Y (value) or X axis (has to be of type value not category). Can be a numeric value or "Auto" (default = Default)
$vMaximumScale Optional: Sets the maximum value on the Y (value) or X axis (has to be of type value not category). Can be a numeric value or "Auto" (default = Default)
$iDisplayUnit Optional: Sets the unit label for the value axis. Can be any of the XlDisplayUnit enumeration, xlCustom or xlNone (default = Default)
$iDisplayUnitCustom Optional: If the value of $iDisplayUnit is $xlCustom, $DisplayUnitCustom sets the value of the displayed units.
The value must be from 0 through 10E307 (default = Default)
$vDisplayUnitLabel Optional: True if the DisplayUnitLabel is displayed. Any non-boolean data will be used as the label caption (default = Default)

 

Return Value

Success: Returns 1
Failure: Returns 0 and sets @error:
    1 - $oObject is no object
    2 - Invalid value for $iMinimumScale. Must be numeric or "Auto"
    3 - Invalid value for $iMaximumScale. Must be numeric or "Auto"
    4 - Parameter $DisplayUnit, $DisplayUnitCustom and $DisplayUnitLabel are only valid for the value axis
    5 - Parameter $DisplayUnit must be $xlCustom if you want to set $DisplayUnitCustom

 

Remarks

When using parameters $vMinimumScale and $vMaximumScale for the X axis the axis has to be a value type axis not a category type axis.
This is true for XYscatter type charts. For all other chart types (e.g. line, column, area) the script will crash.

 

Related

 

Example


#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include-once
#include <ExcelChart.au3>

; *****************************************************************************
; Create example environment
; *****************************************************************************
Global $aExcel = _XLChart_Example(True, 0, -1, -1, -1)
If @error = 2  Then Exit MsgBox(16, "Excel Chart Example Script", "The installed Excel version is not supported by this UDF!" & @CRLF & "Version must be >= 12 (Excel 2007).")
If @error <> 0 Then Exit MsgBox(16, "Excel Chart Example Script", "Error " & @error & " returned by _XLChart_Example on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 1
; Change Y-Axis of Chart 1: Set minimum, maximum
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Y-Axis: Set minimum, maximum")
_XLChart_AxisSet($aExcel[1].Axes($xlValue), 7.5, 44)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_AxisSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 2
; Change Y-Axis of Chart 1: Set unit to Thousands
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Y-Axis: Set unit to Thousands")
_XLChart_AxisSet($aExcel[1].Axes($xlValue), Default, Default, $xlThousands)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_AxisSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 3
; Change Y-Axis of Chart 1: Set DisplayUnitLabel to a custom text
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Y-Axis: Set DisplayUnitLabel to a custom text")
_XLChart_AxisSet($aExcel[1].Axes($xlValue), Default, Default, Default, Default, "in Thousand Units")
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_AxisSet' on line " & @ScriptLineNumber)