如何在移动设备和小屏幕上禁用Chartjs工具提示? [英] How to disable chartjs tooltip on mibile devices and small screens?

查看:80
本文介绍了如何在移动设备和小屏幕上禁用Chartjs工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图表上有很多点,因此当我在移动屏幕或小屏幕上单击时,工具提示仅显示来自多个点的数据:

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.

有任何解决方法吗?

推荐答案

可以禁用工具提示如下所示在选项中(请参阅工具提示配置):

Tooltips can be disabled in the options as shown below (see Tooltip Configuration):

option: 
    tooltips: {
        enabled: false
    }
    ...
}

您可以从返回 true 或<$的函数中获取该值,而不是使用硬编码的值 false c $ c> 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
    }
    ...
}




我没有创建用于移动设备的Web应用程序的经验。因此,
400可能不是正确的选择。以下答案应有助于
找到合适的功能: https://stackoverflow.com/a/11381730/2358409

这篇关于如何在移动设备和小屏幕上禁用Chartjs工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆