Google Charts
วิธีทำ Google Charts บนเว็บไซต์
โค้ด Google Charts สำหรับทำ Charts สถิติ คิดเป็นเปอร์เซนต์ แบบง่ายๆสวยงาม
คัดลอกโค้ดข้างล่างไปใช้ได้เลยครับ อย่าลืมเปลี่ยนชื่อและตัวเลขสีน้ำเงิน ให้เป็น ข้อมูลของท่านเองนะครับ
วิธีวางโค้ด
ไปที่ >>รูปแบบ
>>เพิ่มGadget
>>HTML(จาวาสคริปส์)
>>วางโค้ด
>>บันทึก
<div id="piechart">
</div>
<script src="https://www.gstatic.com/charts/loader.js" type="text/javascript"></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'],
['Condo', 40],
['Home', 47],
['Land', 21],
['Townhome', 9],
['Office', 4],
['Factory', 4],
['Hotel', 3],
]);
// Optional; add a title and set the width and height of the chart
var options = {'title':'All Housing', 'width':350, '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>
//////////
คัดลอกโค้ดข้างล่างไปใช้ได้เลยครับ อย่าลืมเปลี่ยนชื่อและตัวเลขสีน้ำเงิน ให้เป็น ข้อมูลของท่านเองนะครับ
วิธีวางโค้ด
ไปที่ >>รูปแบบ
>>เพิ่มGadget
>>HTML(จาวาสคริปส์)
>>วางโค้ด
>>บันทึก
<div id="piechart">
</div>
<script src="https://www.gstatic.com/charts/loader.js" type="text/javascript"></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'],
['Condo', 40],
['Home', 47],
['Land', 21],
['Townhome', 9],
['Office', 4],
['Factory', 4],
['Hotel', 3],
]);
// Optional; add a title and set the width and height of the chart
var options = {'title':'All Housing', 'width':350, '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>
//////////
แสดงความคิดเห็น
0 ความคิดเห็น