Pie chart does not loaded - ASP.NET MVC

  • Thread starter Thread starter thereisnopatchforhumancruelty
  • Start date Start date
T

thereisnopatchforhumancruelty

Guest
Hi,

I have a .cshtml file which contains the view of my Web App.

In a section I have:

<div class="col-md-6">
<div class="box-header with-border">
<h3 class="box-title">Hosts Situation</h3>
</div>
<div class="box-body">
<canvas id="piechart" style="height: 264px; width: 429px;"
width="529" height="264">
</canvas>
</div>
</div>

and in the windows.onload = function() I have:

var pieChartContext = document.getElementById("piechart").getContext("2d");
new Chart(pieChartContext, {
type: 'pie',
data: pieChartData,
options: {
legend: {
display: true,
position: 'right'
},
responsive: true,
maintainAspectRatio: false
}
});

where pieChartData is:

var pieChartData =
{
labels: ['GOOD', 'WARN', 'BAD'],
datasets: [{
backgroundColor: ['#00e600', '#e6e600', '#E60000'],
data: [1, 1, 1] //1, 1, 1 are example values
}]
};

But this piechart is not loaded in the page. How can I solve that?

Continue reading...
 
Back
Top