Commit 97113153 authored by 郭铭瑶's avatar 郭铭瑶 🤘

更新依赖

parent 7efb3722
...@@ -4,9 +4,8 @@ module.exports = { ...@@ -4,9 +4,8 @@ module.exports = {
es2021: true, es2021: true,
}, },
extends: ['plugin:vue/vue3-recommended', 'plugin:prettier/recommended'], extends: ['plugin:vue/vue3-recommended', 'plugin:prettier/recommended'],
parserOptions: { parser: 'vue-eslint-parser',
parser: 'babel-eslint', plugins: ['vue'],
},
rules: { rules: {
'vue/no-multiple-template-root': 'off', 'vue/no-multiple-template-root': 'off',
'vue/max-attributes-per-line': 'off', 'vue/max-attributes-per-line': 'off',
......
...@@ -3,4 +3,4 @@ module.exports = { ...@@ -3,4 +3,4 @@ module.exports = {
useTabs: false, useTabs: false,
singleQuote: true, singleQuote: true,
semi: false, semi: false,
} };
\ No newline at end of file
## relation-graph ## relation-graph
关系图工具 with D3.js 关系图 with D3.js
---
- 安装依赖
```bash
npm install
```
- 启动
```bash
npm run dev
# or
npm start
```
- 打包
```bash
npm run build
```
This diff is collapsed.
{ {
"name": "relation-graph", "name": "relation-graph",
"version": "0.0.0", "version": "0.0.1",
"description": "关系图",
"author": "Mr.Guo",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"start": "node node_modules/esbuild/install.js && npm run dev", "start": "npm run dev",
"build": "vite build" "build": "vite build"
}, },
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"d3": "^7.0.0", "d3": "^7.0.0",
"qs": "^6.10.1", "qs": "^6.10.1",
"vue": "^3.0.5" "vue": "^3.1.5"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^1.1.5", "@vitejs/plugin-vue": "^1.3.0",
"@vue/compiler-sfc": "^3.0.5", "@vue/compiler-sfc": "^3.1.5",
"babel-eslint": "^10.1.0", "eslint": "^7.30.0",
"eslint": "^7.17.0", "eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^7.1.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-prettier": "^3.3.1", "eslint-plugin-vue": "^7.14.0",
"eslint-plugin-vue": "^7.4.1",
"naive-ui": "^2.16.5", "naive-ui": "^2.16.5",
"prettier": "^2.2.1", "prettier": "^2.3.2",
"stylus": "^0.54.8", "stylus": "^0.54.8",
"vite": "^2.1.0" "vite": "^2.4.4",
}, "vue-eslint-parser": "^7.10.0"
"description": "关系图工具", }
"author": "Guo"
} }
...@@ -11,7 +11,7 @@ export default { ...@@ -11,7 +11,7 @@ export default {
PUT_SUBJECT: '/subject/{id}', PUT_SUBJECT: '/subject/{id}',
GET_RELATIONS: '/relations', GET_RELATIONS: '/relations',
POST_SUBJECT: '/subject', POST_SUBJECT: '/subject',
POST_NODE: '/node/relation', POST_NODE: '/node/relation/v2',
DELETE_RELATION: '/node/relation/{id}', DELETE_RELATION: '/node/relation/{id}',
GET_NODES: '/node/relations', GET_NODES: '/node/relations',
DELETE_NODE: '/node/{id}', DELETE_NODE: '/node/{id}',
......
<template> <template>
<div class="main"> <div class="main">
<Nav style="grid-area: nav" />
<D3 <D3
ref="d3Ref" ref="d3Ref"
style="grid-area: content" style="grid-area: content"
...@@ -13,7 +12,6 @@ ...@@ -13,7 +12,6 @@
@link="openLinkDrawer" @link="openLinkDrawer"
@del-link="deleteLink" @del-link="deleteLink"
/> />
<Side style="grid-area: side" />
<Footer <Footer
style="grid-area: footer" style="grid-area: footer"
:node="curNode" :node="curNode"
...@@ -176,8 +174,6 @@ ...@@ -176,8 +174,6 @@
<script setup> <script setup>
import D3 from './d3.vue' import D3 from './d3.vue'
import Nav from './nav.vue'
import Side from './side.vue'
import Footer from './footer.vue' import Footer from './footer.vue'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { ajax, api } from '@/ajax' import { ajax, api } from '@/ajax'
...@@ -574,9 +570,9 @@ function deleteItem(i) { ...@@ -574,9 +570,9 @@ function deleteItem(i) {
height 100vh height 100vh
display grid display grid
overflow hidden overflow hidden
grid-template-areas 'nav nav' 'side content' 'side footer' grid-template-areas 'content' 'footer'
grid-template-columns 0px 1fr grid-template-columns 1fr
grid-template-rows 0px 1fr 70px grid-template-rows 1fr 70px
padding 4px padding 4px
font-weight bold !important font-weight bold !important
......
<template>
<div class="nav">
<!-- <n-input
v-model:value="searchKey"
type="text"
placeholder="搜索Subject"
clearable
@keypressenter="search"
/> -->
</div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
name: 'Nav',
emits: ['search'],
setup(_, ctx) {
const searchKey = ref(null)
return {
searchKey,
search: () => ctx.emit('search', searchKey.value),
}
},
})
</script>
<style lang="stylus" scoped>
// .nav
// background #f9fbfd
// border-bottom 4px solid #fff
// padding 0 10px
</style>
<template>
<div></div>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Side',
setup() {},
})
</script>
<style lang="stylus" scoped></style>
...@@ -76,6 +76,23 @@ function textWrap(text, width) { ...@@ -76,6 +76,23 @@ function textWrap(text, width) {
}) })
} }
/*
*求圆内接正多边形的顶点串,形如x1,y1,x2,y2,...xn,yn
*cx,cy为圆心,r为半径,n为边数,正多边形底边与X轴平行
*/
function polygonPoints(cx, cy, r, n) {
const alpha = (2 * Math.PI) / n
let a = Math.PI / 2 + alpha / 2
let points = ''
for (let i = 0; i < n; i++) {
x = cx + r * Math.cos(a)
y = cy + r * Math.sin(a)
points += x + ',' + y + ','
a += alpha
}
return points.substring(0, points.length - 1)
}
// 默认配置 // 默认配置
const defaultConfig = { const defaultConfig = {
nodes: [], // 节点数组 nodes: [], // 节点数组
...@@ -167,7 +184,21 @@ export default class RelationGraph { ...@@ -167,7 +184,21 @@ export default class RelationGraph {
} }
}) })
}) })
return { links, nodes } const subjects = []
const objects = []
const others = []
nodes.forEach((n) => {
if (n.subjectType) {
if (n.subjectType == '1') {
subjects.push(n)
} else if (n.subjectType == '2') {
objects.push(n)
}
} else {
others.push(n)
}
})
return { links, nodes, subjects, objects, others }
} }
setKey(key) { setKey(key) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment