why would you need 360 columns?
Im sorry I ment 360 rows with 2 columms
The forum members cannot see your code
Here is my code:
In this example I used Data from 1 month
public List<ChartData> MonthDates()
{
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;
int Days = DateTime.DaysInMonth(year, month);
var DateList = new List<ChartData>();
var GetDate = new DateTime(year, month, 1);
for (int i = 0; i != Days; i++)
{
var chart = new ChartData();
chart.name = GetDate.ToShortDateString();
chart.value = 0;
DateList.Add(chart);
GetDate = GetDate.AddDays(1);
}
return DateList;
}
[HttpGet("SoldItems")]
public async Task<IActionResult> SoldItems()
{
var items = await _dbContext.placedOrderGroups.ToListAsync();
var SoldChart = new List<ChartData>(MonthDates());
var test = new DateTime(2019, 6, 11);
string day = test.Day.ToString();
foreach (var item in SoldChart)
{
var getValue = items.Where(x => x.Time.ToShortDateString() == item.name).ToList();
var X = SoldChart.FirstOrDefault(x => x == item);
string RemoveYear = X.name.Substring(0, X.name.Length - 5);
string newDate = RemoveYear.Replace("-", " / ");
X.name = newDate;
int NewValue = 0;
if (getValue.Count > 0)
foreach(var x in getValue)
NewValue = NewValue + x.TotalProduct;
SoldChart.FirstOrDefault(x => x == item).value = NewValue;
}
return Ok(SoldChart);
}