class CustomChart extends HTMLElement {
constructor (data) {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
`;
this.canvas = this.shadowRoot.querySelector("canvas");
}
set data (data) {
this.canvas.role = "img";
this.canvas.ariaLabel = data.ariaLabel;
createChart(this.canvas, data.chart);
}
get data () {
return null;
}
}
function createChart (ctx, data) {
return new Chart(ctx, data);
}
customElements.define("custom-chart", CustomChart);