In my project ı am trying to use a javascript chart with my datas on database,
firstly I have sent my data with viewbag
public IActionResult Index()
{
var student = _context.Student.Select(x => x.Name).ToList();
ViewBag.student = student;
var notes = _context.Student.Select(y => y.Note).ToList();
ViewBag.notes = notes;
return View();
}
So in javascript The premade chart has a code like this;
$('#graph2').graphify({
start: 'donut',
obj: {
id: 'lol',
legend: false,
showPoints: true,
width: 775,
legendX: 450,
pieSize: 200,
shadow: true,
height: 400,
animations: true,
x: [2000, 2001, 2002, 2003, 2004, 2005, 2006],
points: [17, 33, 64, 22, 87, 45, 38],
xDist: 90,
scale: 12,
yDist: 35,
grid: false,
xName: 'Year',
dataNames: ['Amount'],
design: {
lineColor: 'red',
tooltipFontSize: '20px',
pointColor: 'red',
barColor: 'blue',
areaColor: 'orange'
}
}
});
I want to add my viewbag datas into the x and point arrays i tried something like this;
@foreach(var item in (List<string>Viewbag.student)
{x.push(item);}
but it did not work at all.