Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有办法创建一条从时间轴上的标记到文本的线?_Javascript_Jquery_Html_Css_Svg - Fatal编程技术网

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:)