0

I am using highcharts-angular and typescript and trying to update y-axis type but getting error

Property 'yAxis' does not exist on type 'ExportingButtonsOptionsObject'

This is the code and getting error on

onclick: function () {
            this.yAxis[0].update({
              type: 'linear'
            })
          }

Whole code:

yAxis: [
      {
        labels: {
            align: 'left'
        },
        height: '80%',
        resize: {
            enabled: true
        }
      }, 
      {
        labels: {
            align: 'left'
        },
        top: '80%',
        height: '20%',
        offset: 0
      }
    ],
    exporting: {
      buttons: {
        contextButton: {
          enabled: false,
          align: 'left',
        },
        customButton: {
          text: 'Linear',
          onclick: function () {
            this.yAxis[0].update({
              type: 'linear'
            })
          }
        },
        customButton2: {
          text: 'Logarithmic',
          onclick: function () {
            this.yAxis[0].update({
              type: 'logarithmic'
            })
          }
        }
      }
    },

1 Answers1

1

Looks like this is not what you think it is. You can try using arrow functions instead, these will help you to capture the right this:

onclick: () => {
  this.yAxis[0].update({
    type: 'linear'
  })
}
Octavian Mărculescu
  • 4,312
  • 1
  • 16
  • 29