class anychart.scales.Ordinal Improve this Doc
Extends: anychart.scales.Base
The Ordinal class contains methods for configuring 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. |
mode() | Scale mode. |
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. |
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 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.
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 |
---|---|---|---|
enabled | boolean | false | Inverted state to set. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
mode
Getter for the scale mode.
Returns:
anychart.enums.OrdinalScaleMode | string - Returns the scale mode. See listing
var mode = scale.mode();
Setter for the scale mode.
Detailed description
The mode() method is used to expand the ordinal scale when a continuous series should be drawn visually from the start of the chart to its end.
Let's consider the work of this method on the example of three categories.
If the mode is set to 'discrete' (default value) then drawing representation will be shown as in the image below:
This is suitable for drawing discrete series (column, box).
Otherwise (continuous mode) it will be displayed as:
This is suitable for drawing continuous series (line, area).
Scale transforms values according to a formula which takes into account that:
scale.transform('A', 0.5) should be displayed as 0
scale.transform('F', 0.5) should be 1
See anychart.scales.Ordinal#transform to learn more.
Let's consider the work of this method on the example of three categories.
If the mode is set to 'discrete' (default value) then drawing representation will be shown as in the image below:
This is suitable for drawing discrete series (column, box).
Otherwise (continuous mode) it will be displayed as:
This is suitable for drawing continuous series (line, area).
Scale transforms values according to a formula which takes into account that:
scale.transform('A', 0.5) should be displayed as 0
scale.transform('F', 0.5) should be 1
See anychart.scales.Ordinal#transform to learn more.
Params:
Name | Type | Default | Description |
---|---|---|---|
mode | anychart.enums.OrdinalScaleMode | string | 'discrete' | Scale mode to set. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it:
names
Setter for scale ticks names.
Params:
Name | Type | Default | Description |
---|---|---|---|
names | Array.<*> | string | [] | Array of names or attribute name for data set. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.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 - Self instance for method chaining.ticks
Getter for set of scale ticks in terms of data values.
Returns:
anychart.scales.OrdinalTicks - The set of ordinal ticks.Try it:
Setter for set of scale ticks in terms of data values.
Params:
Name | Type | Description |
---|---|---|
ticks | 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:
values
Getter for the scale input domain.
Returns:
Array.<(number|string)> - Input domain.Try it:
Setter for the 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 series points tied to scale.
Each element of the array is the weight of the series point with the corresponding element index.
Params:
Name | Type | Description |
---|---|---|
weights | Array.<number> | An array of weights. |
Returns:
anychart.scales.Ordinal - Self instance for method chaining.Try it: