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

CommentFileSizeAuthor
#3 moduli.txt16.57 KBrmorelli

Issue fork charts-3384225

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rmorelli created an issue. See original summary.

tguerineau’s picture

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!

rmorelli’s picture

StatusFileSize
new16.57 KB

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.

andileco’s picture

Category: Bug report » Support request

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

cecelias’s picture

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)?

rmorelli’s picture

hi @Heliantropy

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

cecelias’s picture

@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.

Edit: Local files didn't work. Using it on PHP 8.1 (Drupal 9.5.11) I’m still seeing the incremental creation of charts and no ability to remove additional charts. The javascript error is now gone, however.

rmorelli’s picture

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.

andileco’s picture

I think the main issue is really here: https://www.drupal.org/project/drupal/issues/2980806

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

andileco’s picture

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.

rmorelli’s picture

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

  • andileco committed 0d5bd1a9 on 5.0.x
    Issue #3384225: Empty charts added on every save, can't remove charts
    

andileco’s picture

Status: Active » Fixed

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

Status: Fixed » Closed (fixed)

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