eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Getting undefined when called a function inside series.point.events.click

Hi

I am getting undefined when i am calling matdialog .open inside series.point.events.click

this.dialog.open(ModalComponent, {
width: '350px',
height: '350px',
data: { dataObject: this.data },
disableClose: true,
});

here dialog is coming undefined, please tell what is wrong?
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting undefined when called a function inside series.point.events.click

Hi there,

Correct me if I'm wrong but I guess that you are using an Angular Material. In that case, the dialog.open function should be called without the this keyword - that's because the dialog.open is available in global scope, not on the this (which points to the point in that case).

Let me know if this solved your problem, and if not - please recreate your issue in an online code editor, so that I can have a proper look into that.

Have a good day!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting undefined when called a function inside series.point.events.click

Hi
thanks for the response , yes i am using angular material,

here
click: function() {
dialog.open(modalComponent)
}

but dialog without this is giving issues
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting undefined when called a function inside series.point.events.click

its saying Cannot find name 'dialog'
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting undefined when called a function inside series.point.events.click

It seems that there is a problem with the Angular Material, please double check that you are importing the Angular Material correctly and setting the default options for the Dialog, but that is only my guess works.
Although we do provide support for the Highcharts Angular wrapper, we have no knowledge about the Material component. In that case, I'd suggest asking on a more general forum i.e Stack Overflow under Angular Material tag.

In case of any other questions related to Highcharts functionality feel free to contact us anytime,
Best regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting undefined when called a function inside series.point.events.click

I checked angular material if call that modal outside highchart then it is not showing undefined. It is showing undefined in case of highcharts only
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting undefined when called a function inside series.point.events.click

It doesn't look like a Highcharts bug, and as I said before, unfortunately, we do not provide any support for Angular Material - so we can't help with that.

If you are getting undefined, that usually means that you are trying to call a method or property on an object, that does not have this property.

Regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting undefined when called a function inside series.point.events.click

hi

I got the issue when i use
series.data.click with ES6 arrow function then it resolved my problem.

click: (event: any) => {

this.dialog.open(Modal)
}
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting undefined when called a function inside series.point.events.click

Well, if you've managed to resolve the problem by yourself then really glad that it's working right now!

You can learn more about this keyword in arrow functions here: https://developer.mozilla.org/en-US/doc ... _functions

Best regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Gantt”