Polar Chart

Overview

Polar chart plot allows to draw scatter chart using polar coordinate system, which is is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a fixed point and an angle from a fixed direction.

Chart Building

AnyChart allows to draw Line, Area and Marker series on Polar plot. To enable polar plot set plot_type="Polar":

XML Syntax
Plain code
01 <chart plot_type="polar">
02   <data>
03     <series name="Series 1">
04       <point x="0" y="0" />
05       <point x="10" y="1" />
06       <point x="20" y="2" />
07       <point x="30" y="3" />
08       <point x="40" y="4" />
09       <point x="50" y="5" />
10       <point x="60" y="6" />
11       <point x="70" y="7" />
12       <point x="80" y="8" />
13       <point x="90" y="9" />
14       <point x="100" y="10" />
15     </series>
16   </data>
17 </chart>

As you can see each point should have x и y attributes set, they define the location of the point on the polar plot.

Note: point in series must be ordered by x for series to be displayed in a right way.

Take a look at the very basic sample of polar chart:

Live Sample:  Polar Chart Simple sample

to top

Polar plot configuration

Polar plot has several distinctive configuration options, which are presented in this section: chart radius settings, chart rotation and background settings.

Radius size

Polar plot radius can be set absolute or relative. To use absolute settings you need to set fixed_radius="true" in <polar> node, and set radius in pixels, for example: radius="120"

XML Syntax
Plain code
01 <data_plot_settings>
02   <polar fixed_radius="true" radius="120" />
03 </data_plot_settings>

Here is a sample of the polar chart with fixed radius:

Live Sample:  Polar Chart Fixed radius

You can also set radius in percents, relative to chart height and width, to do so you have to set, for example: radius="50%"

XML Syntax
Plain code
01 <polar fixed_radius="true" radius="50%" />

Sample chart with radius set to 50%:

Live Sample:  Polar Chart Percent radius

to top

Start angle

By default radar starts drawing from the top center point (0°), but you can change this using start_angle attribute in <polar> node:

XML Syntax
Plain code
01 <data_plot_settings>
02   <polar start_angle="45" />
03 </data_plot_settings>

Sample chart with starting angle shifted to 90°:

Live Sample:  Polar Chart Start Angle Sample

to top

Plot background

You can change polar background using <background> node, learn more about this node at Background settings tutorial.

XML Syntax
Plain code
01 <polar>
02   <background>
03     <fill type="Gradient">
04       <gradient type="Linear" angle="45">
05         <key color="#ffffff" position="0" opacity="0.5" />
06         <key color="#dddddd" position="0.7" opacity="0.9" />
07       </gradient>
08     </fill>
09   </background>
10 </polar>

Sample polar chart with tuned background:

Live Sample:  Polar Chart Plot background Sample

to top

Border settings

Polar chart border consists of two different lines: <border> of <background> node described above, and X-axis setting - <line> node:

XML Syntax
Plain code
01 <chart_settings>
02   <axes>
03     <x_axis>
04       <line enabled="true" thickness="4" type="Gradient">
05         <gradient>
06           <key color="white" />
07           <key color="black" />
08         </gradient>
09       </line>
10     </x_axis>
11   </axes>
12 </chart_settings>

Sample below shows Х-axis line width and background border are set to 4 pixels:

Live Sample:  Polar Chart Plot border

to top

Data under axes

Another special feature of Polar chart is an ability to set whether data series are displayed under or above axes lines. This is set using display_data_mode attribute, which can be either "AboveAxes" (default) or "UnderAxes".

XML Syntax
Plain code
01 <data_plot_settings>
02   <polar display_data_mode="UnderAxes" />
03 </data_plot_settings>

Sample chart with data series displayed under axes lines:

Live Sample:  Polar Chart axis under data sample

to top

Closed and open contour

By default all series are close - the last point is joined with the first one. You can disjoin any series by setting close_contour attribute of <series> node to false:

XML Syntax
Plain code
01 <series close_contour="false" />

Sample chart with disjointed line:

Live Sample:  Polar Chart close series line sample

to top

X axis settings

This section tells how to configure Х axis and its elements, such as tick marks, grid and labels.

X axis enable/disable

To turn X axis on or off use enabled attribute of <x_axis> node - setting it to false hides all visible components of X axis:

XML Syntax
Plain code
01 <axes>
02   <x_axis enabled="false" />
03 </axes>

Sample chart with X-axis turned off:

Live Sample:  Polar Chart X Axis disabled

Note: You see the chart outline - it comes from background.

to top

Tickmarks

Tickmarks are the small marks used to represent a point on an axis scale, used to indicate major step of an axis scale. You can control their appearance and position. To enable/disable tickmarks set enabled="true" or enabled = "false" to <major_tickmark>

XML Syntax
Plain code
01 <axes>
02   <x_axis>
03     <major_tickmark enabled="true" size="4" thickness="2" inside="true" outside="true" />
04   </x_axis>
05 </axes>

Tickmarks can be placed "inside" and "outside" relatively to axis line. These features are controlled by inside and outside attributes.

Live Sample:  Polar Chart X Axis Tickmarks

Warning: X axis in Polar plot doesn't support minor grids and tickmarks. Only major.

to top

Grids

Each axis has its own grid. By default grid is enabled for all axes and looks like a set of black lines. You can turn it off or configure to fit your needs. Here is a sample XML with grid settings:

XML Syntax
Plain code
01 <x_axis>
02   <major_grid enabled="true" interlaced="true" draw_last_line="true">
03     <line thickness="2" />
04     <interlaced_fills>
05       <even>
06         <fill type="Gradient" opacity="0.4" focal_point="0">
07           <gradient type="Radial">
08             <key color="Gray" />
09             <key color="White" />
10           </gradient>
11         </fill>
12       </even>
13     </interlaced_fills>
14   </major_grid>
15 </x_axis>

In <line> node you can change:

Attribute Description
color Sets line color.
opacity Sets line opacity.
thickness Sets line thickness.

In <interlaced_fills> node you can set <even> and <odd> fills, fills start from axis and the first section is "even".

Live Sample:  Polar Chart X Axis Grid

Warning: X axis in Polar plot doesn't support minor grids and tickmarks. Only major.

to top

Labels settings

You can change format, rotation, placement, paddings and visual settings of axis labels, this section covers all basic available options.

Rotation settings

Using circular_labels_style attribute you can change the way labels are placed near the circular axis of radar chart: the placement options are: "Horizontal", "Circular" or "Radial".

By default Horizontal is set, but you can always change it:

XML Syntax
Plain code
01 <x_axis>
02   <labels circular_labels_style="Horizontal" />
03 </x_axis>

Horizontal labels sample:

Live Sample:  Polar Chart Rotation Sample

Setting Circular mode sample:

XML Syntax
Plain code
01 <axes>
02   <x_axis>
03     <labels circular_labels_style="Circular" />
04   </x_axis>
05 </axes>

And the chart with with such settings:

Live Sample:  Polar Chart Circular rotation Sample

Setting Radial mode:

XML Syntax
Plain code
01 <axes>
02   <x_axis>
03     <labels circular_labels_style="Radial" />
04   </x_axis>
05 </axes>

And the chart with radially placed labels:

Live Sample:  Polar Chart Radial rotation Sample

to top

Position and padding

Labels can be Inside or Outside of the axis and this is configured using position attribute, which is set to Outside by default.

You can also set the padding between the axis and labels (in pixels):

XML Syntax
Plain code
01 <x_axis>
02   <labels position="Inside" padding="10" />
03 </x_axis>

Sample with padding set to 5 and labels placed inside:

Live Sample:  Polar chart X-axis labels position

to top

Background settings

You can change labels background. Learn more about background configuration in Background settings tutorial.

XML Syntax
Plain code
01 <labels>
02   <background enabled="true">
03     <fill type="solid" color="LightColor(DeepSkyBlue)" opacity="0.1" />
04     <inside_margin all="2" />
05     <border enabled="true" thickness="1" color="Blue" type="Linear" opacity="0.2" />
06     <corners all="2" type="Cut" left_top="1" />
07   </background>
08   <format><![CDATA[{%Value}{numDecimals:1,leadingZeros:2}]]></format>
09 </labels>

Sample with labels with tuned background:

Live Sample:  Polar chart Labels Background Sample

to top

Formatting settings

In labels format you can access only %Value token, which can be formatted according to the Axis Labels Formatting rules:

XML Syntax
Plain code
01 <x_axis>
02   <labels>
03     <format><![CDATA[{%Value}{numDecimals:0,thousandsSeparator:'}]]></format>
04   </labels>
05 </x_axis>

Sample labels formatting:

Live Sample:  Polar chart Labels Formatting Sample

to top

Hide first and last labels

You can hide first and/or last labels using show_first_label and show_last_label attributes:

XML Syntax
Plain code
01 <x_axis>
02   <labels show_first_label="false" />
03 </x_axis>

Sample chart with first label hidden:

Live Sample:  Polar chart X-axis Hide last first Labels Sample

to top

Y axis settings

This section tells how to configure Y axis mode, scale and its elements, such as tick marks, grid and labels.

Y axis enable/disable

To turn Y axis on or off use enabled attribute of <y_axis> node - setting it to false hides all visible components of Y axis:

XML Syntax
Plain code
01 <axes>
02   <y_axis enabled="false" />
03 </axes>

Sample with Y axis turned off:

Live Sample:  Polar chart Y-axis disabled

to top

Linear and Logarithmic scale

Polar chart supports to scale types: linear and logarithmic. This is controlled using type attribute of <scale> node :

XML Syntax
Plain code
01 <y_axis>
02   <scale type="Logarithmic" />
03 </y_axis>

Sample polar chart with logarithmic axis:

Live Sample:  Polar chart with log scale

to top

Tickmarks

Tickmarks are the small marks used to represent a point on an axis scale, used to indicate major step of an axis scale. You can control their appearance and position. To enable/disable tickmarks set enabled="true" or enabled = "false" to <major_tickmark>

XML Syntax
Plain code
01 <axes>
02   <y_axis>
03     <major_tickmark enabled="true" size="4" thickness="2" inside="true" outside="false" />
04   </y_axis>
05 </axes>

Tickmarks can be placed "inside" and "outside" relatively to axis line. These features are controlled by inside and outside attributes.

Live Sample:  Polar Chart Y Axis Tickmarks
Warning: Y axis in polar plot doesn't support minor grids and tickmarks. Only major.

to top

Grids

Each axis has its own grid. By default grid is enabled for all axes and looks like a set of black lines. You can turn it off or configure to fit your needs. Here is a sample XML with grid settings:

XML Syntax
Plain code
01 <major_grid enabled="true" interlaced="true" draw_last_line="true">
02   <line thickness="1" opacity="0.4" />
03   <interlaced_fills>
04     <even>
05       <fill type="Gradient" opacity="0.4" focal_point="0">
06         <gradient type="Radial">
07           <key color="SkyBlue" />
08           <key color="White" />
09         </gradient>
10       </fill>
11     </even>
12     <odd>
13       <fill type="Solid" opacity="0.1" color="DeepSkyBlue" />
14     </odd>
15   </interlaced_fills>
16 </major_grid>

Attributes of <line>:

Attribute Description
color Sets line color.
opacity Sets line opacity.
thickness Sets line thickness.

In <interlaced_fills> node you can set <even> and <odd> fills, fills start from axis and the first section is "even".

Live Sample:  Polar Chart Y-Axis Grid

Warning: Y axis in polar plot doesn't support minor grids and tickmarks. Only major.

to top

Labels settings

You can tune Y axis labels format, position, rotation, padding and change visual settings.

Rotation

To rotate the labels you should set rotation angle in rotation attribute:

XML Syntax
Plain code
01 <y_axis>
02   <labels rotation="33" />
03 </y_axis>

Sample Radar chart with rotated labels:

Live Sample:  Polar Chart Y-Axis Rotation Sample

to top

Position and padding

Labels can be Inside or Outside of the axis and this is configured using position attribute, which is set to Outside by default.

You can also set the padding between the axis and labels (in pixels):

XML Syntax
Plain code
01 <y_axis>
02   <labels position="Inside" padding="5" />
03 </y_axis>

Sample with padding set to 10 and labels placed inside:

Live Sample:  Polar chart Y-axis labels position

to top

Background settings

You can change labels background. Learn more about background configuration in Background settings tutorial.

XML Syntax
Plain code
01 <y_axis>
02   <labels>
03     <background enabled="true">
04       <fill type="Solid" color="LightColor(DeepSkyBlue)" opacity="0.2" />
05       <inside_margin all="0" />
06       <border enabled="true" thickness="1" color="Blue" type="Linear" opacity="1" />
07       <corners all="2" type="Cut" />
08     </background>
09   </labels>
10 </y_axis>

Sample with labels with tuned background:

Live Sample:  Polar chart Y-axis Labels Background Sample

to top

Formatting settings

In Y axes labels you can use only %Value token, which can be formatted as described at Axis Labels Formatting.

XML Syntax
Plain code
01 <y_axis>
02   <labels padding="2" position="Inside">
03     <format><![CDATA[{%Value}{numDecimals:1,useNegativeSign:false}]]></format>
04   </labels>
05 </y_axis>

Sample with formatted labels:

Live Sample:  Polar chart Y-axis Labels Formatting Sample

to top

Hide first and last labels

You can hide first and/or last labels using show_first_label and show_last_label attributes:

XML Syntax
Plain code
01 <y_axis>
02   <labels show_first_label="false" />
03 </y_axis>

Sample chart with first label hidden:

Live Sample:  Polar chart Y-axis Hide last|first Labels Sample

to top

Working with data labels and tooltips

In this section we will explain how to add and configure data labels and tooltips. Full explanation of formatting and tuning visual appearance for them can be found in Labels and tooltips.

If you want to configure data labels and tooltips for all series - you should do that in <label> and <tooltip> sub-nodes of <polar> node. You can tune their visual appearance, positioning and format. Let's do that in the following example: we will make data labels appear to the top of the data points, also, we will format labels so they show only the value corresponding to the point and tooltip will show detailed description.

When formatting data labels text and tooltip we will use formatting keywords:
{%Name} - to show month name,
{%YValue} - to show sales for this month,
{%SeriesName} - to show period (Year),
{%YPercentOfSeries} - to show every month percentage to total sales per year.

Live Sample:  Polar chart - Working with data labels and tooltips

to top

Supported series types

Polar chart supports: Line, Area and Marker series types. You can learn how to change and configure styles of these types at: Area styles, Line styles and Marker styles.

Live Sample:  Polar series types

to top

Missing points

Polar chart supports missing control: missing and non-numeric y are ignored:

Live Sample:  Polar plot missing points sample

to top