GraficoPizza
by Maycon Brito
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JavaScript
var arrayDados = [{"data":{"NHC":21,"2UFC":2,"1UFC":1}}];
var arrayPropriedades = {title: 'Titulo', subtitle: 'SubTitulo', tipoDados: 'unidade', legend: '1'};
GraficoPizza(arrayPropriedades, arrayDados);
function GraficoPizza(arrayPropriedades, arrayDados) {
$('#container').highcharts({
chart: {
type: 'pie',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: true
},
title: {
text: arrayPropriedades.title
},
subtitle: {
text: arrayPropriedades.subtitle
},
legend: {
enabled: arrayPropriedades.legend
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: arrayPropriedades.dataLabels,
formatter: function() {
return formatterDataLabels(this, arrayPropriedades);
},
},
showInLegend: true
}
},
tooltip: {
formatter: function() {
return '<span style="font-size:12px;color:' + this.series.color + ';">'
+ this.key + '</span><br /><span style="font-size:11px;">'
+ formatarValor(arrayPropriedades.tipoDados, this.y) + '</b></span><br/>';
}
},
series: arrayDados,
credits: {
enabled: false
},
});
}
function formatterDataLabels(objeto, arrayPropriedades) {
//Define a formatação do valor a ser exibido no tooltip do gráfico
return formatarValor(arrayPropriedades.tipoDados, objeto.y);
}
function formatterTooltip(objeto, propriedades) {
//Define a formatação do valor a ser exibido no tooltip do gráfico
valor = formatarValor(propriedades.tipoDados, objeto.y);
//Verifica se o gráfico tem legenda para exibir ou não o nome...