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
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
Comment #4
andileco commentedThis is looking good. Can I ask you to update the issue summary, @nikathone?
Comment #5
andileco commentedNevermind, @nikathone, sparing you the documentation!
Comment #6
andileco commentedLooking good from my end. @nikathone, can you review?
Comment #7
nikathoneLooks good to me. Thanks for the help with the issue description update and the code to that use the new API.
Comment #9
andileco commentedThanks, @nikathone!