把知识图谱写成组件
基于 sigma v4 的 Nuxt 模块,11 个组件、16 个 composables、7 个工具函数,覆盖渲染、交互、布局、分析与 DOM 覆盖层,面向 1000+ 节点的大规模图谱。封装是加法,不是围墙——原生
Sigma 与 Graph 实例始终直达。- Semantic networks
- Softwares and data mining
- Exploratory data analysis
- Arguments / Logic
- Business intelligence
2085 节点5409 边
pages/index.vue
<script setup lang="ts">
const { data: dataset } = await useFetch('/api/wikipedia.json')
// featuredColors:前 5 大社区的原色,其余落到 defaultValue
const styles: StylesDeclaration = {
nodes: [
{
label: { attribute: 'label' },
color: { attribute: 'cluster', dict: featuredColors, defaultValue: MUTED },
size: { attribute: 'score', min: 6, max: 36, minValue, maxValue }
},
{ whenState: 'isHighlighted', then: { zIndex: 2 } }
],
edges: [
{ color: EDGE, size: 1 },
{ whenState: 'isHighlighted', then: { color: FOCUS_EDGE, size: 2 } }
]
}
</script>
<template>
<SigmaGraph
:data="dataset.data"
:styles="styles"
:settings="{ hideEdgesOnMove: true }"
>
<SigmaControls position="middle-right">
<SigmaZoomControl />
<SigmaFullscreenControl />
</SigmaControls>
<SigmaTooltip />
</SigmaGraph>
</template>
出口兼容
库没覆盖的原生能力,用户必须仍然能用。
原生实例直达
useSigma() 返回原生 Sigma 与 Graph,不包 Proxy、不做代理,sigma 与 graphology 的任何方法都能直接调。settings 整体透传
不逐字段枚举、不过滤未知键,上游新增配置无需本模块升级即可使用。
数据双通道
传
data 由库做增量 diff 并保留布局坐标;传 graph 则库完全不碰数据,只负责渲染与生命周期。styles 合成
用户规则与
DEFAULT_STYLES 按序合成,不会互相顶掉,坐标绑定与悬浮反馈都还在。不 re-export 上游
sigma 与 graphology 保持 peer 依赖,不夹带第二份实例,类型从原包直接 import。控件外观全接管
零第三方依赖,插槽作用域连行为一起暴露,接管外观不等于丢掉功能。
开始构建你的下一张知识图谱
从一个最小组件到大规模节点渲染、交互、布局与分析,Movk Sigma 用声明式组件把 sigma.js 的复杂度收敛为可组合的能力。