chartjs / chartjs/Chart.js

Event listeners for plugin lifecycle methods

Open
#11,200 4 comments 0 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Feature Proposal

Event listeners for plugin lifecycle methods. Rather than needing to create a "standardized" plugin object which lives within the chart ecosystem, you could easily just attach some listeners to an instance of a plugin in certain situations, and remove them imperatively. This would make it much easier to have UI separate from the chart which reflects data of the chart (ex. a custom React legend, which shows all the datasets and allows toggling).

Today it seems like chart.platform.addEventListener supports things like clicks and mouse moves, but not plugin lifecycle methods like "afterUpdate"

### Possible Implementation

Simply exposing a function `chart.addEventListener('afterUpdate', fn)` allowing users to add listeners.

This could be hacked today by adding a custom plugin which attaches an "events" object to Chart instances, allowing callers to hook into any of the plugins methods.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.