Google chart chart_data_item with data value of zero won't render

Created on 13 June 2020, almost 5 years ago
Updated 11 March 2025, 2 months ago

A chart setup something like this will fail to render:

$chart = array(
  '#type' => 'chart',
  '#chart_type' => 'pie',
  'data' => array(
    '#type' => 'chart_data',
    '#title' => t('Title'),
    array(
      '#type' => 'chart_data_item',
      '#data' => 0,
    ),
    array(
      '#type' => 'chart_data_item',
      '#data' => 10,
    ),
  ),
);

The following change fixed this issue for me:

modules/charts_google/charts_google.inc

  ...
  $data_item = $chart[$key][$sub_key];
- if ($data_item['#data']) {
+ if (isset($data_item['#data'])) {
    $chart_definition['data'][$sub_key + 1][$series_number + 1] = $data_item['#data'];
  }
  ...
πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Google Charts integration

Created by

πŸ‡¬πŸ‡§United Kingdom mustanggb Coventry, United Kingdom

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    Thank you for your contributions to this issue. As Drupal 7 has reached its End of Life and is no longer supported, we are closing this issue. We encourage you to upgrade to a supported version of Drupal.

Production build 0.71.5 2024