Chartjs-Loading ViewBag data into a chart.js multichart

1👍

If it is an C# Array in the ViewBag:

var outcomeData = @Html.Raw(Json.Encode(@ViewBag.ChartOutput));

use Json.Encode and Html.Raw

Usefull Links:


If it is a String in the Viewbag:
You can use the value from the ViewBag in JS like this:

var outcomeData = '@ViewBag.ChartOutput';

then you dont need the Html.Raw

Leave a comment