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

214
Visualizações
How to display correct percentage on Y-axis using HighCharts js

I'm working with an area chart and I need to display this percentage on the Y-axis chart with (0%, 50%, 100%) on the Y-axis

But in some cases my labels on the y-axis of the chart behave incorrectly. Maybe I can somehow set the values for the Y-axis labels myself? incorrect labels on the Y-axis

// this is the method from my angular component to get the Y-axis options
public getYAxisOptions(graphData: SeriesAreaOptions[]): YAxisOptions {
    const [allLeads] = graphData[0].data as number[];
    return {
        title: {text: null,},
        floor: 0,
        ceiling: allLeads || 100,
        min: 0,
        max: allLeads || 100,
        labels: {
            enabled: true,
            formatter: (that: AxisLabelsFormatterContextObject<string>) => {
                if (allLeads) {
                    const percent = (Number(that.value) / allLeads * 100).toFixed(0);
                    return /*Number(percent) > 100 ? "" : `${percent}%`;*/  `${percent}%`;
                }
                return `${that.value}%`;
            }
        },
        gridLineDashStyle: "Dash",
        gridLineWidth: 1,
        lineWidth: 1,
        height: 130,
        top: 17,
        minRange: allLeads || 100
    };
}

UPD: this has already been resolved with tickPositions: [0, allLeads/2, allLeads]

about 4 years ago · Juan Pablo Isaza
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