Hello Team,
Help me bind sales data to my line graph
// This is to get sales performance by Month on the Line Graph and the chart area
public JsonResult GetSalesPerformanceOnGraph()
{
ASPNETMASTERPOSTEntities db = new ASPNETMASTERPOSTEntities();
var previousYear = (DateTime.Now.Year - 1);
var sales = db.tblSales.ToList();
var salesByMonthAmount = (from a in sales
where DateTime.Parse(a.OrderDate).Year > previousYear
group a by DateTime.Parse(a.OrderDate).Month into g
select g.Sum(c => c.TotalAmount)).ToArray();
var salesMonths = (from a in sales
where DateTime.Parse(a.OrderDate).Year >
).ToList();
return Json(new , JsonRequestBehavior.AllowGet);
}
Vishal JoshiPosted Nov 21, 2023, 12:46 PM
Hello,
API Code looks good. you need to return data like the below code.
You need to call API and bind data to the chart. please check out below code and add it to your respective chart.js file.
Thanks
Vishal Joshi
Emmmanuel FIADUFEPosted Nov 21, 2023, 3:21 PM
Thank you Mr Vishal, it is working