김철용

그누보드5에 구글차트 넣기

· 2018-09-21 (금) 04:17:09 · 10121 · 5
챠트.png

그누보드5에 구글챠트를 이용해서 간단한 그래프를 넣는 방법입니다.

index.php에서 최신글 부분을 삭제하고 구글챠트 코드를 넣은 것입니다.

타이틀, 세부통계목이나 width, height는 적당히 조절하시면 됩니다.

 

<?php
include_once('./_common.php');

define('_INDEX_', true);
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if(defined('G5_THEME_PATH')) {
    require_once(G5_THEME_PATH.'/index.php');
    return;
}

if (G5_IS_MOBILE) {
    include_once(G5_MOBILE_PATH.'/index.php');
    return;
}

include_once(G5_PATH.'/head.php');
?>

 

<h1 id="chart" style="font-style:italic;">그누보드5에 Google Charts 사용하기</h1>
<br>

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

<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', '전체통계 '],
  ['10권이상', 2],
  ['3권이내', 2],
  ['구입않음', 6],
 
]);

  // Optional; add a title and set the width and height of the chart
  var options = {'title':'시집구입통계 ', 'width':875, 'height':600};

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


<?php
include_once(G5_PATH.'/tail.php');
?>

첨부파일

챠트.png (74.5 KB)
13회 2018-09-21 04:17
구글차트.zip (925 bytes) 55회 2018-09-21 04:17
|

댓글 5개

최곱니다~~
좋은 자료에요 감사합니다
좋은 자료 감사합니다.
제가 소개하는 자료도 사용해보세요.
https://www.chartjs.org/
감사합니다 ^^
2020-09-04 (금) 10:14:59
Gooooooooooooood
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
18-10-23 조회 1.3만
18-10-22 조회 9,743
18-10-21 조회 6,525
18-10-21 조회 6,162
18-10-20 조회 6,079
18-10-18 조회 7,125
18-10-17 조회 7,779
18-10-15 조회 6,342
18-10-14 조회 1.2만
18-10-12 조회 1.6만
18-10-10 조회 6,578
18-10-10 조회 7,616
18-10-10 조회 5,125
18-10-08 조회 5,562
18-10-08 조회 1.1만
18-10-06 조회 8,473
18-10-04 조회 1.4만
18-10-03 조회 7,080
18-10-02 조회 6,860
18-10-02 조회 6,095
18-09-29 조회 5,579
18-09-28 조회 7,061
18-09-21 조회 1만
18-09-20 조회 8,975
18-09-17 조회 7,252
18-09-13 조회 7,457
18-09-12 조회 6,303
18-09-05 조회 8,881
18-09-05 조회 6,668
18-09-02 조회 9,556