AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.2.0 version of this document. Switch to the 8.3.0 version to see the up to date information.

class anychart.elements.Axis Improve this Doc

Extends: anychart.VisualBase

Axis Class.
Any axis must be bound to a scale.
To obtain a new instance of Axis use anychart.elements.axis.

Try it:

Methods Overview

Miscellaneous
draw()Axis drawing.
drawFirstLabel()Getter for the first label drawing flag.
drawLastLabel()Getter for the last label drawing flag.
getRemainingBounds()Returns remaining parent bounds to use elsewhere.
isHorizontal()Whether an axis is horizontal.
labels()Getter for axis labels.
length()Getter for axis length.
minorLabels()Getter for axis minor labels.
minorTicks()Getter for minor axis ticks.
name()Getter for axis name.
offsetX()Getter for axis X offset.
offsetY()Getter for axis Y offset.
orientation()Getter for axis orientation.
overlapMode()Getter for overlap mode for labels.
parentBounds()Getter for parentBounds.
scale()Getter for axis scale.
staggerLines()Getter for stagger lines.
staggerMaxLines()Getter for maximum stagger lines.
staggerMode()Getter for stagger mode state.
stroke()Getter for axis line stroke.
ticks()Getter for axis ticks.
title()Getter for the axis title.

Methods Description

draw

Axis drawing.

Returns:

anychart.elements.Axis - An instance of anychart.elements.Axis class for method chaining.

drawFirstLabel

Getter for the first label drawing flag.

Returns:

boolean - Drawing flag.
Setter for the first label drawing flag.

Params:

Name Type Default Description
value boolean
true
Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

drawLastLabel

Getter for the last label drawing flag.

Returns:

boolean - Drawing flag.
Setter for the last label drawing flag.

Params:

Name Type Default Description
value boolean
true
Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

getRemainingBounds

Returns remaining parent bounds to use elsewhere.

Returns:

anychart.math.Rect - Parent bounds without the space used by the title.

Try it:

isHorizontal

Whether an axis is horizontal.

Returns:

boolean - If the axis is horizontal.

labels

Getter for axis labels.

Returns:

anychart.elements.LabelsFactory - Axis labels of itself for method chaining.
Setter for axis labels.

Params:

Name Type Description
value anychart.elements.LabelsFactory Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

length

Getter for axis length.

Returns:

number - Axis length.
Setter for axis length.
Note: width and height swap in case of horizontal axis.
Note: Works only if you create an independent axis object.

Params:

Name Type Description
value number Axis length.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

minorLabels

Getter for axis minor labels.

Returns:

anychart.elements.LabelsFactory - Axis labels.
Setter for axis minor labels.

Params:

Name Type Description
value anychart.elements.LabelsFactory Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

minorTicks

Getter for minor axis ticks.

Returns:

anychart.elements.Ticks - Axis ticks.
Setter for minor axis ticks.

Params:

Name Type Description
value anychart.elements.Ticks Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

name

Getter for axis name.

Returns:

string - Axis name.
Setter for axis name.

Params:

Name Type Description
value string Name.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

offsetX

Getter for axis X offset.

Returns:

number - Offset by X.
Setter for axis X offset.
Note: Works only if you create an independent axis object.

Params:

Name Type Description
value number Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

offsetY

Getter for axis Y offset.

Returns:

number - Offset by Y.
Setter for axis Y offset.
Note: Works only if you create an independent axis object.

Params:

Name Type Description
value number Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

orientation

Getter for axis orientation.

Returns:

string anychart.enums.Orientation - Axis orientation.
Setter for axis orientation.

Params:

Name Type Default Description
value string | anychart.enums.Orientation
'top'
Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

overlapMode

Getter for overlap mode for labels.

Returns:

anychart.enums.LabelsOverlapMode string - OverlapMode flag.
Setter for overlap mode for labels.

Params:

Name Type Default Description
value anychart.enums.LabelsOverlapMode | string
anychart.enums.LabelsOverlapMode.NO_OVERLAP
Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

parentBounds

Getter for parentBounds.

Returns:

anychart.graphics.math.Rect - Current parent bounds.
Setter for parentBounds.
Note: Works only if you create an independent axis object.

Params:

Name Type Description
value anychart.graphics.math.Rect Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis class for method chaining.

Try it:

scale

Getter for axis scale.

Returns:

anychart.scales.Base - Axis scale.
Setter for axis scale.

Params:

Name Type Description
value anychart.scales.Base Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

staggerLines

Getter for stagger lines.

Returns:

number - Current stagger line settings.
Setter for stagger lines.
Note: pass null to enable autocalculation.

Params:

Name Type Default Description
value number | null
null
Count of stager lines.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

staggerMaxLines

Getter for maximum stagger lines.

Returns:

number - Current stagger line settings.
Setter for maximum stagger lines in autocalculation mode (if anychart.elements.Axis#staggerLines passed null).

Params:

Name Type Default Description
value number | null
2
Limits the number of lines to be used when drawing labels. If we need less – we use less, but never – more.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

staggerMode

Getter for stagger mode state.

Returns:

boolean - Current stagger mode state.
Setter for stagger mode state.

Params:

Name Type Default Description
value boolean
true
On/off stagger mode.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

stroke

Getter for axis line stroke.

Returns:

string anychart.graphics.vector.Stroke - Axis line stroke settings.
Setter for axis line stroke by one value.
Learn more about stroke settings: https://docs.anychart.com/__VERSION__/General_settings/Elements_Stroke

Params:

Name Type Description
value string | anychart.graphics.vector.Stroke Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

ticks

Getter for axis ticks.

Returns:

anychart.elements.Ticks - Axis ticks.
Setter for axis ticks.

Params:

Name Type Description
value anychart.elements.Ticks Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it:

title

Getter for the axis title.

Returns:

string anychart.elements.Title - Axis title.
Setter for the axis title.

Params:

Name Type Description
value string | anychart.elements.Title Value to set.

Returns:

anychart.elements.Axis - anychart.elements.Axis instance for method chaining.

Try it: