Drawing different colored “strokes” between center and different nodes in a D3.js tree

后端 未结 2 1002
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 18:16

Here is my code. I am trying to connect/draw a path between center and different nodes. Now I want to make a different colored stroke for a different path. I ha

2条回答
  •  失恋的感觉
    2021-01-06 18:51

    Take a look at following three jsFiddles. The key idea of the solution is as @AmeliaBR said. Study thoroughly the link implementation in these three graphs (it's fairly simple). I extracted the most important parts of the code.

    Red only

    .link_dashed {
        fill: none;
        stroke: #ff0000;
        stroke-width: 1.5px;
        stroke-dasharray: 0,20,20,30,10,10,10;
    }
    

    Enter image description here

    Black only

    .link_dashed {
        fill: none;
        stroke: #000000;
        stroke-width: 1.5px;
        stroke-dasharray: 20,20,30,10,10,10,0;
    }
    

    Enter image description here

    Red and Black

    .link_dashed {
        fill: none;
        stroke: #ff0000;
        stroke-width: 1.5px;
        stroke-dasharray: 0,20,20,30,10,10,10;
    }
    .link_dashed2 {
        fill: none;
        stroke: #000000;
        stroke-width: 1.5px;
        stroke-dasharray: 20,20,30,10,10,10,0;
    }
    

    Enter image description here

提交回复
热议问题