在德古拉图上绘制不同的节点形状

Drawing a diffrent node shape on dracula graph?

本文关键字:节点 绘制      更新时间:2023-09-26

我对拉斐尔JS非常陌生,有点急于找到如何使用德古拉图绘制多边形。这必须进入一个 costum 渲染器,例如:

var render = function(r, n) {
        /* the Raphael set is obligatory, containing all you want to display */
        var set = r.set().push(
            /* custom objects go here */
            r.rect(n.point[0]-30, n.point[1]-13, 62, 86)
                .attr({"fill": "#fa8", "stroke-width": 2, r : "9px"}))
                .push(r.text(n.point[0], n.point[1] + 30, n.label)
                    .attr({"font-size":"20px"}));
        /* custom tooltip attached to the set */
        set.items.forEach(
            function(el) {
                el.tooltip(r.set().push(r.rect(0, 0, 30, 30)
                    .attr({"fill": "#fec", "stroke-width": 1, r : "9px"})))});
        return set;
    };

如果有人处理过这样的问题,我会喜欢帮助。

这就解决了!在克里斯·威尔逊的拉斐尔js上找到它

var paper = Raphael(0, 0, 500, 500);
function NGon(x, y, N, side, angle) {
    paper.circle(x, y, 3).attr("fill", "black");
    var path = "",
        c, temp_x, temp_y, theta;
    for (c = 0; c <= N; c += 1) {
        theta = (c + 0.5) / N * 2 * Math.PI;
        temp_x = x + Math.cos(theta) * side;
        temp_y = y + Math.sin(theta) * side;
        path += (c === 0 ? "M" : "L") + temp_x + "," + temp_y;
    }
    return path;
}
paper.path(NGon(050, 50, 8, 40));