考慮構建ASP.NET圖表圖像的ASP.NET MVC控制器方法。ASP.NET圖表:在X和Y軸上設置字體
public FileStreamResult MakeImg(IEnumerable<MyObj> stats)
{
Chart barchart = BarChart(400, 300);
Series series1 = new Series("Series1");
series1.ChartArea = "ca1";
series1.ChartType = SeriesChartType.Column;
series1.IsValueShownAsLabel = true;
series1.Font = new Font("Verdana", 9f, FontStyle.Regular);
barchart.Series.Add(series1);
// Set chart data source
barchart.DataSource = stats;
// Set series members names for the X and Y values
barchart.Series["Series1"].XValueMember = "FriendlyDate";
barchart.Series["Series1"].YValueMembers = "NumRecords";
// Data bind to the selected data source
barchart.DataBind();
MemoryStream ms = new MemoryStream();
barchart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return new FileStreamResult(ms, "image/png");
}
的圖像被呈現在一個沒有吸引力的方式:
fugly http://www.imagechicken.com/uploads/1253830647005451400.png
問題:
- X和Y軸標籤:如何用於設置字體編程 - 即Y上的0到35,以及X上的日期
- 數據 - 即12,0,0,3,6?
同樣,這將爲您平滑一切:chart1.AntiAliasing = AntiAliasingStyles.All; – Simon 2012-10-26 21:37:47