Extra Axes

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:

to top

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:

XML Syntax
Plain code
01 <chart_setttings>
02   <axes>
03     <x_axis />
04     <y_axis />
05     <extra>
06       <y_axis name="y2" enabled="true" />
07       <y_axis name="y3" enabled="true" />
08       <y_axis name="y4" enabled="true" />
09     </extra>
10   </axes>
11 </chart_setttings>

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):

Live Sample:  Extra Y Axes Simple Sample

Another example of multiple axes use is multiple Y Axes along with multiple X Axes, which may be very useful in certain areas:

Live Sample:  Extra X Axes Simple Sample

to top

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:

XML Syntax
Plain code
01 <chart_setttings>
02   <axes>
03     <x_axis />
04     <y_axis>
05       <title>
06         <text><![CDATA[Basic Y Axis]]></text>
07       </title>
08       <scale minimum="0" maximum="800000" />
09     </y_axis>
10     <extra>
11       <y_axis name="y2" enabled="true">
12         <title>
13           <text><![CDATA[Extra Y Axis]]></text>
14         </title>
15         <scale minimum="800000" maximum="1600000" />
16       </y_axis>
17       <x_axis name="x2" enabled="true">
18         <title>
19           <text><![CDATA[Extra X Axis]]></text>
20         </title>
21         <scale minimum="800" maximum="1600" />
22       </x_axis>
23     </extra>
24   </axes>
25 </chart_setttings>

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:

Live Sample:  Extra Axes Tuning Sample

to top

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>:

XML Syntax
Plain code
01 <data>
02   <series y_axis="y2">
03     <point name="A" y="1" />
04     <point name="B" y="2" />
05     <point name="C" y="3" />
06   </series>
07 </data>

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:

Live Sample:  Extra Axes Binding Sample

to top

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:

XML Syntax
Plain code
01 <axes>
02   <y_axis>
03     <title>
04       <text><![CDATA[Celsius]]></text>
05     </title>
06     <scale minimum="273.15" maximum="1668" />
07   </y_axis>
08   <extra>
09     <y_axis name="Fahrenheit" enabled="true">
10       <title>
11         <text><![CDATA[Fahrenheit]]></text>
12       </title>
13       <scale minimum="459.67" maximum="3034" />
14     </y_axis>
15     <y_axis name="Kelvin" enabled="true">
16       <title>
17         <text><![CDATA[Kelvin]]></text>
18       </title>
19       <scale minimum="0" maximum="1941" />
20     </y_axis>
21   </extra>
22 </axes>

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:

XML Syntax
Plain code
01 <data>
02   <series type="Marker" y_axis="Kelvin">
03     <point name="Absolute Zero" y="0" />
04     <point name="Lowest recorded surface temperature on Earth" y="184" />
05     <point name="Celsius / Fahrenheit's 'cross-over' temperature" y="233.15" />
06     <point name="Ice melts" y="273.15" />
07     <point name="Average human body temperature" y="309.95" />
08     <point name="Highest recorded surface temperature on Earth" y="331" />
09     <point name="Water boils" y="373.1339" />
10     <point name="Titanium melts" y="1941" />
11   </series>
12 </data>

Here it is - a sample that shows different important temperatures:

Live Sample:  Extra Axes Units Comparison Sample

to top

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:

XML Syntax
Plain code
01 <axes>
02   <y_axis>
03     <title>
04       <text><![CDATA[Debt]]></text>
05     </title>
06     <scale minimum="0" maximum="12000000000000" />
07   </y_axis>
08   <extra>
09     <y_axis name="gdp">
10       <title>
11         <text><![CDATA[% GDP]]></text>
12       </title>
13       <scale minimum="0" maximum="140" />
14     </y_axis>
15   </extra>
16 </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.

Live Sample:  Extra Axes Different Data Comparison Sample

to top