0
如何在GoogleChart中使用任何数据集形式的SQL?我真的很喜欢googleChart。但我想用C#中的Sql查询结果的数据集使用Gchart?如何在GoogleChart中使用任何数据集形式的SQL?
如何在GoogleChart中使用任何数据集形式的SQL?我真的很喜欢googleChart。但我想用C#中的Sql查询结果的数据集使用Gchart?如何在GoogleChart中使用任何数据集形式的SQL?
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;