{"id":701,"date":"2008-04-28T23:26:12","date_gmt":"2008-04-29T03:26:12","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/2008\/04\/28\/google-charts\/"},"modified":"2008-04-28T23:26:12","modified_gmt":"2008-04-29T03:26:12","slug":"google-charts","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/04\/28\/google-charts\/","title":{"rendered":"Google Charts"},"content":{"rendered":"<p>Have you guys seen <a href=\"http:\/\/code.google.com\/apis\/chart\/\">Google Charts<\/a>? It&#8217;s a quirky little API I didn&#8217;t know existed until I saw a passing allusion to it. Essentially, you pass it a specially-crafted URL (essentially the definition of an API) and it will generate a PNG image.<\/p>\n<p>Here&#8217;s a <a href=\"http:\/\/chart.apis.google.com\/chart?cht=lc&#038;chd=t:20,40,200,32,76,141&#038;chs=500x300&#038;chl=Hello|World&#038;chxt=x,y&#038;chxl=0:|First|Last1:0|100\">fairly random line graph<\/a>. My labeling of the axes makes no sense, but it was nonsensical data anyway.<\/p>\n<p>One of the cooler things they support is a &#8220;map&#8221; type of chart, like <a href=\"http:\/\/chart.apis.google.com\/chart?chco=f5f5f5,edf0d4,6c9642,365e24,13390a&#038;chd=s:fSGBDQBQBBAGABCBDAKLCDGFCLBBEBBEPASDKJBDD9BHHEAACAC&#038;chf=bg,s,eaf7fe&#038;chtm=usa&#038;chld=NYPATNWVNVNJNHVAHIVTNMNCNDNELASDDCDEFLWAKSWIORKYMEOHIAIDCTWYUTINILAKTXCOMDMAALMOMNCAOKMIGAAZMTMSSCRIAR&#038;chs=440x220&#038;cht=t\">this US map<\/a>. The URL is a bit tricky, though this one of <a href=\"http:\/\/chart.apis.google.com\/chart?cht=t&#038;chs=440x220&#038;chd=s:Af9&#038;chco=cccccc,edf0d4,13390a,999999&#038;chld=UYVECO&#038;chtm=south_america&#038;chf=bg,s,EAF7FE\">South America<\/a> is easier to understand: <tt>chco<\/tt> (presumably &#8220;CHart COlor&#8221;) sets the colors, with the first being the &#8216;default&#8217; color. <tt>chld<\/tt> lists the countries, as they should map up to the colors: UYVECO is &#8220;Uruguay,&#8221; &#8220;Venezuela,&#8221; and &#8220;Colombia.&#8221;<\/p>\n<p>What has me particularly interested is that I&#8217;ve recently installed code to watch connections to my <a href=\"http:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol\">NTP<\/a> servers. Here&#8217;s <a href=\"http:\/\/ttwagner.com\/ntp_stats.txt\">my Texas box<\/a>, a stratum 2 server in the NTP pool (pool.ntp.org). I bumped it up to list a 10 Mbps connection speed to signal that I could handle a lot more queries than the average, although it&#8217;s still nowhere near its limit. In addition to the stats you see there, it keeps a &#8220;dump file&#8221; of every single connection. (As an aside, this strikes me as inefficient and I want to write an SQL interface to keep aggregate stats&#8230; But that&#8217;s <i>very<\/i> low-priority right now.)<\/p>\n<p>Further, I have <a href=\"http:\/\/ttwagner.com\/newmain\/ipgeo\/\">some IPGeo code<\/a> I played with. More than meets the eye, actually: a separate database can give a city\/state in addition to the country. (It comes from the free <a href=\"http:\/\/www.maxmind.com\/app\/geolitecity\">MaxMind GeoLite City<\/a> database.) Thus I could, in theory, parse the log file created, match each IP to a state, and plot that on a US map.<\/p>\n<p>This reminds me that I never posted&#8230; I set up NTP on the second server Andrew and I got, where we&#8217;re intending to consolidate everything, but haven&#8217;t had time yet. It sat unused for a while, keeping exceptionally good time. So, with Andrew&#8217;s approval, I submitted it to the NTP pool. I set the bandwidth to 3 Mbps, lower than the 10 Mbps my Texas box is at.<\/p>\n<p>I was somewhat surprised to see it handling significantly <i>more<\/i> NTP queries. (They&#8217;re not online, since the box isn&#8217;t running a webserver, but for those in-the-know, <tt>~\/ntp\/ntp_clients_stats | less<\/tt> produces the same type of output seen <a href=\"http:\/\/ttwagner.com\/ntp_stats.txt\">here<\/a>.) It turns out that a flaw in the IPGeo code assigning the server to the right &#8216;zones&#8217; for some reason thought our server was in Brazil. Strangely, while the United States has 550 (at last count) servers in the pool, South America has 16. Thus I got a much greater share of the traffic. It&#8217;s still low: at its peak it looks like me might use 2GB of bandwidth.<\/p>\n<p>So there are a few graphs I think would be interesting:<\/p>\n<ul>\n<li>A <a href=\"http:\/\/chart.apis.google.com\/chart?cht=lc&#038;chd=t:20,40,200,32,76,141&#038;chs=500x300&#038;chl=Hello%7CWorld&#038;chxt=x,y&#038;chxl=0:%7CFirst%7CLast1:0%7C100\">line graph<\/a> of the number of clients served over time. Using Google Charts would save me from having to deal with RRDTool \/ MRTG.<\/li>\n<li>A <a href=\"http:\/\/chart.apis.google.com\/chart?cht=t&#038;chs=440x220&#038;chd=s:Af9&#038;chco=cccccc,edf0d4,13390a,999999&#038;chld=UYVECO&#038;chtm=south_america&#038;chf=bg,s,EAF7FE\">map<\/a> of South American countries, colored to show which of the countries are querying the server most frequently. (The same could be done for my US server, on a state-by-state basis.)<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Have you guys seen Google Charts? It&#8217;s a quirky little API I didn&#8217;t know existed until I saw a passing allusion to it. Essentially, you pass it a specially-crafted URL (essentially the definition of an API) and it will generate &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/04\/28\/google-charts\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,10,11,15,18,22,24],"tags":[],"class_list":["post-701","post","type-post","status-publish","format-standard","hentry","category-cool-links","category-ideas","category-insanity","category-living","category-ocd","category-programming","category-rants-raves"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=701"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/701\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}