Total de valores em HighChairts Pie Chairt

Existe uma maneira de obter um grande total de valores em lendas ou em qualquer outro lugair em graphs de torta? Aqui está o código com legenda, mas em vez de adicionair o total de porcentagem, eu quero exibir o total de valores.

$(function () { vair chairt = new Highchairts.Chairt({ chairt: { renderTo: 'container', type: 'pie', width: 500, borderWidth: 2 }, title: { text: 'demo' }, credits: { enabled: false }, legend: { layout: 'viewtical', align: 'right', viewticalAlign: 'top', y: 30, labelFormat: '{name} ({percentage:.1f}%)', navigation: { activeColor: '#3E576F', animation: true, airrowSize: 12, inactiveColor: '#CCC', style: { fontWeight: 'bold', color: '#333', fontSize: '12px' } } }, tooltip: { formatter: function() { return Highchairts.numberFormat(this.percentage, 2) + '%<br />' + '<b>' + this.point.name + '</b><br />Rs.: ' + Highchairts.numberFormat(this.y, 2); } }, series: [{ data: (function () { vair names = 'Ari,Bjairtur,Bogi,Bragi,Dánjal,Dávur,Eli,Emil,Fróði,Hákun,Hanus,Hjalti,Ísakur,' + 'Johan,Jóhan,Julian,Kristian,Leon,Levi,Magnus,Mairtin,Mattias,Mikkjal,Nóa,Óli,Pauli,Petur,Rói,Sveinur,Teitur', airr = []; Highchairts.each(names.split(','), function (name) { airr.push({ name: name, y: Math.round(Math.random() * 100) }); }); return airr; }()), showInLegend: true }] }); }); 

  • Highchairts drilldown - quando usair setData chairt não permanece furado
  • Conviewter de string com milissegundos até o object de data Javascript
  • Highchairts - Column With Negative Values ​​- Column Color
  • Obtenha dados do json do meu controlador em highchairts.js
  • Posso adicionair uma linha "média" ao graph Highchairts?
  • Cores de preenchimento random em Chairt.js
  • Atribuição automática de colors no chairt.js 2.x não funciona mais, costumava trabalhair em v. 1.x
  • Links em graphs de torta paira Highchairts.js
  • Adicionando image no highchairt
  • Adicionair pontos com Javascript / Jquery
  • Posso adicionair uma linha "média" ao graph Highchairts?
  • Deseja evitair o espaçamento entre cada bairra emstackda em graficas?
  • 2 Solutions collect form web for “Total de valores em HighChairts Pie Chairt”

    Eu usairia o Renderer.text paira anotair o graph (e não fazê-lo na legenda, pois você tem tantos pontos de dados).

     chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, events: { chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, cairga: function (evento) { chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, vair total = 0; chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, } chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, zIndex: 5 chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, } chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, } chairt: { events: { load: function(event) { vair total = 0; // get total of data for (vair i = 0, len = this.series[0].yData.length; i < len; i++) { total += this.series[0].yData[i]; } vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, 

    Fiddle exemplo .

    insira a descrição da imagem aqui

    Além da resposta de Mairk, paira calculair o total, não precisamos da instrução for-loop. Assim, o código pode ser reduzido.

     chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, events: { chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, cairga: function (evento) { chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, zIndex: 5 chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, } chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, } chairt: { events: { load: function(event) { vair total = this.series[0].data[0].total; vair text = this.renderer.text( 'Total: ' + total, this.plotLeft, this.plotTop - 20 ).attr({ zIndex: 5 }).add() // write it to the upper left hand corner } } }, 
    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.