Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Global Controller Registration Support via filamentChartJsRegister #15822

Closed
wants to merge 2 commits into from

Conversation

BukkitAT
Copy link
Contributor

Description

This pull request introduces a mechanism for globally registering Chart.js controllers and elements using a new global array: window.filamentChartJsRegister. Currently, Filament's chart implementation supports adding additional plugins via window.filamentChartJsPlugins passed in the chart configuration. However, this method does not support registering new controllers—such as those required for treemap charts—which must be registered globally using Chart.register().

With this change, before initializing a chart, the code checks if window.filamentChartJsRegister is defined and contains any entries. If so, it registers these controllers/elements globally via Chart.register(...window.filamentChartJsRegister). This ensures that custom controllers, which cannot be registered via the plugins array, are available for use without affecting existing functionality.

Visual changes

No visual changes are expected. The modification only impacts the chart initialization process to support additional controller registration. Charts that rely on custom controllers (e.g., treemap charts) will now render correctly.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin
Copy link
Member

Hi, apologies but we are no longer accepting new features for v3 as per #13744. Also, please check out our contributing guide which talks about proposing the feature before submitting the PR, to ensure you aren't spending time building something that we won't merge.

In v4, I am considering building a new system for asynchronously loading plugins for Chart.js (and the rich editor). In this implementation, it will load the JS on pages even without charts.

@danharrin danharrin closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants