Empty charts added on every save, can't remove charts

Created on 30 August 2023, over 1 year ago
Updated 26 October 2023, about 1 year ago

Problem/Motivation

Every time I save content an empty chart being added.
Moreover they can't be removed. It seems none of the charts actually can

Steps to reproduce

- Create a chart field in any content type and choose unlimited values
- Go in edit mode and save content
- Every save adds and empty chart to content

๐Ÿ’ฌ Support request
Status

Fixed

Version

5.0

Component

Miscellaneous

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly rmorelli

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

Comments & Activities

  • Issue created by @rmorelli
  • ๐Ÿ‡ฆ๐Ÿ‡ทArgentina tguerineau

    Hi @rmorelli,

    I've tried to reproduce this issue on a Drupal 10 environment with PHP 8.1 and the Charts module version 5.0.x-dev, which is the same version mentioned in this issue.

    Here are the steps I followed:

    1- I added a chart field to the Article content type with unlimited values.
    2- Created a new article without any data in the chart field and saved it. I observed that no empty chart was added.
    3- I edited the article but not the chart field and saved it again. Still, no empty chart was appended.
    4- Finally, I added data to the chart field, saved the article and then I went to edit mode and saved it. I observed the chart displayed correctly with the added data.

    Upon following these steps, I couldn't replicate the issue of empty charts being added or being unable to remove them.

    Questions:

    - Could you provide more details on your environment?
    - Are there any other modules interacting with the Charts module?
    - Any special configurations or settings you have applied?

    Thank you!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly rmorelli

    Hi,

    - Drupal Version 9.5.8
    - Web Server Apache/2.4.56 (Debian)
    - PHP Version 7.4.33 (I should upgrade but php 8.0 breaks an old site on the same server)

    I am developing a custom module with no interactions going on, I had "Chart suite" installed but removed when started testing Charts.
    I have no clue about other modules interacting, attached non core module list

    I can provide you an account on the web site I am doing tests.

    Moreover, using unlimited values, field configuration form has 2 charts for default values
    Still can't see where charts can be removed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States andileco

    Moving this to a support request, as I have not experienced this and @tguerineau was not able to replicate.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States helianthropy

    Iโ€™m experiencing this using Charts with the Paragraphs module on Drupal 9.5 and PHP 7.4 (will test on PHP 8.1). Iโ€™ve also noticed this behavior with Address fields (with default values set) in a Paragraphs module under Drupal 7.

    Have you tried changing default values for the Charts module to see if that makes it reproducible (Iโ€™ve done so in my installโ€”specifically perhaps chart type and definitely the colors)?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly rmorelli

    hi @Heliantropy

    I actually switched back to Drupal 9.5.11 and going to test on this fresh installation soon.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States helianthropy

    @rmorelli

    Looking forward to hearing about the experience. I found that if I set a fixed maximum, it creates that fixed maximum right away.

    The duplication is an annoyance, but not being able to remove extra instances is a real challenge.

    Iโ€™m using billboard.js via CDN and am seeing some javascript errors from it of "f is undefined." Going to try a local library to see if that makes a difference.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly rmorelli

    The website encountered an unexpected error. Please try again later.
    TypeError: Drupal\charts\Element\ChartDataCollectorTable::getCategoriesFromCollectedTable(): Argument #2 ($type) must be of type string, null given, called in /home/www/drupal-9.5.11/web/modules/contrib/charts/src/Element/Chart.php on line 348 in Drupal\charts\Element\ChartDataCollectorTable::getCategoriesFromCollectedTable() (line 722 of modules/contrib/charts/src/Element/ChartDataCollectorTable.php).

    Got this fresh new error.
    Moreover I can't upload csv anymore.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States andileco

    I think the main issue is really here: https://www.drupal.org/project/drupal/issues/2980806 ๐Ÿ› Fields with unlimited cardinality show 1 extra input field Needs work

    However, I will try to find a way to address it.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    10 pass
  • @andileco opened merge request.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States andileco

    In the merge request/patch (you can download from the merge request), I've added a method that checks if there are data before adding the chart. For me, solving the Core issue would be ideal, but you can use this patch in the meantime, that should help.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly rmorelli

    I confirm that a new empty chart is being added on every save on drupal 9.5.11

    No default chart type is selected (area, bar, ...) so saving field definition throws error in #5

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    10 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    10 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    10 pass
  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States andileco

    Marking this as fixed. If we want to go back and provide a better solution later, let's do that in a separate ticket.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024