mirror of
https://gitee.com/antv/g6.git
synced 2024-12-16 02:21:25 +08:00
71 lines
1.6 KiB
HTML
71 lines
1.6 KiB
HTML
<!doctype html>
|
|
<html itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="en">
|
|
|
|
<head>
|
|
<meta content="origin" name="referrer">
|
|
<title>mapper</title>
|
|
<script src="../build/g6.js"></script>
|
|
<script src="../build/plugin.behaviour.analysis.js"></script>
|
|
<script src="../build/plugin.tool.mapper.js"></script>
|
|
<script src="./assets/jquery-3.2.1.min.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id='mountNode'></div>
|
|
<div id='legend'></div>
|
|
<script>
|
|
const Mapper = G6.Plugins['tool.mapper']
|
|
const nodeColorMapper = new Mapper('node', 'class', 'color', ['#BAE7FF', '#0050B3'], {
|
|
legendCfg: {
|
|
scale: 0.5
|
|
}
|
|
});
|
|
const edgeSizeMapper = new Mapper('edge', 'weight', 'size', [2, 20], {
|
|
legendCfg: null
|
|
});
|
|
const data = {
|
|
nodes: [{
|
|
id: 'node1',
|
|
x: 100,
|
|
y: 200,
|
|
class: 'class_1'
|
|
}, {
|
|
id: 'node2',
|
|
x: 300,
|
|
y: 200,
|
|
class: 'class_1'
|
|
}, {
|
|
id: 'node3',
|
|
x: 100,
|
|
y: 100,
|
|
class: 'class_2'
|
|
}, {
|
|
id: 'node4',
|
|
x: 300,
|
|
y: 100,
|
|
class: 'class_2'
|
|
}],
|
|
edges: [{
|
|
target: 'node2',
|
|
source: 'node1',
|
|
weight: 5
|
|
}, {
|
|
target: 'node3',
|
|
source: 'node2',
|
|
weight: 20
|
|
}, {
|
|
target: 'node4',
|
|
source: 'node3',
|
|
weight: 50
|
|
}]
|
|
};
|
|
const graph = new G6.Graph({
|
|
id: 'mountNode', // dom id
|
|
plugins: [nodeColorMapper, edgeSizeMapper],
|
|
height: 1000,
|
|
});
|
|
graph.read(data);
|
|
|
|
</script>
|
|
</body>
|