43 | )
44 | }
45 |
--------------------------------------------------------------------------------
/docs/app/routes/docs/plugins/selected-nodes.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | meta:
3 | title: 节点选中插件 | @aoviz/graphs
4 | description: 选中节点插件
5 | sidebar_position: 3
6 | ---
7 |
8 | # 节点选中插件
9 |
10 | 使用鼠标点击节点体验选中效果。
11 |
12 | ```jsx live=true template=configPlayground
13 | import { Force, SelectedNodesPlugin, DEFAULT_LAYOUT_OPTION } from '@aoviz/graphs';
14 | import { ONE_DEGREE_BANK_DATA } from '@aoviz/mock'
15 | import { useRef, useEffect } from 'react'
16 | import { useControls } from 'leva'
17 |
18 | const option = {
19 | link:{
20 | label: {
21 | backgroundColor: 'rgba(114, 193, 209, 0.6)'
22 | }
23 | },
24 | layout: DEFAULT_LAYOUT_OPTION
25 | }
26 | export default function Viz() {
27 | const wrapper = useRef(null);
28 | const instanceRef = useRef(null)
29 | const config = useControls({
30 | space: 5,
31 | borderColor: '#BE6AFF',
32 | borderWidth: 2,
33 | shadowBlur: 3,
34 | shadowColor: '#329485'
35 | })
36 | useEffect(() => {
37 | instanceRef.current = new Force(wrapper.current,{ data: ONE_DEGREE_BANK_DATA, option });
38 | }, [wrapper]);
39 |
40 | useEffect(() => {
41 | instanceRef.current.setPlugins([new SelectedNodesPlugin(config)])
42 | }, [instanceRef, config])
43 |
44 | return (
45 | 53 | Use our imperative API methods to run animations without updating state. 54 | Repsond to events without the react rendering overhead to achieve 55 | smooth, fluid animation. 56 |
57 |{datum.label}
34 | {datum}
55 |