mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#962 added color setting for default link style
This commit is contained in:
parent
2dd4aa31e5
commit
a0e7789d50
@ -549,6 +549,8 @@ it('25: Handle link click events (link, anchor, mailto, other protocol, script)'
|
|||||||
`graph LR
|
`graph LR
|
||||||
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
||||||
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
||||||
|
E{{default<br />style}} -->|default<br />style| F([default<br />style])
|
||||||
|
linkStyle default color:Sienna;
|
||||||
linkStyle 0 color:red;
|
linkStyle 0 color:red;
|
||||||
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
||||||
style A color:red;
|
style A color:red;
|
||||||
@ -567,6 +569,8 @@ it('25: Handle link click events (link, anchor, mailto, other protocol, script)'
|
|||||||
`graph LR
|
`graph LR
|
||||||
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
||||||
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
||||||
|
E{{default<br />style}} -->|default<br />style| F([default<br />style])
|
||||||
|
linkStyle default color:Sienna;
|
||||||
linkStyle 0 color:red;
|
linkStyle 0 color:red;
|
||||||
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
||||||
style A color:red;
|
style A color:red;
|
||||||
|
2
dist/index.html
vendored
2
dist/index.html
vendored
@ -373,6 +373,8 @@ graph TB
|
|||||||
graph LR
|
graph LR
|
||||||
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
A[red<br>text] -->|red<br>text| B(blue<br>text)
|
||||||
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
C[/red<br/>text/] -->|blue<br/>text| D{blue<br/>text}
|
||||||
|
E{{default<br />style}} -->|default<br />style| F([default<br />style])
|
||||||
|
linkStyle default color:Sienna;
|
||||||
linkStyle 0 color:red;
|
linkStyle 0 color:red;
|
||||||
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
linkStyle 1 stroke:DarkGray,stroke-width:2px,color:#0000ff
|
||||||
style A color:red;
|
style A color:red;
|
||||||
|
@ -152,8 +152,12 @@ export const addEdges = function(edges, g) {
|
|||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
|
||||||
let defaultStyle;
|
let defaultStyle;
|
||||||
|
let defaultLabelStyle;
|
||||||
|
|
||||||
if (typeof edges.defaultStyle !== 'undefined') {
|
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) {
|
edges.forEach(function(edge) {
|
||||||
@ -181,6 +185,9 @@ export const addEdges = function(edges, g) {
|
|||||||
if (typeof defaultStyle !== 'undefined') {
|
if (typeof defaultStyle !== 'undefined') {
|
||||||
style = defaultStyle;
|
style = defaultStyle;
|
||||||
}
|
}
|
||||||
|
if (typeof defaultLabelStyle !== 'undefined') {
|
||||||
|
labelStyle = defaultLabelStyle;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'dotted':
|
case 'dotted':
|
||||||
style = 'fill:none;stroke-width:2px;stroke-dasharray:3;';
|
style = 'fill:none;stroke-width:2px;stroke-dasharray:3;';
|
||||||
@ -219,9 +226,9 @@ export const addEdges = function(edges, g) {
|
|||||||
|
|
||||||
if (typeof edge.style === 'undefined') {
|
if (typeof edge.style === 'undefined') {
|
||||||
edgeData.style = edgeData.style || 'stroke: #333; stroke-width: 1.5px;fill:none';
|
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
|
// Add the edge to the graph
|
||||||
|
Loading…
x
Reference in New Issue
Block a user