You're welcome.
On Saturday, January 19, 2013 6:27:10 PM UTC-5, Andy Gan wrote:
>
> Worked like a charm. Thanks a bunch mate for the right answer and for the
> quick response!
>
>
> On Saturday, 19 January 2013 02:54:03 UTC, asgallant wrote:
>>
>> Try it in Chrome and look in the developer's console for error messages
>> to see what might be going on. At a guess, I would say that
>> record["cost"] is being input as a string instead of a number (test with
>> alert(typeof
>> rowdata[2][1]);)..
>>
>> On Friday, January 18, 2013 7:30:56 PM UTC-5, Andy Gan wrote:
>>>
>>> Hi asgallant,
>>>
>>> I'm having a similar issue, and I have tried your technique but failed.
>>> What's wrong here? The array looks fine, as evidenced by the testing, but
>>> for some reason it refuses to push the data. It works if I comment out the
>>> section in blue though.
>>>
>>> Any help would be tremendous!
>>>
>>> Cheers.
>>>
>>> Andy
>>>
>>> // Create the data table.
>>> var data = new google.visualization.DataTable();
>>> data.addColumn('string', 'RAG');
>>> data.addColumn('number', 'Cost');
>>>
>>> // initiates array, and tries push into it
>>> var rowdata = [ ['a',1000] ];
>>> rowdata.push(['b',200]);
>>> alert('2nd row ' + rowdata[1][0] + ' | '+rowdata[1][1]); // this
>>> is OK, returns '2nd row b | 200'
>>>
>>> // iterate through data
>>> act({id:itcap}).each(function (record,recordnumber) {
>>> alert('test 3rd row ' + record["rag"] + ' | '+record["cost"]); //
>>> this is also ok, returns 'test 3rd row A | 60'
>>> //
>>> this proves that record["rag"] and record["cost"] is OK
>>> rowdata.push([record["rag"],record["cost"]]);
>>> });
>>> alert('3rd row ' + rowdata[2][0] + ' | '+rowdata[2][1]); // this
>>> is OK, returns '3rd row A | 60' as expected
>>>
>>> // adds into the data table
>>> data.addRows(rowdata); // no
>>> data appears
>>>
>>>
>>> On Monday, 10 December 2012 17:47:10 UTC, asgallant wrote:
>>>>
>>>> You are creating rowData as a string, not an array, which is why it
>>>> doesn't work. Try this instead:
>>>>
>>>> var rowData = ['a', 10];
>>>> for (var i=0;i<=10;i++){
>>>> c[i]= id.firstChild.getElementsByTagName('th')[i].innerHTML;
>>>> rowData.push([c[i], 10]);
>>>> }
>>>>
>>>> On Monday, December 10, 2012 3:21:21 AM UTC-5, Logesh waran wrote:
>>>>>
>>>>> Hi ,
>>>>> I am using a javascript function to get the row data and storing that
>>>>> in a variable called 'rowData' .
>>>>> Now the value of rowData is ['CVS update Issue',10],['Testbed Issue -
>>>>> Ping Failure',10],['Testbed Issue - Software Missing',10]
>>>>> But when substituted in the addRows([rowData]) it is not creating any
>>>>> chart .
>>>>> But when the values is directly given without using a variable , the
>>>>> chart is produced .
>>>>>
>>>>> Please see my script below .Kindly help .
>>>>>
>>>>> <script type="text/javascript">
>>>>>
>>>>> google.load('visualization', '1.0', {'packages':['corechart']});
>>>>> google.setOnLoadCallback(drawChart);
>>>>>
>>>>> function drawChart() {
>>>>> var data = new google.visualization.DataTable();
>>>>>
>>>>> var rowData="['a',10]";
>>>>>
>>>>> var id= document.getElementById('summary');
>>>>>
>>>>> var c = new Array();
>>>>>
>>>>> for(var i=0;i<=10;i++){
>>>>> c[i]=
>>>>> id.firstChild.getElementsByTagName('th')[i].innerHTML;
>>>>> rowData="['"+c[i]+"',10]"+','+ rowData;
>>>>> }
>>>>>
>>>>>
>>>>> data.addColumn('string', 'Suite');
>>>>> data.addColumn('number', 'TestCases');
>>>>> data.addRows(rowData);
>>>>> // Here is where the problem is .how
>>>>> can i handle this with a variable .
>>>>> var options = {'title':'FA','width':400,'height':300};
>>>>> var chart = new
>>>>> google.visualization.PieChart(document.getElementById('chart_div'));
>>>>> chart.draw(data, options);
>>>>> }
>>>>> </script>
>>>>>
>>>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/LvP8CNbYfzQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.