2009-04-26 33 views

回答

0

Google图表为数据馈送格式化字符串,因为我相信您知道。

您将需要遍历数据集并生成该字符串,然后将其写入到字面控件中的页面。

例如

DataSet d = GetDataSet();// returns your data 
string percentages = string.Empty; 
string names = string.Empty; 
string baseUrl = "http://chart.apis.google.com/chart?cht=p3&chs=250x100"; 

foreach(DataRow row in d.Tables[0].Rows) 
{ 
    string tName = row["name"].ToString(); 
    int value = (int)row["value"]; 
    names += name + "|"; 
    percentages += value.ToString() + ","; 
} 

names = names.TrimEnd('|'); 
percentages = percentages.TrimEnd(','); 

string fullUrl = baseUrl + "&chd=t:" + percentages; 
fullUrl += "&chl=" + namesl 


image1.ImageUrl = fullUrl; 
相关问题