本文整理汇总了C#中Chart.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.Write方法的具体用法?C# Chart.Write怎么用?C# Chart.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.Write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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");
}
示例3: WriteUpdatesResponse
public void WriteUpdatesResponse()
{
var context = GetContext();
var chart = new Chart(context, GetVirtualPathProvider(), 100, 100);
chart.Write();
Assert.Equal("", context.Response.Charset);
Assert.Equal("image/jpeg", context.Response.ContentType);
Assert.True((_writeData != null) && (_writeData.Length > 0));
}
示例4: WriteThrowsWithInvalidFormat
public void WriteThrowsWithInvalidFormat()
{
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
Assert.ThrowsArgument(() => chart.Write("foo"),
"format", "\"foo\" is invalid image format. Valid values are image format names like: \"JPEG\", \"BMP\", \"GIF\", \"PNG\", etc.");
}
示例5: WriteWorksWithJPGFormat
public void WriteWorksWithJPGFormat()
{
var response = new Mock<HttpResponseBase>();
var stream = new MemoryStream();
response.Setup(c => c.Output).Returns(new StreamWriter(stream));
var context = new Mock<HttpContextBase>();
context.Setup(c => c.Response).Returns(response.Object);
var chart = new Chart(context.Object, GetVirtualPathProvider(), 100, 100);
chart.Write("jpeg");
byte[] a = stream.GetBuffer();
stream.SetLength(0);
chart.Write("jpg");
byte[] b = stream.GetBuffer();
Assert.Equal(a, b);
}
示例6: ScoreChart
public ActionResult ScoreChart(int id)
{
var game = handler.GetGameInfo(id);
var chart = new Chart(width: 350, height: 250)
.AddTitle("Game Focus")
.AddSeries(
name: "Score",
chartType: "Radar",
xValue: new[] { "Strategic Difficulty", "Replay Value", "Mechanical Difficulty", "Ease of Access", "Atmosphere" },
yValues: new[] {
game.Score.iStrategy.ToString(),
game.Score.iLongevity.ToString(),
game.Score.iMechanics.ToString(),
game.Score.iEase.ToString(),
game.Score.iAtmosphere.ToString()
});
chart.Write();
return null;
}
示例7: MyChart
/// <summary>
/// Render weight graph.
/// </summary>
/// <param name="username">The username to display graph for.</param>
/// <returns></returns>
public ActionResult MyChart(string username)
{
var dates = new List<DateTime>();
var weights = new List<double>();
var plots = _context.Users.Find(username).WeightPlots.Where(x=>x.PlotStamp>DateTime.Parse("2015-01-01")).OrderByDescending(x => x.PlotStamp);
var minWeight = plots.Min(x => x.Weight);
var maxWeight = plots.Max(x => x.Weight);
minWeight -= 2;
maxWeight += 2;
foreach(var plot in plots)
{
dates.Add(plot.PlotStamp);
weights.Add(Math.Round(plot.Weight,2));
}
var chart = new Chart(540,280);
chart.AddSeries
(
chartType: "line",
xValue: dates,
yValues: weights
);
chart.SetYAxis("", Math.Round(minWeight,1), Math.Round(maxWeight,1));
chart.Write("png");
return null;
}