AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.scales.Linear Improve this Doc

Extends: anychart.scales.ScatterBase

The Linear class contains methods for configuring Linear scale.
Represents simple linear scale that transforms values from domain [a, b] to domain [0, 1]. Note that a can be greater than b. The only condition for the scale is that a != b.
Note: To create instance use anychart.scales#linear method.

Methods Overview

Specific settings
alignMaximum()Align maximum settings.
alignMinimum()Align minimum settings.
compareWith()Changes zero for series.
comparisonMode()Scale changes mode.
extendDataRange()Extends the current input domain with the passed values (if such don't exist in the domain).
finishAutoCalc()Informs the scale that an auto-range calculation started for the chart in past was ended.
getType()Returns scale type.
inverseTransform()Returns tick by its position ratio.
inverted()Inversion state.
maxTicksCount()Maximum ticks count.
maximum()Scale maximum.
maximumGap()Maximum gap settings.
minimum()Scale minimum.
minimumGap()Minimum gap settings.
minorTicks()Minor ticks settings.
softMaximum()Soft maximum settings.
softMinimum()Soft minimum settings.
stackDirection()The stacking direction.
startAutoCalc()Informs scale that an auto-range calculation started for the chart, so it should reset its data range on the first
stickToZero()Stick to zero.
ticks()Ticks settings.
transform()Returns tick position ratio by its name.
Miscellaneous
stackMode()Getter for the stacked mode.

Methods Description

alignMaximum

Getter for a flag if the maximum should be aligned by major ticks interval.

Returns:

boolean - Whether to enable maximum alignment by interval.
See listing
var scale = chart.yScale();
var alignMaximum = scale.alignMaximum();
Getter for a flag if the maximum should be aligned by major ticks interval.

Params:

NameTypeDefaultDescription
enabledboolean
true
Whether to enable maximum alignment by interval.

Returns:

anychart.scales.Linear - Self instance for method chaining.

alignMinimum

Setter for a flag if the minimum should be aligned by major ticks interval.

Returns:

boolean - Whether to enable minimum alignment by interval.
See listing
var scale = chart.yScale();
var alignMinimum = scale.alignMinimum();
Setter for a flag if the minimum should be aligned by major ticks interval.

Params:

NameTypeDefaultDescription
enabledboolean
true
Whether to enable minimum alignment by interval.

Returns:

anychart.scales.Linear - Self instance for method chaining.

compareWith

Getter for date the which should be used as a changes zero for series.

Returns:

anychart.enums.ScaleCompareWithMode | string | number - Data for the changes zero of the series.
Setter for the date which should be used as a changes zero for series.

Params:

NameTypeDefaultDescription
modeanychart.enums.ScaleCompareWithMode | string | number | Date
'firstVisible'
Mode to set

Returns:

anychart.scales.Linear - Self instance for method chaining.

comparisonMode

Getter for the scale changes mode.

Returns:

anychart.enums.ScaleComparisonMode | string - The scale changes mode.
Setter for the scale changes mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.ScaleComparisonMode | string
'none'
Comparison mode to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

extendDataRange

Extends the current input domain with the passed values (if such don't exist in the domain).
Note: Attention! anychart.scales.Base#finishAutoCalc drops all passed values.

Params:

NameTypeDescription
var_args*Values that are supposed to extend the input domain.

Returns:

anychart.scales.Linear - Self instance for method chaining.

finishAutoCalc

Informs the scale that an auto-range calculation started for the chart in past was ended.

Params:

NameTypeDescription
silentlybooleanIf this flag is set, do not dispatch an event if reapplication needed.

Returns:

boolean - If the calculation changed the scale and it needs to be reapplied.

getType

Returns scale type.

Returns:

string - Scale type.

inverseTransform

Returns tick by its position ratio.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().

Params:

NameTypeDescription
rationumberValue to transform in input scope.

Returns:

* - Value transformed to output scope.

inverted

Getter for the scale inversion.

Returns:

boolean - The inversion state.
Setter for scale inversion.
If the scale is inverted, axes and series go upside-down or right-to-left instead of bottom-to-top and left-to-right.

Params:

NameTypeDefaultDescription
enabledboolean
false
Inverted state to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

maxTicksCount

Getter for the maximum ticks count.

Returns:

number - Maximum ticks count.
See listing
var maxTicksCount = scale.maxTicksCount();
Setter for the maximum ticks count.

Params:

NameTypeDefaultDescription
countnumber
1000
Maximum ticks count to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

maximum

Getter for the scale maximum.

Returns:

number - Scale maximum.
See listing
var scale = chart.yScale();
var maximum = scale.maximum();
Setter for the scale maximum.

Params:

NameTypeDefaultDescription
maximumnumber
null
Maximum value to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

maximumGap

Getter for the scale maximum gap.

Returns:

number - Scale maximum gap.
Setter for the scale maximum gap.

Params:

NameTypeDefaultDescription
gapnumber
0.1
Gap value from 0 to 1.

Returns:

anychart.scales.Linear - Self instance for method chaining.

minimum

Getter for the scale minimum.

Returns:

number - Scale minimum.
See listing
var scale = chart.yScale();
var minimum = scale.minimum();
Setter for the scale minimum.

Params:

NameTypeDefaultDescription
minimumnumber
null
Scale minimum to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

minimumGap

Getter for the scale minimum gap.

Returns:

number - Scale minimum gap.
Setter for the scale minimum gap.

Params:

NameTypeDefaultDescription
gapnumber
0.1
Gap value from 0 to 1.

Returns:

anychart.scales.Linear - Self instance for method chaining.

minorTicks

Getter for set of scale minor ticks in terms of data values.

Returns:

anychart.scales.ScatterTicks - Minor ticks.
Setter for set of scale minor ticks in terms of data values.

Params:

NameTypeDescription
settingsObject | ArrayAn array or object of ticks to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

softMaximum

Getter for the soft maximum.

Returns:

number - Soft maximum value.
Setter for the soft maximum.

Params:

NameTypeDefaultDescription
maximumnumber
null
Soft maximum to set

Returns:

anychart.scales.Linear - Self instance for method chaining.

softMinimum

Getter for the soft minimum.

Returns:

number - Soft minimum value.
Setter for the soft minimum.

Params:

NameTypeDefaultDescription
minimumnumber
null
Soft minimum value to set

Returns:

anychart.scales.Linear - Self instance for method chaining.

stackDirection

Getter for the stacking direction.

Returns:

anychart.enums.ScaleStackDirection | string - The stacking direction.
See listing
var stackDirection = scale.stackDirection();
Setter for the stacking direction.

Params:

NameTypeDefaultDescription
directionanychart.enums.ScaleStackDirection | string
'direct'
The stacking direction.

Returns:

anychart.scales.Linear - Self instance for method chaining.

stackMode

Getter for the stacked mode.

Returns:

anychart.enums.ScaleStackMode - Stack mode.
Setter for the stacked mode.

Params:

NameTypeDefaultDescription
valueanychart.enums.ScaleStackMode | string
'none'
Value to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

startAutoCalc

Informs scale that an auto-range calculation started for the chart, so it should reset its data range on the first call of this method if needed.

Returns:

anychart.scales.Linear - Self instance for method chaining.

stickToZero

Getter for stick to zero.

Returns:

boolean - State stick to zero.
Setter for stick to zero. Flag to stick to zero value on auto calc if gaps lead to zero crossing.

Params:

NameTypeDefaultDescription
enabledboolean
true
Whether to stick to zero.

Returns:

anychart.scales.Linear - Self instance for method chaining.

ticks

Getter for set of scale ticks in terms of data values.
Setter for set of scale ticks in terms of data values.

Params:

NameTypeDescription
settingsObject | ArrayAn array or object of ticks to set.

Returns:

anychart.scales.Linear - Self instance for method chaining.

transform

Returns tick position ratio by its name.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().

Params:

NameTypeDescription
value*Value to transform in input scope.

Returns:

number - Value transformed to scope [0, 1].