I have the table in my database called votes, in it I have id, name and votes, I wanted to plot those values being, name and value in a pie chart or what is the percentage of votes each name
<?
$SQL1 = "SELECT * FROM votes";
$result1 = mysql_query($SQL1);
$data1 = array();
$data2 = array();
while ($row = mysql_fetch_array($result1)) {
$data1[] = $row['name'];
$data2[] = hexdec($row['votes']);
}
?>
<script src="js/grafico/highcharts.js"></script>
<script src="js/grafico/exporting.js"></script>
<script type="text/javascript">
$(function () {
$('#graficoPizza').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Grafico Plataforma SMS'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
type: 'pie',
name: 'Quantidade enviados',
data: [
[<?php echo join("','", $data1) ?>, <?php echo join(',',$data2) ?>]
]
}]
});
});
</script>
<div id="graficoPizza" style="min-width: 310px; height: 400px; margin: 0 auto"></div>