本文整理汇总了C#中Chart类的典型用法代码示例。如果您正苦于以下问题:C# Chart类的具体用法?C# Chart怎么用?C# Chart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chart类属于命名空间,在下文中一共展示了Chart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetSaleRankChart
public FileResult GetSaleRankChart()
{
var gQuery = (from m in orderDetailRepo.GetWithFilterAndOrder()
group m by m.Meal.MealName into g
orderby g.Sum(item => item.Quantity * 1) descending
select new Group<string, int> { Key = g.Key, Value = g.Sum(item=> item.Quantity * 1) })
.Take(5);
var chart = new Chart();
chart.ChartAreas.Add(new ChartArea("Default"));
chart.Width = 500;
chart.Height = 400;
chart.ChartAreas["Default"].Area3DStyle.Enable3D = true;
chart.ChartAreas["Default"].Area3DStyle.Inclination = 15;
chart.ChartAreas["Default"].Area3DStyle.Rotation = 15;
chart.Series.Add(new Series("Data"));
foreach (var item in gQuery)
{
chart.Series["Data"].Points.AddXY(item.Key, item.Value);
}
System.IO.MemoryStream ms = new System.IO.MemoryStream();
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, System.IO.SeekOrigin.Begin);
return File(ms, "image/png");
}
开发者ID:ChiYunJai,项目名称:MVCEasyOrderSystem,代码行数:28,代码来源:StatsController.cs
示例2: ReturnChart
private FileContentResult ReturnChart(Chart chart)
{
var stream = new MemoryStream();
chart.SaveImage(stream, ChartImageFormat.Png);
stream.Position = 0;
return File(stream.GetBuffer(), "image/png");
}
开发者ID:piotrosz,项目名称:RoslynChart,代码行数:7,代码来源:ChartController.cs
示例3: LineChart
public static Chart LineChart()
{
Chart chart = new Chart(ChartType.Line);
Series series = chart.SeriesCollection.AddSeries();
series.Name = "Series 1";
series.Add(new double[] { 1, 5, -3, 20, 11 });
series = chart.SeriesCollection.AddSeries();
series.Name = "Series 2";
series.Add(new double[] { 22, 4, 12, 8, 12 });
series = chart.SeriesCollection.AddSeries();
series.Name = "Series 3";
series.Add(new double[] { 12, 14, -3, 18, 1 });
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.XAxis.Title.Caption = "X-Axis";
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.Title.Caption = "Y-Axis";
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.Legend.Docking = DockingType.Bottom;
chart.Legend.LineFormat.Visible = true;
XSeries xseries = chart.XValues.AddXSeries();
xseries.Add("A", "B", "C", "D", "E", "F");
return chart;
}
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:34,代码来源:ChartSamples.cs
示例4: Create_LinearChart_WithYAxis
public void Create_LinearChart_WithYAxis()
{
var chart = new Chart<DateTime, double>();
var linearY = chart.GetLinearY(10d);
Assert.NotNull(linearY);
}
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:7,代码来源:TestData.cs
示例5: BindData
public static void BindData(Chart chart, string prvName, object context, string[] seriesExpr, string labelExpr, string labelLookupName)
{
var prv = WebManager.GetService<IProvider<object,object>>(prvName);
var ognlContext = new Dictionary<string,object>();
ognlContext["data"] = prv.Provide(context);
var ognlExpr = new NReco.OGNL.EvalOgnl();
int seriesIdx = 0;
foreach (var expr in seriesExpr) {
var dataset = (IEnumerable)ognlExpr.Eval( expr, ognlContext );
var series = chart.Series[seriesIdx];
foreach (var val in dataset) {
var decVal = Convert.ToDecimal(val);
series.Points.AddY(decVal);
}
seriesIdx++;
}
/*if (!String.IsNullOrEmpty(labelExpr)) {
var labels = (IEnumerable)ognlExpr.Eval( labelExpr, ognlContext );
var labelsList = new List<string>();
var labelPrv = String.IsNullOrEmpty(labelLookupName) ? null : WebManager.GetService<IProvider<object,string>>(labelLookupName);
foreach (var lbl in labels) {
labelsList.Add( labelPrv!=null ? labelPrv.Provide(lbl) : Convert.ToString(lbl) );
}
res += "&"+labelParam+String.Join("|", labelsList.ToArray() );
}*/
}
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:27,代码来源:MsChartHelper.cs
示例6: Input
public ActionResult Input()
{
List<string> xval = new List<string>();
List<string> yval = new List<string>();
List<string> yval2 = new List<string>();
foreach (var points in db.Users.ToList().OrderByDescending(c => c.Win).Take(9))
{
xval.Add(points.Name);
yval.Add(points.Input.ToString());
yval2.Add(points.Win.ToString());
}
string[] _xval = xval.ToArray();
string[] _yval = yval.ToArray();
string[] _yval2 = yval2.ToArray();
var chartsPoint = new Chart(width: 1000, height: 400, theme: ChartTheme.Blue) //,theme: ChartTheme.Blue
.AddSeries(
name: "Buy-In",
xValue: _xval,
yValues: _yval
)
.AddSeries(
name:"Gewonnen",
xValue: _xval,
yValues: _yval2)
.AddLegend();
return File(chartsPoint.GetBytes("png"), "image/png");
}
开发者ID:rogerbollmann,项目名称:SickFriday,代码行数:32,代码来源:ChartsController.cs
示例7: CreateChart
public static void CreateChart(string imagePath,string name, IEnumerable<BenchResult> results, Func<BenchResult,double> selector)
{
Chart chart = new Chart();
chart.Width = 500;
chart.Height = 400;
chart.Titles.Add(name);
var area = new ChartArea("Default");
chart.ChartAreas.Add(area);
var series = new Series("Default");
chart.Series.Add(series);
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90;
area.AxisX.LabelStyle.TruncatedLabels = false;
area.AxisX.Interval = 1;
series.ChartType = SeriesChartType.Column;
series.IsValueShownAsLabel = true;
series.XValueType = ChartValueType.String;
series.YValueType = ChartValueType.Int32;
foreach(var r in results.OrderBy( r => selector(r)))
{
DataPoint point = new DataPoint();
point.SetValueXY(r.Serializer.Replace("Adapter",""),(int)Math.Round(selector(r)));
point.AxisLabel = r.Serializer.Replace("Adapter", "");
series.Points.Add(point);
}
chart.SaveImage(imagePath, ChartImageFormat.Png);
}
开发者ID:etishor,项目名称:SerializationTests,代码行数:29,代码来源:ChartHelper.cs
示例8: Details
public ActionResult Details(int width = 500, int height = 500)
{
var chart = new Chart { Height = height, Width = width };
var chartArea = new ChartArea("Area1")
{
AxisX = { Interval = 1 },
Area3DStyle = { Enable3D = true },
BackColor = Color.Transparent
};
chart.ChartAreas.Add(chartArea);
chart.BackColor = Color.Transparent;
var seriescountAll = new Series("项目统计");
var countAll =
_iProjectInfoStateService.GetAll()
.Select(a => new { Key = a.ProjectInfoStateName, Count = a.ProjectInfos.Count(b => !b.Deleted) });
seriescountAll.ChartArea = "Area1";
seriescountAll.IsVisibleInLegend = true;
seriescountAll.IsValueShownAsLabel = true;
seriescountAll.Label = "#VALX #VALY";
seriescountAll.Points.DataBind(countAll, "Key", "Count", "");
seriescountAll.ChartType = SeriesChartType.Funnel;
chart.Series.Add(seriescountAll);
var imageStream = new MemoryStream();
chart.SaveImage(imageStream, ChartImageFormat.Png);
imageStream.Position = 0;
return new FileStreamResult(imageStream, "image/png");
}
开发者ID:b9502032,项目名称:MySite,代码行数:30,代码来源:ProjectInfoCountController.cs
示例9: GenerateBarChart
public static Chart GenerateBarChart(IList<LogStatistic<DateTime, int>> values, int width, int height)
{
Chart ch = new Chart();
ch.ChartAreas.Add(new ChartArea());
List<string> dates = new List<string>();
List<int> counts = new List<int>();
foreach (var tuple in values)
{
dates.Add(tuple.Key.Date.ToShortDateString());
counts.Add(tuple.Value);
}
int[] yval = counts.ToArray();
// Initialize an array of strings
string[] xval = dates.ToArray();
Series series = new Series("Default");
series.ChartType = SeriesChartType.Bar;
// Add series into the chart's series collection
ch.Series.Add(series);
// Bind the double array to the Y axis points of the Default data series
ch.Series["Default"].Points.DataBindXY(xval, yval);
ch.Width = width;
ch.Height = height;
return ch;
}
开发者ID:spolnik,项目名称:ApacheLogAnalyzer,代码行数:33,代码来源:ChartCreator.cs
示例10: AddChartData
protected virtual void AddChartData(Chart chart, List<Series> data)
{
foreach (Series series in data)
{
chart.Series.Add(series);
}
}
开发者ID:benhejl,项目名称:SWENG500_Team1,代码行数:7,代码来源:GraphBase.cs
示例11: GetPieChart
public ActionResult GetPieChart()
{
int[] ranges = { 4, 8, 12 };
var query = from value in uploadDataMgr.GetUploadedLive().ToList()
.Where(p => p.ScoreTotal != null)
.Select(p => p.ScoreTotal)
group value by ranges.Where(x => value >= x)
.DefaultIfEmpty()
.Last() into groups
select new { Key = groups.Key, Values = groups };
Dictionary<string, int> dictRiskCat = new Dictionary<string, int>();
foreach (var group in query)
{
if (group.Key == 0)
dictRiskCat.Add("Low Risk", group.Values.Count());
else if (group.Key == 4)
dictRiskCat.Add("Medium Risk", group.Values.Count());
else if (group.Key == 8)
dictRiskCat.Add("High Risk", group.Values.Count());
}
var key = new Chart(width: 300, height: 300)
.AddTitle("Risk Summary")
.AddSeries(
chartType: "Pie",
name: "Risk Summary",
xValue: dictRiskCat.Keys,
yValues: dictRiskCat.Values);
return File(key.ToWebImage().GetBytes(), "image/jpeg");
}
开发者ID:dashboard1234,项目名称:Dashboard,代码行数:32,代码来源:ChartController.cs
示例12: CreateChartByMonthPerYear
public ActionResult CreateChartByMonthPerYear(int year)
{
try
{
List<int> lstArticlesCount = articleManager.GetArticlesPerMonth(year);
string temp = @"<Chart BackColor=""LightGray"" ForeColor=""LightBlue"">
<ChartAreas>
<ChartArea Name=""Default"" _Template_=""All"">
<AxisY>
<LabelStyle Font=""Verdana, 15px"" />
</AxisY>
<AxisX LineColor=""64, 64, 64, 64"" Interval=""1"">
<LabelStyle Font=""Verdana, 14px"" />
</AxisX>
</ChartArea>
</ChartAreas>
</Chart>";
Chart chartPerMonth = new Chart(width: 1000, height: 500, theme: temp).AddTitle(year.ToString()).AddSeries(chartType: "column", xValue: new[] { "Janury", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, yValues: lstArticlesCount).Write("bmp");
return null;
}
catch (Exception e)
{
ViewBag.ErrorTitle = "Server Error";
ViewBag.ErrorDescription = "Please try again later";
return View("~/Views/Shared/ErrorPage.cshtml");
}
}
开发者ID:pabloperfalc,项目名称:TallerDiseno,代码行数:29,代码来源:ReportController.cs
示例13: InitializeBarGraph
private static Chart InitializeBarGraph(SeriesCollection seriesCollection, string yAxisTitle)
{
var chart = new Chart();
//chart.Title = "Burndown";
chart.Type = ChartType.Combo;
chart.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart");
chart.SeriesCollection.Add(seriesCollection);
chart.YAxis.Label.Text = yAxisTitle;
chart.YAxis.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.YAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.XAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
chart.LegendBox.Visible = false;
chart.BorderStyle = System.Web.UI.WebControls.BorderStyle.None;
chart.TitleBox.Visible = false;
chart.Background.Color = System.Drawing.ColorTranslator.FromHtml("#333333");
chart.DefaultSeries.Element.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6");
chart.DefaultElement.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6");
chart.Width = new System.Web.UI.WebControls.Unit(600, System.Web.UI.WebControls.UnitType.Pixel);
chart.Height = new System.Web.UI.WebControls.Unit(400, System.Web.UI.WebControls.UnitType.Pixel);
chart.Font.Name = "Helvetica";
chart.Font.Size = new System.Web.UI.WebControls.FontUnit(24, System.Web.UI.WebControls.UnitType.Pixel);
chart.YAxis.Label.Font = new System.Drawing.Font("Helvetica", 8);
chart.YAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8);
chart.XAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8);
//NOTE: needed to do this for the old version of .net charting (3.4).
chart.FileManager.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart");
chart.FileManager.SaveImage(chart.GetChartBitmap());
//chart.FileManager.FileName = chart.FileManager.TempDirectory + "/" + chart.FileManager.FileName + ".png";
return chart;
}
开发者ID:rkurz,项目名称:Cerebro,代码行数:32,代码来源:ChartService.cs
示例14: ChartActionResult
public ChartActionResult(Chart chart, ChartImageFormat imageFormat = ChartImageFormat.Png)
{
if (chart == null) { throw new ArgumentNullException("chart"); }
_chart = chart;
_imageFormat = imageFormat;
}
开发者ID:rexjohnson,项目名称:GuruPre,代码行数:7,代码来源:ChartActionResult.cs
示例15: ConstructorLoadsTheme
public void ConstructorLoadsTheme() {
//Vanilla theme
/*
* <Chart Palette="SemiTransparent" BorderColor="#000" BorderWidth="2" BorderlineDashStyle="Solid">
<ChartAreas>
<ChartArea _Template_="All" Name="Default">
<AxisX>
<MinorGrid Enabled="False" />
<MajorGrid Enabled="False" />
</AxisX>
<AxisY>
<MajorGrid Enabled="False" />
<MinorGrid Enabled="False" />
</AxisY>
</ChartArea>
</ChartAreas>
</Chart>
*/
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, theme: ChartTheme.Vanilla);
AssertBuiltChartAction(chart, c => {
Assert.AreEqual(c.Palette, DV.ChartColorPalette.SemiTransparent);
Assert.AreEqual(c.BorderColor, Color.FromArgb(0, Color.Black));
Assert.AreEqual(1, c.ChartAreas.Count);
Assert.IsFalse(c.ChartAreas[0].AxisX.MajorGrid.Enabled);
Assert.IsFalse(c.ChartAreas[0].AxisY.MinorGrid.Enabled);
});
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:27,代码来源:ChartTest.cs
示例16: ChartByMonth
//
// GET: /Expense/ChartByMonth
/// <summary>
/// Shows a bar chart based on the expenses between the
/// start and end dates.
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
/// <returns>The bar chart of the expenses by months.</returns>
public ActionResult ChartByMonth(DateTime? start, DateTime? end, int width = 600, int height = 400)
{
if (!end.HasValue)
{
end = DateTime.Now;
}
if (!start.HasValue)
{
start = end.Value.AddYears(-1);
}
var resultByMonth = from e in db.Expenses.Where(x => start <= x.Date && x.Date <= end).ToList()
group e by e.Date.ToString("yyyy. MM.") into expenseGroup
select new
{
Month = expenseGroup.Key,
Value = expenseGroup.Sum(e => e.Amount)
};
resultByMonth = resultByMonth.OrderBy(x => x.Month);
var chart = new Chart(width, height)
.AddSeries(
chartType: "Column",
xValue: resultByMonth.Select(r => r.Month).ToArray(),
yValues: resultByMonth.Select(r => r.Value).ToArray())
.Write(format: "png");
return null;
}
开发者ID:palesz,项目名称:lingocrm,代码行数:38,代码来源:ExpenseController.cs
示例17: PrepChart
/// <summary>
/// Setup the basic settings for a chart, all that needs to be added is a series of data.
/// </summary>
/// <param name="titleText">The title you would like displayed in the graph</param>
/// <returns></returns>
private Chart PrepChart(string titleText)
{
var chart = new Chart();
chart.Width = 412;
chart.Height = 296;
chart.ImageType = ChartImageType.Png;
chart.Palette = ChartColorPalette.BrightPastel;
chart.BackColor = Color.Cornsilk;
chart.RenderType = RenderType.BinaryStreaming;
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.BackGradientStyle = GradientStyle.TopBottom;
chart.BorderlineWidth = 2;
chart.BorderlineColor = Color.Blue;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.AntiAliasing = AntiAliasingStyles.All;
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;
var title = chart.Titles.Add("Main");
title.Text = titleText;
title.Docking = Docking.Top;
title.Font = new Font(FontFamily.GenericSansSerif, 8.25F, FontStyle.Bold);
ChartArea chartArea = chart.ChartAreas.Add("Default");
chartArea.BackColor = Color.Transparent;
chartArea.BorderColor = Color.Red;
chartArea.AxisX.IsMarginVisible = true;
chartArea.Area3DStyle.Enable3D = true;
return chart;
}
开发者ID:ucdavis,项目名称:CRP,代码行数:35,代码来源:IChartProvider.cs
示例18: Weight
public FileStreamResult Weight(int timeFrame = 0)
{
var weightChart = new Chart
{
Width = 600,
Height = 300
};
var weights = _repository.GetWeightsByUser(User.Identity.Name);
if (timeFrame > 0)
{
timeFrame = timeFrame * -1;
var pastDate = DateTime.Today.AddMonths(timeFrame);
weights = weights.Where(w => w.WeightDate > pastDate);
}
weights = weights.OrderBy(w => w.WeightDate);
var builder = new DailyWeightChartBuilder(weights.ToList(), weightChart);
builder.BuildChart();
// Save the chart to a MemoryStream
var imgStream = new MemoryStream();
weightChart.SaveImage(imgStream, ChartImageFormat.Png);
imgStream.Seek(0, SeekOrigin.Begin);
// Return the contents of the Stream to the client
return File(imgStream, "image/png");
}
开发者ID:EdMontalvo,项目名称:TrackIt,代码行数:25,代码来源:ChartController.cs
示例19: paintItem
private void paintItem(Graphics g, int x, int y, Chart chart)
{
System.Diagnostics.Debug.Print("{0}\t{1}\t{2}\t{3}\t{4}", chart.m_obj.Name, chart.m_nLineFromX, chart.m_nLineFromY, chart.m_nLineToX, chart.m_nLineToY);
g.DrawLine(Pens.Black, x + chart.m_nLineFromX, y + chart.m_nLineFromY, x + chart.m_nLineToX, y + chart.m_nLineToY);
foreach (var c in chart._box.Select(_ => _.Value).Where(_ => _ != null))
paintItem(g, x, y, c);
}
开发者ID:danbystrom,项目名称:HeatOn,代码行数:7,代码来源:Form1.cs
示例20: Agitator
public ActionResult Agitator(int Id)
{
var politicalViews = new List<KeyValuePair<string, int>>();
var agitatorHouses = dataManager.AgitatorHouseRelations.GetAll().Where(ah => ah.AgitatorId == Id && ah.HouseId.HasValue).Select(wh => wh.HouseId.Value).ToList();
var houses = dataManager.Houses.GetAll().Where(h => agitatorHouses.Contains(h.Id) && h.Latitude.HasValue && h.Longitude.HasValue).ToList();
var persons = dataManager.Persons.GetAll().Where(p => houses.Select(x => x.Id).Contains(p.HouseId ?? 0)).ToList();
var voters = dataManager.Voters.GetAll().Where(v => persons.Select(x => x.Id).Contains(v.PersonId ?? 0)).ToList();
var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().ToList();
var parties = voterPartyRelations.Where(vp => voters.Select(x => x.Id).Contains(vp.VoterId ?? 0))
.Select(x => dataManager.Parties.Get(x.PartyId ?? 0)).ToList();
foreach (var house in houses)
{
var hPersons = persons.Where(x => x.HouseId == house.Id).ToList();
var hVoters = voters.Where(x => hPersons.Select(x2 => x2.Id).Contains(x.PersonId ?? 0)).ToList();
var hVoterPartyRelations = voterPartyRelations.Where(x => hVoters.Select(x2 => x2.Id).Contains(x.VoterId ?? 0)).ToList();
var hParties = parties.Where(x => hVoterPartyRelations.Select(x2 => x2.PartyId).Contains(x.Id)).ToList();
foreach (var hParty in hParties.GroupBy(x => x.Id).Select(x => x.First()))
{
politicalViews.Add(new KeyValuePair<string, int>(hParty.Name, hVoterPartyRelations.Where(x => x.PartyId == hParty.Id).Count()));
}
}
var chart = new Chart(width: 200, height: 200)
.AddSeries(
name: "Employee",
xValue: politicalViews.Select(p => p.Key).ToArray(),
yValues: politicalViews.Select(p => p.Value).ToArray(),
chartType: "Pie");
return File(chart.GetBytes(), "image/jpeg");
}
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:32,代码来源:ChartController.cs
注:本文中的Chart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论