如何将3列数据表绑定到asp .net饼图

问题描述:

嗨专家,



我有一个数据表,如

名称    percentahe    count

xxx       10%                   1

yyy       40%                    4



我想将名称和百分比列绑定到 asp .net饼图

为x和y值成员和计数列我想显示为饼图的工具提示

目前无法绑定第3列



Plz帮帮我

提前感谢

(Keerthi Kumar)

Hi experts,

I have a data table like
Name   percentahe   count
xxx       10%                   1
yyy       40%                    4

I wanted to bind name and percentage column to asp .net pie chart
as x and y value member and count column i wanted to show as tooltip of pie chart
presently am not able to bind the 3rd column

Plz help me
thanks in advance
(Keerthi Kumar)

这对我来说很好用

在aspx中;我有以下代码

This works fine for me
In aspx; I have the following code
<chart:chart id="Chart1" runat="server" xmlns:chart="#unknown">
           <series>
               <chart:series name="Series1"></chart:series>
           </series>
           <chartareas>
               <chart:chartarea name="ChartArea1"></chart:chartarea>
           </chartareas>
       </chart:chart>




DataTable dt = new DataTable();

 dt.Columns.Add(new DataColumn("Value1"));
 dt.Columns.Add(new DataColumn("Value2"));
 dt.Columns.Add(new DataColumn("Value3"));
 for (int i = 1; i <= 5; i++)
 {
     dt.Rows.Add("Hi" + i, 12*i, "Tooltip"+i);
 }

 Chart1.Series[0].XValueMember = "Value1";
 Chart1.Series[0].YValueMembers = "Value2";
 Chart1.Series[0].YValuesPerPoint = 5;
 Chart1.Series[0].ChartType = SeriesChartType.Pie;
 //Chart1.Series[0].ToolTip = "#VALY";
 Chart1.DataSource = dt;
 Chart1.DataBind();

 for(int cnt=0; cnt<chart1.series[0].points.count;cnt++>            {
     Chart1.Series[0].Points[cnt].ToolTip = dt.Rows[cnt]["Value3"].ToString();
 }


试试这个

http://www.intertech.com/ Blog / create-asp-net-4-0-pie-chart-with-tooltips / [ ^ ]