AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.scales.LinearColor Improve this Doc

Extends: anychart.scales.ScatterBase

The LinearColor class contains methods for configuring Linear color scale.
Note: To create instance use anychart.scales#linearColor method.

Methods Overview

Specific settings
colorToValue()Converts color to value. Returns number ratio by its color.
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.
inverted()Inversion state.
maxTicksCount()Maximum ticks count.
maximum()Scale maximum.
minimum()Scale minimum.
minorTicks()Minor ticks settings.
startAutoCalc()Informs scale that an auto-range calculation started for the chart, so it should reset its data range on the first
ticks()Ticks settings.
valueToColor()Converts value to color. Returns color ratio by its number.
Coloring
colors()Linear gradient settings.
Events
listen()Adds an event listener
listenOnce()Adds a single time event listener
removeAllListeners()Removes all listeners
unlisten()Removes the listener
unlistenByKey()Removes the listener by the key

Methods Description

colorToValue

Converts color to value. Returns number ratio by its color.

Params:

NameTypeDescription
colorstringColor name or hex color representation.

Returns:

number - Returns value relative passed color.

colors

Getter for the linear gradient for the linear color scale.

Returns:

Array.<Object> - Linear gradient.
Setter for the linear gradient for the linear color scale.

Returns:

anychart.scales.LinearColor - 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.LinearColor - 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.

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.LinearColor - Self instance for method chaining.

listen

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction(e:Object)
Callback method. Function that looks like:
function(event){
   // event.actualTarget - actual event target
   // event.currentTarget - current event target
   // event.iterator - event iterator
   // event.originalEvent - original event
   // event.point - event point
   // event.pointIndex - event point index
}
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction(e:Object)
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

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.LinearColor - 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.LinearColor - 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.LinearColor - Self instance for method chaining.

minorTicks

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

Returns:

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

Params:

NameTypeDefaultDescription
ticksObject | Array
false
An array or object of ticks to set.

Returns:

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

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

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.LinearColor - Self instance for method chaining.

ticks

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

Returns:

anychart.scales.ScatterTicks - The set ticks.
Setter for the set of scale ticks in terms of data values.

Params:

NameTypeDefaultDescription
ticksObject | Array
false
An array or object of ticks to set.

Returns:

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

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction(e:Object):boolean|undefined
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

NameTypeDescription
keyObjectThe key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

valueToColor

Converts value to color. Returns color ratio by its number.

Params:

NameTypeDescription
valuenumberValue to convert.

Returns:

string - Returns color in hex representation relative passed value.