Function Reference

_XLChart_TicksSet

Set tick marks and tick labels of a chart.

#Include <ExcelChart.au3>
_XLChart_TicksSet($oObject[, $iMajorTickmark = Default[, $iMinorTickmark = Default[, $vMajorUnit = Default[, $vMinorUnit = Default[, $iLabelPosition = Default[, $vLabelSpacing = Default[, $sLabelNumberFormat = Default]]]]]]])

 

Parameters

$oObject Object of the axis for which the tick properties should be set
$iMajorTickmark Optional: Sets the type of major tick marks. Can be one of the enumeration XlTickMark (default = Default)
$iMinorTickmark Optional: Sets the type of minor tick marks. Can be one of the enumeration XlTickMark (default = Default)
$vMajorUnit Optional: Sets the major units for the value axis. Can be numeric or "Auto" (default = Default)
$vMinorUnit Optional: Sets the minor units for the value axis. Can be numeric or "Auto" (default = Default)
$iLabelPosition Optional: Sets the position of tick-mark labels. Can be one of the enumeration XlTickLabelPosition (default = Default)
$vLabelSpacing Optional: Sets the spacing between tick labels. Can be a numeric value or "Auto" (default = Default)
$sLabelNumberFormat Optional: Sets the number format of the tick labels (default = Default)

 

Return Value

Success: Returns 1
Failure: Returns 0 and sets @error:
    1 - $oObject is no object
    2 - Parameter $vMajorUnit and $vMinorUnit are only valid for the value axis
    3 - Invalid value for $vMajorUnit. Must be numeric or "Auto"
    4 - Invalid value for $vMinorUnit. Must be numeric or "Auto"
    5 - Invalid value for $iLabelPosition. Must be numeric
    6 - Invalid value for $vLabelSpacing. Must be numeric or "Auto"
    7 - Error setting $vMajorUnit. Please check @extended for detailed error code
    8 - Error setting $vMinorUnit. Please check @extended for detailed error code
    9 - Error setting $iLabelPosition. Please check @extended for detailed error code
    10 - Error setting $iLabelSpacing. Please check @extended for detailed error code
    11 - $iMajorTickmark is not an integer
    12 - $iMinorTickmark is not an integer
    13 - $sLabelNumberFormat format error

 

Remarks

$sLabelNumberFormat: The format code is the same string as the Format Codes option in the Format Cells dialog box

 

Related

 

Example


#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#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)
_XLChart_GridSet($aExcel[1] .Axes($xlValue), True, True) ; Set major and minor grid lines of the y-axis
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_GridSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 1
; Change tick marks on x-axis of Chart 1:
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Tickmarks for x-axis")
_XLChart_TicksSet($aExcel[1] .Axes($xlCategory), $xlTickMarkCross)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TicksSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 2
; Change major- and minor-unit on Y-axis of Chart 1:
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Major and minor unit for y-axis")
_XLChart_TicksSet($aExcel[1] .Axes($xlValue), Default, Default, 10, 2.5)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TicksSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 3
; Change tick label position on y-axis of Chart 1:
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Tick label position for y-axis")
_XLChart_TicksSet($aExcel[1] .Axes($xlValue), Default, Default, Default, Default, $xlTickLabelPositionHigh)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TicksSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 3
; Change tick label spacing on x-axis of Chart 1:
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Tick label spacing for x-axis")
_XLChart_TicksSet($aExcel[1] .Axes($xlCategory), Default, Default, Default, Default, Default, 2)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TicksSet' on line " & @ScriptLineNumber)