D3多行图表与工具提示转换问题
D3 Multiline Chart with Tooltip Transition Issue
我一直在使用d3创建一个带有焦点和上下文刷的多行图表。一切都很顺利,只是在转换时,带有工具提示的数据点移动到了一个完全错误的位置。我不知道是什么原因造成的。任何帮助都将不胜感激。我在这里附上了完整的代码,并在图上指出了我很确定错误应该是:
http://jsbin.com/osumaq/20/edit
当单击该按钮时,会将一个新的json传递给图形进行读取。
我认为有缺陷的代码块是这样的:
topicEnter.append("g").selectAll(".dot")
.data(function (d) { return d.values }).enter().append("circle").attr("clip-path", "url(#clip)")
.attr("stroke", function (d) {
return color(this.parentNode.__data__.name)
})
.attr("cx", function (d) {
return x(d.date);
})
.attr("cy", function (d) {
return y(d.probability);
})
.attr("r", 5)
.attr("fill", "white").attr("fill-opacity", .5)
.attr("stroke-width", 2).on("mouseover", function (d) {
div.transition().duration(100).style("opacity", .9);
div.html(this.parentNode.__data__.name + "<br/>" + d.probability).style("left", (d3.event.pageX) + "px").style("top", (d3.event.pageY - 28) + "px").attr('r', 8);
d3.select(this).attr('r', 8)
}).on("mouseout", function (d) {
div.transition().duration(100).style("opacity", 0)
d3.select(this).attr('r', 5);
});
非常感谢。
工具提示是什么意思?当我们悬停在点上时,会出现窗口吗?他们看起来很好。我能看到的是,当线条移动时,你的点没有移动,如果我不得不猜测的话,我会说你的输入和更新选择是混合的。如果这些点已经在屏幕上了,并且你想更新它们的位置(通过调用你的方法update
),你应该有以下内容:
// Bind your data
topicEnter.append("g").selectAll(".dot")
.data(function (d) { return d.values })
// Enter selection
topicEnter.enter().append("circle").attr("clip-path", "url(#clip)").attr("class", "dot");
// Update all the dots
topicEnter.attr("stroke", function (d) {
return color(this.parentNode.__data__.name)
})
.attr("cx", function (d) {
return x(d.date);
})
.attr("cy", function (d) {
return y(d.probability);
})
[...]
相关文章:
- d3.js Chord图的动态工具提示
- Graphiti中是否有任何工具提示功能
- "工具提示"jQuery插件坏了
- 单元格的工具提示或标题不显示超过2000个字符
- d3.js用按钮更新条形图工具提示
- 使Intro.js工具提示响应
- 画布中绘制的矩形区域的弹出工具提示
- 使用CSS/JavaScript更改剑道图工具提示文本颜色
- 禁用NVD3 multiBarHorizontalChart中0值的工具提示
- 如何更改已显示的工具提示
- 如何访问高图表工具提示中的任何特定数据
- 如何在jQuery点击函数中添加并显示引导工具提示
- 我可以't使用jQuery更改工具提示引导程序的位置
- 语义UI中格式化的工具提示
- 柱状图上的Highcharts工具提示
- 引导工具提示用法,在搜索字段中
- 将工具提示添加到d3散点图中
- 使用引导将斜体文本转换为工具提示
- D3多行图表与工具提示转换问题
- 如何将DOM元素转换为工具提示