AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.scales.OrdinalColor Improve this Doc

Extends: anychart.scales.Base

The OrdinalColor class contains methods for configuring Ordinal color scale.
Note: To create instance use anychart.scales#ordinalColor method.

Methods Overview

Specific settings
colorToValue()Returns value for passed color. Value is a middle of its range.
finishAutoCalc()Informs the scale that an auto-range calculation started for the chart in past was ended.
getIndexByValue()Returns range index relative passed value.
getProcessedRanges()Returns processed ranges.
getRangeByValue()Returns range for passed value.
getType()Returns scale type.
inverseTransform()Returns tick value by its ratio position.
inverted()Scale inversion.
names()Scale names settings.
ranges()Scale ranges
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.
transform()Returns tick position ratio by its value.
valueToColor()Converts value to color. Returns color relative to passed value.
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

Returns value for passed color. Value is a middle of its range.

Params:

NameTypeDescription
colorstringColor to search value.

Returns:

number - Middle of searched range.

colors

Getter for the linear gradient for linear color scale.

Returns:

Array.<string> - The linear gradient.
Setter for the linear gradient for linear color scale.

Params:

NameTypeDescription
colorsArray.<string>Colors set.

Returns:

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

getIndexByValue

Returns range index relative passed value.

Params:

NameTypeDescription
valuenumberValue to search index.

Returns:

number - Range index.

getProcessedRanges

Returns processed ranges.

Returns:

Array.<Object> - Processed ranges.

getRangeByValue

Returns range for passed value.

Params:

NameTypeDescription
valuenumberValue to search its range.

Returns:

Object - Searched range or null.

getType

Returns scale type.

Returns:

string - Scale type.

inverseTransform

Returns tick value by its ratio position.

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 the scale inversion.

Params:

NameTypeDefaultDescription
enabledboolean
false
Whether to invert the scale.

Returns:

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

names

Getter for scale names for data set.

Returns:

Array.<*> - Scale names.
Setter for scale names for data set.

Params:

NameTypeDescription
namesArray.<*> | stringArray of names or attribute name for data set.

Returns:

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

ranges

Getter for the scale ranges.

Returns:

Array.<Object> - Scale ranges.
Setter for the scale ranges.

Params:

NameTypeDescription
rangesArray.<Object>An array of the ranges.

Returns:

anychart.scales.OrdinalColor - 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.OrdinalColor - Self instance for method chaining.

ticks

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

Returns:

anychart.scales.OrdinalTicks - Ordinal ticks instance.
Setter for the set of scale ticks in terms of data values.

Params:

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

Returns:

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

transform

Returns tick position ratio by its value.

Params:

NameTypeDescription
value*Value to transform in input scope.
subRangeRationumberSub range ratio.

Returns:

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

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 relative to passed value.

Params:

NameTypeDescription
valuenumberValue to convert.

Returns:

string - Returns color in hex representation relative passed value.