跳转到内容
Pivotick
Main Navigation 首页
快速入门
配置
API 参考
示例库项目在线体验

简体中文

English
Français
Deutsch
Português

简体中文

English
Français
Deutsch
Português

外观

Sidebar Navigation

快速入门

使用 Pivotick 的项目

配置

回调

边图层

简化

布局

渲染

模拟

自定义界面

侧栏

提示框

上下文菜单

筛选

图例

数据表格

界面样式

翻译界面

插件

Pivotick API

拓展与数据增强

保存拓展结果

撤销与历史记录

安全

API 文档

示例库

基础

节点样式

边样式

布局

事件与回调

界面自定义

编辑与创建

备注与注释

筛选、搜索与层级

编程控制

主题与性能

拓展与数据增强

综合示例

侧边栏定制 ​

侧边栏是一个包含电池的表面,您可以在三个级别上重塑:mainHeader映射标题和副标题,propertiesPanel.nodePropertiesMap策划显示哪些字段,extraPanels添加您自己的面板。返回字符串的面板将其呈现为文本 - 返回一个元素以提供您自己的标记。

在加载时选择一个节点,以便自定义侧边栏可见 - 单击任何其他节点即可更新它。

js
// Reshape the sidebar at three levels: map the header, curate the properties, and
// add your own panels with arbitrary HTML.
const options = {
    UI: {
        // The sidebar is part of the full UI (the default 'viewer' mode ships
        // pan/zoom only); enable it and keep it open so it's visible right away:
        mode: 'full',
        // Off: `full` mode brings a minimap and the data dock, and this card is about
        // neither (see the Minimap and Data table cards for those).
        minimap: false,
        table: false,
        sidebar: { collapsed: false },
        // 1 — map the header's title & subtitle from your data:
        mainHeader: {
            nodeHeaderMap: {
                title: (node) => node.getData().label,
                subtitle: (node) => `${node.getData().role} · ${node.getData().team}`
            }
        },
        // 2 — curate which properties show (instead of every data key):
        propertiesPanel: {
            nodePropertiesMap: (node) => {
                const d = node.getData()
                return [
                    { name: 'Role', value: d.role },
                    { name: 'Team', value: d.team },
                    { name: 'Commits', value: String(d.commits) }
                ]
            }
        },
        // 3 — add your own panel (great for persistent, graph-level context that
        //     sits alongside the per-node panels above). A returned string renders
        //     as text, so build an element when you want your own markup:
        extraPanels: [
            {
                title: 'Team summary',
                render: () => {
                    const people = data.nodes.length
                    const commits = data.nodes.reduce((sum, n) => sum + n.data.commits, 0)
                    const panel = document.createElement('div')
                    panel.style.cssText = 'font-size:12px;line-height:1.7'
                    for (const line of [`${people} people`, `${commits} commits total`]) {
                        const row = document.createElement('div')
                        row.textContent = line
                        panel.append(row)
                    }
                    return panel
                }
            }
        ]
    }
}
js
const data = {
    nodes: [
        { id: 'alice', data: { label: 'Alice', role: 'Maintainer', team: 'Core', commits: 342 } },
        { id: 'bob', data: { label: 'Bob', role: 'Contributor', team: 'Core', commits: 87 } },
        { id: 'carol', data: { label: 'Carol', role: 'Reviewer', team: 'Docs', commits: 45 } },
        { id: 'dave', data: { label: 'Dave', role: 'Contributor', team: 'Docs', commits: 63 } },
        { id: 'erin', data: { label: 'Erin', role: 'Maintainer', team: 'Infra', commits: 210 } }
    ],
    edges: [
        { from: 'alice', to: 'bob', data: { label: 'mentors' } },
        { from: 'alice', to: 'carol', data: { label: 'reviews' } },
        { from: 'carol', to: 'dave', data: { label: 'pairs' } },
        { from: 'erin', to: 'alice', data: { label: 'syncs' } }
    ]
}
Pager
下一页快速入门