I have the following code:
<html><head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Polarity', 'Percentage'],
['positive', 0],
['negative', 0],
['neutral', 0]
]);
var options = {
title: 'Sentiment Chart',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<?php
$positive = 20;
$negative = 30;
$neutral = 50;
echo "<div id=\"piechart\" style=\"width: 900px; height: 500px;\"></div>";
?>
</body>
</html>
It is a Google Pie Chart. How can I pass the PHP variables $positive, $negative and $neutral to the 'positive', 'negative' and 'neutral' labels in the chart so that it shows their values of 20%, 30% and 50% respectively on the chart?
I have searched SO, but have not found a simple approach.