Chart.js: options.events property works weird

Created on 2 Aug 2016  ·  5Comments  ·  Source: chartjs/Chart.js

I want to make my chart static and not to show any tooltips and/or hover highlighting.

So I set options.events = [] for chart. This doesn't work
https://jsfiddle.net/wcfp91bh/

If I set options.events = ["fakeEvent"]. This works better but still provides tooltips for "click" event
https://jsfiddle.net/h7g8hngn/2/

Idk, but seems it shouldn't work like this.
Any comments?

help wanted bug

Most helpful comment

@demoalex You are right.
option.events = []
It won't work. I think it's a bug.@etimberg

but you also can set the global option:
Chart.defaults.global.events = [];
It can solve your problem right now.

All 5 comments

You can set the global option like this:

Chart.defaults.global.tooltips.enabled = false;

Then it will be work. You can try it.

@rain-js thanks for this tip. I know it.

The problem is not in tooltips but in any event based behavior. I don't want lines and points to be highlighted and hovered as well.

If I do add tooltips.enabled = false to chart's options you can see that this won't help to achieve what I want. That's better can be seen on Doughnut
https://jsfiddle.net/7ewnxsu6/

I'm not sure why option.events = [] doesn't work properly. As described in doc this assignment should remove any reaction of chart to mouse/touch or other events. Obviously it doesn't which looks like wrong behavior. Also I don't understand why option.events = ["fake"] actually works for some events (mouseover, click event) but not all (doubleclick event).

@demoalex You are right.
option.events = []
It won't work. I think it's a bug.@etimberg

but you also can set the global option:
Chart.defaults.global.events = [];
It can solve your problem right now.

Yeah, this looks like a bug. I think it might be in the code that merges properties from the global config to the local config.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benmccann picture benmccann  ·  3Comments

JewelsJLF picture JewelsJLF  ·  3Comments

lizbanach picture lizbanach  ·  3Comments

nanospeck picture nanospeck  ·  3Comments

lbowers picture lbowers  ·  3Comments