You are setting values int he wrong columns:

data.setValue(0,1,'Client 1 INCORPORATED') ;
data.setValue( 0,0,1);

should be the other way around:

data.setValue(0,0,'Client 1 INCORPORATED') ;
data.setValue(0,1,1);

since your string column is first and the number column is second.  
Incidentally, there is an easier way to add data without resorting to so 
many setValue calls; just pass in arrays of data in the addRows call:

data.addRows([
    ['Client 1', 1],
    ['Client 2', 9],
    ['Client 3', 4]
]);

On Monday, May 26, 2014 10:47:25 AM UTC-4, David Mhluzi wrote:
>
> <script type=text/javascript>
> google.load( "visualization" , "1" , {packages: [ "corechart" ] });
> google.setOnLoadCallback(drawChart);
> function drawChart() {
> var data = new google.visualization.DataTable();
> data.addColumn('string', 'ClientName ');
> data.addColumn('number', 'Number');
> data.addRows(1);data.setValue(0,1,'Client 1 INCORPORATED') ;data.setValue( 
> 0,0,1);var chart = new 
> google.visualization.BarChart(document.getElementById('chart_div'));chart.draw(data,
>  
> {title:'Report', titleTextStyle:{color: 'Blue'},vAxis: { title: 'Client', 
> titleTextStyle: { color: 'red' } }}); }</script>
>
>
> 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