简体   繁体   English

如何避免标签重叠?

[英]How can I avoid labels overlapping?

I'm trying to create a.network containing nodes with long labels, but this results in the labels overlapping with each other, making it difficult to read them all clearly.我正在尝试创建一个包含带有长标签的节点的网络,但这会导致标签相互重叠,从而难以清楚地阅读它们。

How can I separate those labels?我怎样才能分开这些标签?

How can I align elements in one compound?如何对齐一种化合物中的元素?

  • Adjust the relative sizes of your labels in your stylesheet 调整样式表中标签的相对大小
  • Adjust your layout so that your nodes are spread farther apart 调整布局,使节点分布得更远
  • Use short labels; 使用短标签; you can show long text elsewhere, like in a tooltip 您可以在其他地方显示长文本,例如在工具提示中

You can use avoidOverlap: true and nodeDimensionsIncludeLabels: true .您可以使用avoidOverlap: truenodeDimensionsIncludeLabels: true

var layout = cy.elements().layout({
    name: 'dagre',
    avoidOverlap: true,
    nodeDimensionsIncludeLabels: true
});
layout.run();

Here I am using the cytoscape-dagre , but the same is possible with the layouts that come with cytoscape.js according to the documentation , for example with the grid layout.在这里,我使用的是cytoscape-dagre ,但根据文档,使用 cytoscape.js 附带的布局也是可能的,例如网格布局。

Interestingly these options are not listed in the documentation of cytoscape-dagre, but they do work with it.有趣的是,这些选项没有列在 cytoscape-dagre 的文档中,但它们确实可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM