728x90
300x250
위와 같은 파이차트를 출력했다
사실 이전에 포스팅한 컬럼 차트와 크게 다를게 없고, 그냥 자바스크립트 내부만 좀 바꿔주면 된다
javascript 부분
$.ajax({
type: "POST",
url : "ajax.php",
data :{ 각종 데이터 seq, id 등등 },
success : function (res) {
var pieData = google.visualization.arrayToDataTable(JSON.parse(res));
var options = {
title: '파이통계',
colors: ['#3F6D98','#D26812']
};
$("#piechart_material").show();
var chart = new google.visualization.PieChart(document.getElementById('piechart_material'));
chart.draw(pieData, options);
}
});
res 가져오는 데이터 형식이 아래와 같아야하고 , 저대로 출력되게끔 ajax.php 에서 DB 를 출력하고 배열을 요리조리 조합하고 마지막에 json_encode 로 return 해줘야한다
[["\uc77c\ubcc4","\uacac\uc801\uac74\uc218"],["\uc790\uc720\ud1b5\ud654",80],["\uc77c\ubc18\uc694\uae08\uc81c",39]]
728x90
300x250
'IT > PHP' 카테고리의 다른 글
[PHP] 데스크탑 모바일 접속기기 구분방법 (0) | 2020.08.26 |
---|---|
[PHP] 엑셀 다운로드 파일 한글 깨짐 현상 (0) | 2020.08.26 |
[PHP] 구글 차트 사용 및 mysql DB 연동, mysql 배열 출력 (0) | 2020.08.11 |
PHP 라라벨 기초 : 프로젝트 만들기, DB연동 , 회원가입, 로그인(1) (0) | 2020.08.09 |
[Laravel] There is no existing directory at "blah blah" and its not buildable:Permission denied 접근권한 문제 (0) | 2020.07.27 |