mirror of
https://gitee.com/antv/g6.git
synced 2024-12-05 21:28:33 +08:00
77 lines
1.7 KiB
HTML
77 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<script src="./assets/jquery-3.2.1.min.js"></script>
|
|
<script src="../build/g6.js"></script>
|
|
<script src="../build/plugin.layout.forceAtlas2.js"></script>
|
|
<script src="../build/plugin.layout.circle.js"></script>
|
|
<script src="../build/plugin.util.dataCleaner.js"></script>
|
|
<script src="../build/plugin.layout.dagre.js"></script>
|
|
<script src="../build/plugin.tool.tooltip.js"></script>
|
|
<title>测试</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="mountNode"></div>
|
|
<script>
|
|
const plugin = new G6.Plugins['tool.tooltip']();
|
|
const data = {
|
|
nodes: [{
|
|
id: 'node1',
|
|
x: 100,
|
|
y: 200,
|
|
title: 'aaa',
|
|
}, {
|
|
id: 'node2',
|
|
x: 300,
|
|
y: 200,
|
|
title: 'bbb',
|
|
}],
|
|
edges: [{
|
|
target: 'node2',
|
|
source: 'node1',
|
|
}]
|
|
};
|
|
const graph = new G6.Graph({
|
|
container: 'mountNode',
|
|
width: 500,
|
|
height: 500,
|
|
plugins: [ plugin ]
|
|
});
|
|
graph.node({
|
|
tooltip(model) {
|
|
return [
|
|
['id', model.id],
|
|
['x', model.x],
|
|
['y', model.y],
|
|
['标题', model.title]
|
|
];
|
|
},
|
|
label(model) {
|
|
return model.title;
|
|
}
|
|
});
|
|
graph.edge({
|
|
tooltip(model) {
|
|
return [
|
|
['来源', model.source],
|
|
['去向', model.target],
|
|
['标题', model.title]
|
|
];
|
|
}
|
|
});
|
|
graph.read(data);
|
|
setTimeout(()=>{
|
|
graph.update('node1', {
|
|
title: 'sss'
|
|
});
|
|
}, 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|