chartjs / chartjs/Chart.js

[plugin][HTML Legend]: Support Shadow Dom

Open
#10,624 0 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

The plugin uses `document.getElementById(id)` and therefore cannot find elements within a Shadow DOM.

```
options: {
plugins: {
htmlLegend: {
// ID of the container to put the legend in
containerID: 'legend-container',
},
legend: {
display: false,
}
}
},
```

### Possible Implementation

The plugin accepts nodes in addition to CSS selectors.

```
options: {
plugins: {
htmlLegend: {
getContainer: () => this.shadowRoot.querySelector('#legend-container'),
},
legend: {
display: false,
}
}
},
```

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.