![enter image description here](https://i.stack.imgur.com/Gn46j.png)
![enter image description here](https://i.stack.imgur.com/kc0Yg.png)
Привет, я пытаюсь отобразить количество проданных туфель в чарте. У меня есть четыре таблицы, такие как tblCategory, tblProduct, tblTransaction и tblTransactionItem.
У меня есть три категории (MenShose, WemanShose и KiddsShose, как вы видите на картинке)
Я хочу отобразить на оси X название категории и размер шоса, как, например, на Wemanshose-35, там "WomenShe is categoryName, а 35 - размер шоса."
Когда
Я пытался так, но показывает неправильный результат.
public DisplaySales()
{
InitializeComponent();
chart1.Series.Clear();
var series = chart1.Series.Add("Series1");
series.XValueMember = "ProduktId";
series.YValueMembers = "TolatlSold";
series.Name = "Shose";
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.Series["Shose"].IsValueShownAsLabel = true;
series.CustomProperties = "LabelStyle=Left";
ShowTodaysSoldProduct();
}
// And here is what I'am trying but shows me wrong result. Please Help!
private void ShowTodaysSoldProduct()
{
using (Db db = new Db())
{
DateTime today = DateTime.Today;
DateTime tomorrow = today.AddDays(1);
var result = (from tr in db.TransactionItems
join t in db.Transactions on tr.TransactionId equals t.TransactionId
//join p in db.Products on tr.ProductId equals p.ProductId
join c in db.Categories on tr.CategoryId equals c.CategoryId
where t.TransactionDate >= today && t.TransactionDate < tomorrow
group tr by tr.categories.CategoryName into g
select new ProductSaled
{
ProduktId = g.Key, // Before g.Key I want to display CategoryName too
TolatlSold = g.Count()
}).ToList();
chart1.DataSource = result;
chart1.DataBind();
chart1.Show();
}
}
Я действительно не знаю, как их сгруппировать