none
Pie chart does not loaded - ASP.NET MVC RRS feed

  • Question

  • 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?


    Monday, October 14, 2019 2:07 PM

All replies

  • There is no C# anywhere in that so this is not a C# question. It is a HTML question.


    Sam Hobbs
    SimpleSamples.Info

    Monday, October 14, 2019 3:05 PM
  • You can post to the MVC forum in ASP.NET forums.

    http://forums.asp.net/

    Monday, October 14, 2019 3:25 PM
  • You can post to the MVC forum in ASP.NET forums.

    http://forums.asp.net/

    Ok, I'm sorry
    Monday, October 14, 2019 3:35 PM
  • There is no C# anywhere in that so this is not a C# question. It is a HTML question.


    Sam Hobbs
    SimpleSamples.Info

    I'm sorry but I'm developing my app in C# so I thinked to post there. I'm so sorry 
    Monday, October 14, 2019 3:36 PM