Skip to content

Commit a77ff90

Browse files
committed
little optimization
1 parent f17c8bd commit a77ff90

10 files changed

+19
-7
lines changed

example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
chart = flowchart.parse(code);
2424
chart.drawSVG('canvas', {
25-
'x': 30,
26-
'y': 50,
25+
// 'x': 30,
26+
// 'y': 50,
2727
'line-width': 3,
2828
'line-length': 50,
2929
'text-margin': 10,

release/flowchart-1.2.12.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376

377377
FlowChart.prototype.render = function() {
378378
var maxWidth = 0,
379+
maxHeight = 0,
379380
i = 0,
380381
len = 0,
381382
maxX = 0,
@@ -387,12 +388,15 @@
387388
if (symbol.width > maxWidth) {
388389
maxWidth = symbol.width;
389390
}
391+
if (symbol.height > maxHeight) {
392+
maxHeight = symbol.height;
393+
}
390394
}
391395

392396
for (i = 0, len = this.symbols.length; i < len; i++) {
393397
symbol = this.symbols[i];
394398
symbol.shiftX(this.options.x + (maxWidth - symbol.width)/2);
395-
symbol.shiftY(this.options.y);
399+
symbol.shiftY(this.options.y + (maxHeight - symbol.height)/2);
396400
}
397401

398402
this.start.render();

release/flowchart-1.2.12.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/flowchart-1.2.12.zip

66 Bytes
Binary file not shown.

release/flowchart-latest.zip

66 Bytes
Binary file not shown.

release/flowchart.amd-1.2.12.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@
378378

379379
FlowChart.prototype.render = function() {
380380
var maxWidth = 0,
381+
maxHeight = 0,
381382
i = 0,
382383
len = 0,
383384
maxX = 0,
@@ -389,12 +390,15 @@
389390
if (symbol.width > maxWidth) {
390391
maxWidth = symbol.width;
391392
}
393+
if (symbol.height > maxHeight) {
394+
maxHeight = symbol.height;
395+
}
392396
}
393397

394398
for (i = 0, len = this.symbols.length; i < len; i++) {
395399
symbol = this.symbols[i];
396400
symbol.shiftX(this.options.x + (maxWidth - symbol.width)/2);
397-
symbol.shiftY(this.options.y);
401+
symbol.shiftY(this.options.y + (maxHeight - symbol.height)/2);
398402
}
399403

400404
this.start.render();

release/flowchart.amd-1.2.12.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/flowchart.amd-1.2.12.zip

60 Bytes
Binary file not shown.

release/flowchart.amd-latest.zip

60 Bytes
Binary file not shown.

src/flowchart.chart.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ FlowChart.prototype.startWith = function(symbol) {
5050

5151
FlowChart.prototype.render = function() {
5252
var maxWidth = 0,
53+
maxHeight = 0,
5354
i = 0,
5455
len = 0,
5556
maxX = 0,
@@ -61,12 +62,15 @@ FlowChart.prototype.render = function() {
6162
if (symbol.width > maxWidth) {
6263
maxWidth = symbol.width;
6364
}
65+
if (symbol.height > maxHeight) {
66+
maxHeight = symbol.height;
67+
}
6468
}
6569

6670
for (i = 0, len = this.symbols.length; i < len; i++) {
6771
symbol = this.symbols[i];
6872
symbol.shiftX(this.options.x + (maxWidth - symbol.width)/2);
69-
symbol.shiftY(this.options.y);
73+
symbol.shiftY(this.options.y + (maxHeight - symbol.height)/2);
7074
}
7175

7276
this.start.render();

0 commit comments

Comments
 (0)