From a0e7789d508b1623a3d5e0f6499c8d0f02a22fcc Mon Sep 17 00:00:00 2001 From: Marc Faber Date: Tue, 4 Feb 2020 22:07:10 +0100 Subject: [PATCH] #962 added color setting for default link style --- cypress/integration/rendering/flowchart.spec.js | 4 ++++ dist/index.html | 2 ++ src/diagrams/flowchart/flowRenderer.js | 13 ++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cypress/integration/rendering/flowchart.spec.js b/cypress/integration/rendering/flowchart.spec.js index 60f6cfbe2..9bc48a399 100644 --- a/cypress/integration/rendering/flowchart.spec.js +++ b/cypress/integration/rendering/flowchart.spec.js @@ -549,6 +549,8 @@ it('25: Handle link click events (link, anchor, mailto, other protocol, script)' `graph LR A[red
text] -->|red
text| B(blue
text) C[/red
text/] -->|blue
text| D{blue
text} + E{{default
style}} -->|default
style| F([default
style]) + linkStyle default color:Sienna; linkStyle 0 color:red; linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff style A color:red; @@ -567,6 +569,8 @@ it('25: Handle link click events (link, anchor, mailto, other protocol, script)' `graph LR A[red
text] -->|red
text| B(blue
text) C[/red
text/] -->|blue
text| D{blue
text} + E{{default
style}} -->|default
style| F([default
style]) + linkStyle default color:Sienna; linkStyle 0 color:red; linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff style A color:red; diff --git a/dist/index.html b/dist/index.html index 9290199cc..e28890ce7 100644 --- a/dist/index.html +++ b/dist/index.html @@ -373,6 +373,8 @@ graph TB graph LR A[red
text] -->|red
text| B(blue
text) C[/red
text/] -->|blue
text| D{blue
text} + E{{default
style}} -->|default
style| F([default
style]) + linkStyle default color:Sienna; linkStyle 0 color:red; linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff style A color:red; diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index b62c3ecbe..3a25e6e74 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -152,8 +152,12 @@ export const addEdges = function(edges, g) { let cnt = 0; let defaultStyle; + let defaultLabelStyle; + if (typeof edges.defaultStyle !== 'undefined') { - defaultStyle = edges.defaultStyle.toString().replace(/,/g, ';'); + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; } edges.forEach(function(edge) { @@ -181,6 +185,9 @@ export const addEdges = function(edges, g) { if (typeof defaultStyle !== 'undefined') { style = defaultStyle; } + if (typeof defaultLabelStyle !== 'undefined') { + labelStyle = defaultLabelStyle; + } break; case 'dotted': style = 'fill:none;stroke-width:2px;stroke-dasharray:3;'; @@ -219,9 +226,9 @@ export const addEdges = function(edges, g) { if (typeof edge.style === 'undefined') { edgeData.style = edgeData.style || 'stroke: #333; stroke-width: 1.5px;fill:none'; - } else { - edgeData.labelStyle = edgeData.labelStyle.replace('color:', 'fill:'); } + + edgeData.labelStyle = edgeData.labelStyle.replace('color:', 'fill:'); } } // Add the edge to the graph