Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
show percent values instead of value

I am using the apexcharts to generate a "donut". If I move the cursor over an element it will sho me the value of this element:

enter image description here

My code for this:

plotOptions: {
   pie: {
      donut: {
         labels: {
            show: true,
            value: {
               formatter: function (val) {
                  return val;
               }
            }
         }
      }
   }
}

But how can I show the percent value of the element instead of the "normal value"?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think the only way is to calculate percentages yourself

formatter: function (val,chart) {
  if(val){
    let valPercent = val/chart.config.series.reduce((a, b) => a + b, 0)*100;
    return `${valPercent.toFixed(1)}%`; // or round with Math
  }
  return ''
}

Actualy there is array with percentage values chart.globals.seriesPercent but no seriesIndex is provided

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda