At least part of your problem is that you are doing a google.load every time drawChart(data_array) is called. You should not be doing this, and it can cause undefined behavior. Bring the google.load call out of the function, and things may work. Your code is very confusing to read and could use some reorganization/formatting for readability. Also, while it doesn't affect JavaScript specifically, it's generally a good idea to define your functions before they are called.
I hope I helped. On Mon, Apr 6, 2015 at 2:27 PM G Z <[email protected]> wrote: > Thanks man those two things fixed it very helpful thank you. > > > On Monday, April 6, 2015 at 11:15:39 AM UTC-6, G Z wrote: > >> Here is my code, I'm using a custom library I built that allows me to >> make rest commands, to interface with a rest api plugin that sits ontop of >> my db. I'm trying to get my cpu usage graph to display, however >> following the example on the documentation doesn't seem to be working. >> my console doesn't throw an answer but no graph shows up and I can >> verify in console that my data is there. >> >> any help would be appriciated. >> >> >> >> >> <!DOCTYPE HTML> >> >> >> <html> >> >> >> <head> >> >> >> <title>TheWayWardJourney</title> >> >> <script src="cynergi.js"></script> >> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/ >> jquery.min.js"></script> >> <script type="text/javascript" src="https://www.google.com/jsapi"></ >> script> >> <script> >> function updateData(){ >> // this is retrieving rows from the db and looping through them. >> var data = Cynergi.get('http://youllneverknow:3000/computer_ >> stats?order=time.asc'); >> var data_array = [] >> $.each( data, function( i, item ) { >> html_insert = 'Computer Name:' + item.computer_name + '<br>Operating >> System:' + item.operating_system + '<br>CPU Model: ' + item.cpu_model + >> '<br>Cores >> Assigned: ' + item.cores + '<br>CPU MHz: ' + item.cpu_mhz + '<br>CPU >> Cache: ' + item.cpu_cache + '<br>Net Devices: ' + item.net_devices + >> '<br>Devices: >> ' + item.devices; >> >> stats = 'Total Memory: ' + item.total_memory + '<br>Free Memory:' + >> item.free_memory + '<br> Active Memory:' + item.active_memory + '<br> >> Bounce Memory:' + item.bounce_memory + '<br> Buffered Memory:' + >> item.buffers_memory >> + '<br> Locked Memory:' + item.locked_memory + '<br> Swap Memory:' + item >> .swap_memory + '<br> Swap Free:' + item.swapfree_memory >> >> var time = new Date(parseInt(item.time)) >> data_array.push([time, item.cpu_usage]); >> }); >> >> >> console.log(data_array); >> $( "#computer_info" ).html(html_insert); >> $( "#computer_stats" ).html(stats); >> setTimeout(function(){ updateData(); }, 30000); >> } >> updateData(); >> >> function update_messages(){ >> >> var message_data = Cynergi.get('http://neverknow. >> com:3000/page_contact?order=time.asc'); >> var message_insert = ''; >> $.each( message_data, function( i, item ) { >> var time = new Date(parseInt(item.time)) >> message_insert = message_insert + '<p>From: ' +item.name+ '</p><p>Message: >> ' + item.message + '</p><p>Email: ' + item.email + '</p><p>Time: ' + >> time + '</p><button onclick="delete_post(' + item.id + >> ')">Delete</button>' >> }); >> >> $( "#messages" ).html(message_insert); >> setTimeout(function(){ update_messages(); }, 1000); >> } >> >> >> update_messages(); >> >> var d = new Date(); >> var time = d.getTime(); >> var post = {"name":"Grant Zukel","email":"Test Email","message":"Test >> Message","read":"no","username":"zukeru","time":time}; >> var json_data = post; >> Cynergi.insert('http://neverknow.com:3000/page_contact', json_data); >> >> >> //this is how you delete from the db >> function delete_post(id){ >> if (confirm('Are you sure you want to delete this post?')) { >> Cynergi.delete('http://neverknow:3000/page_contact?id=eq.' + id); >> } >> } >> >> >> var d = new Date(); >> var time = d.getTime(); >> var post = {"name":"Grant Zukel","email":"Test Email@fuckaroasdasd", >> "message":"Test Message UPDATED","read":"no","username":"zukeruasdasd"," >> time":time}; >> var json_data = post; >> Cynergi.update('http://thewaywardjourney.com:3000/page_contact?id=eq.26' >> , json_ >> > ... > > -- > You received this message because you are subscribed to the Google Groups > "Google Chart 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-chart-api. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Chart 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-chart-api. For more options, visit https://groups.google.com/d/optout.
