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

270
Visualizações
Highcharts Pie/Donut Chart highlighting and aligning labels

I have an pie chart with data labels, that are directly at the point and show the value and name of it. But I got some issues I couldn't solve, even after hours of trying and googling.

  • I want to let one label stand out, by increasing the font size. I managed it through using the formatter and adding an inline-style, but I don't know if there is an easier/better solution.
  • In some cases the labels might be overflowing, so the get cropped. Thats alright, but if the text has multiple words, I would like to do a break before cropping the text.
  • All labels that are on the left side of the pie should be text-aligned right and on the right side text-aligned left. So that they are always aligning towards the center. I haven't even figured out a way to change the text-alignment at all.

I created a small JSFiddle: https://jsfiddle.net/x503prs6/54/

Thanks for reading and all your help!

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

0

Inside events chart.events.load you can also update style for specific data labels.

   events: {
      load: function() {
        let chart = this;
        chart.series[0].data[0].update({
          dataLabels: {
            useHTML: true,
            style: {
              fontSize: '20px',
              color: 'red',
            }
          }
        })
      }
    }

https://jsfiddle.net/BlackLabel/vnbxf64a/

Other options is change properties format and add breaks, to customize the text truncation in data tables you have the option to add extra CSS styles in line.

  dataLabels: {
    useHTML: true,
    format: '<p class="truncate"><b>{point.name}</b></br>{point.y}</p>',
    style: {
      fontSize: '20px',
      color: 'red',
      textOverflow: 'ellipsis'
    }
  }

.truncate {
    width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 5px 0;
} 

https://jsfiddle.net/BlackLabel/vnbxf64a/1/

Try use alignTo: 'plotEdges', they set label touches the nearest vertical edge of the plot area, but I'm not sure how exactly you want to align the labels. https://api.highcharts.com/highcharts/series.pie.dataLabels.alignTo

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