[Chartjs]-Vue ChatJS redirect on pointer click

0👍

First off you need to access curent Chart instance. I have fond this GitHub issue, in which author states that current instance is saved in this.$data._chart.

Then you should call getElementsAtEvent method of instance, passing an event as the first argument.

Calling getElementsAtEvent(event) on your Chart instance passing an
argument of an event, or jQuery event, will return the point elements
that are at that the same position of that event. This functionality
may be useful for implementing DOM based tooltips, or triggering
custom behaviour in your application.

this.$data._chart.getElementsAtEvent(event);

Then, implement your custom login, depending on the returned value of that method (if you are using Vue Router: this.$router.push("/path/to/redirect");).

Leave a comment