ForceDirected
名稱:ForceDirected(力導向關聯圖)
說明:以 d3-force 繪製的力導向關聯圖形
params$
型別:
DeepPartial<ForceDirectedParams>欄位:
名稱 說明 型別 dot 圓點設定 ObjectdotLabel 圓點標籤設定 Objectarrow 箭頭設定 ObjectarrowLabel 箭頭標籤設定 Objectforce d3-force(力導向)設定 Objectzoomable 能否 Zoom In/Out/Drag(滑鼠操作) booleantransform 位移變形設定 ObjectscaleExtent Zoom In/Out 最小/大值 Objectparams.dot名稱 說明 型別 radius 半徑 numberfillColorType 底色顏色類別 ColorTypestrokeColorType 外框顏色類別 ColorTypestrokeWidth 外框寬度 numberstyleFn Node 樣式函式 (node: ComputedNode) => stringparams.dotLabel名稱 說明 型別 colorType 顏色類別 ColorTypesizeFixed 是否固定大小(不受到 Zoom In/Out 影響) booleanstyleFn Node 標籤樣式函式 (node: ComputedNode) => stringparams.arrow名稱 說明 型別 colorType 半徑 ColorTypestrokeWidth 外框寬度 numberpointerWidth 箭頭寬度 numberpointerWidth 箭頭高度 numberstyleFn 箭頭樣式函式 (node: ComputedEdge) => stringparams.arrowLabel名稱 說明 型別 colorType 半徑 ColorTypesizeFixed 是否固定大小(不受到 Zoom In/Out 影響) booleanstyleFn Edge 標籤樣式函式 (node: ComputedEdge) => stringparams.force名稱 說明 型別 nodeStrength 泡泡引力 numberlinkDistance 連結長度 numbervelocityDecay 速度衰減數 numberalphaDecay α 衰減數 numberparams.transform名稱 說明 型別 x x 偏移 numbery y 偏移 numberk 放大倍率 numberparams.scaleExtent名稱 說明 型別 min Zoom 最小值,如為 0則可無限縮小numbermax Zoom 最大值,如為 Infinity則可無限放大number
詳細型別
type ColorType = 'none' | 'label' | 'labelContrast' | 'primary' | 'secondary' | 'background'
interface ComputedNode {
id: string
index: number
label: string
visible: boolean
data: any
value: number | null
color: string
categoryIndex: number
categoryLabel: string
}
interface ComputedEdge {
id: string
index: number
label: string
visible: boolean
data: any
value: number | null
color: string
categoryIndex: number
categoryLabel: string
startNode: ComputedNode
endNode: ComputedNode
}
- 預設值:
{
dot: {
radius: 10,
fillColorType: 'label',
strokeColorType: 'label',
strokeWidth: 1,
styleFn: (node) => '',
},
dotLabel: {
colorType: 'primary',
sizeFixed: false,
styleFn: (node) => 'text-shadow:0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff'
},
arrow: {
colorType: 'primary',
strokeWidth: 1.5,
pointerWidth: 5,
pointerHeight: 5,
styleFn: (edge) => '',
},
arrowLabel: {
colorType: 'primary',
sizeFixed: false,
styleFn: (edge) => ''
},
force: {
nodeStrength: -500,
linkDistance: 100,
velocityDecay: 0.1,
alphaDecay: 0.05
},
zoomable: true,
transform: {
x: 0,
y: 0,
k: 1
},
scaleExtent: {
min: 0,
max: Infinity
}
}