Adds the ability to display graphs on a polar (circular) grid.

It is views compatible through a checkbox in settings -> display.

Unfortunately, it only works with highcharts as the google api does not appear to have polar charts included. (If I'm worng about that, please let me know and I'll create a new patch).

CommentFileSizeAuthor
charts-add_polar_charts.patch2.96 KBjohn cook

Comments

Pierre.Vriens’s picture

Status: Active » Postponed (maintainer needs more info)

It took a while before getting back to you (sorry for that), but thanks anyway for this patch. I first had to lookup what a polar chart is actually about. Then it reminded me about a radar graph. For google charts, such polar or radar chart doesn't seem to exist at all (a bit surprising I think).

So here we are now. Anybody any suggestion about how to move forward with this issue? Would it make sense to come up with some new technique to be introduced, so that we do support it via Highcharts, but when you try to use such type with Google Charts then some type of error (like not support by "Google charts") occurs?

john cook’s picture

I think Google charts lost the ability when it moved APIs. I kept finding references to polar/radar charts but just for a deprecated version.

I did put a "May not work depending on library and module used." message on checkbox's description, It was the easiest best option I could think of.

The other option would be to let the provider modules (charts_google and charts_highcharts) hook into the admin forms and other places.

It might need a re-think of how to implement it - maybe for a D8 version.

ryantollefson’s picture

This might be a lot of work/not possible, bu perhaps the scatter chart could be adapted to achieve the same thing? https://developers.google.com/chart/interactive/docs/gallery/scatterchart

Pierre.Vriens’s picture

Ryan, I don't quite understand (from your link) what the relationship of such polar (radar?) chart is with a scatter chart. Can you explain why you think so?

renatabin’s picture

Hi all, I'm very very new in Drupal and I need some help about polar charts and how to insert them in a module's form.
I've followed John Cook's suggestions and I've written new code lines in charts.pages.inc, charts.highcharts.inc etc.
Then I need to put a polar charts inside my form, so I've thought I could write something like:

$form['example'] = array (
'#type' => 'chart',
'#title' => 'A polar chart',
'#chart_type' => 'polar', (is it correct?)
'#chart_library' => 'highcharts',
and so on...
);

$form['example']['datafromDB'] = array(
'#type' => 'chart_data',
'#data' => ???? How?
.... and???
I don't know what parameters and data to pass to obtain a polar chart and, more, I get an error like "Notice: Undefined index: #polar in _charts_highcharts_populate_chart_options() (line 72 of /var/www/html/drupal/sites/all/modules/charts/modules/charts_highcharts/charts_highcharts.inc)."
Some help?
Thank you so much!

john cook’s picture

@RenataBin
It's been a while since I wrote that - and the client I wrote it for changed their minds and didn't want a polar chart any more.

But from what I can remember you need to set:

'#chart_type'' => 'line', // or 'bar'.
'#polar' => TRUE, // <-- render the chart as a polar chart.

Also, '#data' => array(/* list of values for the graph to plot */),

I found the example graphs useful for constructing my graph's render arrays. Also, Google charts api documentation might be helpful (https://developers.google.com/chart/) as I believe that Charts was designed around it.

renatabin’s picture

Thanks John,
Ok, it works! But... a little problem: suppose I get my data from a DB, in a two columns-360 rows array, just like:

.. (Array, 360 elements)
0 (Array, 2 elements)
0 (String, 1 characters ) 0
1 (String, 8 characters ) 0.005041
1 (Array, 2 elements)
0 (String, 1 characters ) 1
1 (String, 8 characters ) 0.005641
2 (Array, 2 elements)
0 (String, 1 characters ) 2
1 (String, 8 characters ) 0.006241

and so on... Suppose its name is "$diagramdata", I thought I could write

'#data' => $diagramdata

Is it correct?
Thank you!

john cook’s picture

@RenataBin
Assuming you want one line on the graph you will want to end up with:
'#data' => array(0.005041, 0.005641, 0.006241, ...)

You could build it with a loop like:

$data = array();
foreach ($diagramdata as $value) {
$data[] = $value[1];
}
...
'#data' => $data,
svanp’s picture

The patch seems not to work for the current version of Charts. Is there any body who can update the patch? I am a complete newbie in this regard.

andileco’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Polar charts are an option in 8.x, but I do not plan to add them as an options for 7.x.