chartjs / chartjs/Chart.js

Events can't be used with Legend plugin

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

Description

### Expected behavior

[This closed issue](https://github.com/chartjs/Chart.js/issues/11283) describes how not having events property in legend breaks onclick - mousedown behavior. The fix was implemented for Plugin, but Legend does not implement Plugin, so Legend still has a bug.

### Current behavior

What happens now in the [example](https://stackblitz.com/edit/angular-chart-js-xkhcjv?file=src%2Fapp%2Fapp.component.ts), is that legend's onClick is run twice, therefore disabling and enabling the signal immediately. In the [code ](https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.legend.js)it looks like mouseup and onClick are treated as the same event.

### Reproducible sample

https://stackblitz.com/edit/angular-chart-js-xkhcjv?file=src%2Fapp%2Fapp.component.ts

### Optional extra steps/info to reproduce

_No response_

### Possible solution

_No response_

### Context

_No response_

### chart.js version

4.4.0

### Browser name and version

_No response_

### Link to your project

_No response_

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.