问题
I have to many points on my chart so when I am clicking through on mobile or small screen my tooltip just showing data from multiple points:
I researched on that and find out the the best approach would be is to disable the tooltip on small screens. I tried to follow this advice from the docs. But have no luck:
options: {
// This chart will not respond to mousemove, etc
events: ['click']
}
Also I found that but I think it is actually related to what I just did based on the advice form the docs.
Any ideas how to fix?
回答1:
Tooltips can be disabled in the options
as shown below (see Tooltip Configuration):
option:
tooltips: {
enabled: false
}
...
}
Instead of using a hard coded value false
, you may obtain the value from a function that returns true
or false
depending on the screen size.
option:
tooltips: {
enabled: window.screen.width > 400
}
...
}
I've no experience in creating web apps for mobile devices. Therefore 400 is probably not the right choice. The following answer should help finding the appropriate function: https://stackoverflow.com/a/11381730/2358409
来源:https://stackoverflow.com/questions/60132952/how-to-disable-chartjs-tooltip-on-mibile-devices-and-small-screens