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

120
Visualizações
I want to know how to use the onclick() function and symbol in highcharts Iam using it in angular.Tell me please

I need two things to be done I have tried every way to my knowledge. Don't mistake me if I am asking small questions. I just wanna know

below is my custom button in highcharts

MY COMPONENT.TS FILE

textData = 0; //declared outside the function
chartGenerate(){
chart:{......},
yAxis:{.....},
xAxis:{....},
series:[....],
exporting: {
            buttons: {
                contextButton: {
                    menuItems: [.......]
                },
                change:{
                  symbol:'triangle',
                  onclick: function () {
                        this.textData += 1
                    },

            },
               gotit:{
                  text:this.textData
                 },

        },
}

FIRST THING How to change the text in gotit when clicking change button SECOND THING How to rotate the symbol to 180deg

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You can use the arrow function to refer to the context of this some properties above.

  counter = 0;

  constructor() {
    this.chartOptions = {
      exporting: {
        buttons: {
          change: {
            symbol: 'triangle',
            onclick: () => {
              this.counter += 1;
              console.log('change btn, counter:',this.counter)
            }
          },
          gotit: {
            text: `${this.counter}`,
          }
        }
      },
    };
  }

Next, your change has to be passed somewhere, notice when you click it you have to update it via chartRef i.e. referring to the chart reference.

  updateChart(): void {
    this.chartRef.title.update({
      text: 'Title was updated',
    });

    this.chartRef.exporting.update({
        buttons: {
          gotit: {
            text: `${this.counter}`,
          }
        }
    });

  }

In official wrapper docs you will find how to load exporting module in Highcharts in Angular.

Check this docs options for the export button.

Demo: https://stackblitz.com/edit/highcharts-angular-basic-line-gh8gsg

EDIT -----

To change the symbol rotation, the best option will be implement symbol as custom shape with rotation

Highcharts.SVGRenderer.prototype.symbols.download = function(x, y, w, h) {
  var path = [
    // Arrow stem
    'M', x + w * 0.5, y,
    'L', x + w * 0.5, y + h * 0.7,
    // Arrow head
    'M', x + w * 0.3, y + h * 0.5,
    'L', x + w * 0.5, y + h * 0.7,
    'L', x + w * 0.7, y + h * 0.5,
  ];
  return path;
};

Highcharts.chart('container', {
  exporting: {
    buttons: {
      contextButton: {
        symbol: 'download'
      }
    }
  }

});

API: https://api.highcharts.com/highcharts/exporting.buttons.contextButton.symbol

Demo: https://jsfiddle.net/BlackLabel/ansk53cy/

about 4 years ago · Santiago Gelvez 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