Merge pull request #390 from antvis/maxSpanningTree_template

docs: readme of template.maxSpanningForest
This commit is contained in:
Yellowthrough 2018-07-23 19:24:25 +08:00 committed by GitHub
commit 5727d3e114
4 changed files with 46 additions and 1 deletions

View File

@ -10,6 +10,7 @@
<script src="../build/plugin.tool.mapper.js"></script>
<script src="../build/plugin.tool.fisheye.js"></script>
<script src="../build/plugin.util.extractSubgraph.js"></script>
<!-- <script src="../build/plugin.util.maxSpanningForest.js"></script> -->
<script src="../build/plugin.tool.highlightSubgraph.js"></script>
<script src="../build/plugin.edge.quadraticCurve.js"></script>
<script src="../build/plugin.tool.minimap.js"></script>
@ -132,7 +133,6 @@
if (minimap !== undefined) minimap.style.display = 'none';
if (legend !== undefined) legend.style.display = 'none';
});
</script>
</body>

View File

@ -195,6 +195,7 @@ class Layout {
worker.terminate();
loading.style.display = 'none';
onLayoutComplete();
};
}
}

View File

@ -0,0 +1,43 @@
## maxSpanningForest
template.maxSpanningForest for jiuselu graph analyzer, which is a plugin for graph. This is a collection of fundamental functions, including:
- the style of the nodes and graphs,
- extracting max spanning forest,
- Force Atlas 2 layout algorithm( with webworker ),
- interactions
- extracting subgraph
- highlight subgraph
- fisheye lens
- onclick
- menu operations
parameter for this plugin:
- layoutCfg: the configuration for layout.
- max_iteration: the number of iteration for terminating the layout algorithm
- kg: the gravity parameter for layout. The larger kg, more compact the graph, expecialy for the isolated subgraphs.
- prev_overlapping: whether preventing the node overlapping
- onLayoutComplete: a listener for layout completement. When the layout is complete, the loading div and img disappear.
## use
simple use.
```js
const MaxSpanningForestPlugin = G6.Plugins['template.maxSpanningForest'];
//the instances of plugins
const maxSpanningForest = new MaxSpanningForestPlugin({
layoutCfg: {
max_iteration: 600,
kg: 10,
prev_overlapping: true,
onLayoutComplete: function () {
const minimap = document.getElementById('minimap');
const legend = document.getElementById('legend');
if (minimap !== undefined) minimap.style.display = 'block';
if (legend !== undefined) legend.style.display = 'block';
}
}
});
```

View File

@ -11,6 +11,7 @@ const Size = require('@antv/g2/src/component/legend/size');
const Attr = require('@antv/attr');
const Util = G6.Util;
const Scale = require('@antv/scale');
class Plugin {
constructor(itemType, dim, channel, range, otherCfg) {
Util.mix(this, {