Problem/Motivation

An undefined array key can occur if the $grouping_field is not included in the View in ChartsPluginStyleChart::extractGroupingColorsForSingleAxisChartType().

Warning: Undefined array key "field_KEY" in Drupal\charts\Plugin\views\style\ChartsPluginStyleChart->extractGroupingColorsForSingleAxisChartType() (line 1028 of modules/contrib/charts/src/Plugin/views/style/ChartsPluginStyleChart.php).

Proposed resolution

Fallback to a null value for $grouping_entity_field.

Remaining tasks

Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork charts-3624379

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

liam morland created an issue. See original summary.

liam morland’s picture

Assigned: liam morland » Unassigned
Status: Active » Needs review
StatusFileSize
new928 bytes

This patch is the contents of the merge request.

andileco made their first commit to this issue’s fork.

andileco’s picture

@liam morland, here's what I did to replicate the error:

  • I opened a view with a field not needed for rendering a chart
  • I opened the format settings and selected that field as the grouping field and applied the settings
  • I then deleted the field

I applied your patch, but it didn't actually remove said error for me. Instead, I needed to apply the same fix at line 603.

Then I tried to open the format settings for the chart, and it wouldn't open. There was a type error and another array key missing error, both of which were in the BaseSettings class. I made a couple updates to that file (see the MR), and that restored my ability to open the format settings.

Can you please let me know if this updated MR works for you?

liam morland’s picture

Yes, and I was having the problem with the settings as well. This fixes that for me.

andileco’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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