2009-04-26 13 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; 
相關問題