Google 차트를 사용하고 있으며 차트에 데이터를 제공하기 위해 PHP 파일 (또는 HTML 파일 내부의 PHP)에서 데이터를 가져와야합니다. 그렇다면 어떻게해야할까요? 차트를 그리기 전에 데이터를 가져와야합니다. 가 이미 PHP와 MySQL 데이터베이스에서 데이터를 잡아하는 방법을 알아내는 불구 갔다HTML에서 PHP의 vars를 사용하는 가장 쉬운 방법
여기 내가 HTML에서와 같은 어떤 변수가 없습니다
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Color');
data.addColumn('number', 'Votees ');
data.addRows([
['Value from Mysql', 3000],
['Value2 from Mysql', 13000],
]);
// Set chart options
var options = {'title':'Table Name From MySql',
'width':600,
'height':450};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
직접 시도하십시오. –
이 차트를 구현하는 방법에 대한 자세한 정보를 제공해 주시면보다 구체적인 답변을 드릴 수 있습니다.) – Lix