Skip to content

Commit c927bdb

Browse files
committed
version 0.15
1 parent ef5c47f commit c927bdb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

flowgorithm.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* FlowgorithmJS
3-
* @versione 0.14
4-
* @date 2019-02-19
3+
* @version 0.15
4+
* @date 2019-03-05
5+
* @author Andrea Vallorani <[email protected]>
56
*/
67
var maxW,maxH,flowX=0,funX=0;
78
var flow;
@@ -97,9 +98,8 @@ function drawFlowchart($xml,selector,options){
9798
var s = drawStart(txtStart);
9899
s += drawSequence($xml.children('body'));
99100
s += drawEnd(txtEnd);
100-
$('#gtest').get(0).innerHTML = '<g transform="translate(0,0)">'+s+'</g>';
101-
var fwidth = $('#gtest').children('g').get(0).getBBox().width+5;
102-
var fx = Math.abs($('#gtest').children('g').get(0).getBBox().x);
101+
var fwidth = calcBlockWidth(s)+5;
102+
var fx = calcBlockX(s);
103103
var tempX = funX;
104104
if(tempX!=0){
105105
tempX+=fx;
@@ -151,25 +151,25 @@ function drawFlowchart($xml,selector,options){
151151
};
152152
function drawStart(content){
153153
flow.Y += 20;
154-
var l = Math.max(calcExtraWidth(content)-35,35);
154+
var padding = 10;
155+
var l = Math.max(calcExtraWidth(content),50)/2+padding;
155156
var s = '<g class="block" transform="translate(0,'+flow.Y+')">'+
156157
' <g class="start">'+
157158
' <ellipse class="symbol" cx="0" cy="0" rx="'+l+'" ry="20"/>'+
158-
' <text x="0" y="5">'+content+'</text>'+
159+
' <text x="0" y="4">'+content+'</text>'+
159160
' </g>'+
160161
'</g>';
161162
flow.Y += 20;
162-
//console.log("start ("+flow.Y+")");
163163
return s;
164164
};
165165
function drawEnd(content){
166-
//console.log("end ("+flow.Y+")");
167-
var l = Math.max(calcExtraWidth(content)-30,35);
166+
var padding = 10;
167+
var l = Math.max(calcExtraWidth(content),50)/2+padding;
168168
var s = '<g class="block" transform="translate(0,'+flow.Y+')">'+
169169
drawArrow()+
170170
' <g class="end" transform="translate(0,'+(options.aH+30)+')">'+
171171
' <ellipse class="symbol" cx="0" cy="0" rx="'+l+'" ry="20"/>'+
172-
' <text x="0" y="5">'+content+'</text>'+
172+
' <text x="0" y="4">'+content+'</text>'+
173173
' </g>'+
174174
'</g>';
175175
flow.Y += 50+options.aH;
@@ -306,8 +306,8 @@ function drawFlowchart($xml,selector,options){
306306
}
307307
else{
308308
var contidionWidth = Math.max(calcExtraWidth(condition),70)+20;
309-
condition = '<text x="0" y="30">'+condition.escape()+'</text>';
310-
romH = 25;
309+
condition = '<text x="0" y="31">'+condition.escape()+'</text>';
310+
romH = 27;
311311
}
312312
var oldY = 0, maxH = 0;
313313
oldY = flow.Y;
@@ -520,14 +520,14 @@ function drawFlowchart($xml,selector,options){
520520
return l;
521521
};
522522
function calcBlockWidth(content){
523-
$("#gtest").get(0).innerHTML = content;
524-
var l = $('#gtest').get(0).getBBox().width;
523+
$('#gtest').get(0).innerHTML = '<g transform="translate(0,0)">'+content+'</g>';
524+
var l = $('#gtest').children('g').get(0).getBBox().width;
525525
maxW = Math.max(maxW,l);
526526
return l;
527527
};
528528
function calcBlockX(content){
529-
$("#gtest").get(0).innerHTML = content;
530-
return Math.abs($('#gtest').get(0).getBBox().x);
529+
$("#gtest").get(0).innerHTML = '<g transform="translate(0,0)">'+content+'</g>';
530+
return Math.abs($('#gtest').children('g').get(0).getBBox().x);
531531
};
532532
function drawArrow(){
533533
return '<line class="arrow" x1="0" y1="0" x2="0" y2="'+options.aH+'"/>';

0 commit comments

Comments
 (0)