//========================================================== //DASH BOARD VIEW========================================================== public List <ItemChart> GetDataForChart() { List <OrderBill> orders = this.GetOrderBillByIDStore(Infor.IDStore); List <ItemChart> itemCharts = new List <ItemChart>(); int currentMonth = DateTime.Today.Month; int LastSixMonth = currentMonth - 5; for (int i = LastSixMonth; i <= currentMonth; i++) { int month = i; int year = DateTime.Today.Year; if (month == 0) { month = 12; year -= 1; } if (month < 0) { month = 12 + i; year -= 1; } int countOrder = 0; foreach (OrderBill order in orders) { DateTime orderDate = order.Date; if (orderDate.Year == year && orderDate.Month == month) { countOrder++; } } ItemChart itemChart = new ItemChart { Month = month, NumberOrder = countOrder, }; itemCharts.Add(itemChart); } return(itemCharts); }
public void CreateChartData() { List <SkiaSharp.SKColor> colors = new List <SKColor> { SKColor.Parse("#ff3333"), SKColor.Parse("#009933"), SKColor.Parse("#0000ff"), SKColor.Parse("#ff66cc"), SKColor.Parse("#ffff1a"), SKColor.Parse("#00ffff"), }; List <string> MonthName = new List <string> { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; DataProvider dataProvider = DataProvider.GetInstance(); List <ItemChart> itemCharts = dataProvider.GetDataForChart(); var entries = new List <Microcharts.Entry>(); for (int i = 0; i < itemCharts.Count; i++) { ItemChart item = itemCharts[i]; Microcharts.Entry entry = new Microcharts.Entry(item.NumberOrder) { Label = MonthName[item.Month - 1], ValueLabel = item.NumberOrder.ToString(), Color = colors[i] }; entries.Add(entry); } /* * var entries = new[] * { * new Microcharts.Entry(2) * { * Label = "January", * ValueLabel = "2", * Color = SKColor.Parse("#ff3333") * }, * new Microcharts.Entry(15) * { * Label = "February", * ValueLabel = "15", * Color = SKColor.Parse("#009933"), * * }, * new Microcharts.Entry(10) * { * Label = "March", * ValueLabel = "10", * Color = SKColor.Parse("#0000ff") * } * }; */ _chart = new LineChart() { Entries = entries, LabelTextSize = 40, LineSize = 5, PointSize = 20, LineMode = LineMode.Straight, Margin = 20, PointMode = PointMode.Square, PointAreaAlpha = 5 }; }
private void Awake() { instance = this; }