private void PopulateControls() { if (module == null) { return; } Title = SiteUtils.FormatPageTitle(siteSettings, module.ModuleTitle + " - " + Resource.SalesOverviewReportHeading); if (moduleGuid == Guid.Empty) { return; } if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByModule(moduleGuid); } if (salesByMonthData == null) { return; } heading.Text = Server.HtmlEncode(module.ModuleTitle); lnkThisPage.Text = module.ModuleTitle; lnkAllItems.NavigateUrl = SiteRoot + "/Admin/SalesItemReport.aspx?m=" + moduleGuid.ToString(); try { if (salesByYearData == null) { salesByYearData = CommerceReport.GetSalesByYearByModule(moduleGuid); } grdSalesByYear.DataSource = salesByYearData; grdSalesByYear.DataBind(); } catch { //this will throw an error until the upgrade script for 2.3.4.6 is enabled grdSalesByYear.Visible = false; } grdSales.DataSource = salesByMonthData; grdSales.DataBind(); DataTable dt = CommerceReport.GetItemRevenueByModule(moduleGuid); grdTopItems.DataSource = dt; grdTopItems.DataBind(); decimal allTimeRevenue = CommerceReport.GetAllTimeRevenueByModule(moduleGuid); litAllTimeRevenue.Text = string.Format(currencyCulture, Resource.AllTimeRevenueFormatString, allTimeRevenue.ToString("c", currencyCulture)); if (WebConfigSettings.DisableZedGraph) { BindBarChart(); } }
private void BindBarChart() { zgSales.Visible = false; bcSales.Visible = true; if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByModule(moduleGuid); } 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 (module == null) { return; } if (moduleGuid == 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.GetSalesByYearMonthByModule(moduleGuid); } 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); }
private void PopulateControls() { if (module == null) { return; } if (moduleGuid == Guid.Empty) { return; } if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByModule(moduleGuid); } if (salesByMonthData == null) { return; } Title = SiteUtils.FormatPageTitle(siteSettings, module.ModuleTitle + " - " + Resource.SalesOverviewReportHeading); litHeading.Text = Server.HtmlEncode(module.ModuleTitle); lnkThisPage.Text = module.ModuleTitle; lnkAllItems.NavigateUrl = SiteRoot + "/Admin/SalesItemReport.aspx?m=" + moduleGuid.ToString(); grdSales.DataSource = salesByMonthData; grdSales.DataBind(); DataTable dt = CommerceReport.GetItemRevenueByModule(moduleGuid); grdTopItems.DataSource = dt; grdTopItems.DataBind(); decimal allTimeRevenue = CommerceReport.GetAllTimeRevenueByModule(moduleGuid); litAllTimeRevenue.Text = string.Format(currencyCulture, Resource.AllTimeRevenueFormatString, allTimeRevenue.ToString("c", currencyCulture)); }