【问题标题】:tool tip for half donut or half pie chart半甜甜圈或半饼图的工具提示
【发布时间】:2014-11-24 23:33:37
【问题描述】:

在堆栈上找到此链接。我们可以在半馅饼/半甜甜圈图表中添加工具提示: http://tributary.io/inlet/5260888

【问题讨论】:

    标签: jquery d3.js jquery-tooltip


    【解决方案1】:

    这是一个将div 工具提示添加到图表的示例。

    // create div add to DOM
    var div = d3.select("body").append("div")   
        .style("position", "absolute")
        .style("width", "60px")
        .style("height", "18px")
        .style("background", "lightsteelblue")
        .style("border-radius","4px")
        .style("opacity", 0);
    
    .....
    
    // after you append the "arcs"
    // set up some mouse handler to show/hide div
    arcs.append("svg:path")
                .attr("fill", function(d, i) { return color(i); } ) 
                .attr("d", arc)
    
        .on("mousemove", function(d) {
            div.transition()        
                .duration(200)      
                .style("opacity", 0.9);      
            div.html("Seats: " + d.value)  
                .style("left", (d3.event.pageX) + "px")     
                .style("top", (d3.event.pageY - 28) + "px");    
            })                
        .on("mouseout", function(d) {       
            div.transition()        
                .duration(500)      
                .style("opacity", 0);   
        });
    

    参见示例here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-28
      • 1970-01-01
      相关资源
      最近更新 更多