Пример #1
0
        private void PopulateControls()
        {
            if (salesByMonthData == null)
            {
                salesByMonthData = CommerceReport.GetSalesByYearMonthBySite(siteSettings.SiteGuid);
            }
            if (salesByMonthData == null)
            {
                return;
            }


            grdSales.DataSource = salesByMonthData;
            grdSales.DataBind();


            decimal allTimeRevenue = CommerceReport.GetAllTimeRevenueBySite(siteSettings.SiteGuid);

            litAllTimeRevenue.Text = string.Format(currencyCulture,
                                                   Resource.AllTimeRevenueFormatString, allTimeRevenue.ToString("c", currencyCulture));

            using (IDataReader reader = CommerceReport.GetSalesGroupedByModule(siteSettings.SiteGuid))
            {
                grdSalesByModule.DataSource = reader;
                grdSalesByModule.DataBind();
            }

            using (IDataReader reader = CommerceReport.GetSalesGroupedByUser(siteSettings.SiteGuid))
            {
                grdTopCustomers.DataSource = reader;
                grdTopCustomers.DataBind();
            }
        }
Пример #2
0
        private void BindBarChart()
        {
            zgSales.Visible = false;
            bcSales.Visible = true;
            if (salesByMonthData == null)
            {
                salesByMonthData = CommerceReport.GetSalesByYearMonthBySite(siteSettings.SiteGuid);
            }

            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.
        }
Пример #3
0
        private void OnRenderUserChart(ZedGraphWeb z, Graphics g, MasterPane masterPane)
        {
            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.GetSalesByYearMonthBySite(siteSettings.SiteGuid);
            }

            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);
        }