Ahh, ok. Here's how you would do it:
var dataArray = [
['ID', '', '', 'frequncy', '']
];
for (var i = 0; i < mymap.length; i++) {
dataArray.push([mymap[i], 1, 6, mymapcount[i], 6]);
}
var data = google.visualization.arrayToDataTable(dataArray);
If you know the data types of your columns ahead of time, I suggest a
slightly different approach, as it is less likely to encounter problems (as
there are some data types that the arrayToDataTable method doesn't handle
well):
var data = google.visualization.arrayToDataTable();
data.addColumn('string', 'ID');
data.addColumn('number', '');
data.addColumn('number', '');
data.addColumn('number', 'frequency');
data.addColumn('number', '');
for (var i = 0; i < mymap.length; i++) {
data.addRow([mymap[i], 1, 6, mymapcount[i], 6]);
}
On Thursday, September 27, 2012 2:10:53 AM UTC-4, taps wrote:
>
> I got that value but now I need to take that in loop.so how can I do
> that.I mean I want to create row based on loop like this:
> for(var i=0;i<mymap.length;i++)
> {
> var data = google.visualization.arrayToDataTable([
> ['ID', '', '', 'frequncy', ''],
>
> [mymap[i], 1, 6, mymapcount[i], 6 ]
> ]);
> }
> how should I create that?
>
> On Wednesday, 26 September 2012 20:46:21 UTC+5:30, asgallant wrote:
>>
>> Assuming mymap and mymapcount are populated correctly, your code looks
>> like it would work as is. Do your alert statements produce the results you
>> expect? If they do, then what happens when you try to draw a chart?
>>
>> On Wednesday, September 26, 2012 2:02:27 AM UTC-4, taps wrote:
>>>
>>> I have an array which I create from dynamic data.and I want to use this
>>> as haxis and yaxis.so how can I do that?
>>> I am getting value for maymap array but for mymapcount m not getting.
>>> my code is:
>>>
>>> var mymap=[];
>>> var mymapcount=[];
>>>
>>> function drawChart() {
>>> alert(mymap);
>>>
>>> alert(mymapcount);
>>> var dt=mymapcount[0];
>>> alert(dt);
>>> var data = google.visualization.arrayToDataTable([
>>> ['ID', '', '', 'frequncy', ''],
>>>
>>> [mymap[0], 1, 6, mymapcount[0], 6 ],
>>> [mymap[1], 2, 9, 9, 9],
>>> [mymap[2], 3, 3, 3, 3],
>>> [mymap[3], 4, 8, 8, 8],
>>> [mymap[4], 5, 2, 2, 2],
>>> ['helo', 6, 5, 5, 5]
>>> ]);
>>>
>>>
>>>
>>
--
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/-/ez5kgUrs654J.
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.