private void PopulateControls() { if (reportItem == null) { return; } if (itemGuid == Guid.Empty) { return; } if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByItem(itemGuid); } if (salesByMonthData == null) { return; } Title = SiteUtils.FormatPageTitle(siteSettings, reportItem.ItemName + " - " + Resource.SalesOverviewReportHeading); litHeading.Text = reportItem.ItemName; lnkModuleReport.Text = reportItem.ModuleTitle; lnkModuleReport.NavigateUrl = SiteRoot + "/Admin/SalesByModule.aspx?m=" + reportItem.ModuleGuid.ToString(); lnkThisPage.Text = reportItem.ItemName; grdSales.DataSource = salesByMonthData; grdSales.DataBind(); litAllTimeRevenue.Text = string.Format(currencyCulture, Resource.AllTimeRevenueFormatString, reportItem.TotalRevenue.ToString("c", currencyCulture)); }
private void BindBarChart() { zgSales.Visible = false; bcSales.Visible = true; if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByItem(itemGuid); } StringBuilder categories = new StringBuilder(); string comma = string.Empty; List <decimal> revenue = new List <decimal>(); // original data is sorted descending on Y, M resorting here DataRow[] result = salesByMonthData.Select(string.Empty, "Y ASC, M ASC"); int spaceInterval = 0; int totalItems = result.Length; int itemsAdded = 0; if (totalItems > 12) { spaceInterval = 4; } int nextItemToShow = 0; foreach (DataRow row in result) { categories.Append(comma); if (itemsAdded == nextItemToShow) { categories.Append(row["Y"].ToString()); categories.Append("-"); categories.Append(row["M"].ToString()); nextItemToShow = itemsAdded + spaceInterval; } comma = ","; revenue.Add(Convert.ToDecimal(row["Sales"])); itemsAdded += 1; } bcSales.ChartTitle = Resource.SalesByMonthChartLabel; bcSales.CategoriesAxis = categories.ToString(); BarChartSeries series = new BarChartSeries(); //series.Name = Resource.SalesByMonthChartSalesLabel; series.Data = revenue.ToArray(); bcSales.Series.Add(series); //bcSales.CategoriesAxis //bcSales.Series. }
private void OnRenderUserChart(ZedGraphWeb z, Graphics g, MasterPane masterPane) { if (reportItem == null) { return; } if (itemGuid == Guid.Empty) { return; } GraphPane graphPane = masterPane[0]; graphPane.Title.Text = Resource.SalesByMonthChartLabel; graphPane.XAxis.Title.Text = Resource.SalesByMonthChartMonthLabel; graphPane.YAxis.Title.Text = Resource.SalesByMonthChartSalesLabel; PointPairList pointList = new PointPairList(); if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByItem(itemGuid); } foreach (DataRow row in salesByMonthData.Rows) { double x = new XDate(Convert.ToInt32(row["Y"]), Convert.ToInt32(row["M"]), 1); double y = Convert.ToDouble(row["Sales"]); pointList.Add(x, y); } LineItem myCurve2 = graphPane.AddCurve(Resource.SalesByMonthChartLabel, pointList, Color.Blue, SymbolType.Circle); // Fill the area under the curve with a white-red gradient at 45 degrees myCurve2.Line.Fill = new Fill(Color.White, Color.Green, 45F); // Make the symbols opaque by filling them with white myCurve2.Symbol.Fill = new Fill(Color.White); // Set the XAxis to date type graphPane.XAxis.Type = AxisType.Date; graphPane.XAxis.CrossAuto = true; // Fill the axis background with a color gradient graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F); masterPane.AxisChange(g); }