I want to show statistics on what percentages of each answer given in a survey question I'm designing here. I studied and saw several tutorials on how to use Charts.JS. It works normally if you create a separate page. But in this particular case I need the graph (in the form of Pizza) to appear in a Bootstrap Modal. But I can not do it at all. The modal is left blank, and only the line chart of the Chart.JS documentation itself works.
I'm using the following code:
<canvas id="myChart" width="300" height="300"></canvas>
<script type="text/javascript">$('#ModalPadrao3').on('shown.bs.modal', function () {
var option = {
responsive: true,
};
var data = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
}
];
var ctx = document.getElementById("myChart").getContext('2d');
var myPieChart = new Chart(ctx,{type: 'pie', data: data, options: option});
});
</script>
What's wrong with only one blank area but no chart I've programmed?