I added the goolge stacked chart types for horizontal and vertical bars (cht=bhs and cht=bvs) to the google_charts module. Here is the patch, so that it could be integrated to the module.

Therefore i had to disable the simple coding for this type. Here is an example for the data schema:

$chart = array(
    '#plugin'    => 'google', // Google Charts API will be used
    '#type'     => 'hbar2Ds', // To show a horizontal stacked 2D bars chart
    '#height'   => 100, // in pixels
    '#width'    => 300, // in pixels
    array(
      '#legend' => t('Percentage'),
      '#color' => '4D89F9,C6D9FD',
      array('#value' => "20|100", '#label' => '20%'),
    ),
  );
  
  return charts_chart($chart);

Comments

carsten müller’s picture

Hi,

here is a patch to be able to overwrite the default chart settings from the chart settings page. I need it to overwrite the #color attribute of the first chart in the settings without changing the chart color settings of series 1. So it is possible to set multiple custom colors for this series when the type is hbar2Ds without changing the default settings.

in chart.inc

/**
 * Merge the default series attributes with the actual data.
 */
function _chart_series_attributes(&$data, &$value, &$settings) {
  foreach ($settings['#series_attributes'] as $attribute) {
    if (empty($data[$attribute])) {
      $data[$attribute] = $settings[$attribute][$value];
    }
  }
}
carsten müller’s picture

Title: Patch to add the google stacked bars type to the google charts module » Patch to fix empty labels in custom attributes
StatusFileSize
new2.18 KB

Hi,

here is also another patch for the google_charts.inc. If the label for a chart is not set it will be set with NULL. But then an empty param for the label (&chl=) will be submitted.
Here is a small fix

kenorb’s picture

Status: Patch (to be ported) » Needs review
brmassa’s picture

Carsten,

the problem pointed on comment #2 fixed by another way. The problem with your patch is that if the 1st and the 3rd series have labels, but not the 2nd, the 2nd will get the 3rd label.

im now going to give a look on the other patches..

regards,

massa

quicksketch’s picture

Status: Needs review » Closed (won't fix)

The D6 version of the module is no longer being updated. Please reopen if the same problem exists in the D7 version.