本文介绍了如何使用Microsoft Chart Control for .NET Framework 3.5绘制雷达图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Microsoft Chart Control for .NET Framework 3.5绘制雷达图表。我可以使用MSDN中的以下代码绘制列图表。我找不到任何雷达图的例子。

 系列锦标赛系列= chtNBAChampionships2.Series [锦标赛]; 
//添加数据点
ChampionshipsSeries.Points.AddXY(凯尔特人,17);
ChampionshipsSeries.Points.AddXY(湖人,15);
ChampionshipsSeries.Points.AddXY(公牛队,6);
ChampionshipsSeries.Points.AddXY(马刺,4);
ChampionshipsSeries.Points.AddXY(76ers,3);
ChampionshipsSeries.Points.AddXY(活塞,3);
ChampionshipsSeries.Points.AddXY(勇士,3);

寻找您的善意帮助。

解决方案

最后,我在对来自以下源码的示例进行了实验之后管理自己, .msdn.microsoft.com / mschart / Release / ProjectReleases.aspx?ReleaseId = 4418rel =nofollow>用于图表控件的样本 - .NET Framework 4



虽然这些例子都是针对.NET Framework 4的,但我在.NET Framework 3.5中为它测试了它,并且它工作正常。



如果您有兴趣,您可能有看看这个页面,

稍后,我从



作为一个理由dy引用,你可以关注这个,

  / * 
----------- ---------------
标准沃尔沃丰田
-------- ----- ------
速度37 23
燃料32 19
舒适度38 31
安全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);

图表aRadarChart =新图表();
aRadarChart.Width = Unit.Pixel(500);
aRadarChart.DataSource = dt;
//添加标题
aRadarChart.Titles.Add(TOYOTA VS VOLVO);
//添加图例
图例lgnd = new Legend();
lgnd.Enabled = true;
aRadarChart.Legends.Add(lgnd);

//重要:添加ChartArea,否则不显示图形
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;
$ b $ aRadarChart.Series.Add(car); //系列名称:沃尔沃和丰田
aRadarChart.Series [汽车] .YValueMembers =汽车; //沃尔沃或丰田
aRadarChart.Series [car] .XValueMember = dt.Columns [0] .ColumnName; // Criteria
//定义这里:你想要什么样的Chart
aRadarChart.Series [car] .ChartType = SeriesChartType.Radar;
}

//绑定数据
aRadarChart.DataBind();
//将图表添加到PlaceHolder控件
plhForChart.Controls.Add(aRadarChart);
//Page.Controls.Add(aRadarChart);

//用于保存图像
aRadarChart.SaveImage(Server.MapPath(App_Data / Sample.jpg));


How can I draw a Radar Chart using Microsoft Chart Control for .NET Framework 3.5. I can draw "column" chart using the following code from MSDN. I could not find any example for Radar Chart.

    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);

Looking for your kind help.

解决方案

Finally I managed myself after doing experimenting with the examples from the following source,

Samples for Chart Control - .NET Framework 4

Though the examples are for .NET Framework 4, I tried it in .NET Framework 3.5 for Radar Chart and it worked.

If you are interested you may have a look at this page, http://nazmulweb.com/site5/demo/chart/

Later on , I have found the examples for .NET Freamework 3.5 from http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=1591

As a ready reference, you can follow this one,

        /*
    --------------------------
    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"));

这篇关于如何使用Microsoft Chart Control for .NET Framework 3.5绘制雷达图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:17