1
I want to show statistics on what percentages of each answer given in a question from a survey I’m projecting here. I studied and saw several tutorials on how to use Charts.JS. It usually works if I create an independent page. But in this particular case I need the chart (in Pizza format) to appear in a Bootstrap Modal. But I’m not getting it at all. The modal is 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 that only a blank area appears but without the graph I programmed?
I couldn’t do it in the modal. I believe that this system that I am managing has some particularity or is not importing the jQuery correctly. Worse that I can not move because otherwise it disfigures the whole site. I had to do in a separate page even. But the chart size is 1550px wide and height even I forcing a smaller number. What can be?
– WitnessTruth