简体   繁体   English

Chart.js 鼠标悬停工具提示出现在 cursor 错误 position 时

[英]Chart.js mouseover tooltips appears when cursor in wrong position

I am making a webpage with charts using chart.js.我正在使用 chart.js 制作一个带有图表的网页。 I want to have 3 pie charts, side-by-side, and I wrapped them in a div with display: flex;我想要 3 个并排的饼图,然后将它们包装在一个带有display: flex;的 div 中。 . . The first's chart mouseover tooltips works fine.第一个图表鼠标悬停工具提示工作正常。 However,for the 2nd and 3rd chart, the tooltip only appear when I place my cursor at a distance from a section of data, but not when my cursor is directly on the section of data.但是,对于第 2 和第 3 个图表,工具提示仅在我将 cursor 放置在与数据段有一定距离时出现,但当我的 cursor 直接在数据段上时不会出现。

I have tried setting pointHitRadius and tooltips modes but nothing seems to work.我尝试设置 pointHitRadius 和工具提示模式,但似乎没有任何效果。

Here is a jsfiddle to my work: https://jsfiddle.net/6twvhpab/这是我工作的一个 jsfiddle: https://jsfiddle.net/6twvhpab/

The problem isn't with display:flex it is with:问题不在于display:flex它在于:

html{
    zoom: 90%;
}

This must mess with how chartjs calculates the datapoint position, if you remove the above code from your stylesheet then it will fix your problem.这必须与 chartjs 如何计算数据点 position 的方式相混淆,如果您从样式表中删除上述代码,那么它将解决您的问题。

I have created a fiddle to tidy up your sylesheet and demonstrate this working: https://jsfiddle.net/kopf7d0L/我创建了一个小提琴来整理您的样式表并演示此工作: https://jsfiddle.net/kopf7d0L/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM