Problem/Motivation

Sometimes a chart library + chart type combination may require additional options to be set. For example, the Highcharts library has a "solid gauge" chart type that requires "steps" and associated colors. It wouldn't make sense for these settings to be a part of the core Charts module, as it would add a lot of code that isn't relevant for all the libraries. While we already have library-specific settings, these are set globally and can't be changed on a per-chart basis through the UI.

Proposed resolution

Charts Core Schema and Configuration Updates

  • Add library_type_options field to the charts configuration schema to store chart type-specific settings
  • Create new schema mapping for charts.library_plugin.*.options.* to handle library-specific chart type configurations

Highcharts Solid Gauge Implementation

In order to demonstrate how the new feature can be used (so that other developers will add their own features), add code that supports the Highcharts "solid gauge" chart type:

  • Add a new "Solid Gauge" chart type with support for configurable min/max values and up to 4 color stops with positions
  • Update composer requirements and library definitions to include the Highcharts solid gauge (JS) module
  • Implement solid gauge-specific form elements for configuring gauge appearance (min/max values, stop positions, and colors)
  • Add logic to generate appropriate Highcharts configuration for solid gauge charts including pane settings

Base Framework Enhancements

  • Extend the ChartInterface with addBaseSettingsElementOptions() method to allow libraries to add type-specific form elements
  • Modify BaseSettings element to dynamically load and display library/chart type-specific options in the UI
  • Add AJAX refresh functionality for chart type selection to update available options
  • Updat the Chart element and Views integration to pass through library type options

Developer Experience

  • Libraries can now implement chart type-specific configuration forms that only appear when relevant
  • Options are stored per-chart rather than globally, allowing different charts to have different settings for the same chart type
  • The framework gracefully handles chart type validation and fallback when switching between libraries

User interface changes

The settings form now has a new fieldset with form fields when the appropriate library and chart type combination is made.

Issue fork charts-3525857

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

nikathone created an issue. See original summary.

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

andileco’s picture

Status: Active » Needs work

This is looking good. Can I ask you to update the issue summary, @nikathone?

andileco’s picture

Issue summary: View changes

Nevermind, @nikathone, sparing you the documentation!

andileco’s picture

Status: Needs work » Needs review

Looking good from my end. @nikathone, can you review?

nikathone’s picture

Assigned: nikathone » Unassigned
Status: Needs review » Reviewed & tested by the community

Looks good to me. Thanks for the help with the issue description update and the code to that use the new API.

  • andileco committed 4f9fa02e on 5.1.x authored by nikathone
    Issue #3525857 by andileco, nikathone: Allow chart plugins to add more...
andileco’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, @nikathone!

Status: Fixed » Closed (fixed)

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