我想总结一下我的图表的数量列的值。
var db = Database.Open("OrdersContext");
var data = db.Query("SELECT ProductId,Quantity FROM OrderDetails");
var myChart = new Chart(width: 600, height: 400, theme: ChartTheme.Green)
.AddTitle("Product Sales")
.AddSeries("Default",
xValue: data, xField: "ProductId",
yValues: data, yFields:"Quantity")
.Write();
答案 0 :(得分:0)
试试此代码
var db = Database.Open("OrdersContext");
var data = db.Query("SELECT ProductId, SUM(Quantity) TotalQuantity FROM OrderDetails Group By ProductId");
var myChart = new Chart(width: 600, height: 400, theme: ChartTheme.Green)
.AddTitle("Product Sales")
.AddSeries("Default",
xValue: data, xField: "ProductId",
yValues: data, yFields:"TotalQuantity")
.Write();
此查询将为您提供每个产品数量的总和