Make charts online using the Google Chart API ±¸±Û Â÷Æ® API¸¦ »ç¿ëÇÏ¿© Â÷Æ®¸¦ ¸¸µé¾î ¿Â¶óÀÎ

Posted on December 1, 2008 at 5:34 am 12 ¿ù 1 ÀÏ, 2008 °Ô½ÃµÊ ¿ÀÀü 5:33

The Google Chart API is a web service that you can connect to quickly generate charts for your blogs or websites.  Since it is a web service, you will not have to install anything in your web server.  All you need is a basic understanding on how it works. ±¸±Û Â÷Æ® API´Â À¥ ¼­ºñ½º¸¦ ½Å¼ÓÇÏ°Ô ±ÍÇÏÀÇ ºí·Î±× ¶Ç´Â À¥»çÀÌÆ®¿¡ ´ëÇÑ Â÷Æ®¸¦ »ý¼ºÇÒ¿¡ ¿¬°áÇÒ ¼öÀÖ´Ù. ÀÌÈÄ À¥ ¼­ºñ½º´Â, ´ç½ÅÀÇ À¥ ¼­¹ö¿¡ ¾Æ¹«°Íµµ ¼³Ä¡ÇÒ Çʿ䰡¾ø½À´Ï´Ù. ¸ðµç Çʿ信 ´ëÇÑ ±âº»ÀûÀÎ ÀÌÇØÇÏ´Â ¹æ¹ý ±×°ÍÀ» ÀÛµ¿ÇÕ´Ï´Ù.

Here is an actual example of a À̰÷ÀÇ ½ÇÁ¦ ¿¹Á¦ÀÔ´Ï´Ù chart created using Google Chart API Â÷Æ® ±¸±Û Â÷Æ® API¸¦ »ç¿ëÇÏ¿© ¸¸µç :

À̹ÌÁö

You can see that the chart was generated using a simple URL parameter manipulation: ´ç½ÅÀº ±× Â÷Æ®´Â °£´ÜÇÑ Á¶ÀÛÀ» »ç¿ëÇÏ¿© »ý¼ºµÈ URL ¸Å°³ º¯¼ö¸¦ È®ÀÎÇÒ ¼öÀÖ½À´Ï´Ù :

À̹ÌÁö

There are at least 3 parameters ( cht, chd and chl )  to set to be able to generate a chart.  Below are the steps to make those parameters: (CHD cht¿¡´Â Àû¾îµµ 3 ÆÄ¶ó¹ÌÅÍ¿Í chl)À» ¼³Á¤Çϰí Â÷Æ®¸¦ »ý¼ºÇÒ ¼öÀÖ½À´Ï´Ù. ¾Æ·¡´Â ±× ¸Å°³ º¯¼ö¸¦ È®ÀÎÇÏ´Â ´Ü°è°¡ÀÖ½À´Ï´Ù :

Step 1: Define the Chart Type: cht 1 ´Ü°è : Â÷Æ® À¯ÇüÀ» Á¤ÀÇ : cht

First you will need to define what type of chart you want.  A listing of all available chart types are located here: ´ç½ÅÀº ´ç½ÅÀÌ ¿øÇÏ´Â °Ô ¹ºÁö ¸ÕÀú Â÷Æ®ÀÇ À¯ÇüÀ» Á¤ÀÇÇØ¾ßÇÕ´Ï´Ù. »ç¿ëÇÒ ¼öÀÖ´Â ¸ðµç Â÷Æ® À¯ÇüÀÇ ¸ñ·ÏÀÌ ¿©±â¿¡ÀÖ½À´Ï´Ù : http://code.google.com/apis/chart/types.html

In the example that we will create, we will use cht=p3 which is a pie chart.  To make other types of charts like bar or line charts, just browse the types of charts and put in the corresponding cht parameter value. ¿¹Á¦¿¡¼­, ¿ì¸®´Â cht = p3´Â ÆÄÀÌ Â÷Æ®¸¦ »ç¿ëÇÏ¿© ¸¸µé °ÍÀ̶ó°íÇß´Ù. Ç¥½ÃÁÙÀ̳ª ¶óÀÎ Â÷Æ®¿Í °°Àº Â÷Æ®ÀÇ ´Ù¸¥ À¯ÇüÀ» È®ÀÎÇÏ·Á¸é, ±×³É Â÷Æ®ÀÇ À¯ÇüÀ» Ž»öÇϰí ÇØ´ç cht ¸Å°³ º¯¼ö °ªÀ» ³Ö¾î.

Step 2: Define the parameter for data and labels: chd and chl 2 ´Ü°è : µ¥ÀÌÅÍ¿Í ·¹ÀÌºí¿¡ ´ëÇÑ ¸Å°³ º¯¼ö : Á¤ÀÇ CHD¿Í chl

For example, we want to chart the distribution of each of the four brands below: ¿¹¸¦ µé¾î, ¿ì¸®´Â ¾Æ·¡ÀÇ °¢ 4 °³ ºê·£µåÀÇ À¯Åë Â÷Æ®¸¦ ¿øÇϽøé :

  1. BrandX=40 BrandX = 40
  2. BrandY=30 ºê·£µð = 30
  3. BrandZ=20 BrandZ = 20
  4. BrandA=10 BrandA = 10

The data (chd) parameter will be: chd=t:40,30,20,10 µ¥ÀÌÅÍ () ¸Å°³ º¯¼ö°¡ µÉ °ÍÀÔ´Ï´Ù CHD : CHD = ¸¶ : 40,30,20,10

Note: In the example I chose to use Text Encoding.  To use other types of encoding click on the link below: Âü°í :ÀÌ ¿¹Á¦¿¡¼­´Â ÅØ½ºÆ® ÀÎÄÚµùÀ» »ç¿ëÇϱâ·Î °áÁ¤Çß½À´Ï´Ù. ¾Æ·¡ ¸µÅ©¸¦ Ŭ¸¯ÇÏ¿© ´Ù¸¥ Á¾·ùÀÇ ÀÎÄÚµùÀ» »ç¿ëÇÏ·Á¸é : http://code.google.com/apis/chart/formats.html

The label parameter (chl) is chl=BrandX,BrandY,BrandZ,BrandA ·¹ÀÌºí ¸Å°³ º¯¼ö (chl) = BrandX, ºê·£µð, BrandZ, BrandA chlÀÔ´Ï´Ù

The label parameter values are comma delimited and should have the same number of values as the data parameter. ·¹ÀÌºí ¸Å°³ º¯¼ö °ª ±¸ºÐµÈ µ¥ÀÌÅ͸¦ ¸Å°³ º¯¼ö·Î °ªÀ» ½°Ç¥¿Í °°Àº ¹øÈ£°¡ÇؾßÇÕ´Ï´Ù.

Step 3: Define the size of the chart in pixel 3 ´Ü°è : Çȼ¿¿¡¼­ Â÷Æ®ÀÇ Å©±â¸¦ Á¤ÀÇ

The format is a simple chs=<width in pixels>x<height in pixels> , so if we want to have a 250X100 chart, we put it like this: chs=250X100 Çü½ÄÀº ´Ü¼ø chs=<width in pixels>x<height in pixels> ±×·¡¼­ ¿ì¸®°¡ 250X100 Â÷Æ®¸¦ °®°í ½Í¾î¿ä, ¿ì¸®´ÂÀÌ °°Àº ³Ö¾î : chs = 250X100

Step 4: Put the parameters together 4 ´Ü°è : ÇÔ²² ¸Å°³ º¯¼ö¸¦ ³Ö¾î

Append the parameters to the main URL: ±âº» URL¿¡ ¸Å°³ º¯¼ö Ãß°¡ : http://chart.apis.google.com/chart?

+ parameter from step 1 + ¡°&¡± + parameter from step 2 + ¡°&¡± parameter from step 3 1 ´Ü°è¿¡¼­ ¸Å°³ º¯¼ö + + "&"+ ¸Å°³ º¯¼ö¸¦ 2 ´Ü°è¿¡¼­ + "&"¸Å°³ º¯¼ö 3 ´Ü°è¿¡¼­

Note that the order of parameters in web services is not important as long as you separate them with the ampersand character ¡°&¡±.  See example below: À¥ ¼­ºñ½º¿¡¼­ ¸Å°³ º¯¼öÀÇ ¼ø¼­´ë·Î ¾ÚÆÛ»÷µå ¹®ÀÚ·Î ±×µéÀ» º°µµ·Î ¿À·¡ "&"Áß¿äÇÏÁö ¾Ê½À´Ï´Ù. ¾Æ·¡ÀÇ ¿¹¸¦ ÂüÁ¶ :

http://chart.apis.google.com/chart?cht=p3&chd=t:40,30,20,10&chs=250¡¿100&chl=BrandX|BrandY|BrandZ|BrandA http://chart.apis.google.com/chart?cht=p3&chd=t:40, 30,20,10 & chs = 250 ¡¿ 100 & chl = BrandX | ºê·£µð | BrandZ | BrandA

It is clear that users can easily create dynamic charts using Google Chart API.  This is ideal for users who don¡¯t want to buy complex charting solutions for their web projects. ±×°ÍÀº µ¿Àû Â÷Æ® ±¸±Û Â÷Æ® API¸¦ »ç¿ëÇÏ¿© »ç¿ëÀÚµéÀ̺¸´Ù ½±°Ô ¸¸µé ¼öÀÖ½À´Ï´Ù ºÐ¸íÇÏ´Ù. À̰ÍÀº ÀÚ½ÅÀÇ À¥ ÇÁ·ÎÁ§Æ®¿¡ ´ëÇÑ º¹ÀâÇÑ Â÷Æ® ¼Ö·ç¼ÇÀ» ±¸¸ÅÇÏ°í ½ÍÁö ¾Ê¾Æ »ç¿ëÀÚ¿¡°Ô ÀÌ»óÀûÀÔ´Ï´Ù.

Ben Carigtan shows you how it¡¯s done. Carigtan º¥ ¾î¶»°ÔÇϸéµÇ´ÂÁö º¸¿©ÁÝ´Ï´Ù.

Enjoyed this post? ÀÌ °Ô½Ã¹°À» ÀßÇß³ª? Subscribe to Online Tech Tips via ¿Â¶óÀÎ Å×Å© ÆÁÀ» ÅëÇØ ±¸µ¶ ½Åû RSS Feed RSS Çǵå or via ¶Ç´Â¸¦ ÅëÇØ Email À̸ÞÀÏ and receive free daily productivity tips. ¹«·á ÀÏÀÏ »ý»ê¼º ÆÁÀ»¹ÞÀ» ¼öÀÖ´Ù.

» Filed Under »Ãâ¿ø¿¡¼­ Google Software/Tips Google ¼ÒÇÁÆ®¿þ¾î / ÆÁ

¸ÀÀִ¿¡ Ãß°¡ Save this page ÀÌ ÆäÀÌÁö¸¦ ÀúÀå ±×°Í Mixx Stir it up on Mixx Mixx¿¡ ¿Ã·Á ÆÄ¹®
reddit Add to Reddit reddit¿¡ Ãß°¡ StumbleUpon Stumble this page ÀÌ ÆäÀÌÁö¸¦ ´õµë´Ù

Related Posts °ü·Ã °Ô½Ã¹°

Please post your comments/suggestions! ±ÍÇÏÀÇ ÀǰßÀ» °Ô½ÃÇϽñ⠹ٶø´Ï´Ù / Á¦¾È!