I'm trying to create custom Icons for a Apex Chart Graph toolbar

3k views Asked by At

I'm working on customizing a chart I'm working on and no matter what I try anytime I try to add something in the customIcons section of the toolbar in the options for the apex chart I get the error "apexcharts:6 Uncaught (in promise) TypeError: Cannot read property 'bind' of undefined". For example, the code below works.

toolbar:{
  customIcons:[],
  .....
  }
But if I try to actually have a custom icon it gets that error even with it blank like this.`enter code here

toolbar:{
  customIcons:[{}],
  }
  ........
When I do fill out the custom Icon sections it can properly show the custom image but it will receive that error still and no functions that happen after work including onclick functions for the Icon. I have tried looking for similar errors but I haven't seen someone have this error with apexcharts specifically any suggestions would be helpful.

2

There are 2 answers

0
hoostin On

in my situation what was causing it was the fact you have to have a click function defined or it will give you the bind error.

0
XAronX On

For what i'm seeing your customIcons should be placed inside tools, something like that:

  toolbar: {
   show: true,
   tools: {
     download: true,
     customIcons: [{
       icon: 'icon',
       index: 0,
       title: 'tooltip of the icon',
       class: 'custom-icon',
       click: function (chart, options, e) {
          console.log('clicked')
       }
     }]
    }
   },

source: https://apexcharts.com/docs/options/chart/toolbar/