mirror of
https://gitee.com/antv/g6.git
synced 2024-12-05 05:09:07 +08:00
rewrite some demo
This commit is contained in:
parent
6a3c9408ed
commit
eb32fe68ba
@ -19,6 +19,7 @@
|
||||
<script src="./assets/d3-4.13.0.min.js"></script>
|
||||
<script src="./assets/d3-legend-2.25.6.min.js"></script>
|
||||
<script src="../build/g6.js"></script>
|
||||
<script src="../build/plugin.tool.minimap.js"></script>
|
||||
<script src="../build/plugin.behaviour.analysis.js"></script>
|
||||
<script src="../build/plugin.tool.d3.mapper.js"></script>
|
||||
<script>
|
||||
@ -35,7 +36,11 @@
|
||||
const graph = new G6.Graph({
|
||||
container: 'mountNode',
|
||||
height: window.innerHeight,
|
||||
plugins: [nodeSizeMapper, nodeColorMapper],
|
||||
plugins: [nodeSizeMapper, nodeColorMapper, new G6.Plugins['tool.minimap']({
|
||||
container: 'minimap',
|
||||
width: 180,
|
||||
height: 120
|
||||
})],
|
||||
modes: {
|
||||
default: ['rightPanCanvas']
|
||||
},
|
||||
@ -55,6 +60,7 @@
|
||||
.force('x', forceX())
|
||||
.on('tick', () => {
|
||||
graph.updateNodePosition();
|
||||
graph.emit('afterlayout');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@
|
||||
"d3": "^5.4.0",
|
||||
"d3-svg-legend": "^2.25.6",
|
||||
"dagre": "~0.8.2",
|
||||
"html-to-image": "^0.0.2",
|
||||
"dom-to-image": "^2.6.0",
|
||||
"lodash": "~4.17.4",
|
||||
"wolfy87-eventemitter": "~5.2.4"
|
||||
},
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
const Util = require('../../util/');
|
||||
const G = require('@antv/g');
|
||||
const htmlToImage = require('html-to-image');
|
||||
const domToImage = require('dom-to-image');
|
||||
const Mixin = function() {};
|
||||
|
||||
Util.augment(Mixin, {
|
||||
@ -22,14 +22,13 @@ Util.augment(Mixin, {
|
||||
html = html.cloneNode(true);
|
||||
}
|
||||
el.parentNode.appendChild(html);
|
||||
htmlToImage.toPng(html, {
|
||||
domToImage.toPng(html, {
|
||||
width,
|
||||
height
|
||||
})
|
||||
.then(dataUrl => {
|
||||
const img = new Image();
|
||||
img.src = dataUrl;
|
||||
el.parentNode.appendChild(img);
|
||||
img.onload = () => {
|
||||
context.setTransform(tm[0], tm[1], tm[3], tm[4], tm[6], tm[7]);
|
||||
context.drawImage(img, x, y, width, height);
|
||||
|
Loading…
Reference in New Issue
Block a user