本文整理汇总了C#中Chart.AddTitle方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.AddTitle方法的具体用法?C# Chart.AddTitle怎么用?C# Chart.AddTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.AddTitle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Chart
public ActionResult Chart(string strid, int acYr)
{
ArrayList xValues = new ArrayList();
ArrayList yValues = new ArrayList();
var myChart = new Chart(350, 300, ChartTheme.Blue);
if (acYr == 201617)
{
var chart_data = db.Lecture_Attendance_Count_view_201617.Where(t => t.idsubject_faculties == strid).OrderBy(t => t.lecture_no);
try
{
chart_data.ToList().ForEach(rs => xValues.Add(rs.lecture_no));
chart_data.ToList().ForEach(rs => yValues.Add(rs.Total_students));
}
catch (Exception e)
{
string msg = e.Message;
}
ViewBag.idsubject_faculties = strid;
myChart = new Chart(350, 300, ChartTheme.Blue);
myChart.AddSeries(chartType: "Line", xValue: xValues, yValues: yValues);
myChart.SetXAxis(title: "Lecture No.", min: 1);
myChart.SetYAxis(title: "No. of Students");
myChart.AddTitle("Attendance Chart");
myChart.Write("png");
//return File(myChart.ToWebImage().GetBytes(), "image/bytes");
}
else if(acYr == 201516)
{
var chart_data = db.Lecture_Attendance_Count_view.Where(t => t.idsubject_faculties == strid).OrderBy(t => t.lecture_no);
try
{
chart_data.ToList().ForEach(rs => xValues.Add(rs.lecture_no));
chart_data.ToList().ForEach(rs => yValues.Add(rs.Total_students));
}
catch (Exception e)
{
string msg = e.Message;
}
ViewBag.idsubject_faculties = strid;
myChart = new Chart(350, 300, ChartTheme.Blue);
myChart.AddSeries(chartType: "Line", xValue: xValues, yValues: yValues);
myChart.SetXAxis(title: "Lecture No.", min: 1);
myChart.SetYAxis(title: "No. of Students");
myChart.AddTitle("Attendance Chart");
myChart.Write("png");
//return File(myChart.ToWebImage().GetBytes(), "image/bytes");
}
return File(myChart.ToWebImage().GetBytes(), "image/bytes");
}
示例2: 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");
}
示例3: 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");
}
示例4: GenerateDateChart
private static Chart GenerateDateChart(IEnumerable<Player> players, int? width, int? height, bool? title)
{
var maxDate = double.MinValue;
var minDate = double.MaxValue;
var maxRating = int.MinValue;
var minRating = int.MaxValue;
var chart = new Chart(width: width ?? DefaultWidth, height: height ?? DefaultHeight);
if (title ?? true) chart.AddTitle("ELO vs Time");
var now = DateTime.UtcNow;
foreach (var player in players.OrderBy(p => p.Name))
{
var ratings = player.Ratings.OrderBy(r => r.TimeFrom).ToList();
ratings.Add(new Rating { Value = ratings.Last().Value, TimeFrom = now });
var yValues = ratings.Select(r => r.Value).ToArray();
var xValues = ratings.Select(r => r.TimeFrom).ToArray();
maxDate = Math.Max(maxDate, xValues.Max().ToOADate());
minDate = Math.Min(minDate, xValues.Min().ToOADate());
maxRating = Math.Max(maxRating, yValues.Max());
minRating = Math.Min(minRating, yValues.Min());
chart.AddSeries(
name: player.Name,
xValue: xValues,
yValues: yValues,
chartType: "Line");
}
chart.SetXAxis("Time", minDate, maxDate);
chart.SetYAxis("ELO", minRating - 100, maxRating + 100);
return chart;
}
示例5: BuildHistoryChart
private Chart BuildHistoryChart(IEnumerable<WirelessScaleData> datas, double minYVal, int width, int height, string title)
{
Chart chart = new Chart(
width: width,
height: height);
chart.AddTitle(title);
//chart.AddLegend(title: "Legend", name: null);
chart.SetYAxis(min: minYVal);
ArrayList xValueArray = new ArrayList();
ArrayList yValuesArray = new ArrayList();
foreach (WirelessScaleData data in datas)
{
xValueArray.Add(data.ReceivedDateTime.ToString("d"));
yValuesArray.Add(data.Value);
}
chart.AddSeries(
name: "History",
chartType: "Line",
axisLabel: "Weight",
xValue: xValueArray,
yValues: yValuesArray);
return chart;
}
示例6: BuildChart
private Chart BuildChart(string name, DateTime startTime, DateTime endTime,
List<object> x, List<object> y, string axisX, string axisY)
{
var chart = new Chart(300, 300);
chart.AddTitle(string.Format("{0} {1} {2}",
name,
startTime != DateTime.MinValue ? "\nFrom: " + (startTime).ToString("yyyy.MM.dd H:mm"): string.Empty,
endTime != DateTime.MinValue ? "\nUntil: " + (endTime).ToString("yyyy.MM.dd H:mm") : string.Empty
));
chart.AddSeries(
xValue: x,
yValues: y);
chart.SetXAxis(axisX);
chart.SetYAxis(axisY);
return chart;
}
示例7: GenerateGameChart
private static Chart GenerateGameChart(IEnumerable<Player> players, int? width, int? height, bool? title)
{
var chart = new Chart(width: width ?? DefaultWidth, height: height ?? DefaultHeight);
if (title ?? true) chart.AddTitle("ELO vs Games");
var maxGames = int.MinValue;
var minGames = int.MaxValue;
var maxRating = int.MinValue;
var minRating = int.MaxValue;
foreach (var player in players.OrderBy(p => p.Name))
{
var ratings = player.Ratings.OrderBy(r => r.TimeFrom);
var yValues = ratings.Select(r => r.Value).ToArray();
var xValues = ratings.Select((x, i) => i).ToArray();
maxGames = Math.Max(maxGames, xValues.Max());
minGames = Math.Min(maxGames, xValues.Min());
maxRating = Math.Max(maxRating, yValues.Max());
minRating = Math.Min(minRating, yValues.Min());
chart.AddSeries(
name: player.Name,
xValue: xValues,
yValues: yValues,
chartType: "Line");
}
chart.SetXAxis("Games", minGames, maxGames);
chart.SetYAxis("ELO", minRating - 100, maxRating + 100);
return chart;
}
示例8: 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;
}
示例9: GetCategoryReport
public Chart GetCategoryReport()
{
List<KeyValuePair<string, int>> amountByName = GetAmountsByCategoryName().Select(t => new KeyValuePair<string, int>(t.Key.Name, t.Value)).ToList();
Chart c = new Chart(width: 600, height: 400, theme: ChartTheme.Green);
c.AddSeries(chartType: "doughnut",
xValue: amountByName, xField: "Key",
yValues: amountByName, yFields: "Value");
c.AddTitle("Kiadások kategóriánként");
return c;
}
示例10: GetBalanceReport
public Chart GetBalanceReport()
{
List<TotalCash> totalCashes = new List<TotalCash>();
List<TotalCash> orderedTotalCashes = TotalCashes.OrderBy(t => t.Date).ToList();
for (int i = 0; i < orderedTotalCashes.Count; i++)
{
if ((orderedTotalCashes[i].Date <= EndDate && orderedTotalCashes[i].Date >= StartDate) ||
(orderedTotalCashes[i].Date < StartDate && i + 1 == orderedTotalCashes.Count) ||
(orderedTotalCashes[i].Date < StartDate && i + 1 < orderedTotalCashes.Count && orderedTotalCashes[i + 1].Date > StartDate))
{
totalCashes.Add(orderedTotalCashes[i]);
}
}
if (totalCashes.Count == 0)
return null;
totalCashes = totalCashes.OrderBy(t => t.Date).ToList();
// TotalCashes
//List<DateTime> xValues = totalCashes.Where(t => t.Date <= EndDate && t.Date >= StartDate).Select(t => t.Date).ToList();
List<DateTime> xValues = new List<DateTime>();
List<int> yValues = new List<int>();
//xValues.Insert(0, StartDate);
//yValues.Insert(0, GetStartingTotalCash());
for (int i = 0; i < totalCashes.Count; i++)
{
List<Transaction> innerTransactions = AllTransactions.Where(t => t.CreateDate > totalCashes[i].Date
&& t.CreateDate <= (i + 1 < totalCashes.Count ? totalCashes[i + 1].Date : EndDate)).ToList();
int total = totalCashes[i].Amount;
if (innerTransactions.Count == 0)
{
xValues.Add(totalCashes[i].Date);
yValues.Add(total);
}
foreach(var trans in innerTransactions.GroupBy(t => t.CreateDate))
{
DateTime date = trans.Key;
foreach (Transaction tr in trans.ToList())
{
total -= tr.Amount;
}
xValues.Add(date);
yValues.Add(total);
}
}
xValues.Add(EndDate);
yValues.Add(GetCurrentTotalCash());
//List<int> yValues = totalCashes.Where(t => t.Date <= EndDate && t.Date >= StartDate).Select(t => t.Amount).ToList();
Chart c = new Chart(width: 600, height: 400, theme: ChartTheme.Green);
c.AddSeries(chartType: "line",
xValue: xValues,
yValues: yValues);
c.AddTitle("Aktuális pénzmennyiség alakulása");
return c;
}