Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

[plugin][HTML Legend]: Support Shadow Dom

Open JaySunSyn opened this issue 3 years ago • 0 comments

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,
      }
    }
  },

JaySunSyn avatar Aug 23 '22 20:08 JaySunSyn