如何将3列数据表绑定到asp .net饼图 [英] how to bind data table with 3 columns to asp .net pie chart

查看:91
本文介绍了如何将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 / [ ^ ]


这篇关于如何将3列数据表绑定到asp .net饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆