最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Tooltip flickering when hovered on chart - Stack Overflow

programmeradmin4浏览0评论

I have created custom tooltip for my chart in chartjs. But the issue es when I hover on the chart, the tooltip starts flickering. Anyone knows how can I prevent this? Thanks!

if (!tooltip) {
               var tooltip = document.createElement('div');
               tooltip.id = 'tooltip';
               document.body.appendChild(tooltip);
            }

            if (!model.opacity) {
               tooltip.style.display = 'none';
               return;
            }

            tooltip.innerHTML = `<div class="tooltip-body">
                                            <label>` + model.body[0].lines[0] + `</label>
                                        </div>
                                        <div class="tooltip-caret"></div>`;

            tooltip.style.display = 'inline-block';
            tooltip.style.position = 'absolute';
            tooltip.style.top = getTooltipPosition().y + 'px';
            tooltip.style.left = getTooltipPosition().x + 'px';

I have created custom tooltip for my chart in chartjs. But the issue es when I hover on the chart, the tooltip starts flickering. Anyone knows how can I prevent this? Thanks!

if (!tooltip) {
               var tooltip = document.createElement('div');
               tooltip.id = 'tooltip';
               document.body.appendChild(tooltip);
            }

            if (!model.opacity) {
               tooltip.style.display = 'none';
               return;
            }

            tooltip.innerHTML = `<div class="tooltip-body">
                                            <label>` + model.body[0].lines[0] + `</label>
                                        </div>
                                        <div class="tooltip-caret"></div>`;

            tooltip.style.display = 'inline-block';
            tooltip.style.position = 'absolute';
            tooltip.style.top = getTooltipPosition().y + 'px';
            tooltip.style.left = getTooltipPosition().x + 'px';
Share Improve this question asked Jul 23, 2017 at 14:48 Albert SerbAlbert Serb 231 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

TRY setting style - pointer-events to none , for the tool-tip element, like so :

...
tooltip.style.pointerEvents = 'none';
...

Change this:

google.charts.load('current', {'packages':['corechart']})

To

google.charts.load('42', {'packages':['corechart']})

There is bug in current version.kindly use 42 version.It solved issue for me.

发布评论

评论列表(0)

  1. 暂无评论