Drupal – Radar/Polar charts with Chart API Module

I have been developing a web application for one of our clients using drupal, it’s a dashboard type data visualisation system that consumes and displays data over an intranet from their software systems.  I have been using google charts with great success.

 

The Chart API module for drupal is very nice, it lets you quite easily incorporate google charts into your web site or application without having to get into the details of the google chart API itself, and the charts themselves look great – just the kind of thing to cheer up a busy software developer.  However it deosn’t seem to support Radar or Polar charts.  There is no mention of them in the documentation, no example on the examples page.  There is also no symbol such as ‘CHART_TYPE_RADAR’ defined in the module as there is for the other chart types, for example ‘CHART_TYPE_LINE’ defined for line charts.

 

So is it possible to plot radar charts using the Chart API module?  I consulted the google chart api and found that the radar chart type is donated as ‘r’, so I tried creating a simple chart and just set it’s type to ‘r’ (rather than say CHART_TYPE_LINE) and it worked just fine!

 


$chart = array(
'#chart_id' => 'sink_radar',
'#title' => chart_title(t('Failures by Sink'), '001334', 15),
'#type' => 'r',
'#size' => chart_size(400, 240),
);
$chart['#data'][] = array(20, 30, 15, 70, 90, 20);
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink1');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink2');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink3');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink4');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink5');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] =
                      chart_mixed_axis_label('sink6');
echo chart_render($chart);

 This code yileds a chart like this:

 

Radar Chart