我在IE和Edge中有一个问题,即节点在当前显示的图表上展开。
这种行为只出现在IE和Edge中,Chrome和Firefox按预期显示图表。
var peopleElement = document.getElementById("people");
var orgChart = new getOrgChart(peopleElement, {
theme: "monica",
primaryFields: ["Name", "Title", "Department", "Office", "Email", "Phone", "Mobile"],
photoFields: ["Image"],
enableEdit: false,
enableSearch: true,
enableMove: true,
enablePrint: false,
enableZoomOnNodeDoubleClick: true,
layout: getOrgChart.MIXED_HIERARCHY_RIGHT_LINKS,
expandToLevel: 2,
dataSource: source发布于 2018-08-15 11:16:35
修正了2.5.2版的
此问题是在以下getOrgChart函数中引起的:
getOrgChart.util._5 = function (a) {
var b = a.getAttribute("transform");
// Chome/FireFox value: matrix(1,0,0,1,265,100)
// IE value: matrix(1 0 0 1 265 100)
b = b.replace("matrix", "").replace("(", "").replace(")", "");
b = getOrgChart.util._zJ(b);
b = "[" + b + "]";
// Chrome/Firefox value: [1,0,0,1,265,100]
// IE Value: [1 0 0 1 265 100]
b = JSON.parse(b);
return b
}缺少的逗号导致解析数组时JSON失败。用下面的代码替换函数,它应该可以工作。
getOrgChart.util._5 = function (a) {
var b = a.getAttribute("transform");
// replace all spaces with commas to ensure compatibility in IE
b = b.replace("matrix", "").replace("(", "").replace(")", "").replace(/ /g, ",");
b = getOrgChart.util._zJ(b);
b = "[" + b + "]";
b = JSON.parse(b);
return b
};https://stackoverflow.com/questions/51787651
复制相似问题