Scales allow you to control such features as minimum and maximum scale values, scale inversion, intervals, scale type and so on for a single axis. To create additional axes - please read Additional axis first. To adjust axes display - please see: Axis Basics tutorial.

In this section we will explain main scales options.

If you want to control any of scale settings - you should do that using scale() method.


There are four types of scales in AnyChart charting framework: "Linear", "Logarithmic", "Ordinal" and "DateTime". To set scale type use appropriate constructor:


  var newScale = anychart.scales.ordinal();

Note: working with extra axes is explained in Additional Axes Tutorial


Linear scale type is a default type for yScale in most charts. Values for this scale should be numbers and scale intervals will be evenly distributed along the axis. This type of scale is used when values fall within one reasonable range.


JsFiddle Playground


A logarithmic scale is a scale of measurement that uses the logarithm of a physical quantity instead of the quantity itself. Presentation of data on a logarithmic scale can be helpful when the data covers a large range of values the logarithm reduces this to a more manageable range.


In the sample below A = 637.166, B = 721.630, and C=1.000, D=78, E = 90.

JsFiddle Playground


Ordinal scale type is a default type for xScale in all cartesian charts. Values for this scale should be of string type and scale intervals will be set automatic.


JsFiddle Playground

Note: You can set custom names for ordinal scale using names() method. Use string parameter for this method to set data field with names for scale values or use array as parameter for names() method to set custom names.

Date Time

A dateTime scale is a scale of measurement that is based on the UTC Date format, but accepts variety of data formats. Presentation of data on a dateTime scale can be helpful for displaying time lines and time intervals. More information about data formats and usage is in Date/Time tutorial.


JsFiddle Playground

Stack Mode

Scale mode defines some additional behavior of a chart. In the table below all modes are listed and their applicability to different chart types:

Scale mode Charts
Normal Default for all
Stacked All liner types (Bar, Line, Area, etc.)
PercentStacked All liner types (Bar, Line, Area, etc.)

To change scale mode you need to set stackMode() parameter. Possible attributes are: value and percent.

  var yScale = chart.yScale();

In the sample below stacked and percent stacked scales are demonstrated on the same data sets:

JsFiddle Playground


For stacked charts with multiple series it is possible to divide stacked series into groups. The groups can be created by using a new y scale for each group. New scale should be used as a parameter of .yScale() method for each series in the group:

  var newScale = anychart.scales.linear()

  var series = chart.column(data);

Here is a sample of clustered series groups in a stacked modes:

JsFiddle Playground

Note: You can find more accurate sample with information on scales' sync in Stacked Bar-Column Charts and Percent Stacked Bar-Column Charts articles.

Minimum and Maximum

For any scale, but ordinal, you can set maximum and/or minimum values which are calculated automatically by default.

  var yScale = chart.yScale();

Note, if you will set maximum value lesser than chart elements values, or minimum greater than them - these elements will be cropped, and you will see only a part of them or will not see them at all.

JsFiddle Playground

Soft Minimum and Soft Maximum

For any scale, but ordinal, you can set soft maximum and/or soft minimum values.

  var yScale = chart.yScale();

In some cases you may have no need to define solid minimum or maximum and need a scale to be autocalculated, but at the same time you may want a scale to remain in a certain range (i.e. "never go below zero" or "never go above 100"): that's the case when soft maximum and soft_minimum parameters help you.

Sample below shows how soft minimum and soft maximum help to show data better than simple minimum and maximum.

JsFiddle Playground

Stick to Zero

stickToZero() method allows to disable the default scale autocalculation behavior and always include zero in scale range.

Minor and Major Ticks

For any scale, but ordinal, you can set major and minor ticks intervals, which are calculated automatically by default.

Major and minor ticks intervals are axis steps, which define where axis labels (major interval), axis ticks (major and minor, correspondingly) and major and minor grids are displayed.

  // get ticks
  var yTicks = chart.yScale().ticks();
  // set ticks interval
  // get minor ticks
  var minorTicks = chart.yScale().minorTicks();
  // set minor ticks interval

In the sample below you can see how interval settings affects grids, ticks and labels.

JsFiddle Playground

Minimum and Maximum Gap

For any axis scale you can set minimum and maximum offsets. Maximum and minimum offsets are the spacing between maximum or minimum axis scale values and they are set as a ratio to the maximum and minimum scale values.

  var yScale = chart.yScale();

In the sample below you can see how offsets settings affects js chart. The chart to the left has minimum and maximum offsets set to 0.5, the chart to the right has all the same settings, but offsets are not set. Note that offsets are ignored when maximum or minimum scale values are specified.

JsFiddle Playground


If you want to display scale in the inverted mode use inverted() method with "true" parameter.

  var yScale = chart.yScale();

Sample of the chart with inverted scale:

JsFiddle Playground

One Scale for Different Charts

Scale calculates values and in many cases it is very useful to adjust settings of one scale and then use it for multiple charts. in example below we will create custom scale, adjust it and apply it for 2 charts. Click "launch in playground" to see the code

JsFiddle Playground

You are looking at an outdated 7.10.0 version of this document. Switch to the 8.3.0 version to see the up to date information.