为什么 gRaphael 使用看似随机的圆圈作为悬停侦听器?
Why does gRaphael use seeming random circles for hover listener?
我一直在尝试创建一个图表来显示以前的数据,以便在输入数据时为用户提供明智的决定。每个数据点都需要有一个标签(显示值的工具提示)以及一个点击侦听器来显示该值。
我观察到更大的数据集 >10 个值,悬停和点击圆圈的半径很大,不允许鼠标查看每个单独的数据点。
听众:
.hover(function () {
this.tags = r.set();
this.tags.push(r.tag(this.x, this.y, this.value, 0, 10).insertBefore(this).attr([{
fill: "#FFF"
}, {
fill: this.symbol.attr("fill")
}]
));
}, function () {
this.tags && this.tags.remove();
}).attr("stroke", "#000")
.click(function(){
alert("you clicked " + this.value);});
chrt.tags = r.set();
这是我 运行 的演示。 http://jsfiddle.net/vpGyL/1428/
问题是每个符号的半径仅根据图中的下一个标绘点计算。如果数据不是线性的或有多个系列,圆圈可能会变得很大并掩盖其他符号。这可以通过
进行调整
this.attr({r:6})
悬停功能内部。
我一直在尝试创建一个图表来显示以前的数据,以便在输入数据时为用户提供明智的决定。每个数据点都需要有一个标签(显示值的工具提示)以及一个点击侦听器来显示该值。
我观察到更大的数据集 >10 个值,悬停和点击圆圈的半径很大,不允许鼠标查看每个单独的数据点。
听众:
.hover(function () {
this.tags = r.set();
this.tags.push(r.tag(this.x, this.y, this.value, 0, 10).insertBefore(this).attr([{
fill: "#FFF"
}, {
fill: this.symbol.attr("fill")
}]
));
}, function () {
this.tags && this.tags.remove();
}).attr("stroke", "#000")
.click(function(){
alert("you clicked " + this.value);});
chrt.tags = r.set();
这是我 运行 的演示。 http://jsfiddle.net/vpGyL/1428/
问题是每个符号的半径仅根据图中的下一个标绘点计算。如果数据不是线性的或有多个系列,圆圈可能会变得很大并掩盖其他符号。这可以通过
进行调整this.attr({r:6})
悬停功能内部。