yaxis gets filed with same values when there are not enough data values

Created on 18 April 2017, about 8 years ago
Updated 11 March 2025, 2 months ago

I am partly recreating example 4 from here https://www.drupal.org/node/2423443#example4 β†’
with the values below:

$chart['male'] = array(
  '#type' => 'chart_data',
  '#title' => t('Male'),
  '#data' => array(0, 2, 0),
  '#suffix' => 'lbs',
);
$chart['xaxis'] = array(
  '#type' => 'chart_xaxis',
  '#labels' => array('Jan', 'Feb', 'Mar'),
);

And I get the output in the first attachment:

Notice how the Yaxis says 0, 1, 1, 2, 2 instead of 0, 1, 2.

Then I change the code to:

$chart['male'] = array(
  '#type' => 'chart_data',
  '#title' => t('Male'),
  '#data' => array(0, 3, 0),
  '#suffix' => 'lbs',
);
$chart['xaxis'] = array(
  '#type' => 'chart_xaxis',
  '#labels' => array('Jan', 'Feb', 'Mar'),
);

Notice that I only changed 2 to 3 in the data array, and I get a proper Yaxis, that goes from 0 to 4 in proper steps:

I've been trying to debug this for the better part of the day, but I can't seem to locate the source of it.
It looks like, when there are not enough "big" values to create many rows in the Y axis, the system adds duplicates in order to create 5 rows, or something like that.

Any ideas?

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Chart API

Created by

πŸ‡¬πŸ‡·Greece bserem

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