javascript - 使用 d3.js 单击圆圈来显示工具提示

标签 javascript d3.js

我正在使用foreignObject生成一个工具提示,当我单击圆圈时,会检查foreignObject是否出现在它应该去的地方,但它没有显示。我怎样才能让它显示出来?

enter image description here

https://plnkr.co/edit/C0fODNtfbBw4v37Sb1CT?p=preview

 var div= svg.append('foreignObject')
    .attr("width", 100)
    .attr("height", 100)
    .append("xhtml:div")
    .attr("class", "tooltip")
    .style("opacity", 1);
    div.append('img').attr("id", "img_tweet").attr("src", "").attr("class", "imagen_tweet");
    div.append('div').attr("id", "texto_tweet");

        //add circle on map
        var coordenadas=map.latLngToLayerPoint([coordinates[0].lat,coordinates[0].long]);
            svg.append('circle').attr("cx",position.x)
            .attr("cy", position.y)
            .attr("r", 30)
            .style("fill",'red')
            .style('pointer-events', 'all')
            .attr("class",'circulo_mapa')
            //click event
            .on("click", function(element){
           document.getElementById('img_tweet').src='https://www.amrita.edu/sites/default/files/news-images/new/news-events/images/l-nov/grass.jpg';
           document.getElementById('texto_tweet').innerHTML='this is a message';
           var coordenadas=map.latLngToLayerPoint([coordinates[0].lat,coordinates[0].long]);
           d3.select('foreignObject').style("opacity", .9)
        //.html(tweet_recibido[index].texto)
           .attr("x",coordenadas.x)
           .attr("y",coordenadas.y )
        })

最佳答案

您检查过相关元素的 z-index 吗? 它可能就在那里,但它位于其他一切之下。 请告诉我。

关于javascript - 使用 d3.js 单击圆圈来显示工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45764596/

相关文章:

javascript - 单击按钮时动态设置 jssor slider 的 AutoPlay 属性

javascript - 重置浏览器地理位置值

javascript - 使用按钮单击禁用 anchor 标记

javascript - 倒计时并在发生时更改变量

D3.js 与 Turf.js 错误 : "Uncaught (in promise) Error: Each LinearRing of a Polygon must have 4 or more Positions."

javascript - D3 js 正交标记旋转

javascript - 插入新元素时如何向下移动 DOM 元素,以免它们重叠?

d3.js - D3js : ":last is not a valid selector"?

node.js - 使用 dc 和 Node.js 预渲染图表

javascript - d3 不透明度转换 flash 最终状态