I'm using the Charts module and I've been trying to set up a simple pie chart that has HTML in the tooltips. We would like the HTML to be menu links, but they can just be manually coded into the chart code. However, I have not been able to get this working. Looking at the API (http://cgit.drupalcode.org/charts/tree/charts.module#n46) it seems there is an option to set:
'#tooltips_use_html' => TRUE
But I haven't been able to get it to work. I've tried the following code in the body of a node:
$chart = array( '#type' => 'chart', '#title' => t('Pie Chart with tooltips (no data labels)'), '#chart_type' => 'pie', '#chart_library' => 'google', // Allowed values: 'google' or 'highcharts' '#legend_position' => 'right', '#data_labels' => FALSE, '#tooltips' => TRUE, '#tooltips_use_html' => TRUE ); $chart['pie_data'] = array( '#type' => 'chart_data', '#title' => t('Gender'), '#labels' => array('<a href="http://localhost:8888/node/246095/edit">Male</a>', 'Female'), '#data' => array(10, 20), ); /* $chart['pie_data_item'] = array( '#data' => 10, '#color' => 'NULL', '#title' =>'<a href="http://localhost:8888/node/246095/edit">Male</a>', ); $chart['pie_data_item'] = array( '#data' => 20, '#color' => 'NULL', '#title' =>'Female', ); */ $example['chart'] = $chart;
In place of
$chart['pie_data'] I've also tried the commented out code
$chart['pie_data_item']. With the first approach I do get a result, but the HTML is not rendered correctly, and labels are being treated as the tooltips? Is there anyway to tell what HTML goes into each tooltip?
EDIT: Using the patch in https://www.drupal.org/files/issues/2209467-9--raw_options.patch as recommended by Pierre.Vriens I was able to enable the #raw_options array. I've looked around and haven't found any clear documentation what that array is supposed to look like though. How would I use #raw_options to generate HTML tooltips?