Fix for problem with text definitions being overridden by empty strings.

This commit is contained in:
knsv
2014-11-10 07:42:01 +01:00
parent f55336259b
commit c23a185b98
3 changed files with 7 additions and 6 deletions

View File

@@ -38,8 +38,9 @@
</div> </div>
<div class="mermaid"> <div class="mermaid">
a[Lasa bok]-->b; a[Lasa bok]-->b;
b-->c(Vidar)|Klocka; b{Fundera}-->c(Vidar)|Klocka;
b{Fundera}-->d(Bjarke)|Lego; b-->d(Bjarke)|Lego;
style a background:#aaa;
</div> </div>
</body> </body>
</html> </html>

View File

@@ -21,7 +21,7 @@ define(['parser/graph','parser/mermaid'],function(graph,parser){
g.setNode(vertice.id, { label: verticeText,rx:5,ry:5 }); g.setNode(vertice.id, { label: verticeText,rx:5,ry:5 });
}else{ }else{
if(vertice.type==='diamond'){ if(vertice.type==='diamond'){
g.setNode(vertice.id, {shape: "house", label: verticeText,rx:0,ry:0 }); g.setNode(vertice.id, {shape: "house", label: verticeText,rx:0,ry:0,style: "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;" });
}else{ }else{
g.setNode(vertice.id, { label: verticeText,rx:0,ry:0 }); g.setNode(vertice.id, { label: verticeText,rx:0,ry:0 });
} }

View File

@@ -6,13 +6,14 @@ define('parser/graph',function() {
var edges = []; var edges = [];
var graph = { var graph = {
addVertex: function (id, text, type, style) { addVertex: function (id, text, type, style) {
console.log('Got node ' + id + ' ' + type + ' ' + text + ' styles: ' + JSON.stringify(style));
if(typeof vertices[id] === 'undefined'){ if(typeof vertices[id] === 'undefined'){
vertices[id]={id:id, styles:[]}; vertices[id]={id:id, styles:[]};
} }
if(typeof text !== undefined){ if(typeof text !== 'undefined'){
vertices[id].text = text; vertices[id].text = text;
} }
if(typeof type !== undefined){ if(typeof type !== 'undefined'){
vertices[id].type = type; vertices[id].type = type;
} }
if(typeof style !== 'undefined'){ if(typeof style !== 'undefined'){
@@ -23,7 +24,6 @@ define('parser/graph',function() {
}); });
} }
} }
//console.log('Got node ' + id + ' ' + type + ' ' + text + ' styles: ' + JSON.stringify(style));
}, },
getVertices:function(){ getVertices:function(){
return vertices; return vertices;