The label of the first component in the chart is empty

Created on 19 August 2024, 4 months ago
Updated 13 September 2024, 3 months ago

Problem/Motivation

For the first component in the chart, the label appears empty. This issue occurs because if the key of the first element ($value) is an integer, it gets converted to an empty string. Consequently, when referencing the first element, $values[0] is not retrieved properly since it is interpreted as $values[''].

Steps to reproduce

  1. Create a Webform with questions that have integer options (radio buttons).
  2. Use the option values as 0, 1, 2 ... etc
  3. Make several submissions to the form.
  4. Go to the analysis page.
  5. Observe any type of chart (table, pie, column); the label of the first option is missing.

Proposed resolution

This issue was introduced in #3364950 🐛 PHP 8.1+ Compatiblity: Float to Int Conversion at Array Key Fixed .
The problem arises because integers are being converted to empty strings in the castNumeric() function. To fix this, we should replace the following :

if (empty($i)) {
  return '';
}

with:

if (empty($i)) {
  return 0;
}

This adjustment will ensure that integer keys are handled correctly and prevent them from being misinterpreted as empty strings.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India sushyl@gmail.com Pune

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024