Hi there,
I am trying to build a pie chart using c# code behind, and for some reason,
don't appear to have the percentage showing on all slices. They are
available when i click on each slice though.
Here is my code:
function drawMsgTypeCount() {
var hdValue = document.getElementById("<%=hdMsgTypeCount.ClientID%>"
).value;
var response = $.parseJSON(hdValue);
var data = new google.visualization.DataTable();
data.addColumn(
'string', 'MessageType');
data.addColumn(
'number', 'Count');
for (var i = 0; i < response.length; i++) {
var row = new Array();
row[0] = response[i].MessageType;
row[1] = parseInt(response[i].Count);
data.addRow(row);
}
var options = {
title:
'My chart',
sliceVisibilityThreshold:
'0',
pieSliceText:
'percentage'
};
var chart = new google.visualization.PieChart(document.getElementById(
'msgTypeCount_Chart'));
public StringBuilder msgTypeCountData = new StringBuilder();
public JavaScriptSerializer json = new JavaScriptSerializer();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (User.Identity.IsAuthenticated)
{
json.Serialize(GetMessageTypeCount(), msgTypeCountData);
hdMsgTypeCount.Value = msgTypeCountData.ToString();
}
}
}
private List<MessageTypeCount> GetMessageTypeCount()
{
var returnList = new List<MessageTypeCount>();
string sql = "select msgtype, counter from MsgDateSummary where
sender = 'sender1'";
using (var conn = new
SqlConnection(WebConfigurationManager.ConnectionStrings["Connectino"].ConnectionString))
{
conn.Open();
var cmd = new SqlCommand(sql, conn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
returnList.Add(new MessageTypeCount { MessageType =
reader.GetValue(0).ToString(), Count = reader.GetValue(1).ToString() });
}
}
}
return returnList;
}
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.