Commit 6afe093c authored by frank.xa.zhang's avatar frank.xa.zhang

fixed shareholder structure -- frank

parent 9e9aa1ec
......@@ -18,6 +18,11 @@ infrastructureModule.controller('organizationFullChartController', ['$scope', '$
OrgChart.templates.myTemplate.minus =
'<rect x="0" y="0" width="36" height="36" rx="12" ry="12" fill="#2E2E2E" stroke="#aeaeae" stroke-width="1"></rect>'
+ '<line x1="4" y1="18" x2="32" y2="18" stroke-width="1" stroke="#aeaeae"></line>';
OrgChart.templates.myTemplate.nodeMenuButton = '<g style="cursor:pointer;" transform="matrix(1,0,0,1,93,15)" control-node-menu-id="{id}">' +
'<rect x="-4" y="-10" fill="#000000" fill-opacity="0" width="22" height="22"></rect>' +
'<line x1="0" y1="0" x2="0" y2="10" stroke-width="2" stroke="#0890D3" />' +
'<line x1="7" y1="0" x2="7" y2="10" stroke-width="2" stroke="#0890D3" />' +
'<line x1="14" y1="0" x2="14" y2="10" stroke-width="2" stroke="#0890D3" /></g>';
$scope.chart = new OrgChart(document.getElementById("tree"), {
template: "myTemplate",
......@@ -25,6 +30,9 @@ infrastructureModule.controller('organizationFullChartController', ['$scope', '$
menu: {
png: {text: "Export PNG"}
},
nodeMenu: {
png: {text: "Export PNG"}
},
linkBinding: {
link_field_0: "percent"
},
......@@ -130,7 +138,67 @@ infrastructureModule.controller('organizationFullChartController', ['$scope', '$
return el;
};
var getGArray = function (nodeId, gArray) {
var nodeSelector = "svg>g[node-id='" + nodeId + "']";
var linkSelector = "svg>g[link-id*='" + nodeId + "']";
var secondLinkSelector = "svg>g[second-link-id*='" + nodeId + "']";
var nodeG = $(nodeSelector);
var linkGs = $(linkSelector);
var secondLinkGs = $(secondLinkSelector);
gArray.push(nodeG);
if (linkGs.length > 0) {
for (var i = 0; i < linkGs.length; i++) {
var linkG = linkGs[i];
var link_id = linkG.attributes[0].value;
var linkGSelector = "svg>g[link-id='" + link_id + "']";
linkG = $(linkGSelector);
var inResut = _.find(gArray, function (item) {
return item.attr("link-id") === link_id || item.attr("second-link-id") === link_id;
});
if (inResut) {
continue;
}
gArray.push(linkG);
var numbers = link_id.match(/\d+/g).map(Number);
for (var j = 0; j < numbers.length; j++) {
if (numbers[j].toString() !== nodeId) {
getGArray(numbers[j], gArray);
}
}
}
}
if (secondLinkGs.length > 0) {
for (var i = 0; i < secondLinkGs.length; i++) {
var secondLinkG = secondLinkGs[i];
var secondLink_id = secondLinkG.attributes[0].value;
var secondLinkGSelector = "svg>g[second-link-id='" + secondLink_id + "']";
secondLinkG = $(secondLinkGSelector);
var inResut = _.find(gArray, function (item) {
return item.attr("link-id") === secondLink_id || item.attr("second-link-id") === secondLink_id;
});
if (inResut) {
continue;
}
gArray.push(secondLinkG);
var numbers = secondLink_id.match(/\d+/g).map(Number);
for (var j = 0; j < numbers.length; j++) {
if (numbers[j].toString() !== nodeId) {
getGArray(numbers[j], gArray);
}
}
}
}
};
var exportStart = function (sender, options, svg) {
var nodeId = options.options.nodeId;
var gArray = [];
getGArray(nodeId, gArray);
$("svg>g").remove();
for (var i = 0; i < gArray.length; i++) {
$("svg").append(gArray[i]);
}
var svg = $('svg')[0].outerHTML;
console.log("svg", svg);
canvg(document.getElementById('canvas'), svg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment