Javascript 有没有办法创建一条从时间轴上的标记到文本的线?
下面是一个显示时间轴的示例代码,有人知道如何创建一条从时间轴上的点标记到上面文本的线吗? 谢谢 可能与此有关:Javascript 有没有办法创建一条从时间轴上的标记到文本的线?,javascript,jquery,html,css,svg,Javascript,Jquery,Html,Css,Svg,下面是一个显示时间轴的示例代码,有人知道如何创建一条从时间轴上的点标记到上面文本的线吗? 谢谢 可能与此有关: $svg.circle = function (cx, cy, r, options) { var element = $(svg("circle")) .attr("cx", cx) .attr("cy", cy) .attr("r", r); setSvgOptions(
$svg.circle = function (cx, cy, r, options) {
var element = $(svg("circle"))
.attr("cx", cx)
.attr("cy", cy)
.attr("r", r);
setSvgOptions(element, options);
return element;
};
如果我正确理解了你的问题,那么你试图从黑点到它们正上方的标签再画一条垂直线,如下所示: 要实现这一点,您可以在
Timeline
原型的drawervent
函数中调用$svg.line()
var newLine = $svg.line(
x, // Horizontal offset of the line being drawn
this.height, // Height is the vertical height of timeline
x, // Re-use "x" to achieve vertical line
this.height - 30) // 30 represents the height of newLine
.attr("stroke", "#000000")
.attr("stroke-width", 1)
.appendTo(group); // Adds this newLine to the current svg group
有关工作示例,请参见:@crateouskoala You bet:)