本文整理汇总了C#中Chart.ToWebImage方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.ToWebImage方法的具体用法?C# Chart.ToWebImage怎么用?C# Chart.ToWebImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.ToWebImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: GetUrlFromChart
public static object GetUrlFromChart(this HtmlHelper helper, Chart chart)
{
string path = "~/Images/graphs/";
string filename = path + Guid.NewGuid();
chart.ToWebImage("jpeg").Save(filename);
return ".." + filename.Substring(1) + ".jpeg";
}
示例3: ToWebImageUsesFormat
public void ToWebImageUsesFormat()
{
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
var image = chart.ToWebImage(format: "png");
Assert.NotNull(image);
Assert.Equal("png", image.ImageFormat);
}
示例4: TemplateWithIncorrectPropertiesThrows
public void TemplateWithIncorrectPropertiesThrows()
{
var template = WriteTemplate(@"<Chart borderWidth=""2""><fjkjkgjklfg /></Chart>");
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: template);
Assert.Throws<InvalidOperationException>(() => chart.ToWebImage(),
"Cannot deserialize property. Unknown property name 'borderWidth' in object \" System.Web.UI.DataVisualization.Charting.Chart");
}
示例5: TemplateWithCommentsDoesNotThrow
public void TemplateWithCommentsDoesNotThrow()
{
var template = WriteTemplate(@"<Chart BorderWidth=""2""><!-- This is a XML comment. --> </Chart>");
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: template);
Assert.NotNull(chart.ToWebImage());
}
示例6: Chart
public ActionResult Chart(string strid, int acYear)
{
ArrayList xValues = new ArrayList();
ArrayList yValues = new ArrayList();
var myChart = new Chart(350, 300, ChartTheme.Blue);
if (acYear == 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.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");
}
else if(acYear==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.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");
}
示例7: TaskDetails
public ActionResult TaskDetails(string id)
{
if (id == null)
{
return RedirectToAction("MessagePage", "Home", "Task ID is null");
}
Chart chart = new Chart(height:400, width:600).AddSeries(name:"Title", chartType:"line");
ViewBag.Chart = chart.ToWebImage().GetBytes();
var task = _dbContext.CoursesCreatingTasks.Find(x => x.Id == ObjectId.Parse(id)).SingleAsync().Result;
return View(task);
}
示例8: ToWebImage
public void ToWebImage() {
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
var image = chart.ToWebImage();
Assert.IsNotNull(image);
Assert.AreEqual("jpeg", image.ImageFormat);
}