lang/jquery

구글 차트 API 로 원형(pi)차트 그리기

C/H 2018. 7. 17. 08:30

 

구글 API를 이용해서 파이차트 그리기

<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() 
    {
        var data = google.visualization.arrayToDataTable(
            [["Employee","Rating"],["Suresh",25],["Amit",56],["Rahul",37],["Lucky",71],["Pooja",11],["Manoj",49]]
        );
        var options = {
            title: "Employee Ratings"
        };
        var chart = new google.visualization.PieChart(document.getElementById("employee_piechart"));
        chart.draw(data, options);
    }
</script>
</head>
<body>
    <div id="employee_piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
반응형