I’m trying to integrate data from a database into Chart.js, but I’m encountering an error: Uncaught SyntaxError: expected expression, got ‘&’
Here is the code in the controller:
for (int i = 1; i <= days; i++)
{
daysMonth.Add(string.Format(""Day {0}"", i));
}
ViewBag.XLabelCommission = string.Join(", ", daysMonth);
This is the returned result values of @ViewBag.XLabelCommission
: "Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7", "Day 8", "Day 9", "Day 10", "Day 11", "Day 12", "Day 13", "Day 14", "Day 15", "Day 16", "Day 17", "Day 18", "Day 19", "Day 20", "Day 21", "Day 22", "Day 23", "Day 24", "Day 25", "Day 26", "Day 27", "Day 28", "Day 29", "Day 30", "Day 31"
And when I put it into the chart as label.
var myChart1 = new Chart(ctx1, {
type: 'line',
data: {
labels: [@ViewBag.XLabelCommission],
datasets: [{