Thank you Andrew, True I was setting values to the wrong columns, Fixed it 
and it works thank you.

On Friday, May 23, 2014 3:18:20 PM UTC+2, David Mhluzi wrote:
>
>    <td>
>
>              <div>
>             <asp:Literal ID="lt" runat="server"></asp:Literal>
>              </div> 
>             <div id="chart_div" style="width: 550px; height: 400px;"></div>
>         </td>
>
>
>
>         protected void Page_Load(object sender, EventArgs e)
>
>     {
>        if (Page.IsPostBack == false)
>          {
>            BindBarChart();
>          }
>     }
> private DataTable GetBarData() {
>     DataTable dt = new DataTable();
>     using (SqlConnection conn = new   
> SqlConnection(Application_Info.CompanyConnection()))
>     {
>             string cmd = "select ID, ClientName from Company with(nolock)"
>             SqlDataAdapter adp = new SqlDataAdapter(cmd, conn);
>             adp.Fill(dt);
>             return dt;
>     }}
>
>     private void BindBarChart() {
>     StringBuilder str = new StringBuilder();
>     DataTable dt = new DataTable();
>
>     try
>     {
>         dt = GetBarData();
>         str.Append(@"<script type=text/javascript> google.load( 
> *visualization*, *1*, {packages:[*corechart*]});
>                    google.setOnLoadCallback(drawChart);
>
>                     function drawChart() {
>                     var data = new google.visualization.DataTable();
>                     data.addColumn('number', 'Number');
>                     data.addColumn('string', 'ClientName');
>                     data.addRows(" + dt.Rows.Count + ");");
>
>         for (int i = 0; i <= dt.Rows.Count - 1; i++)
>         {
>             str.Append("data.setValue( " + i + "," + 0 + "," + "'" + 
> dt.Rows[i]["Number"].ToString() + "');");
>             str.Append("data.setValue(" + i + "," + 1 + "," + 
> dt.Rows[i]["ClientName"].ToString() + ") ;");
>         }
>
>         str.Append("var chart = new 
> google.visualization.BarChart(document.getElementById('chart_div'));");
>         str.Append("chart.draw(data, {title:'Report', titleTextStyle:{color: 
> 'Blue'},");
>         str.Append("vAxis: { title: 'Client', titleTextStyle: { color: 'red' 
> } }");
>         str.Append("}); }");
>         str.Append("</script>");
>         lt.Text = str.ToString().TrimEnd(',').Replace('*', '"');
>     }
>     catch { }}
>
>
> Please help
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to