mirror of
https://gitee.com/antv/g6.git
synced 2024-12-14 09:30:48 +08:00
commit
e48a41ac1d
@ -35,6 +35,9 @@
|
|||||||
],
|
],
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
0
|
0
|
||||||
|
],
|
||||||
|
"no-loop-func": [
|
||||||
|
0
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
CHANGELOG.md
21
CHANGELOG.md
@ -2,7 +2,20 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## v2.0.0
|
#### 2.0.2 (2018-06-13)
|
||||||
|
|
||||||
|
##### New Features
|
||||||
|
|
||||||
|
* chore(plugin): require g6 by src/index
|
||||||
|
* chore(dev test): remove useless test script
|
||||||
|
|
||||||
|
##### Bug Fixes
|
||||||
|
|
||||||
|
* fix(plugin) minimap destroy Closes #308
|
||||||
|
* fix(saveImage) saveImage bug
|
||||||
|
* fix(event): fix dom coord. Closes #305
|
||||||
|
|
||||||
|
## v2.0.1
|
||||||
|
|
||||||
`2018-06-11`
|
`2018-06-11`
|
||||||
|
|
||||||
@ -20,12 +33,6 @@
|
|||||||
|
|
||||||
## v1.2.1
|
## v1.2.1
|
||||||
|
|
||||||
`2018-04-15`
|
|
||||||
|
|
||||||
* feat: 新增 layout 接口
|
|
||||||
|
|
||||||
## v1.2.1
|
|
||||||
|
|
||||||
`2018-03-15`
|
`2018-03-15`
|
||||||
|
|
||||||
* feat: 新增 layout 接口
|
* feat: 新增 layout 接口
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
<script src="../build/g6.js"></script>
|
<script src="../build/g6.js"></script>
|
||||||
<script src="../build/templateMaxSpanningForest.js"></script>
|
<script src="../build/templateMaxSpanningForest.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const Plugin = window.TemplateMaxSpanningForest;
|
const plugin = new G6.Plugins['template.maxSpanningForest']();
|
||||||
const plugin = new Plugin();
|
|
||||||
const data = {
|
const data = {
|
||||||
nodes: [
|
nodes: [
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
<script src="../build/g6.js"></script>
|
<script src="../build/g6.js"></script>
|
||||||
<script src="../build/toolMinimap.js"></script>
|
<script src="../build/toolMinimap.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const Plugin = window.ToolMinimap;
|
const plugin = new G6.Plugins['tool.minimap']({
|
||||||
const plugin = new Plugin({
|
|
||||||
container: 'minimap',
|
container: 'minimap',
|
||||||
width: 180,
|
width: 180,
|
||||||
height: 120
|
height: 120
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antv/g6",
|
"name": "@antv/g6",
|
||||||
"version": "2.0.1-beta.1",
|
"version": "2.0.1",
|
||||||
"description": "graph visualization frame work",
|
"description": "graph visualization frame work",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"browser": "build/g6.js",
|
"browser": "build/g6.js",
|
||||||
@ -98,10 +98,7 @@
|
|||||||
"screenshot": "node ./bin/screenshot.js",
|
"screenshot": "node ./bin/screenshot.js",
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
"test": "torch --compile --renderer --recursive ./test/unit",
|
"test": "torch --compile --renderer --recursive ./test/unit",
|
||||||
"test-all": "npm run test && npm run test-cases",
|
"test-live": "torch --compile --interactive --watch --recursive ./test/bugs/issue-308-spec.js",
|
||||||
"test-cases": "torch --compile --renderer --recursive ./test/cases",
|
|
||||||
"test-cases-live": "torch --compile --interactive --watch --recursive ./test/cases",
|
|
||||||
"test-live": "torch --compile --interactive --watch --recursive ./test/unit",
|
|
||||||
"watch": "webpack --config webpack-dev.config.js",
|
"watch": "webpack --config webpack-dev.config.js",
|
||||||
"win-dev": "node ./bin/win-dev.js"
|
"win-dev": "node ./bin/win-dev.js"
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 拓展分析交互
|
* @fileOverview 拓展分析交互
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
|
|
||||||
function panCanvas(graph, button = 'left') {
|
function panCanvas(graph, button = 'left') {
|
||||||
let lastPoint;
|
let lastPoint;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* cpd control point distance detail {number} could be 0 ~ 1
|
* cpd control point distance detail {number} could be 0 ~ 1
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
|
|
||||||
G6.registerEdge('quadraticCurve', {
|
G6.registerEdge('quadraticCurve', {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Layout = require('./layout');
|
const Layout = require('./layout');
|
||||||
|
|
||||||
G6.Layouts.ArchimeddeanSpiral = Layout;
|
G6.Layouts.ArchimeddeanSpiral = Layout;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* https://zh.wikipedia.org/wiki/%E9%98%BF%E5%9F%BA%E7%B1%B3%E5%BE%B7%E8%9E%BA%E7%BA%BF
|
* https://zh.wikipedia.org/wiki/%E9%98%BF%E5%9F%BA%E7%B1%B3%E5%BE%B7%E8%9E%BA%E7%BA%BF
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
|
|
||||||
class Layout {
|
class Layout {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Layout = require('./layout');
|
const Layout = require('./layout');
|
||||||
|
|
||||||
G6.Layouts.Circle = Layout;
|
G6.Layouts.Circle = Layout;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 圆形布局
|
* @fileOverview 圆形布局
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview DAG 分层布局
|
* @fileOverview DAG 分层布局
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Layout = require('./layout');
|
const Layout = require('./layout');
|
||||||
|
|
||||||
G6.Layouts.Dagre = Layout;
|
G6.Layouts.Dagre = Layout;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* dagre layout wiki: https://github.com/cpettitt/dagre/wiki
|
* dagre layout wiki: https://github.com/cpettitt/dagre/wiki
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const dagre = require('dagre');
|
const dagre = require('dagre');
|
||||||
const { Util } = G6;
|
const { Util } = G6;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 栅格布局
|
* @fileOverview 栅格布局
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Layout = require('./layout');
|
const Layout = require('./layout');
|
||||||
|
|
||||||
G6.Layouts.Grid = Layout;
|
G6.Layouts.Grid = Layout;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 栅格布局
|
* @fileOverview 栅格布局
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
|
|
||||||
class Layout {
|
class Layout {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* node.rank 分层权重
|
* node.rank 分层权重
|
||||||
* node.label 节点标签
|
* node.label 节点标签
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const maxSpanningForest = require('./maxSpanningForest');
|
const maxSpanningForest = require('./maxSpanningForest');
|
||||||
const d3 = require('d3');
|
const d3 = require('d3');
|
||||||
const { forceSimulation, forceLink, forceManyBody, forceCenter, forceCollide } = d3;
|
const { forceSimulation, forceLink, forceManyBody, forceCenter, forceCollide } = d3;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 最大生成森林
|
* @fileOverview 最大生成森林
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const { Util } = G6;
|
const { Util } = G6;
|
||||||
const maxSpanningTree = require('./maxSpanningTree');
|
const maxSpanningTree = require('./maxSpanningTree');
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* https://zh.wikipedia.org/wiki/%E6%99%AE%E6%9E%97%E5%A7%86%E7%AE%97%E6%B3%95
|
* https://zh.wikipedia.org/wiki/%E6%99%AE%E6%9E%97%E5%A7%86%E7%AE%97%E6%B3%95
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const { Util } = G6;
|
const { Util } = G6;
|
||||||
|
|
||||||
let treeNodes = [];
|
let treeNodes = [];
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* d3-legend https://github.com/susielu/d3-legend
|
* d3-legend https://github.com/susielu/d3-legend
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const d3 = require('d3');
|
const d3 = require('d3');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
const DEFAULT_LEGEND_FILL = '#199CFB';
|
const DEFAULT_LEGEND_FILL = '#199CFB';
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 缩略图
|
* @fileOverview 缩略图
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Minimap = require('./minimap');
|
const Minimap = require('./minimap');
|
||||||
|
|
||||||
class Plugin {
|
class Plugin {
|
||||||
@ -34,6 +34,10 @@ class Plugin {
|
|||||||
this.renderViewPort = () => {
|
this.renderViewPort = () => {
|
||||||
minimap.renderViewPort();
|
minimap.renderViewPort();
|
||||||
};
|
};
|
||||||
|
this.minimap = minimap;
|
||||||
|
}
|
||||||
|
destroy() {
|
||||||
|
this.minimap.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview minimap
|
* @fileOverview minimap
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const { Util, G } = G6;
|
const { Util, G } = G6;
|
||||||
const Canvas = G.Canvas;
|
const Canvas = G.Canvas;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @fileOverview 模拟数据生成的工具
|
* @fileOverview 模拟数据生成的工具
|
||||||
* @author huangtonger@aliyun.com
|
* @author huangtonger@aliyun.com
|
||||||
*/
|
*/
|
||||||
const G6 = require('@antv/g6');
|
const G6 = require('../../src/index');
|
||||||
const Util = G6.Util;
|
const Util = G6.Util;
|
||||||
const randomData = {
|
const randomData = {
|
||||||
// 生成链式图数据
|
// 生成链式图数据
|
||||||
|
@ -292,13 +292,14 @@ class Controller extends Base {
|
|||||||
const point = this._parsePoint(canvasPoint.x, canvasPoint.y);
|
const point = this._parsePoint(canvasPoint.x, canvasPoint.y);
|
||||||
const shape = canvas.getShape(canvasPoint.x, canvasPoint.y);
|
const shape = canvas.getShape(canvasPoint.x, canvasPoint.y);
|
||||||
const item = graph.getItemByShape(shape);
|
const item = graph.getItemByShape(shape);
|
||||||
|
const pixelRatio = canvas.get('pixelRatio');
|
||||||
return {
|
return {
|
||||||
item,
|
item,
|
||||||
shape,
|
shape,
|
||||||
x: point.x,
|
x: point.x,
|
||||||
y: point.y,
|
y: point.y,
|
||||||
domX: ev.offsetX,
|
domX: canvasPoint.x / pixelRatio,
|
||||||
domY: ev.offsetY,
|
domY: canvasPoint.y / pixelRatio,
|
||||||
domEvent: ev
|
domEvent: ev
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -787,12 +787,11 @@ class Graph extends Base {
|
|||||||
* @return {object} canvas dom
|
* @return {object} canvas dom
|
||||||
*/
|
*/
|
||||||
saveImage() {
|
saveImage() {
|
||||||
const graph = this.getGraph();
|
|
||||||
const box = this.getBBox();
|
const box = this.getBBox();
|
||||||
const padding = this.getFitViewPadding();
|
const padding = this.getFitViewPadding();
|
||||||
|
|
||||||
return Util.graph2Canvas({
|
return Util.graph2Canvas({
|
||||||
graph,
|
graph: this,
|
||||||
width: box.width + padding[1] + padding[3],
|
width: box.width + padding[1] + padding[3],
|
||||||
height: box.height + padding[0] + padding[2]
|
height: box.height + padding[0] + padding[2]
|
||||||
});
|
});
|
||||||
|
@ -1 +1 @@
|
|||||||
module.exports = '2.0.1-beta.1';
|
module.exports = '2.0.1';
|
||||||
|
58
test/bugs/issue-308-spec.js
Normal file
58
test/bugs/issue-308-spec.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
const G6 = require('../../src/index');
|
||||||
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
|
describe('issue-308-spec', () => {
|
||||||
|
const div = G6.Util.createDOM(`
|
||||||
|
<div>
|
||||||
|
<div id="mountNode"></div>
|
||||||
|
<div id="minimap"></div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
require('../../plugins/index');
|
||||||
|
document.body.appendChild(div);
|
||||||
|
const plugin = new G6.Plugins['tool.minimap']({
|
||||||
|
container: 'minimap',
|
||||||
|
width: 180,
|
||||||
|
height: 120
|
||||||
|
});
|
||||||
|
const data = {
|
||||||
|
nodes: [{
|
||||||
|
id: 'node0',
|
||||||
|
x: -100,
|
||||||
|
y: 200
|
||||||
|
}, {
|
||||||
|
id: 'node1',
|
||||||
|
x: 100,
|
||||||
|
y: 200
|
||||||
|
}, {
|
||||||
|
id: 'node2',
|
||||||
|
x: 300,
|
||||||
|
y: 200
|
||||||
|
}, {
|
||||||
|
id: 'node3',
|
||||||
|
x: 600,
|
||||||
|
y: 200
|
||||||
|
}],
|
||||||
|
edges: [{
|
||||||
|
target: 'node0',
|
||||||
|
source: 'node1'
|
||||||
|
}, {
|
||||||
|
target: 'node2',
|
||||||
|
source: 'node1'
|
||||||
|
}, {
|
||||||
|
target: 'node2',
|
||||||
|
source: 'node3'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
const graph = new G6.Graph({
|
||||||
|
container: 'mountNode',
|
||||||
|
fitView: 'cc',
|
||||||
|
height: window.innerHeight,
|
||||||
|
plugins: [ plugin ]
|
||||||
|
});
|
||||||
|
graph.read(data);
|
||||||
|
it('test minimap has been destroy when graph destroy', () => {
|
||||||
|
graph.destroy();
|
||||||
|
expect(document.getElementById('minimap').innerHTML).eql('');
|
||||||
|
});
|
||||||
|
});
|
@ -353,6 +353,10 @@ describe('graph test', () => {
|
|||||||
it('reRender', () => {
|
it('reRender', () => {
|
||||||
graph.reRender();
|
graph.reRender();
|
||||||
});
|
});
|
||||||
|
it('saveImage', () => {
|
||||||
|
const imageCanvas = graph.saveImage();
|
||||||
|
expect(imageCanvas.tagName).eql('CANVAS');
|
||||||
|
});
|
||||||
it('destroy', () => {
|
it('destroy', () => {
|
||||||
graph.destroy();
|
graph.destroy();
|
||||||
expect(div.childNodes.length).equal(0);
|
expect(div.childNodes.length).equal(0);
|
||||||
|
@ -27,7 +27,8 @@ module.exports = {
|
|||||||
path: resolve(__dirname, 'build/')
|
path: resolve(__dirname, 'build/')
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
'@antv/g6': 'G6'
|
'@antv/g6': 'G6',
|
||||||
|
'../../src/index': 'G6'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
Loading…
Reference in New Issue
Block a user