Estoy tratando de crear un gráfico js popover pero recibo el error:
No se pudo crear el gráfico: no se puede adquirir el contexto del elemento dado
Creo que esto probablemente suceda porque la etiqueta del lienzo se crea dinámicamente, pero no estoy seguro de cómo solucionarlo. ¿Algunas ideas? Este es el código js que estoy usando:
$(function() { $('[data-toggle="popover"]').popover({ html: true, content: '<canvas id="myChart" width="400" height="400"></canvas>', }).on('shown.bs.popover', function() { new Chart($('#myChart'), { // The type of chart we want to create type: 'line', // The data for our dataset data: { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', data: [0, 10, 5, 2, 20, 30, 45], }] }, // Configuration options go here options: {} }); });HTML:
<button type="button" class="btn btn-lg btn-primary" data-toggle="popover" title="Good vs. Evil Winrate" data-placement="bottom">Who's Winning?</button>