From af2b7abff8512f34f09e8f2a9a2045bb787dac9b Mon Sep 17 00:00:00 2001 From: dabeng Date: Sun, 26 Jun 2016 23:04:53 +0800 Subject: [PATCH] fix-bug: export doesn't work well when chart-container has overflow:hidden --- bower.json | 2 +- dist/js/jquery.orgchart.js | 15 ++++++++++++++- examples/js/jquery.orgchart.js | 15 ++++++++++++++- examples/pan-zoom/scripts.js | 1 - package.json | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index c63f6758..280f6696 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "orgchart", - "version": "1.0.9.7", + "version": "1.1.0", "homepage": "https://github.com/dabeng/OrgChart", "authors": [ "dabeng " diff --git a/dist/js/jquery.orgchart.js b/dist/js/jquery.orgchart.js index a919e459..a0d1162d 100755 --- a/dist/js/jquery.orgchart.js +++ b/dist/js/jquery.orgchart.js @@ -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'); }); } }); diff --git a/examples/js/jquery.orgchart.js b/examples/js/jquery.orgchart.js index a919e459..a0d1162d 100755 --- a/examples/js/jquery.orgchart.js +++ b/examples/js/jquery.orgchart.js @@ -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'); }); } }); diff --git a/examples/pan-zoom/scripts.js b/examples/pan-zoom/scripts.js index c85e40e0..0607a213 100644 --- a/examples/pan-zoom/scripts.js +++ b/examples/pan-zoom/scripts.js @@ -31,7 +31,6 @@ $('#chart-container').orgchart({ 'data' : datascource, - 'depth': 2, 'nodeContent': 'title', 'pan': true, 'zoom': true diff --git a/package.json b/package.json index 8574e8c0..efe9c5f7 100755 --- a/package.json +++ b/package.json @@ -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": [