Thank you very much for this very light, straightforward module. It is amazing! Do you have any plans to further develop it like to add possibility to change the color for chart?
Added. sorry typo in the title not chat -> but chart

Comments

cvangysel’s picture

I'm currently not planning on implementing any additional features, but I might do so if I've got some spare time left. If you write a patch to get this started, then I'll probably be more tempted to get this functionality in. ;-)

sinasalek’s picture

StatusFileSize
new908 bytes

Hope it's tempting enough :)

sinasalek’s picture

StatusFileSize
new908 bytes

Hope it's tempting enough :)

sinasalek’s picture

Note that colors should be like this and should be passed in options array
Each color will be used for each series

'colors' => array(
  '#ffffff',
  '#666666',
);
guillaumev’s picture

Title: Custom colors for chats? » Provide more control on charts ?
Status: Active » Needs review
StatusFileSize
new3.63 KB

Here is a new patch that includes the patch of sinasalek, but also provides more control over Highcharts by giving the possibility to override the different settings of the chart.

rooby’s picture

Title: Provide more control on charts ? » Provide more control over chart options
Component: User interface » Code
Status: Needs review » Needs work

We definitely need to be able to have more control, however I don't know about adding a

+ 'highcharts' => array(),

to theme_visualization().

The reason being is that this is supposed to be an API that deals with other plugins.
The point of an API is not to have to add a bunch of things specific to each plugin.

Maybe "highcharts" could become "plugin_options" or similar, and be used by all plugins for their own needs.

The GoogleVisualizationAPIHandler will also have to be updated to use the new options.

Then we have to make these things configurable via the views UI, but that's another story for another issue.

Also, some nit-picking:

+++ b/includes/plugins/highcharts.inc
@@ -84,23 +90,41 @@ class HighchartsHandler implements VisualizationHandlerInterface {
+    ¶
+    if (isset($options['highcharts']['plotOptions'])) {
+      $plotOptions = array_merge($plotOptions, $options['highcharts']['plotOptions']);
+    }
+
+    $highchart->plotOptions = _visualization_array_to_object($plotOptions);
+    ¶
+    if (isset($options['colors'])) {
+      $highchart->colors = (object) $options['colors'];
+    }
+    ¶
+    $credits = array(
+      'enabled' => FALSE,
+    );
+    ¶
+    if (isset($options['highcharts']['credits'])) {
+      $credits = array_merge($credits, $options['highcharts']['credits']);

Trailing spaces on empty lines.

+++ b/includes/plugins/highcharts.inc
@@ -140,7 +164,7 @@ class HighchartsHandler implements VisualizationHandlerInterface {
   public function supportedTypes() {
-    return array('line', 'column', 'pie');
+    return array('line', 'column', 'pie', 'bar');

This seems like maybe it should be in its own issue.

+++ b/visualization.module
@@ -104,3 +106,26 @@ function visualization_plugin($type = FALSE) {
+    foreach ($array as $name=>$value) {

Missing spaces around the =>

+++ b/visualization.module
@@ -104,3 +106,26 @@ function visualization_plugin($type = FALSE) {
+    foreach ($array as $name=>$value) {
+    $name = trim($name);
+    if (!empty($name)) {
+      $object->$name = _visualization_array_to_object($value);
+    }
+    }

Indentation issue.

rooby’s picture

Status: Needs work » Needs review
StatusFileSize
new7 KB

Here is my take on this.

It is baseed on the patch in #5 with some changes:
* template_preprocess_visualization() has been changed to template_process_visualization(). This is to allow overrides to happen in other preprocess functions before we do the rendering. It is still possible to override things after by using other process functions. See the other the functions run at theme().
* Renamed the "highcharts" parameter to "chart_options" so we can use that same name for all plugins.
* It now merges the entire chart_options array, instead of individual chart, plotOptions, and credits overrides. This allows much greater ability to override.
* Removed all use of objects in HighchartsHandler::render(). This is because when this is passed into drupal_add_js() as settings it is encoded into JSON, which means the arrays will be converted into js objects or arrays based on content. This also means we can do away with the array to object conversion.
* Adds support for the new chart_options parameter to the google plugin.
* 'title' is removed from $chart_options defaults in the google plugin because it is already handled by $options['title'] so shouldn't also be handled by $options['chart_options']['title']. This is also in line with the way the highcharts one works, which is another good thing.
* The google plugin size default are explicitly set to 100%, instead of allowing for $options['width'] & $options['height']. Correct me if I'm wrong but those variables never exist anyway right?

This is working for my usage. I am using highcharts and haven't had a chance to test overriding google viz yet.

Also, it seems like maybe colors could go in chart_options? Thoughts?

rooby’s picture

Title: Provide more control over chart options » Provide more ability to override chart options
haggins’s picture

I did not apply your patch yet. But from your description and by reviewing the code it looks good for the google part.

It also makes sense to set width and height to a default value and make it possible to overwrite it by $chart_options as this is a configuration option of i.e. Line Chart.

haggins’s picture

Issue summary: View changes

Added. sorry typo in the title not chat -> but chart

AgentJay’s picture

Issue summary: View changes

I tried to apply the patch from #7 and I get the error:

Fatal error: Cannot redeclare class HighchartsHandler in /srv/www/testalpha/sites/all/modules/visualization/includes/plugins/highcharts.inc on line 7

I am not sure why as I can't seem to find where it HighchartsHandler is declared twice

AgentJay’s picture

Niremizov’s picture

Cannot apply patch in #7 to the current dev version.

Niremizov’s picture

Updated patch from #7, so it is appliable to the latest dev version. Created a patch and not commited, becouse this patch should come in next minor module release, but firstly I should create stable version (should make it in short time).

PS: 'colors' moved into charts_options.

eebanos’s picture

Hi guys, any ideas on how to support stacked columns like here?

stiknoltz’s picture

Not sure if this is the right queue for this, but it seemed applicable.

I modified includes/plugins/google_visualization_api.inc to allow for yAxis min and max values as provided by the Google Visualization API.

mradcliffe’s picture

I re-rolled the patch from #13 so that it applies against 7.x-1.x as well as the latest beta version, and I created an interdiff between #13 and #16.