D3.js如何使用折线图在我的图例中添加工具提示
D3.js How to add tooltip in my legend using line graph
我使用 D3 绘制折线图.js我在折线图中使用工具提示,但我也在图例中使用工具提示,但启用以图例显示工具提示,我编写了给定的代码,可以在图例中显示工具提示。
var dates=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
var legend = canvas.append("g")
.attr("class", "legend")
// .attr("transform", "translate(70,10)");
var legendRect = legend.selectAll('rect').data(dates);
legendRect.enter()
.append("rect")
.attr("x", function (d,i){return i*14;})
.attr("width", 12)
.attr("height", 20)
.attr("y", 10)
.style("fill","steelblue")
legend.selectAll("text")
.data(dates)
.enter()
.append("text")
.attr("x", function (d,i){return i*14;})
.attr("y", 25)
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("fill", "white")
.text(function(d) {
return d;
})
.on("mouseover", function(d) {
div.transition()
.duration(200)
.style("opacity", .9);
div .html(formatTime(d.key) + "<br/>" + 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);
});
Iam adding tooltip in text but enable to show the tooltip in my values(I have only problem in legend tooltip)
查看此代码。它完全符合您的要求。
这也是一个很好的例子。
相关文章:
- 高图表 - 是否可以为每个系列添加工具提示格式化程序
- HTML5/Bootstrap-如何为引导程序图标添加工具提示
- 如何在d3js垂直分组条形图中添加工具提示
- 如何使用d3js为循环中的圆环图添加工具提示
- 在d3.js地图中添加工具提示
- D3.js如何使用折线图在我的图例中添加工具提示
- 使用 dojo 将鼠标悬停在动态下拉列表选择上时添加工具提示
- 在 Dojo Select 中添加工具提示
- 从 XML 列表填充的 ASP 下拉列表如何添加工具提示
- 在jQuery中添加工具提示
- 如何使用dojocharts为指标绘图添加工具提示
- 如何使用bootstrap或jquery添加工具提示以在下拉列表中显示所选值
- 在 data.feature 对象上添加工具提示,就像我们可以对标记所做的那样
- 在javascript图形中添加工具提示
- nvd3向多条形图添加工具提示
- 如何使用C#向方框图添加工具提示
- 为html.dropdownlist添加工具提示
- 在进度条引导中添加工具提示
- 在D3js甘特图中添加工具提示
- 如何在chart.js图形中添加工具提示