Chartjs-How to split a List into View in C#

0👍

Try formatting your output. Something like below should work.

labels: @String.Join(",", Model.Select(x => $"'{x.NameArea}'"))

So basically what this is doing is instead of a foreach we are selecting just the name area from all of the models in your list. That Select is also adding single quotes around your NameArea using String Interpolation. From there we are doing a join to comma delimit the list.

Hopefully this works for you.

Leave a comment