0
Using Flot to generate the graphics in pie format, the graph is generated with the values in percentage, but the Labels are displayed with 'Undefined'.
$(document).ready(function () {
var chartError = function(req, status, err) {
console.log('An error occurred: ', status, err);
};
function chartDataReceived(data) {
$.plot($("#placeholder"), data, {
series: {
pie: {
show: true,
radius: 1,
label: {
show: true,
radius: 1,
formatter: function(label, series) {
return '<div style="font-size:11px; text-align:center; padding:2px; color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
},
background: {
opacity: 0.8,
color: '#444'
}
}
}
}
});
}
$.ajax({
url: 'data.php',
method: 'GET',
dataType: 'json',
success: chartDataReceived,
error: chartError
});
});
My select
SELECT tipo,status,valor, SUM(valor) AS valor_conta_tipo, caixa.tipo AS tipo_conta, caixa.status AS status_conta from caixa where caixa.status=1 GROUP BY tipo_conta
Filing cabinet data php. (the'accum_type' column has value)
while ($row = mysql_fetch_assoc($result))
{
$dataset1[] = array($row['tipo_conta_nome'],$row['valor_conta_tipo']);
}
print json_encode($dataset1);
I changed my answer
– Maicon Carraro