0

我正在使用Tipsy生成通过 D3 生成的 SVG 圆圈的工具提示。我的代码取自这个例子。使用此代码,当我将鼠标悬停在我的圆形对象上时,我的工具提示显示得很好:

$('.circles').tipsy({ title: 'My tooltip text' })

有没有办法让工具提示显示在页面加载而不是悬停?我尝试过使用show,但这似乎不起作用:

$('.circles').tipsy({ title: 'My tooltip text' })      // show tips on hover
$('.circles').tipsy('show')                            // show tips on page load?

根据这个示例问题,理论上在页面加载时显示工具提示似乎是可能的;但是,我不知道如何操纵 D3 来使这个逻辑工作。如何让我的工具提示在页面加载和悬停时显示?

4

1 回答 1

1

奇怪的是 - Tipsy 不适用于每个圆圈的选择器,因此必须使用 JQueryeach函数才能使其工作。您还必须trigger: 'manual'在 Tipsy 中设置该选项。

$('.circles').each(function() {
   $(this).tipsy({ 
    trigger: 'manual',
    gravity: 'w', 
    html: true, 
    title: function() {
      return 'My tooltip text'; 
    }
   });

   $(this).tipsy('show');
});
于 2014-07-14T21:16:12.217 回答