Ejemplo n.º 1
0
    private void DrawPie()
    {
        string ttt = string.Concat(new object[] { "第", this.WeekOfYear(DateTime.Parse(this.week).AddDays(-7.0)), "周与第", this.WeekOfYear(DateTime.Parse(this.week)), "周的人流统计分析图-周图表" });

        ChartServices.SetChartTitle(this.WebChartControl1, true, ttt, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "人数", this.types, this.loadz(), "类型", "人数");
    }
Ejemplo n.º 2
0
    private void DrawPie()
    {
        string title = "店铺消费金额统计表";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "消费金额", this.types, this.load(), "sName", "mony");
    }
Ejemplo n.º 3
0
    private void DrawPie()
    {
        string title = "区域会员统计树形图";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "人数", ViewType.Bar, this.load(), "mTown", "cout");
    }
Ejemplo n.º 4
0
        public void GetBarNames_OneDay_MultipleItemsDifferentNames()
        {
            // arrange
            var foodItems = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Name = "XXX"
                },
                new FoodItem {
                    Code = "2", Name = "YYY"
                }
            };

            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19), Food = foodItems
                }
            };

            var expected = new List <string> {
                "XXX", "YYY", "Total"
            };

            // act
            List <string> actual = new ChartServices().GetBarNames(days);

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
    private void DrawPie()
    {
        string title = "年龄段会员统计比例饼状图";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "人数", ViewType.Pie, this.llnian(), "nian", "count");
    }
Ejemplo n.º 6
0
    private void DrawPie()
    {
        string title = DateTime.Parse(this.day).AddDays(-1.0).ToString("yyyy-MM-dd") + "与" + this.day + "的人流统计分析图-日图表";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "人数", this.types, this.loadz(), "类型", "人数");
    }
Ejemplo n.º 7
0
    private void DrawPie()
    {
        string title = this.years + "年-每月会员充值金额统计分析图";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "充值金额", this.types, this.load(), "month", "money");
    }
Ejemplo n.º 8
0
        public void TestCalculateMicronutrientByDayOneProductOneDay()
        {
            // Arrange
            ChartServices chartServices   = new ChartServices(myFoodItemServices.Object, myProductServices.Object);
            var           productServices = new ProductServices();

            myProductServices.Setup(m => m.GetProducts(It.IsAny <string>(), It.IsAny <List <Day> >())).Returns(new List <Product>
            {
                new Product {
                    Code = "XXX", ProductMicronutrients = productServices.UpdateProductMicronutrients(Micronutrients)
                }
            });

            myFoodItemServices.Setup(m => m.GetDays(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <string>())).Returns(new List <Day>
            {
                new Day {
                    Food = new List <FoodItem> {
                        new FoodItem {
                            Code = "XXX", Quantity = 10
                        }
                    }
                }
            });

            var nutrients = new List <string>
            {
                "Folate"
            };

            // Act
            var result = chartServices.CalculateMicronutrientByDay(DateTime.Now, DateTime.Now, nutrients, It.IsAny <string>());

            // Assert
            Assert.AreEqual(5, result[0].Sum());
        }
Ejemplo n.º 9
0
 private void DrawLine()
 {
     ChartServices.SetChartTitle(this.WebChartControl3, true, "2012年12月第1周收入情况", StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
     ChartServices.DrawChart(this.WebChartControl3, "收益", ViewType.Line, ServiceData.GetWeekMoneyAndCost(), "week", "money");
     ChartServices.DrawChart(this.WebChartControl3, "成本", ViewType.Line, ServiceData.GetWeekMoneyAndCost(), "week", "cost");
     ChartServices.SetAxisX(this.WebChartControl3, true, StringAlignment.Center, "星期", Color.Red, true, new Font("宋体", 12f, FontStyle.Bold));
     ChartServices.SetAxisY(this.WebChartControl3, true, StringAlignment.Center, "金额", Color.Red, true, new Font("宋体", 12f, FontStyle.Bold));
 }
Ejemplo n.º 10
0
    private void DrawPie()
    {
        string    sql   = "select DATEADD(wk, DATEDIFF(wk,0,'" + this.month + "'), 0) as one";
        DataTable dt    = this.bc.ReadTable(sql);
        string    title = DateTime.Parse(dt.Rows[0][0].ToString()).ToString("yyyy-MM-dd") + "至" + DateTime.Parse(dt.Rows[0][0].ToString()).AddDays(6.0).ToString("yyyy-MM-dd") + "会员消费金额统计分析图";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        ChartServices.DrawChart(this.WebChartControl1, "消费金额", this.types, this.load(), "day", "money");
    }
Ejemplo n.º 11
0
        public string GetmonthByChart()
        {
            int                  adminid = Convert.ToInt16(Session["AdminId"]);
            ChartServices        _ser    = new ChartServices();
            var                  chart   = _ser.GetJobByMonth(adminid);
            JavaScriptSerializer obj     = new JavaScriptSerializer();

            return(obj.Serialize(chart));
        }
        public void TestCalculateMacroNutrientByProductTwoDifferentFoodItems()
        {
            // Arrange
            ChartServices chartServices   = new ChartServices(myFoodItemServices.Object, myProductServices.Object);
            var           productServices = new ProductServices();

            myProductServices.Setup(m => m.GetProducts(It.IsAny <string>(), It.IsAny <List <Day> >())).Returns(new List <Product>
            {
                new Product {
                    Code = "XXX", ProductMicronutrients = productServices.UpdateProductMicronutrients(Micronutrients)
                },
                new Product {
                    Code = "YYY", ProductMicronutrients = productServices.UpdateProductMicronutrients(Micronutrients)
                }
            });

            myFoodItemServices.Setup(m => m.GetDays(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <string>())).Returns(new List <Day>
            {
                new Day {
                    Food = new List <FoodItem>
                    {
                        new FoodItem {
                            Code = "XXX", Quantity = 10
                        },
                        new FoodItem {
                            Code = "YYY", Quantity = 20
                        }
                    }
                }
            });

            var nutrients = new List <string>
            {
                "Folate",
                "Calcium"
            };

            var expected = new List <List <decimal?> >
            {
                new List <decimal?> {
                    5, 10
                },
                new List <decimal?> {
                    5, 10
                }
            };

            // Act
            var actual = chartServices.CalculateMicronutrientByProduct(DateTime.Now, DateTime.Now, nutrients, It.IsAny <string>());

            // Assert
            CollectionAssert.AreEqual(expected[0], actual[0]);
            CollectionAssert.AreEqual(expected[1], actual[1]);
        }
Ejemplo n.º 13
0
        public void CalculateTotalEnergyData_MultipleDays_OneItem()
        {
            // arrange
            var foodItems1 = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Quantity = 1
                }
            };

            var foodItems2 = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Quantity = 1
                }
            };

            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19), Food = foodItems1
                },
                new Day {
                    Date = new DateTime(2015, 1, 20), Food = foodItems2
                }
            };

            var products = new List <Product>
            {
                new Product {
                    Code = "1", Nutrients = new Dictionary <string, double> {
                        { "Protein", 10 }, { "Carbohydrates", 10 }, { "Fat", 10 }
                    }, ServingSize = 100
                },
                new Product {
                    Code = "2", Nutrients = new Dictionary <string, double> {
                        { "Protein", 10 }, { "Carbohydrates", 10 }, { "Fat", 10 }
                    }, ServingSize = 0
                }
            };

            var expected = new List <double> {
                23.5, 23.5, 52.9
            };

            // act
            List <double> actual = new ChartServices().CalculateTotalEnergyData(days, products);

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 14
0
        public void CalculateNutrientByProduct_OneDay_TwoItemsOneMultiple()
        {
            // arrange
            var foodItems = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Quantity = 3
                },
                new FoodItem {
                    Code = "2", Quantity = 100
                }
            };

            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19), Food = foodItems
                }
            };

            var products = new List <Product>
            {
                new Product {
                    Code = "1", Nutrients = new Dictionary <string, double> {
                        { "Protein", 5.6 }
                    }, ServingSize = 100
                },
                new Product {
                    Code = "2", Nutrients = new Dictionary <string, double> {
                        { "Protein", 1.4 }
                    }, ServingSize = 0
                }
            };

            var expected = new List <double>
            {
                16.8,
                1.4,
                18.2
            };

            // act
            List <double> actual = new ChartServices().CalculateNutrientByProduct(days, products, "Protein");

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 15
0
    private void DrawPie()
    {
        string ttt = string.Concat(new object[] { "第", this.WeekOfYear(DateTime.Parse(this.week).AddDays(-7.0)), "周与第", this.WeekOfYear(DateTime.Parse(this.week)), "周的会员消费金额统计分析图" });

        ChartServices.SetChartTitle(this.WebChartControl1, true, ttt, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        if (this.types == ViewType.Bar)
        {
            ChartServices.DrawChart(this.WebChartControl1, "会员卡", this.types, this.load(), "类型", "会员卡");
            ChartServices.DrawChart(this.WebChartControl1, "临时卡", this.types, this.load(), "类型", "临时卡");
            ChartServices.DrawChart(this.WebChartControl1, "散客卡", this.types, this.load(), "类型", "散客卡");
        }
        else
        {
            ChartServices.DrawChart(this.WebChartControl1, "上周", this.types, this.loadz(), "CardType", "上周");
            ChartServices.DrawChart(this.WebChartControl1, "本周", this.types, this.loadz(), "CardType", "本周");
        }
    }
Ejemplo n.º 16
0
    private void DrawPie()
    {
        string title = DateTime.Parse(this.day).AddDays(-1.0).ToString("yyyy-MM-dd") + "与" + this.day + "的会员消费金额统计分析图";

        ChartServices.SetChartTitle(this.WebChartControl1, true, title, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
        if (this.types == ViewType.Bar)
        {
            ChartServices.DrawChart(this.WebChartControl1, "会员卡", this.types, this.load(), "类型", "会员卡");
            ChartServices.DrawChart(this.WebChartControl1, "临时卡", this.types, this.load(), "类型", "临时卡");
            ChartServices.DrawChart(this.WebChartControl1, "散客卡", this.types, this.load(), "类型", "散客卡");
        }
        else
        {
            ChartServices.DrawChart(this.WebChartControl1, "昨天", this.types, this.loadz(), "CardType", "昨天");
            ChartServices.DrawChart(this.WebChartControl1, "今天", this.types, this.loadz(), "CardType", "今天");
        }
    }
Ejemplo n.º 17
0
        public void CalculateAlcoholByProduct_OneDay_MultipleItems()
        {
            // arrange
            var foodItems = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Quantity = 568
                },
                new FoodItem {
                    Code = "2", Quantity = 2
                }
            };

            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19), Food = foodItems
                }
            };

            var products = new List <Product>
            {
                new Product {
                    Code = "1", Nutrients = new Dictionary <string, double> {
                        { "Alcohol", 4.2 }
                    }, ServingSize = 0
                },
                new Product {
                    Code = "2", Nutrients = new Dictionary <string, double> {
                        { "Alcohol", 4.2 }
                    }, ServingSize = 568
                }
            };

            var expected = new List <double> {
                2.4, 4.8, 7.2
            };

            // act
            List <double> actual = new ChartServices().CalculateAlcoholByProduct(days, products);

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 18
0
        public void GetDates_OneDay()
        {
            // arrange
            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19)
                }
            };

            var expected = new List <string> {
                "19/01/2015"
            };

            // act
            List <string> actual = new ChartServices().GetDates(days);

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 19
0
        public void CalculateNutrientByDay_MultipleDays_MultipleItems()
        {
            // arrange
            var foodItems1 = new List <FoodItem>
            {
                new FoodItem {
                    Code = "1", Quantity = 1
                },
                new FoodItem {
                    Code = "2", Quantity = 100
                }
            };

            var foodItems2 = new List <FoodItem>
            {
                new FoodItem {
                    Code = "3", Quantity = 2
                },
                new FoodItem {
                    Code = "4", Quantity = 10
                }
            };

            var foodItems3 = new List <FoodItem>
            {
                new FoodItem {
                    Code = "3", Quantity = 1
                },
                new FoodItem {
                    Code = "4", Quantity = 5
                }
            };

            var days = new List <Day>
            {
                new Day {
                    Date = new DateTime(2015, 1, 19), Food = foodItems1
                },
                new Day {
                    Date = new DateTime(2015, 1, 20), Food = foodItems2
                },
                new Day {
                    Date = new DateTime(2015, 1, 21), Food = foodItems3
                }
            };

            var products = new List <Product>
            {
                new Product {
                    Code = "1", Nutrients = new Dictionary <string, double> {
                        { "Protein", 5 }
                    }, ServingSize = 100
                },
                new Product {
                    Code = "2", Nutrients = new Dictionary <string, double> {
                        { "Protein", 30 }
                    }, ServingSize = 0
                },
                new Product {
                    Code = "3", Nutrients = new Dictionary <string, double> {
                        { "Protein", 10 }
                    }, ServingSize = 100
                },
                new Product {
                    Code = "4", Nutrients = new Dictionary <string, double> {
                        { "Protein", 50 }
                    }, ServingSize = 0
                }
            };

            var expected = new List <double> {
                35, 25, 12.5
            };

            // act
            List <double> actual = new ChartServices().CalculateNutrientByDay(days, products, "Protein");

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 20
0
 private void DrawPie()
 {
     ChartServices.SetChartTitle(this.WebChartControl4, true, "2012年12月第1周收入情况", StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font("宋体", 12f, FontStyle.Bold), Color.Red, 10);
     ChartServices.DrawChart(this.WebChartControl4, ServiceData.GetWeekMoneyAndCost().Rows[0][0].ToString(), ViewType.Pie, ServiceData.GetWeekMoneyAndCost(), "week", "money");
 }
Ejemplo n.º 21
0
 public ChartsController(UserManager <IdentityUser> users, ChartServices services, ApplicationDbContext db)
 {
     this.users    = users;
     this.services = services;
     this.db       = db;
 }