Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gojs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴斌
vue-gojs
Commits
98e737d6
Commit
98e737d6
authored
Oct 09, 2023
by
吴斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:分析结果显示
parent
c0665cb0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
26 deletions
+81
-26
App.vue
src/App.vue
+19
-10
analyze-data.vue
src/components/info/analyze-data.vue
+13
-13
GOJSKit.ts
src/kit/GOJSKit.ts
+49
-3
No files found.
src/App.vue
View file @
98e737d6
...
...
@@ -22,6 +22,7 @@
</div>
<div
class=
"flex"
>
<div
class=
"w-full"
></div>
<el-button
@
click=
"changeData"
>
数据变化
</el-button>
<el-button
@
click=
"importData"
>
导入
</el-button>
<el-button
type=
"primary"
@
click=
"exportData"
>
导出
</el-button>
</div>
...
...
@@ -159,7 +160,7 @@ function initDiagram() {
GO
(
go
.
TextBlock
,
{
margin
:
4
,
text
:
""
,
editable
:
true
,
alignment
:
go
.
Spot
.
Top
},
new
go
.
Binding
(
"text"
,
"press"
),
new
go
.
Binding
(
"stroke"
,
""
,
function
(
data
,
_node
)
{
return
data
.
press
>
1
0
?
"red"
:
"green"
}
function
(
data
,
_node
)
{
return
data
.
press
>
5
0
?
"red"
:
"green"
}
),
new
go
.
Binding
(
'angle'
,
"angle"
,
v
=>-
v
),
),
...
...
@@ -326,16 +327,24 @@ function analyseData(){
function
changeData
(){
let
model
=
myDiagram
.
model
setInterval
(()
=>
{
let
nodeDataArray
=
myDiagram
.
model
.
nodeDataArray
nodeDataArray
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
picture_category
===
"ammonia"
){
model
.
set
(
item
,
"press"
,
Math
.
floor
(
Math
.
random
()
*
100
))
model
.
set
(
item
,
"thick"
,
Math
.
random
().
toFixed
(
2
)),
let
nodeDataArray
=
myDiagram
.
model
.
nodeDataArray
nodeDataArray
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
picture_category
===
"ammonia"
){
model
.
set
(
item
,
"press"
,
Math
.
floor
(
Math
.
random
()
*
100
))
model
.
set
(
item
,
"thick"
,
Math
.
random
().
toFixed
(
2
)),
model
.
set
(
item
,
"temperature"
,
Math
.
floor
(
Math
.
random
()
*
10
))
}
})
},
5000
)
}
})
// setInterval(()=>{
// let nodeDataArray = myDiagram.model.nodeDataArray
// nodeDataArray.forEach((item:any)=>{
// if (item.picture_category === "ammonia"){
// model.set(item, "press", Math.floor(Math.random()*100))
// model.set(item, "thick", Math.random().toFixed(2)),
// model.set(item, "temperature", Math.floor(Math.random()*10))
// }
// })
// },5000)
}
onMounted
(()
=>
{
...
...
src/components/info/analyze-data.vue
View file @
98e737d6
<
template
>
<div>
<div
class=
"text-center"
v-show=
"paths.length === 0"
>
暂无分析数据
</div>
<div
v-show=
"paths.length > 0"
>
<div>
线路结果
</div>
<div
v-show=
"paths.length === 0"
>
暂无分析数据
</div>
<div
v-show=
"paths.length > 0"
>
<div
class=
"mb-2 mt-0 text-xl font-medium leading-tight text-primary"
>
线路结果
</div>
<el-scrollbar
max-height=
"200px"
>
<el-collapse>
<el-collapse-item
class=
"m-2"
v-for=
"(value, key) in pathNodesMap"
:title=
"'线路' + key "
>
...
...
@@ -14,14 +14,16 @@
</el-form>
<div
class=
"flex justify-center"
>
<el-checkbox
@
change=
"highlightPath(key)"
v-model=
"value.highlight"
>
高亮
</el-checkbox>
<el-button
type=
"primary"
>
确定
</el-button>
<el-button
type=
"primary"
@
click=
"computeData(pathNodesMap, analyzeResult)"
class=
"ml-4"
>
确定
</el-button>
</div>
</el-collapse-item>
</el-collapse>
</el-scrollbar>
<div>
分析结果
</div>
<div
class=
"w-full h-26 bg-red-200"
>
<div
class=
"w-full h-32 bg-red-200"
>
<div
class=
"mb-2 mt-0 text-xl font-medium leading-tight text-primary"
>
分析结果
</div>
<div
v-for=
"(value, key) in analyzeResult"
class=
"flex"
>
<div>
{{
nodeMap
[
key
].
data
.
name
}}
:
{{
value
}}
</div>
</div>
</div>
</div>
</div>
...
...
@@ -30,7 +32,7 @@
<
script
setup
lang=
"ts"
>
import
{
ref
,
watch
}
from
"vue"
;
import
{
highlightLink
,
cancelHighlightLink
}
from
"../../kit/GOJSKit"
;
import
{
highlightLink
,
cancelHighlightLink
,
computeData
}
from
"../../kit/GOJSKit"
;
const
props
=
defineProps
({
paths
:
{
...
...
@@ -47,6 +49,7 @@ const props = defineProps({
})
let
pathNodesMap
=
ref
<
Record
<
string
,
any
>>
({})
let
analyzeResult
=
ref
<
any
>
({})
watch
(()
=>
props
.
paths
,
(
newValue
)
=>
{
newValue
.
forEach
((
path
:
any
)
=>
{
...
...
@@ -57,9 +60,10 @@ watch(()=>props.paths, (newValue) => {
pathNodeName
.
push
(
props
.
nodeMap
[
node
].
data
.
name
)
})
pathNodesMap
.
value
[
newValue
.
indexOf
(
path
)
+
1
]
=
{
'nodeKeys'
:
path
,
'nodesName'
:
pathNodeName
,
"nodes"
:
pathNode
,
'highlight'
:
false
,
'weight'
:
1
'nodeKeys'
:
path
,
'nodesName'
:
pathNodeName
,
"nodes"
:
pathNode
,
'highlight'
:
false
,
'weight'
:
1
/
props
.
paths
.
length
}
})
computeData
(
pathNodesMap
.
value
,
analyzeResult
)
});
function
highlightPath
(
pathIndex
:
string
){
...
...
@@ -72,8 +76,5 @@ function highlightPath(pathIndex:string){
}
}
function
computeData
(){
}
</
script
>
\ No newline at end of file
src/kit/GOJSKit.ts
View file @
98e737d6
import
{
log
}
from
'console'
;
import
go
from
'gojs'
;
export
var
GO
=
go
.
GraphObject
.
make
;
...
...
@@ -167,4 +166,52 @@ export function cancelHighlightLink(myDiagram:any){
linkDataArray
.
forEach
((
item
:
any
)
=>
{
model
.
set
(
item
,
"color"
,
"black"
)
})
}
\ No newline at end of file
}
/**
* 这里只以计算压力数据为例。
*/
export
function
computeData
(
pathNodesMap
:
any
,
analyzeResult
:
any
){
let
nodesDataMap
:
Record
<
any
,
any
>
=
{}
let
offset
=
0.1
console
.
log
(
"compute"
,
pathNodesMap
);
for
(
let
key
in
pathNodesMap
){
let
path
=
pathNodesMap
[
key
]
console
.
log
(
path
.
nodeKeys
)
for
(
let
node
of
path
.
nodes
){
if
(
node
.
data
.
key
in
nodesDataMap
){
let
currentNodeIndex
=
path
.
nodes
.
indexOf
(
node
)
if
(
currentNodeIndex
==
0
){
continue
}
let
lastNode
=
path
.
nodes
[
currentNodeIndex
-
1
]
nodesDataMap
[
node
.
data
.
key
][
'predict'
]
+=
lastNode
.
data
.
press
*
path
.
weight
console
.
log
(
"predict"
,
nodesDataMap
[
node
.
data
.
key
][
'predict'
],
lastNode
.
data
.
press
,
path
.
weight
);
}
else
{
nodesDataMap
[
node
.
data
.
key
]
=
{
'predict'
:
0
,
'real'
:
node
.
data
.
press
}
let
currentNodeIndex
=
path
.
nodes
.
indexOf
(
node
)
if
(
currentNodeIndex
==
0
){
nodesDataMap
[
node
.
data
.
key
][
'predict'
]
=
node
.
data
.
press
continue
}
let
lastNode
=
path
.
nodes
[
currentNodeIndex
-
1
]
nodesDataMap
[
node
.
data
.
key
][
'predict'
]
+=
lastNode
.
data
.
press
*
path
.
weight
}
}
}
analyzeResult
.
value
=
{}
for
(
let
key
in
nodesDataMap
){
let
value
=
nodesDataMap
[
key
]
if
(
value
[
'predict'
]
<
value
[
'real'
]
*
(
1
-
offset
)){
analyzeResult
.
value
[
key
]
=
"压力过高"
}
else
if
(
value
[
'predict'
]
>
value
[
'real'
]
*
(
1
+
offset
)){
analyzeResult
.
value
[
key
]
=
"压力过低"
}
else
{
analyzeResult
.
value
[
key
]
=
"压力正常"
}
}
return
nodesDataMap
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment