Skip to content

Commit

Permalink
fix-bug: export doesn't work well when chart-container has overflow:h…
Browse files Browse the repository at this point in the history
…idden
  • Loading branch information
dabeng committed Jun 26, 2016
1 parent 1dad907 commit af2b7ab
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orgchart",
"version": "1.0.9.7",
"version": "1.1.0",
"homepage": "https://github.com/dabeng/OrgChart",
"authors": [
"dabeng <[email protected]>"
Expand Down
15 changes: 14 additions & 1 deletion dist/js/jquery.orgchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@
} else {
$mask.removeClass('hidden');
}
html2canvas($chartContainer.find('.orgchart:visible').get(0), {
var sourceChart = $chartContainer.addClass('canvasContainer').find('.orgchart:visible').get(0);
var flag = opts.direction === 'l2r' || opts.direction === 'r2l';
html2canvas(sourceChart, {
'width': flag ? sourceChart.clientHeight : sourceChart.clientWidth,
'height': flag ? sourceChart.clientWidth : sourceChart.clientHeight,
'onclone': function(cloneDoc) {
$(cloneDoc).find('.canvasContainer').css('overflow', 'visible')
.find('.orgchart').css('transform', '');
},
'onrendered': function(canvas) {
$chartContainer.find('.mask').addClass('hidden')
.end().find('.oc-download-btn').attr('href', canvas.toDataURL())[0].click();
}
})
.then(function() {
$chartContainer.removeClass('canvasContainer');
}, function() {
$chartContainer.removeClass('canvasContainer');
});
}
});
Expand Down
15 changes: 14 additions & 1 deletion examples/js/jquery.orgchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@
} else {
$mask.removeClass('hidden');
}
html2canvas($chartContainer.find('.orgchart:visible').get(0), {
var sourceChart = $chartContainer.addClass('canvasContainer').find('.orgchart:visible').get(0);
var flag = opts.direction === 'l2r' || opts.direction === 'r2l';
html2canvas(sourceChart, {
'width': flag ? sourceChart.clientHeight : sourceChart.clientWidth,
'height': flag ? sourceChart.clientWidth : sourceChart.clientHeight,
'onclone': function(cloneDoc) {
$(cloneDoc).find('.canvasContainer').css('overflow', 'visible')
.find('.orgchart').css('transform', '');
},
'onrendered': function(canvas) {
$chartContainer.find('.mask').addClass('hidden')
.end().find('.oc-download-btn').attr('href', canvas.toDataURL())[0].click();
}
})
.then(function() {
$chartContainer.removeClass('canvasContainer');
}, function() {
$chartContainer.removeClass('canvasContainer');
});
}
});
Expand Down
1 change: 0 additions & 1 deletion examples/pan-zoom/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

$('#chart-container').orgchart({
'data' : datascource,
'depth': 2,
'nodeContent': 'title',
'pan': true,
'zoom': true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orgchart",
"version": "1.0.9.7",
"version": "1.1.0",
"description": "Simple and direct organization chart(tree-like hierarchy) plugin based on pure DOM and jQuery.",
"main": "./dist/js/jquery.orgchart.js",
"style": [
Expand Down

0 comments on commit af2b7ab

Please sign in to comment.