本文整理汇总了C#中Chart.AddSeries方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.AddSeries方法的具体用法?C# Chart.AddSeries怎么用?C# Chart.AddSeries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.AddSeries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// Called at the start of your algorithm to setup your requirements:
/// </summary>
public override void Initialize()
{
//Set the date range you want to run your algorithm:
SetStartDate(startDate);
SetEndDate(endDate);
//Set the starting cash for your strategy:
SetCash(100000);
//Add any stocks you'd like to analyse, and set the resolution:
// Find more symbols here: http://quantconnect.com/data
AddSecurity(SecurityType.Equity, "SPY", resolution: Resolution.Minute);
//Chart - Master Container for the Chart:
Chart stockPlot = new Chart("Trade Plot");
//On the Trade Plotter Chart we want 3 series: trades and price:
Series buyOrders = new Series("Buy", SeriesType.Scatter, 0);
Series sellOrders = new Series("Sell", SeriesType.Scatter, 0);
Series assetPrice = new Series("Price", SeriesType.Line, 0);
stockPlot.AddSeries(buyOrders);
stockPlot.AddSeries(sellOrders);
stockPlot.AddSeries(assetPrice);
AddChart(stockPlot);
Chart avgCross = new Chart("Strategy Equity");
Series fastMA = new Series("FastMA", SeriesType.Line, 1);
Series slowMA = new Series("SlowMA", SeriesType.Line, 1);
avgCross.AddSeries(fastMA);
avgCross.AddSeries(slowMA);
AddChart(avgCross);
resamplePeriod = TimeSpan.FromMinutes((endDate - startDate).TotalMinutes / 2000);
}
示例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: ChartImage
public void ChartImage()
{
var products = new[]
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275m},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95m},
new Product {Name = "Soccer ball", Category = "Football", Price = 19.50m},
new Product {Name = "Corner flags", Category = "Football", Price = 34.95m},
new Product {Name = "Thinking cap", Category = "Chess", Price = 16m},
};
Chart chart = new Chart(600, 200,
@"<Chart BackColor=""Gray"" BackSecondaryColor=""WhiteSmoke""
BackGradientStyle=""DiagonalRight"" AntiAliasing=""All""
BorderlineDashStyle = ""Solid"" BorderlineColor = ""Gray"">
<BorderSkin SkinStyle = ""Emboss"" />
<ChartAreas>
<ChartArea Name=""Default"" _Template_=""All"" BackColor=""Wheat""
BackSecondaryColor=""White"" BorderColor=""64, 64, 64, 64""
BorderDashStyle=""Solid"" ShadowColor=""Transparent"">
</ChartArea>
</ChartAreas>
</Chart>");
chart.AddSeries(
chartType: "Column",
yValues: products.Select(p => p.Price).ToArray(),
xValue: products.Select(p => p.Name).ToArray()
);
chart.Write();
}
示例4: profile_viewer_Index
//
// GET: /Profile_Viewers/
public ActionResult profile_viewer_Index()
{
var v = db.profile_viewers.OrderByDescending(r => r.visit_date)
.Where(r => r.profile_name == User.Identity.Name).ToList();
ViewBag.total = v.Count();
List<int> i = new List<int>();
List<int> li = new List<int>();
DateTime dt = DateTime.UtcNow;
var z = v.Where(r => r.visit_date.Day >= (dt.Day - 7)).AsEnumerable().ToList();
var z1 = z.Select(r => r.visit_date.Day).Distinct();
foreach (var n in z1)
{
var z2 = z.Where(r => r.visit_date.Day == n).ToList();
i.Add(z2.Count());
li.Add(n);
}
// chart
var mychart = new Chart(width: 250, height: 150, theme: ChartTheme.Blue);
// mychart.AddTitle(dt.ToString("MMMM,yyyy"));
mychart.AddSeries(
"Default",
xValue: li,
yValues: i
);
//mychart.DataBindTable(i);
string s = User.Identity.Name;
var filename = string.Format("~/Images/pv_{0}.png", s);
mychart.Save(filename);
ViewBag.weeklytotal = li.Count();
//membership check
membership_check mc = new membership_check();
string status = mc.member_status(s);
ViewBag.status = status;
if (status == "Premium")
{
//paging
decimal p = v.Count();
ViewBag.total_page = Math.Ceiling(p / 10);
ViewBag.pagenumber = 1;
var v1 = v.Take(10);
//
return View(v1);
}
else
{
var v2 = v.Take(5);
//paging
decimal p = v2.Count();
ViewBag.total_page = Math.Ceiling(p / 5);
ViewBag.pagenumber = 1;
//
return View(v2);
}
}
示例5: 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");
}
示例6: 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");
}
示例7: Grapher
/// <summary>
/// Create a graph on the server of a data series
/// </summary>
/// <param name="dataSetX">IEnumerable horizontal series</param>
/// <param name="dataSetY">IEnumberable vertical series</param>
public Grapher(System.Collections.IEnumerable dataSetX, System.Collections.IEnumerable dataSetY)
{
this.dataSetX = dataSetX;
this.dataSetY = dataSetY;
if (!File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(filePath)))
{
//TODO log any exceptions
chart = new Chart(width: 600, height: 600);
chart.AddSeries(chartType: "Line",
xValue: dataSetX,
yValues: dataSetY);
chart.Save(filePathName, "png");
//TODO solve file cleanup problem
}
}
示例8: GetMinutesAsSleepImage
public User GetMinutesAsSleepImage(User user)
{
List<int> MinutesAsSleepList = new List<int>();
List<string> MinutesAsSleepDatesList = new List<string>();
foreach (MinutesAsSleep kvp in user.MinutesAsSleepList)
{
MinutesAsSleepDatesList.Add(kvp.date);
MinutesAsSleepList.Add(kvp.value);
}
Chart MinutesAsSleepChart = new Chart(width: 800, height: 400);
MinutesAsSleepChart.AddSeries(chartType: "Line", xValue: MinutesAsSleepDatesList,
yValues: MinutesAsSleepList);
//FatFreeMassChart.SetYAxis(min: 190, max: 230);
var path = Path.Combine(Server.MapPath("~/Images/userMinutesAsSleep"), user.userId.ToString() + ".jpeg");
MinutesAsSleepChart.Save(path);
user.ImageMinutesAsSleepUrl = "../Images/userMinutesAsSleep/" + user.userId + ".jpeg";
return user;
}
示例9: GetFatRationImage
public User GetFatRationImage(User user)
{
List<double> FatRationList = new List<double>();
List<string> FatRationDatesList = new List<string>();
foreach (FatRation kvp in user.FatRationList)
{
FatRationDatesList.Add(kvp.date.ToShortDateString());
FatRationList.Add(kvp.value);
}
Chart FatRationChart = new Chart(width: 800, height: 400);
FatRationChart.AddSeries(chartType: "Line", xValue: FatRationDatesList,
yValues: FatRationList);
//FatRationChart.SetYAxis(min: 190, max: 230);
var path = Path.Combine(Server.MapPath("~/Images/userFatRation"), user.userId.ToString() + ".jpeg");
FatRationChart.Save(path);
user.ImageFatRationUrl = "../Images/userFatRation/" + user.userId + ".jpeg";
return user;
}
示例10: GetCaloriesImage
public User GetCaloriesImage(User user)
{
List<int> CaloriesList = new List<int>();
List<string> CaloriesDatesList = new List<string>();
foreach (Calories kvp in user.CaloriesList)
{
CaloriesDatesList.Add(kvp.date);
CaloriesList.Add(kvp.value);
}
Chart CaloriesChart = new Chart(width: 800, height: 400);
CaloriesChart.AddSeries(chartType: "Line", xValue: CaloriesDatesList,
yValues: CaloriesList);
//FatFreeMassChart.SetYAxis(min: 190, max: 230);
var path = Path.Combine(Server.MapPath("~/Images/userCalories"), user.userId.ToString() + ".jpeg");
CaloriesChart.Save(path);
user.ImageFatFreeMassUrl = "../Images/userCalories/" + user.userId + ".jpeg";
return user;
}
示例11: GetChart
public ActionResult GetChart()
{
var user = db.Users.Include("WeightCheckIns").Where(e => e.UserName == HttpContext.User.Identity.Name).FirstOrDefault();
var weights = user.WeightCheckIns.Select(e => e.Weight).ToList();
var dates = user.WeightCheckIns.Select(e => e.CheckInDate).ToList();
var chart = new Chart(width: 600, height: 440, theme: ChartTheme.Blue);
chart.SetYAxis(min: Convert.ToDouble(Math.Round(weights.Min()) - 1), max: Convert.ToDouble(Math.Round(weights.Max()) + 1));
chart.AddSeries(
name: "Checkins",
chartType: "Line",
chartArea: null,
xValue: dates,
xField: "Checkin Dates",
yValues: weights,
yFields: "Weights").Write();
return null;
}
示例12: 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;
}
示例13: SeriesThrowsWhenChartTypeIsNull
public void SeriesThrowsWhenChartTypeIsNull()
{
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
Assert.ThrowsArgumentNullOrEmptyString(() => { chart.AddSeries(chartType: null); }, "chartType");
}
示例14: ChartGenerator
public ActionResult ChartGenerator()
{
List<ChartData> listData = Session["ListData"] as List<ChartData>;
RiskChartViewModel vm = Session["RiskChartViewModel"] as RiskChartViewModel;
List<string> xValues = new List<string>();
List<decimal> yValues = new List<decimal>();
List<decimal> yValues2 = new List<decimal>();
foreach (var data in listData)
{
xValues.Add(data.Name);
yValues.Add(data.Value);
yValues2.Add(data.Value2);
}
string seriesName = string.Empty;
string seriesName2 = string.Empty;
if (vm.YValueId == DATA_COUNT)
seriesName = "Banyak Data";
else if (vm.YValueId == DATA_PROBLEVEL)
seriesName = "Tingkat Probabilitas";
else if (vm.YValueId == DATA_IMPACTLEVEL)
seriesName = "Tingkat Dampak";
else if (vm.YValueId == DATA_PROBIMPACTLEVEL)
{
seriesName = "Tingkat Probabilitas";
seriesName2 = "Tingkat Dampak";
}
else
seriesName = "Tingkat Risiko";
string chartType = "column";
int chartTypeId = vm.ChartTypeId;
if (chartTypeId == 2)
chartType = "bar";
else if (chartTypeId == 3)
chartType = "pie";
string xAxisTitle = GetXAxisTitle(vm.XValueId);
string yAxisTitle = GetYAxisTitle(vm.YValueId);
var cht = new Chart(width: 600, height: 400, theme: ChartTheme.Blue)
.SetXAxis(xAxisTitle)
.SetYAxis(yAxisTitle)
.AddSeries(name: seriesName,
chartType: chartType,
xValue: xValues,
yValues: yValues, markerStep: 1);
if (!string.IsNullOrEmpty(seriesName2))
{
cht = cht
.AddSeries(name: seriesName2,
chartType: chartType,
xValue: xValues,
yValues: yValues2)
.AddLegend();
}
var bytes = cht.GetBytes("jpg");
return File(bytes, "image/jpg");
}
示例15: 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;
}