当前位置:   article > 正文

dagre-d3流程图_dagred3清除

dagred3清除
<!doctype html>

<meta charset="utf-8">
<title>Dagre D3 Demo: Arrows</title>

<link rel="stylesheet" href="demo.css">
<script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
<script src="../dagre-d3.js"></script>

<style id="css">
body {
  font: 300 14px 'Helvetica Neue', Helvetica;
}

.node rect,
.node circle,
.node ellipse {
  stroke: #333;
  fill: #fff;
  stroke-width: 1px;
}

.edgePath path {
  stroke: #333;
  fill: #333;
  stroke-width: 1.5px;
}

.node rect {
  background: lightblue;
  font-size: 16px;
  color: white;
  width: 50px;
  height: 50px;
}

</style>

<h1>Dagre D3 Demo: Arrows</h1>

<svg width=960 height=600><g/></svg>

<section>
<p>A sample that shows the different arrows available in dagre-d3.
</section>

<script id="js">
// Create a new directed graph
var g = new dagreD3.graphlib.Graph().setGraph({});

g.setGraph({
    nodesep: 70,
    ranksep: 50,
    rankdir: "LR", // 流程方向
    marginx: 20,
    marginy: 20
  });

  
// 设置节点
g.setNode('p2', { label: 'p'});
g.setNode('p', { label: 'p'});
g.setNode('c', { label: 'c'});

var html = `<div style="color: white;background-color: red;">html</div>`
g.setNode('p1', { 
  labelType: 'html',
  label: html,
  rx: 0, // 圆角
  ry: 0,
  // padding: 0,
});
g.setNode('c1', { label: 'c'});
// 连接线 (start, end, lineStyle)
g.setEdge('c', 'p', {
  arrowhead: 'normal',
  label: ''
});
g.setEdge('c', 'p2', {
  arrowhead: 'normal',
  label: ''
});

var svg = d3.select('svg'),
  inner = svg.select('g');

// 可以收缩放大
var zoom = d3.zoom().on("zoom", function() {
      inner.attr("transform", d3.event.transform);
    });
svg.call(zoom);
// 渲染到页面
var render = new dagreD3.render();
render(inner, g);

var initialScale = 0.75;
svg.call(zoom.transform, d3.zoomIdentity.translate((svg.attr("width") - g.graph().width * initialScale) / 2, 20).scale(initialScale));
svg.attr('height', g.graph().height * initialScale + 40);

</script>

<script src="demo.js"></script>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/563021
推荐阅读