4
I have the table in my database called votes, I have id, name and votes (number of votes), I wanted to plot these values being, name and value in a pie chart or whatever the percentage of votes has 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>
could post the [tag:json] which is returned by
data: [[<?php echo join("','", $data1) ?>, <?php echo join(',',$data2) ?>]]
? It is an essential factor to know what is happening with your code– Erlon Charles
http://crissite.com/GFILA/index.php?pag=grafico
– Cristiano
I’m kind of layy in javascript I’m learning now more json is what returns it or is values?
– Cristiano
Your date it must be so
data:[{
 name: 'Fulano',
 data: [49.9]
}, {
 name: 'Cicrano',
 data: [83.6]
}, {
 name: 'Beltrano',
 data: [48.9]
}, {
 name: 'Arlindo',
 data: [42.4]
}]
– Erlon Charles
database table: votes id=1 name= Cristiano vote=1,
– Cristiano