如何使用Microsoft Chart Control for .NET Framework 3.5绘制雷达图。我可以使用MSDN中的以下代码绘制“列”图表。我找不到雷达图的任何例子。
Series ChampionshipsSeries = chtNBAChampionships2.Series["Championships"];
//Add data points
ChampionshipsSeries.Points.AddXY("Celtics", 17);
ChampionshipsSeries.Points.AddXY("Lakers", 15);
ChampionshipsSeries.Points.AddXY("Bulls", 6);
ChampionshipsSeries.Points.AddXY("Spurs", 4);
ChampionshipsSeries.Points.AddXY("76ers", 3);
ChampionshipsSeries.Points.AddXY("Pistons", 3);
ChampionshipsSeries.Points.AddXY("Warriors", 3);
寻求你的帮助。
答案 0 :(得分:3)
最后,我在尝试了以下来源的示例后自我管理,
Samples for Chart Control - .NET Framework 4
虽然这些示例适用于.NET Framework 4,但我在.NET Framework 3.5中尝试使用Radar Chart并且它可以工作。
如果您有兴趣,可以查看此页面http://nazmulweb.com/site5/demo/chart/
后来,我从http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=1591
找到了.NET Freamework 3.5的示例作为现成的参考,你可以按照这个,
/*
--------------------------
Criteria Volvo Toyota
-------- ----- ------
Speed 37 23
Fuel 32 19
Comfort 38 31
Safety 39 33
--------------------------
*/
DataTable dt = new DataTable();
dt.Columns.Add("Criteria");
dt.Columns.Add("Volvo");
dt.Columns.Add("Toyota");
DataRow dr1 = dt.NewRow();
dr1.ItemArray = new object[] { "Speed", 37, 23 };
dt.Rows.Add(dr1);
DataRow dr2 = dt.NewRow();
dr2.ItemArray = new object[] { "Fuel", 32, 19 };
dt.Rows.Add(dr2);
DataRow dr3 = dt.NewRow();
dr3.ItemArray = new object[] { "Comfort", 38, 31 };
dt.Rows.Add(dr3);
DataRow dr4 = dt.NewRow();
dr4.ItemArray = new object[] { "Price", 39, 33 };
dt.Rows.Add(dr4);
Chart aRadarChart = new Chart();
aRadarChart.Width = Unit.Pixel(500);
aRadarChart.DataSource = dt;
// Add title
aRadarChart.Titles.Add("TOYOTA VS VOLVO");
// Add a legend
Legend lgnd = new Legend();
lgnd.Enabled = true;
aRadarChart.Legends.Add(lgnd);
//Important: add ChartArea, otherwise no graph will be shown
ChartArea ca = new ChartArea("myChartArea");
aRadarChart.ChartAreas.Add(ca);
string car = String.Empty;
for (int i = 1; i < dt.Columns.Count; i++)
{
car = dt.Columns[i].ColumnName;
aRadarChart.Series.Add(car);//Name of the series :Volvo and Toyota
aRadarChart.Series[car].YValueMembers = car;//Either Volvo or Toyota
aRadarChart.Series[car].XValueMember = dt.Columns[0].ColumnName;//Criteria
//Define here: what kind of Chart you want
aRadarChart.Series[car].ChartType = SeriesChartType.Radar;
}
//binding data
aRadarChart.DataBind();
//Add Chart to a PlaceHolder Control
plhForChart.Controls.Add(aRadarChart);
//Page.Controls.Add(aRadarChart);
//for saving image
aRadarChart.SaveImage(Server.MapPath("App_Data/Sample.jpg"));