score:1

Accepted answer

The this keyword in onclick callback function refers to a chart, use arrow function to get the external this reference:

buttons: {
  contextButton: {
    menuItems: [..., {
      textKey: 'downloadCSV',
      onclick: () => {

        if (this.downloadCsvRoute && this.downloadCsvRoute != '') {
          axios.get(this.downloadCsvRoute)
        }
      }
    }]
  }
}

API Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions


Related Query