本文整理汇总了C#中Chart.SetXAxis方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.SetXAxis方法的具体用法?C# Chart.SetXAxis怎么用?C# Chart.SetXAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.SetXAxis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例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;
}