Extra Axes
- Overview
- Definition
- Tuning extra axes
- Binding data series to extra axis
- Multi axes sample for comparing units
- Multi axes sample for showing different data on the same plot
Overview
In AnyChart axes are used to control values or arguments scales, grids, axes labels, lines and tickmarks. You can add multiple X and Y axes ot your charts with AnyChart.
This note will describe how to use the multi axis feature of AnyChart. With this feature an arbitrary number of axes can be added to the chart. AnyChart itself doesn't impose any restrictions on the number of extra axes but from a practical concern it is most likely very difficult to interpret a chart with more than 2-3 extra axes.
Consider using multiple axes when you need:
- Compare data point values in different units, for example: Celsius against Fahrenheit degrees, kilopascal (KPa) or hectopascal (HPa) against millimeters or inches of mercury (mmHg or inHg), different currencies (USD against EUR), etc.
- Show data from the different ranges on the same plot, for example: absolute stock price changes and sales volume (price will be in dollars and volume in millions of dollars)
- Show data measured in different units on the same plot, for example: gross domestic product (GDP) volume and GDP growth rate (GDP will be in billions and rate in percents)
Define an extra axis
If you want to define an extra axis all you need to do is to add <extra> node to <axes> node, and place as many <y_axis> or <x_axis> nodes into it, each additional axis should have a unique name:
Note: this axes definition format is introduced in 4.2 version. Old extra axes format is supported, but we recommend to switch to new one.
Here is the sample of the chart that will be show when three extra y axes are added and almost no configuration is done, as you can see three extra axes are drawn on the right side of data plot and their maximum and minimum values are calculated automatically (and they are the same as main Y axis have):
Another example of multiple axes use is multiple Y Axes along with multiple X Axes, which may be very useful in certain areas:
Tuning extra axes
If you want to change any settings of extra axes you can that just the same way as basic X and Y axes are configured, see Axes basics and Axes Scale for the details:
In the a sample below we will add one extra axis and set value ranges and titles for both basic Y axis and extra Y axis:
Binding data series to extra axis
To bind data series to the certain axis you should specify it in y_axis or x_axis attribute of <series> node, by default all series work with basic <y_axis> or <x_axis>:
In the a sample below we will add one extra axis with a range from 0 to 100 and and bind series of "Line" type to it:
Multi axes sample for comparing units
Lets see how extra axes can be used to compare data in different units, for example we measure temperature an want to show Celsius, Fahrenheit and Kelvin scales. To do that we have to create three Y Axes - the basic one will be Celsius degrees, first extra axis - Fahrenheit and second extra axis - Kelvin:
We defined three axes and set absolute zero as a minimum value, and Titanium melting temperature as a maximum value. We will create one series of a "Marker" type and bind it to Kelvin scale:
Here it is - a sample that shows different important temperatures:
Multi axes sample for showing different data on the same plot
Lets see how extra axes can be used to show different data on the same plot: we will plot a US Debt amount in dollars and in percents of GDP. We need to create to axes:
We defined two axes and will create one series of a "Bar" type to show debt and bind it to <y_axis>, one series of a "Line" type to show percentage changes.
Here it is - a sample chart comparing the US debt, in red, to the debts percent of GDP, in blue.