當前位置: 首頁>>代碼示例>>C#>>正文


C# Chart.AddLegend方法代碼示例

本文整理匯總了C#中Chart.AddLegend方法的典型用法代碼示例。如果您正苦於以下問題:C# Chart.AddLegend方法的具體用法?C# Chart.AddLegend怎麽用?C# Chart.AddLegend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Chart的用法示例。


在下文中一共展示了Chart.AddLegend方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateStats

        private ActionResult GenerateStats(int years)
        {
            var db = new ZkDataContext();
            db.Database.CommandTimeout = 600;

            var data = MemCache.GetCached("gameStats",
                () =>
                {
                    var start = DateTime.Now.AddYears(-years); //new DateTime(2011, 2, 3);
                    var end = DateTime.Now.Date;
                    return (from bat in db.SpringBattles
                        where bat.StartTime < end && bat.StartTime > start
                        group bat by DbFunctions.TruncateTime(bat.StartTime)
                        into x
                        orderby x.Key
                        let players = x.SelectMany(y => y.SpringBattlePlayers.Where(z => !z.IsSpectator)).Select(z => z.AccountID).Distinct().Count()
                        select
                        new GameStats
                        {
                            Day = x.Key.Value,
                            Players = x.SelectMany(y => y.SpringBattlePlayers.Where(z => !z.IsSpectator)).Select(z => z.AccountID).Distinct().Count(),
                            MinutesPerPlayer = x.Sum(y => y.Duration*y.PlayerCount)/60/players,
                            FirstGamePlayers =
                                x.SelectMany(y => y.SpringBattlePlayers)
                                    .GroupBy(y => y.Account)
                                    .Count(y => y.Any(z => z == y.Key.SpringBattlePlayers.FirstOrDefault()))
                        }).ToList();
                },
                60*60*20);

            var chart = new Chart(1500, 700, ChartTheme.Blue);

            chart.AddTitle("Daily activity");
            chart.AddLegend("Daily values", "dps");

            chart.AddSeries("unique players", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.Players).ToList(), legend: "dps");
            chart.AddSeries("minutes/player",
                "Line",
                xValue: data.Select(x => x.Day).ToList(),
                yValues: data.Select(x => x.MinutesPerPlayer).ToList(),
                legend: "dps");
            chart.AddSeries("new players",
                "Line",
                xValue: data.Select(x => x.Day).ToList(),
                yValues: data.Select(x => x.FirstGamePlayers).ToList(),
                legend: "dps");

            return File(chart.GetBytes("png"), "image/png");
        }
開發者ID:GoogleFrog,項目名稱:Zero-K-Infrastructure,代碼行數:49,代碼來源:LaddersController.cs

示例2: Games

	    public ActionResult Games() {

	        var db = new ZkDataContext();
	        db.Database.CommandTimeout = 600;
            
	        var data = (List<GameStats>)HttpContext.Cache.Get("gameStats");
	        if (data == null) {

	            var start = new DateTime(2011, 2, 3);
	            var end = DateTime.Now.Date;
                data = (from bat in db.SpringBattles
	                    where bat.StartTime < end && bat.StartTime > start
	                    group bat by DbFunctions.TruncateTime(bat.StartTime)
	                    into x orderby x.Key
	                    let players = x.SelectMany(y => y.SpringBattlePlayers.Where(z => !z.IsSpectator)).Select(z => z.AccountID).Distinct().Count()
	                    select
	                        new GameStats
	                        {
	                            Day = x.Key.Value, 
	                            PlayersAndSpecs = x.SelectMany(y => y.SpringBattlePlayers).Select(z => z.AccountID).Distinct().Count(),
	                            MinutesPerPlayer = x.Sum(y => y.Duration*y.PlayerCount)/60/players,
	                            FirstGamePlayers =
	                                x.SelectMany(y => y.SpringBattlePlayers)
	                                 .GroupBy(y => y.Account)
	                                 .Count(y => y.Any(z => z == y.Key.SpringBattlePlayers.FirstOrDefault()))
	                        }).ToList();

                HttpContext.Cache.Add("gameStats", data, null, DateTime.Now.AddHours(20), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
	        }
            
			var chart = new Chart(1500, 700, ChartTheme.Blue);

			chart.AddTitle("Daily activity");
			chart.AddLegend("Daily values", "dps");

			chart.AddSeries("unique players+specs", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.PlayersAndSpecs).ToList(), legend: "dps");
			chart.AddSeries("minutes/player", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.MinutesPerPlayer).ToList(), legend: "dps");
			chart.AddSeries("new players", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.FirstGamePlayers).ToList(), legend: "dps");

            return File(chart.GetBytes("png"), "image/png");
		}
開發者ID:ParzivalX,項目名稱:Zero-K-Infrastructure,代碼行數:41,代碼來源:LaddersController.cs

示例3: GetCashFlowReport

        public Chart GetCashFlowReport()
        {
            if (Limits.Count == 0)
                return null;

            // Transactions
            List<DateTime> xValues = Transactions.Select(t => t.CreateDate).ToList();
            xValues.Insert(0, StartDate);
            xValues.Add(EndDate);
            List<int> yValues = new List<int>();
            int total = 0;
            yValues.Insert(0, total);
            foreach (int amount in Transactions.Select(t => t.Amount))
            {
                total += amount;
                yValues.Add(total);
            }
            yValues.Add(total);

            // Monthly limit
            List<DateTime> x2values = new List<DateTime>();
            List<int> y2Values = new List<int>();

            int limit = GetTotalLimit();
            x2values.Add(StartDate);
            y2Values.Add(limit);

            x2values.Add(EndDate);
            y2Values.Add(limit);
            
            //foreach (BudgetLimit limit in Limits.Where(t => t.IsMonthly && t.StartDate < EndDate && (!t.EndDate.HasValue || t.EndDate > StartDate)))
            //{
            //    x2values.Add(xValues.Min() > limit.StartDate ? xValues.Min() : limit.StartDate);
            //    y2Values.Add(limit.Limit);

            //    x2values.Add(!limit.EndDate.HasValue || xValues.Max() < limit.EndDate.Value ? xValues.Max() : limit.EndDate.Value);
            //    y2Values.Add(limit.Limit);
            //}

            // Average expense
            List<DateTime> x3values = new List<DateTime>();
            x3values.Add(StartDate);
            x3values.Add(EndDate);

            List<int> y3Values = new List<int>();
            y3Values.Add(0);
            y3Values.Add(y2Values.Last());

            Chart c = new Chart(width: 600, height: 400, theme: ChartTheme.Green);
            c.AddSeries(chartType: "line",
                        xValue: xValues,
                        yValues: yValues,
                        name: "Tényleges költés");
            c.AddSeries(chartType: "line",
                        xValue: x2values,
                        yValues: y2Values,
                        name: "Költés felső határa");
            c.AddSeries(chartType: "line",
                        xValue: x3values,
                        yValues: y3Values,
                        name: "Egyenletes költés");
            c.AddTitle("Költés és limit");
            c.AddLegend();
            return c;
        }
開發者ID:jesuska,項目名稱:FamilyFine,代碼行數:65,代碼來源:Reporter.cs


注:本文中的Chart.AddLegend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。