[Chartjs]-How to implement Chart.js in ASP.NET Core MVC properly?

1👍

You can open the developer tools and you should see this error:
enter image description here

This is because you call the code of C# in js, what you actually fill in the array is a variable, not a string:
enter image description here

You can add quotes to convert it to a string:

@if (TempData["success"] != null)
{
    foreach (var item in ViewBag.States)
    {
        if (item == "completed")
        {
            @:completed.push('@item');
        }
        else if (item == "no-answer")
        {
            @:no_answer.push('@item');
        }
        else if (item == "busy")
        {
            @:busy.push('@item');
        }
        else if (item == "failed")
        {
            @:failed.push('@item');
        }
    }
}

Test Result:

enter image description here

enter image description here

Leave a comment