• Google API 막대 그래프

    2016. 11. 18.

    by. Yo.

    728x90




    Google API를 이용한 막대 그리기 샘플 코드입니다.



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">   
    <head>     
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>     
    <title>월별 예약 통계 현황</title>    
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>     
    <script type="text/javascript">       
    google.load('visualization', '1', {packages: ['corechart']});     
    </script>     
    <script type="text/javascript">       
    function drawVisualization() {         
    // Some raw data (not necessarily accurate)
    var data = google.visualization.arrayToDataTable([
    ['Month', '2011년 ', '2012년 '],
    ['1월',  20,      30],
    ['2월',  25,      30],
    ['3월',  45,      40],
    ['4월',  42,      60],
    ['5월',  45,      70],
    ['6월',  67,      70],
    ['7월',  55,      60],
    ['8월',  44,      50],
    ['9월',  22,      50],
    ['10월',  34,      40],
    ['11월',  56,      20],
    ['12월',  123,      10]         
    ]);
    var options = {
    title : '월별 예약 통계 현황',
    vAxis: {title: "명"},
    hAxis: {title: "월"},
    seriesType: "bars",
    series: {5: {type: "line"}}
    };
    var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
    chart.draw(data, options);
    }
    google.setOnLoadCallback(drawVisualization);
    </script>  
    </head>  
    <body>     
    <div id="chart_div" style="width: 900px; height: 500px;"></div>   
    </body> 
    </html>
    


    728x90

    댓글