接口: LegendEntry
图例中的一行:样本、标签以及如何辨别它代表哪些元素 - 节点或 edge 范围部分中的边。
示例
js
{ id: 'hub', label: 'Hub', color: '#7EA2FB',
predicate: (node) => node.getData()?.type === 'hub' }属性
badge?
optionalbadge:NodeBadge
将此徽章绘制为样本而不是点,因为元素通过 NodeStyle.badges 标记而不是填充来区分。它的绘制方式与画布的绘制方式相同,因此图例显示相同的标记。参赛作品的徽章名为 color。在 edge 范围的部分中被忽略,其样本是一条线。
示例
js
{ id: 'enriched', label: 'From enrichment', color: '#8b5cf6',
badge: { svgIcon: sparkle }, predicate: (node) => node.getData().enriched }color
color:
string
样本颜色 — 任何 CSS 颜色。在派生模式下从渲染器采样:节点的填充,或 edge 范围部分中的边缘描边。
id
id:
string
稳定身份:切换键和写入过滤器的值。
label?
optionallabel:string
人工标签,逐字使用(因此可以翻译)。
默认值
美化后的id
order?
optionalorder:number
显示顺序,升序。
默认值
ts
declaration (or first-seen) orderpredicate?
optionalpredicate: (node) =>boolean| (edge) =>boolean
该条目代表哪些元素。当声明 key 时,默认将元素数据上的 id 与 LegendOptions.key 进行匹配。
当节声明 scope: 'edge' 时,接收 Node 或 Edge。