override normal flowchart arrowhead to allow css styling

This commit is contained in:
Charles Liu
2016-07-20 13:19:27 +08:00
parent 2830c70140
commit 5302ca38da
7 changed files with 35 additions and 0 deletions

View File

@@ -425,6 +425,25 @@ exports.draw = function (text, id,isDot) {
dagreD3.util.applyStyle(path, edge[type + 'Style']); dagreD3.util.applyStyle(path, edge[type + 'Style']);
}; };
// Override normal arrowhead defined in d3. Remove style & add class to allow css styling.
render.arrows().normal = function normal(parent, id, edge, type) {
var marker = parent.append("marker")
.attr("id", id)
.attr("viewBox", "0 0 10 10")
.attr("refX", 9)
.attr("refY", 5)
.attr("markerUnits", "strokeWidth")
.attr("markerWidth", 8)
.attr("markerHeight", 6)
.attr("orient", "auto")
var path = marker.append("path")
.attr("d", "M 0 0 L 10 5 L 0 10 z")
.attr("class", "arrowheadPath")
.style("stroke-width", 1)
.style("stroke-dasharray", "1,0");
};
// Set up an SVG group so that we can translate the final graph. // Set up an SVG group so that we can translate the final graph.
var svg = d3.select('#' + id); var svg = d3.select('#' + id);
//svgGroup = d3.select('#' + id + ' g'); //svgGroup = d3.select('#' + id + ' g');

View File

@@ -9,6 +9,11 @@
stroke-width: 1px; stroke-width: 1px;
} }
.arrowheadPath {
fill: @arrowheadColor;
}
.edgePath .path { .edgePath .path {
stroke: @lineColor; stroke: @lineColor;
} }

View File

@@ -5,6 +5,7 @@
@lineColor: @mainContrastColor; @lineColor: @mainContrastColor;
@border1: #81B1DB; @border1: #81B1DB;
@border2: rgba(255, 255, 255, 0.25); @border2: rgba(255, 255, 255, 0.25);
@arrowheadColor: @mainContrastColor;
/* Flowchart variables */ /* Flowchart variables */

View File

@@ -9,6 +9,10 @@
stroke-width: 1px; stroke-width: 1px;
} }
.arrowheadPath {
fill: @arrowheadColor;
}
.edgePath .path { .edgePath .path {
stroke: @lineColor; stroke: @lineColor;
} }

View File

@@ -3,6 +3,7 @@
@lineColor: #333333; @lineColor: #333333;
@border1:#CCCCFF; @border1:#CCCCFF;
@border2:#aaaa33; @border2:#aaaa33;
@arrowheadColor: #333333;
/* Flowchart variables */ /* Flowchart variables */
@nodeBkg:@mainBkg; @nodeBkg:@mainBkg;

View File

@@ -12,6 +12,10 @@ color:#333
stroke-width: 1px; stroke-width: 1px;
} }
.arrowheadPath {
fill: @arrowheadColor;
}
.edgePath .path { .edgePath .path {
stroke: @lineColor; stroke: @lineColor;
stroke-width: 1.5px; stroke-width: 1.5px;

View File

@@ -4,6 +4,7 @@
@lineColor: green; @lineColor: green;
@border1: #13540c; @border1: #13540c;
@border2: #6eaa49; @border2: #6eaa49;
@arrowheadColor: green;
/* Flowchart variables */ /* Flowchart variables */
@nodeBkg:@mainBkg; @nodeBkg:@mainBkg;