1
I set up a chart with highcharts where I need to know the percentage of financial input and output.
<div id="container" style="min-width: 410px; height: 500px; max-width: 600px; margin: 0 auto; margin-top: 25px"></div>
<script>
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Gastos Periodo - <?php echo $periodoEntrada . ' - ' . $periodoSaida?>'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
colorByPoint: true,
data: [{
name: 'Entradas',
y: <?php echo str_replace(",", ".", $entrada);?>,
}, {
name: 'Saidas',
y: <?php echo str_replace(",", ".", $saida);?>,
}]
}]
});
</script>
How Do I Get Where Series Is
Entrada
- Porcentagem - 93%
- Valor - 500,00
Pq 93%? This number is not automatic?
– Sam
Something like that:
pointFormat: 'Porcentagem - <b>{point.percentage:.1f}%</b> <br> Valor - <?php echo $variavelDoValor ?>'
?– Costamilam
Try:
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b><br>Valor: <b>{point.y:.2f}</b>'
– Sam