我正在努力让getOrgChart在具有固定宽度的iframe中工作,以便我可以显示组织结构图。功能确实有效,但是有一件事似乎不能正常工作,那就是比例:自动实际对中组件:
这是我使用的主题:
size: [300, 370],
toolbarHeight: 46,
textPoints: [
{ x: 150, y: 50, width: 285 },
{ x: 150, y: 90, width: 285 },
{ x: 150, y: 120, width: 285 }
],
textPointsNoImage: [
{ x: 150, y: 50, width: 285 },
{ x: 150, y: 90, width: 285 },
{ x: 150, y: 120, width: 285 }
],
expandCollapseBtnRadius: 20,
defs: '<filter id="f1" x="0" y="0" width="200%" height="200%"><feOffset result="offOut" in="SourceAlpha" dx="5" dy="5" /><feGaussianBlur result="blurOut" in="offOut" stdDeviation="5" /><feBlend in="SourceGraphic" in2="blurOut" mode="normal" /></filter>',
box: '<rect x="0" y="0" height="370" width="300" rx="10" ry="10" class="myCustomTheme-box" filter="url(#f1)" />',
text: '<text text-anchor="middle" width="[width]" class="get-text get-text-[index]" x="[x]" y="[y]">[text]</text>',
image: '<clipPath id="getMonicaClip"><circle cx="150" cy="235" r="85" /></clipPath><image preserveAspectRatio="xMidYMid slice" clip-path="url(#getMonicaClip)" xlink:href="[href]" x="65" y="130" height="190" width="170"/>',
reporters: '<circle cx="80" cy="170" r="20" class="reporters"></circle><text class="reporters-text" text-anchor="middle" width="120" x="80" y="177">[reporters]</text>'
只是从演示2稍微改变了。然后我改变了记者文字:
.reporters-text {
font-size: large;
fill: #ffffff;
}
但是,即使将自定义主题更改回原来的样子,使用我的数据集,我总能得到相同的结果:
这一切都发生在Salesforce Dev Org的iframe中。但是,我已经看到这只发生在我动态生成的数据上,而Demos中提供的固定数据集仍然显示它们应该显示的内容。
它在Visualforce页面内呈现,而后者又由Lightning组件打开,但即使单独打开VF页面也会获得相同的结果。
我很好奇这是怎么发生的,因为当我自己不生成数据而是采用一些预生成的数据时,渲染中心没有问题:
订购节点列表没有任何帮助,因为我已经尝试使用硬编码数组,但svg仍然没有完全居中。
(最近几个小时已经花了很多时间来破解这个错误,但在发布后不久就发现了)
似乎问题是,只有他的名字记者的人才处于第二级层次结构的中间。我在他和第2级最左边的人之间切换了位置,瞧,它以某种方式认出它应该再次正确居中。
对我来说,这意味着我必须首先创建具有最多管理者的节点,并且从一侧到另一侧或者仅仅远离中心来订购它们。
{ id: 1, parentId: null, name: "Test", title: "fancy", image:'available'},
{ id: 2, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 3, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 4, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 5, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 6, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 7, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 8, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 9, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 10, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 11, parentId: 3, name: "Test", title: "fancy", image:'available'},
{ id: 12, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 13, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 14, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 15, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 16, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 17, parentId: 10, name: "^Test", title: "fancy", image:'available'}
虽然这个数组:
{ id: 1, parentId: null, name: "Test", title: "fancy", image:'available'},
{ id: 2, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 3, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 4, parentId: 1, name: "Test", title: "fancy", image:'available'},
{ id: 5, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 6, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 7, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 8, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 9, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 10, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 11, parentId: 2, name: "Test", title: "fancy", image:'available'},
{ id: 12, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 13, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 14, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 15, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 16, parentId: 6, name: "Test", title: "fancy", image:'available'},
{ id: 17, parentId: 10, name: "^Test", title: "fancy", image:'available'}
(注意我将parentIds更改为现在与2而不是3相关)
当我把它改为4而不是3时,同样的事情发生了。