注册结点时遇到的问题
版本
"gg-editor": "^2.0.1",
请检查问题是否存在于最新版本中
环境
"react": "^16.8.0", "react-dom": "^16.8.0" window系统, 谷歌浏览器
系统、浏览器、React 等版本信息
重现链接
index.tsx:43 Uncaught TypeError: item.getGraphicGroup is not a function at Object.draw (index.tsx:43) at Object.draw (g6.js:1) at n._drawInner (g6.js:9) at n.draw (g6.js:9) at n.t (g6.js:9) at new n (g6.js:9) at t.n.addItem (g6.js:9) at e.n.addItem (g6.js:9) at e.n.add (g6.js:9) at Object.execute (add.ts:34)
重现步骤
使用的是你提供的一个demo <RegisterNode name="model-card" config={{ draw(item) { const group = item.getGraphicGroup(); const model = item.getModel(); const width = 184; const height = 40; const x = -width / 2; const y = -height / 2; const borderRadius = 4; const keyShape = group.addShape('rect', { attrs: { x, y, width, height, radius: borderRadius, fill: 'white', stroke: '#CED4D9', }, });
// 左侧色条
group.addShape('path', {
attrs: {
path: [
['M', x, y + borderRadius],
['L', x, y + height - borderRadius],
['A', borderRadius, borderRadius, 0, 0, 0, x + borderRadius, y + height],
['L', x + borderRadius, y],
['A', borderRadius, borderRadius, 0, 0, 0, x, y + borderRadius],
],
fill: '#F4F4F4',
},
});
// 类型 logo
group.addShape('image', {
attrs: {
// img: this.type_icon_url,
x: x + 16,
y: y + 12,
width: 20,
height: 16,
},
});
// 名称文本
const label = model.label ? model.label : '8888';
group.addShape('text', {
attrs: {
text: label,
x: x + 52,
y: y + 13,
textAlign: 'start',
textBaseline: 'top',
fill: 'rgba(0,0,0,0.65)',
},
});
// 状态 logo
group.addShape('image', {
attrs: {
// img: this.state_icon_url,
x: x + 158,
y: y + 12,
width: 16,
height: 16,
},
});
return keyShape;
},
// 设置锚点
anchor: [
[0.5, 0], // 上面边的中点
[0.5, 1], // 下边边的中点
],
}}
/>
清晰的重现步骤以便迅速定位问题 draw函数的item里面并没有demo的方法,网上也找了好多例子 也都是不行 是版本问题嘛
期望的结果是什么
希望能解决下
实际的结果是什么
@licaitong 请使用最新的 3.1.0 版本,之前 2.x 版本依赖的 antv/g6 已经不再维护了 :)
{ "name": "gg-editor", "version": "3.0.6", "description": "A visual graph editor based on G6 and React", "keywords": [ "react", "graph", "editor", "flow", "mind" ], "main": "lib/index.js", "unpkg": "dist/index.js", "module": "es/index.js", "types": "lib/index.d.ts", "files": [ "dist", "lib", "es", "src" ], "scripts": { "start": "node ./scripts/start.js", "build": "node ./scripts/build.js", "lint": "eslint --cache --ext .ts,.tsx ./src", "lint:fix": "npm run lint -- --fix", "pretty-quick": "pretty-quick", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0" }, "husky": { "hooks": { "pre-commit": "pretty-quick --staged" } }, "repository": { "type": "git", "url": "git+https://github.com/alibaba/GGEditor.git" }, "author": { "name": "高力", "email": "[email protected]" }, "license": "MIT", "bugs": { "url": "https://github.com/alibaba/GGEditor/issues" }, "homepage": "https://github.com/alibaba/GGEditor#readme", "peerDependencies": { "react": "^16.8.0", "react-dom": "^16.8.0" }, "dependencies": { "@antv/g6": "~3.2.10", "@babel/runtime": "^7.7.6", "dva": "^2.4.1", "gg-editor": "^2.0.1", "lodash": "^4.17.15" }, "devDependencies": { "@babel/cli": "^7.7.5", "@babel/core": "^7.7.5", "@babel/plugin-transform-runtime": "^7.7.6", "@babel/preset-env": "^7.7.6", "@babel/preset-react": "^7.7.4", "@types/lodash": "^4.14.144", "@types/react": "^16.9.9", "@types/react-dom": "^16.9.2", "@typescript-eslint/eslint-plugin": "^2.4.0", "@typescript-eslint/parser": "^2.4.0", "antd": "^3.24.2", "conventional-changelog-cli": "^2.0.31", "cz-conventional-changelog": "^3.0.2", "eslint": "^6.5.1", "eslint-config-prettier": "^6.4.0", "eslint-plugin-prettier": "^3.1.1", "eslint-plugin-react": "^7.16.0", "husky": "^3.0.9", "inquirer": "^7.0.0", "less": "^3.10.3", "lodash": "^4.17.15", "prettier": "^1.18.2", "pretty-quick": "^2.0.0", "react": "^16.11.0", "react-dom": "^16.11.0", "rimraf": "^3.0.0", "rollup": "^1.24.0", "rollup-plugin-babel": "^4.3.3", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-json": "^4.0.0", "rollup-plugin-livereload": "^1.0.4", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-postcss": "^2.0.3", "rollup-plugin-replace": "^2.2.0", "rollup-plugin-serve": "^1.0.1", "rollup-plugin-terser": "^5.1.2", "rollup-plugin-typescript2": "^0.24.3", "signale": "^1.4.0", "tscpaths": "^0.0.9", "typescript": "^3.7.2" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } } }
这个是算3.0.6版本吧? 还是算2.0.1版本
@licaitong 改成这样,不然会是 2.x 版本
"gg-editor": "^3.1.0"
@licaitong 改成这样,不然会是 2.x 版本
"gg-editor": "^3.1.0"
TypeError: item.getGraphicGroup is not a function 改了版本并且重装了依赖draw方法里面第一个参数依然没有getGraphicGroup等方法
@licaitong 把 "@antv/g6": "~3.2.10" 这行去掉,我们已经支持 g6 ts 版本 :)
Error: EPERM: operation not permitted, rename 'D:\GGEditor2\node_modules.cache\rollup-plugin-typescript2/rpt2_ca88eb5aa172e28f3f3f2e3b97b279e0448e3880/semanticDiagnostics/cache_' -> 'D:\GGEditor2\node_modules.cache\rollup-plugin-typescript2/rpt2_ca88eb 5aa172e28f3f3f2e3b97b279e0448e3880/semanticDiagnostics/cache'
还有改了些东西重启的时候会报这个,重装依赖就又行了 这算是BUG嘛
同问