本文整理汇总了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");
}
示例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");
}
示例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;
}