구글 차트란?


HTML

Google 지도는 Google API입니다.

Google 글꼴은 Google API입니다.

Google 차트는 Google API입니다.


웹페이지에 Google 차트를 추가하는 방법을 알아보세요.


예시


구글 파이 차트

간단한 기본 웹 페이지로 시작하십시오.

ID가 "piechart"인 <div> 요소를 추가합니다.

예시

<!DOCTYPE html>
<html>
<body>

<h1>My Web Page</h1>

<div id="piechart"></div>

</body>
<html>


google.com에서 Chart API에 대한 참조를 추가합니다.

예시

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

그리고 자바스크립트 함수를 추가합니다:

예시

<script type="text/javascript">
// Load google charts
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);

// Draw the chart and set the chart values
function drawChart() {
  var data = google.visualization.arrayToDataTable([
  ['Task', 'Hours per Day'],
  ['Work', 8],
  ['Friends', 2],
  ['Eat', 2],
  ['TV', 2],
  ['Gym', 2],
  ['Sleep', 8]
]);

  // Optional; add a title and set the width and height of the chart
  var options = {'title':'My Average Day', 'width':550, 'height':400};

  // Display the chart inside the <div> element with id="piechart"
  var chart = new google.visualization.PieChart(document.getElementById('piechart'));
  chart.draw(data, options);
}
</script>