NOTE: this now only is needed for Google Charts as reported in #9

seems like #raw_options is being ignored; I'm not sure whether the patch attached implements what was originally meant, but it does work for me and allows me to set:

$chart['#raw_options'] = array('curveType' => 'function');

to get a nice curved version of a line chart.

my patch adds the following to _charts_google_populate_chart_options():

if (isset($chart['#raw_options'])) {
    foreach($chart['#raw_options'] as $key => $value) $chart_definition['options'][$key] = $value;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Title: #raw_options ignored » #raw_options exists not actually implemented
Status: Patch (to be ported) » Active

Thanks! You're right that #raw_options is not currently used. You mentioned that you had a patch, could you upload it here? We'll need to support both implementations of course, so if it'd be possible to make it work with both Highcharts and Google charts that would be great. We also need to provide a demonstration/test of the #raw_options ability in the charts.examples.inc file.

andrea at ghanaweb’s picture

patch for 7.x-2.0-rc1 here:

diff -ur charts-7.x-2.0-rc1/modules/charts_google/charts_google.inc charts/modules/charts_google/charts_google.inc
--- charts-7.x-2.0-rc1/modules/charts_google/charts_google.inc	2014-03-28 10:37:14.000000000 -0400
+++ charts/modules/charts_google/charts_google.inc	2014-03-28 10:37:59.000000000 -0400
@@ -90,6 +90,8 @@
   $chart_definition['options']['animation']['duration'] = 10000;
   $chart_definition['options']['animation']['easing'] = 'out';
 
+  if (isset($chart['#raw_options'])) $chart_definition['options'] = $chart['#raw_options'];
+
   return $chart_definition;
 }
 

NOTES:
1) there is a blank line at the end of the patch; if it doesn't apply cleanly, it shouldn't be hard to make out the change
2) the "if" part may be unnecessary.
3) I can't test highcharts, sorry.

quicksketch’s picture

The suggested approach would also completely wipe out any existing options. At the very least it should be merged with the existing options instead of replacing them entirely.

quicksketch’s picture

Status: Active » Needs work
FileSize
2.01 KB

This probably isn't entirely helpful, but I put together a solution for Highcharts that merges in options. If we can combine a similar approach for Google charts, we can commit both when they have equivalent functionality.

arruk’s picture

Andrea, could this be used to add a pie hole? If so, would you mind sharing what the syntax would be?

Pierre.Vriens’s picture

Title: #raw_options exists not actually implemented » Implement the already existing #raw_options
Parent issue: » #2395779: Charts 7.x-3.x Release

Quite some (open) issues exist that refer to this issue. I suggest using this issue as the parent of those issues.

Also, it would be great if anybody can help to get the status of this issue moving forward (such as "Reviewed and tested by the community") ...

Note: I'm slightly adapting the title of this issue to better reflect what this issue is really about.

Pierre.Vriens’s picture

Title: Implement the already existing #raw_options » Pass library-specific options via existing #raw_options
Priority: Normal » Major
Parent issue: #2395779: Charts 7.x-3.x Release » #2382151: Charts 7.x-2.0 Release

Little by little I start to understand what this #raw_options is all about, why they are included in parts of the charts coding already (but don't actually work yet ...), and also what the missing pieces are to really facilitate using them. The information shared in #2304323: Easy way to add custom Charts properties was very helpful for me to understand what this issue is all about, and especially what the missing pieces (patches) are to finalize "this" issue (i.e. '... a similar approach for Google charts ...' as requested in #4). I think to soon be able now to get this issue in status fixed ...

Moreover the various (child) issues of this issue seem to be like variations of this issue. So that after we fix "this" issue, all those child issues may be considered as something like a variation of this issue (each child issue is about yet some other library specific options to be added). Therefor I'm going to further adapt the title of this issue, inspired by the last phrase in #2146261-2: Add an extra #description to data items for better tooltips.. And I'm going to even update the parent issue of this issue, i.e. try to get it in the 7.x-2.x release added (instead of waiting for the future 7.x-3.x release). And by giving this issue a higher priority, I'd hope that the amount of these kinds of issue variations gets reduced (or can be responded with something like 'Yet another usecase of #raw_options, as explained within the docu that comes with the charts module').

Pierre.Vriens’s picture

Category: Bug report » Feature request
drunken monkey’s picture

Status: Needs work » Needs review
FileSize
2.64 KB

It seems Nate already committed the patch in #4, probably accidentally, along with #2247551: Clean examples.

The attached patch should be all that's needed to implement the same for Google Charts. Please have a look!

Jed_BH’s picture

I needed to display a chart correctly in a block view in a localized page that flips from LTR to RTL when the language switches from English to Arabic, and as usual things break upon doing that. In the case of Charts Highcharts the legend, labels and tooltips were not displaying correctly.

So, I submitted an issue then asked on askdrupal where Pierre.Vriens advised me to apply patch #4. I tried to but since I was running 7.x-2.x-dev(2015-Feb-13) I got:

Reversed (or previously applied) patch detected! Assume -R? [n]

Raw options worked for me without applying anything.

drunken monkey’s picture

Raw options worked for me without applying anything.

As written, the patch for Highcharts (#4) was already committed, #9 just implements it for Google Charts, too.
But thanks for verifying that it at least works for Highcharts, good to know!

elshae’s picture

I have an issue open at Drupal Answers, but I am currently at a stand-still. I am trying to put my Google Chart API code into a node and have the tooltips have links to other nodes. I applied the Google #raw_options patch and it was successful, but I still have no idea how to declare the #raw_options for HTML tooltips. I've added the following code to a custom module as well as suggested by Majed.Bahar on their Drupal Answers post:

function my_module_chart_alter(&$chart, $chart_id) {
	$chart['#tooltips_use_html'] = TRUE;

	$chart['#raw_options'] = array(
				'labels' => array(
						'useHTML' => True
				),
				'legend' => array(
						'useHTML' => True,
						'rtl' => True
				)
	);
}

And still have no luck... How can I use #raw_options to have a link in my tooltips?

amaria’s picture

@elshae, if you are building the chart yourself, use chart_data_item instead of raw options, and then try the patch at https://www.drupal.org/node/2876131

clemens.tolboom’s picture

Title: Pass library-specific options via existing #raw_options » Google Charts only: Pass library-specific options via existing #raw_options
Component: Chart API » Google Charts integration
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

As #4 is already applied we only need a Google Charts review of #9

In #12 @elshae applied it

I applied the Google #raw_options patch and it was successful

So I mark this as RTBC.

andileco’s picture

Status: Reviewed & tested by the community » Fixed
andileco’s picture

Status: Fixed » Closed (fixed)