class anychart.scales.Ordinal Improve this Doc
Extends: anychart.scales.Base
Define Ordinal scale. Note: To create instance use anychart.scales#ordinal method.
Methods Overview
Specific settings | |
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 name by its ratio position. |
inverted() | Inversion state. |
names() | Tics names. |
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 name. |
values() | Input domain. |
weights() | Scale weights. |
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
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:
Name | Type | Description |
---|---|---|
var_args | * | Values that are supposed to extend the input domain. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
finishAutoCalc
Informs the scale that an auto range calculation started for the chart in past was ended.
Params:
Name | Type | Description |
---|---|---|
silently | boolean | If 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
inverseTransform
Returns tick name by its ratio position.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().
Params:
Name | Type | Description |
---|---|---|
ratio | number | Value to transform in input scope. |
Returns:
* - Value transformed to output scope.Try it:
inverted
Getter for scale inversion.
Returns:
boolean - Current 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:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Value to set. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
listen
Adds an event listener to an implementing object.
Detailed description
The listener can be added to an object once, and if it is added one more time, its key will be returned.
Note Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.
Note Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function | 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
} . | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
listenOnce
Adds an event listener to an implementing object.
Detailed description
After the event is called, its handler will be deleted.
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
names
Setter for scale ticks names.
Params:
Name | Type | Default | Description |
---|---|---|---|
value | Array.<*> | string | [] | Array of names or attribute name for data set. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
removeAllListeners
Removes all listeners from an object. You can also optionally remove listeners of some particular type.
Params:
Name | Type | Description |
---|---|---|
type | string | Type of event to remove, default is to remove all types. |
Returns:
number - Number of listeners removed.Try it:
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.Ordinal - Chaining.ticks
Getter for set of scale ticks in terms of data values.
Returns:
anychart.scales.OrdinalTicks - An instance of the class for method chaining.Try it:
Setter for set of scale ticks in terms of data values.
Params:
Name | Type | Description |
---|---|---|
value | Object | Array | An array of indexes of ticks values. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
transform
Returns tick position ratio by its name.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().
Params:
Name | Type | Description |
---|---|---|
value | * | Value to transform in input scope. |
subRangeRatio | number | Sub range ratio. |
Returns:
number - Value transformed to output scope.Try it:
unlisten
Removes a listener added using listen() or listenOnce() methods.
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
boolean - Whether any listener was removed.Try it:
unlistenByKey
Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().
Params:
Name | Type | Description |
---|---|---|
key | Object | The key returned by listen() or listenOnce(). |
Returns:
boolean - Whether any listener was removed.Try it:
values
Getter for scale input domain.
Returns:
Array.<(number|string)> - Current input domain.Try it:
Setter for scale input domain.
Params:
Name | Type | Default | Description |
---|---|---|---|
values | Array.<*> | * | null | [] | Array of values, or values, or null for autocalc. |
var_args | * | Other values, that should be contained in input domain. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
weights
Getter for scale weights.
Returns:
Array.<number> - Scale weights. See listing
var weights = scale.weights();
Setter for scale weights.
Detailed description
Weights affect the width of the points of the series tied to scale.
Each element of the array is the weight of the point of the series with the corresponding element index.
Params:
Name | Type | Description |
---|---|---|
value | Array.<number> | An array of weights. |
Returns:
anychart.scales.Ordinal - Scale weights or self for chaining.Try it: