diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f63f962fb..376cb4584f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ ## v2.0.0 +`2018-06-11` + +* fix: reDraw edge after layout +* feat: add beforelayout && afterlayout event +* chore: .travis.yml add add Node.js +* chore: .travis.yml cache node_modules + +## v2.0.0 + `2018-06-06` * refactor: 重构架构 && 代码 diff --git a/bin/version.js b/bin/version.js new file mode 100644 index 0000000000..06698b0863 --- /dev/null +++ b/bin/version.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node +const fs = require('fs'); +const path = require('path'); +const cPath = path.join(process.cwd(), './package.json'); +const version = require('../src/version'); +const pk = JSON.parse(fs.readFileSync(cPath, 'utf8')); +pk.version = version; + +fs.writeFile(cPath, JSON.stringify(pk, null, ' '), function(err) { + if (err) { + return console.error(err); + } +}); diff --git a/package.json b/package.json index d94cfcc371..350ec28789 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g6", - "version": "2.0.0", + "version": "2.0.1-beta", "description": "graph visualization frame work", "main": "lib/index.js", "browser": "build/g6.js", @@ -89,12 +89,12 @@ "coverage-viewer": "torch-coverage", "demos": "electron ./demos/app.js", "demos-web": "node ./demos/app.js --web --port 2046", - "dev": "npm run watch & npm run demos-web", + "dev": "npm run demos-web & npm run watch", "dist": "npm run mkdir-dist && npm run build && npm run copy", "lint": "eslint --ext .js ./src", "lint-fix": "eslint --ext .html,.js --fix ./", "mkdir-dist": "node ./bin/mkdir-dist.js", - "prepublishOnly": "npm run build-lib && npm run dist", + "prepublishOnly": "npm run build-lib && npm run dist && node ./bin/version.js", "screenshot": "node ./bin/screenshot.js", "start": "npm run dev", "test": "torch --compile --renderer --recursive ./test/unit", @@ -121,4 +121,4 @@ "engines": { "node": ">=8.9.0" } -} +} \ No newline at end of file diff --git a/src/controller/layout.js b/src/controller/layout.js index 3e2304afa7..67f76c5c88 100644 --- a/src/controller/layout.js +++ b/src/controller/layout.js @@ -56,6 +56,7 @@ class Controller extends Base { layout() { const graph = this.graph; const processer = this.processer; + graph.emit('beforelayout'); const nodes = graph.getNodes() .filter(node => { return node.isVisible(); @@ -72,6 +73,7 @@ class Controller extends Base { }); graph._executeLayout(processer, nodes, edges); graph.updateNodePosition(); + graph.emit('afterlayout'); } getLayoutProcesser() { return this.processer; diff --git a/src/global.js b/src/global.js index ac03b9bbe9..70ca57ed22 100644 --- a/src/global.js +++ b/src/global.js @@ -2,6 +2,7 @@ * @fileOverview global config * @author huangtonger@aliyun.com */ +const version = require('./version'); module.exports = { trackable: true, @@ -26,5 +27,5 @@ module.exports = { updateEasing: 'easeQuadOut', enterEasing: 'easeQuadOut', leaveEasing: 'easeQuadOut', - version: '____G6_VERSION____' + version }; diff --git a/src/index.js b/src/index.js index 338c330de1..4469ea0c0d 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,7 @@ const Shape = require('./shape/'); const Handler = require('./handler'); const Global = require('./global'); +const version = require('./version'); const G6 = { Graph: require('./graph'), @@ -20,7 +21,7 @@ const G6 = { registerGroup: Shape.registerGroup, registerGuide: Shape.registerGuide, registerBehaviour: Handler.registerBehaviour, - version: Global.version + version }; G6.track = function(enable) { diff --git a/src/item/edge.js b/src/item/edge.js index 8fda8141fb..dbf1859141 100644 --- a/src/item/edge.js +++ b/src/item/edge.js @@ -67,6 +67,8 @@ class Edge extends Item { const keyShape = this.keyShape; const shapeObj = this.shapeObj; keyShape.attr('path', shapeObj.getPath(this)); + } else { + this.draw(); } this._afterDraw(); } diff --git a/src/track.js b/src/track.js index 2e85211259..3721fb13de 100644 --- a/src/track.js +++ b/src/track.js @@ -4,6 +4,7 @@ */ const Global = require('./global'); const SERVER_URL = 'https://kcart.alipay.com/web/bi.do'; +const version = require('./version'); // 延迟发送请求 setTimeout(function() { @@ -13,7 +14,7 @@ setTimeout(function() { pg: document.URL, r: new Date().getTime(), g6: true, - version: Global.version, + version, page_type: 'syslog' }; const d = encodeURIComponent(JSON.stringify([ newObj ])); diff --git a/src/version.js b/src/version.js new file mode 100644 index 0000000000..96d156f6e6 --- /dev/null +++ b/src/version.js @@ -0,0 +1 @@ +module.exports = '2.0.1-beta';