Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
39a95f5c
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
1 年多 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
39a95f5c
编写于
3月 29, 2018
作者:
D
daminglu
提交者:
GitHub
3月 29, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2nd PR on Interactive Graph 0.0.3 (#348)
上级
37a3559a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
119 deletion
+92
-119
frontend/package.json
frontend/package.json
+9
-6
frontend/src/graph/Graph.vue
frontend/src/graph/Graph.vue
+4
-3
frontend/src/graph/ui/Chart.vue
frontend/src/graph/ui/Chart.vue
+79
-110
未找到文件。
frontend/package.json
浏览文件 @
39a95f5c
...
...
@@ -16,10 +16,13 @@
"csshint"
:
"^0.3.3"
,
"cytoscape"
:
"^3.2.11"
,
"cytoscape-dagre"
:
"^2.2.0"
,
"d3"
:
"^4.7.4"
,
"d3-format"
:
"^1.2.1"
,
"dagre"
:
"^0.8.2"
,
"dagre-d3"
:
"^0.6.1"
,
"echarts"
:
"^3.8.5"
,
"file-saver"
:
"^1.3.3"
,
"graphlib"
:
"^1.0.5"
,
"htmlcs"
:
"^0.4.1"
,
"lesslint"
:
"^1.0.2"
,
"lodash"
:
"^4.17.4"
,
...
...
@@ -67,15 +70,15 @@
"stylus"
:
"^0.54.5"
,
"stylus-loader"
:
"^3.0.1"
,
"url-loader"
:
"^0.5.8"
,
"webpack"
:
"^2.4.1"
,
"vue-jest"
:
"^1.0.2"
,
"vue-loader"
:
"^13.3.0"
,
"vue-style-loader"
:
"^3.0.1"
,
"vue-template-compiler"
:
"^2.5.2"
,
"webpack"
:
"^2.7.0"
,
"webpack-dev-middleware"
:
"^1.12.1"
,
"webpack-dev-server"
:
"^2.4.2"
,
"webpack-hot-middleware"
:
"^2.19.1"
,
"webpack-merge"
:
"^4.1.0"
,
"yargs"
:
"^8.0.2"
,
"vue-jest"
:
"^1.0.2"
,
"vue-loader"
:
"^13.3.0"
,
"vue-style-loader"
:
"^3.0.1"
,
"vue-template-compiler"
:
"^2.5.2"
"yargs"
:
"^8.0.2"
}
}
frontend/src/graph/Graph.vue
浏览文件 @
39a95f5c
...
...
@@ -2,9 +2,9 @@
<div
class=
"visual-dl-page-container"
>
<div
class=
"visual-dl-page-left"
>
<ui-chart
:fitScreen=
"fitScreen"
:download=
"download"
:scale=
"config.scale"
:fitScreen=
"fitScreen"
:download=
"download"
:scale=
"config.scale"
></ui-chart>
</div>
<div
class=
"visual-dl-page-right"
>
...
...
@@ -24,6 +24,7 @@ import autoAdjustHeight from '../common/util/autoAdjustHeight';
import
Config
from
'
./ui/Config
'
import
Chart
from
'
./ui/Chart
'
;
export
default
{
components
:
{
'
ui-config
'
:
Config
,
...
...
frontend/src/graph/ui/Chart.vue
浏览文件 @
39a95f5c
<
template
>
<div
class=
"visual-dl-graph-charts"
>
<div
id=
"container"
class=
"cy draggable"
ref=
"draggable"
></div>
<svg
class=
"visual-dl-page-left"
>
<g/>
</svg>
</div>
</
template
>
<
script
>
...
...
@@ -16,8 +18,11 @@
// https://github.com/taye/interact.js
import
interact
from
'
interactjs
'
;
import
cytoscape
from
'
cytoscape
'
;
import
dagre
from
'
cytoscape-dagre
'
;
// for d3 drawing
import
*
as
d3
from
"
d3
"
;
import
*
as
dagre
from
"
dagre
"
;
import
*
as
dagreD3
from
'
dagre-d3
'
;
export
default
{
props
:
[
'
fitScreen
'
,
'
download
'
,
'
scale
'
],
...
...
@@ -30,8 +35,6 @@
data
()
{
return
{
myCY
:
null
,
width
:
800
,
height
:
600
,
graphUrl
:
''
,
};
},
...
...
@@ -50,121 +53,73 @@
}
},
mounted
()
{
var
that
=
this
;
this
.
getOriginChartsData
();
cytoscape
.
use
(
dagre
);
getPluginGraphsGraph
().
then
(({
errno
,
data
})
=>
{
getPluginGraphsGraph
().
then
(({
errno
,
data
})
=>
{
var
raw_data
=
data
.
data
;
var
data
=
raw_data
;
var
graph_data
=
{
nodes
:
[],
edges
:
[]
};
var
node_names
=
[];
for
(
var
i
=
0
;
i
<
data
.
input
.
length
;
++
i
)
{
graph_data
.
nodes
.
push
({
data
:
{
id
:
data
.
input
[
i
].
name
,
node_data
:
data
.
input
[
i
].
name
}
});
node_names
.
push
(
data
.
input
[
i
].
name
);
}
for
(
var
i
=
0
;
i
<
data
.
edges
.
length
;
++
i
)
{
var
source
=
data
.
edges
[
i
].
source
;
var
target
=
data
.
edges
[
i
].
target
;
// d3 svg drawing
var
g
=
new
dagreD3
.
graphlib
.
Graph
()
.
setGraph
({})
.
setDefaultEdgeLabel
(
function
()
{
return
{};
});
var
render
=
new
dagreD3
.
render
();
var
nodeKeys
=
[];
if
(
node_names
.
includes
(
source
)
===
false
)
{
graph_data
.
nodes
.
push
({
data
:
{
id
:
source
,
node_data
:
source
}
});
node_names
.
push
(
source
);
}
var
buildInputNodeLabel
=
function
(
inputNode
)
{
var
nodeLabel
=
inputNode
[
'
data_type
'
]
+
'
:
'
+
inputNode
[
'
shape
'
].
join
(
'
x
'
);
return
nodeLabel
+
'
'
.
repeat
(
Math
.
floor
(
nodeLabel
.
length
/
5
));
};
if
(
node_names
.
includes
(
target
)
===
false
)
{
var
node_data
=
target
;
if
(
target
.
includes
(
'
node_
'
))
{
// it is an operator node
var
node_id
=
target
.
substring
(
5
);
node_data
=
data
.
node
[
node_id
].
opType
;
// add input nodes
for
(
var
i
=
0
;
i
<
data
[
'
input
'
].
length
;
++
i
)
{
var
curInputNode
=
data
[
'
input
'
][
i
];
var
nodeKey
=
curInputNode
[
'
name
'
];
g
.
setNode
(
nodeKey
,
{
label
:
buildInputNodeLabel
(
curInputNode
),
class
:
"
input
"
}
graph_data
.
nodes
.
push
({
data
:
{
id
:
target
,
node_data
:
node_data
}
});
node_names
.
push
(
target
);
}
graph_data
.
edges
.
push
({
data
:
{
source
:
source
,
target
:
target
}
});
);
nodeKeys
.
push
(
nodeKey
);
}
// >> cy
var
cy
=
cytoscape
({
container
:
document
.
getElementById
(
'
container
'
),
boxSelectionEnabled
:
false
,
autounselectify
:
true
,
layout
:
{
name
:
'
dagre
'
},
// add operator nodes then add edges from inputs to operator and from operator to output
for
(
var
i
=
0
;
i
<
data
[
'
node
'
].
length
;
++
i
)
{
var
curOperatorNode
=
data
[
'
node
'
][
i
];
var
nodeKey
=
'
opNode_
'
+
i
;
style
:
[
// add operator node
var
curOpLabel
=
curOperatorNode
[
'
opType
'
];
g
.
setNode
(
nodeKey
,
{
selector
:
'
node
'
,
style
:
{
'
width
'
:
40
,
'
height
'
:
40
,
'
content
'
:
'
data(node_data)
'
,
'
text-opacity
'
:
0.5
,
'
text-valign
'
:
'
center
'
,
'
text-halign
'
:
'
right
'
,
'
background-color
'
:
'
#11479e
'
}
},
{
selector
:
'
edge
'
,
style
:
{
'
curve-style
'
:
'
bezier
'
,
'
width
'
:
6
,
'
target-arrow-shape
'
:
'
triangle
'
,
'
line-color
'
:
'
#9dbaea
'
,
'
target-arrow-color
'
:
'
#9dbaea
'
}
label
:
curOpLabel
+
'
'
.
repeat
(
Math
.
floor
(
curOpLabel
.
length
/
5
)),
class
:
"
operator
"
}
],
elements
:
graph_data
,
});
this
.
myCY
=
cy
;
);
nodeKeys
.
push
(
nodeKey
);
cy
.
nodes
().
forEach
(
function
(
node
){
if
(
node
.
id
().
includes
(
'
node_
'
))
{
node
.
style
(
'
width
'
,
'
80px
'
);
node
.
style
(
'
height
'
,
'
36px
'
);
node
.
style
(
'
shape
'
,
'
roundrectangle
'
);
node
.
style
(
'
background-color
'
,
'
#158c96
'
);
node
.
style
(
'
text-valign
'
,
'
center
'
);
node
.
style
(
'
text-halign
'
,
'
center
'
);
// add output node
var
outputNodeKey
=
curOperatorNode
[
'
output
'
][
0
];
g
.
setNode
(
outputNodeKey
,
{
label
:
outputNodeKey
+
'
'
.
repeat
(
Math
.
floor
(
outputNodeKey
.
length
/
5
)),
class
:
"
output
"
}
);
nodeKeys
.
push
(
outputNodeKey
);
// add edges from inputs to node and from node to output
for
(
var
e
=
0
;
e
<
curOperatorNode
[
'
input
'
].
length
;
++
e
)
{
g
.
setEdge
(
curOperatorNode
[
'
input
'
][
e
],
nodeKey
);
}
g
.
setEdge
(
nodeKey
,
curOperatorNode
[
'
output
'
][
0
]);
}
let
collapsed
=
true
;
node
.
on
(
'
tap
'
,
function
(
evt
){
if
(
node
.
id
().
includes
(
'
node_
'
))
{
collapsed
=
!
collapsed
;
if
(
!
collapsed
)
{
node
.
style
(
'
width
'
,
'
120px
'
);
node
.
style
(
'
height
'
,
'
54px
'
);
}
else
{
node
.
style
(
'
width
'
,
'
80px
'
);
node
.
style
(
'
height
'
,
'
36px
'
);
}
}
});
});
render
(
d3
.
select
(
"
svg g
"
),
g
);
});
},
...
...
@@ -259,13 +214,27 @@
};
</
script
>
<
style
lang=
"stylus"
>
.cy
height: 100%
width: 70%
position: absolute
top: 0px
left: 0px
.node rect
.node circle
.node ellipse
.node polygon
stroke: #333
fill: #fff
stroke-width: 1.5px
.edgePath path.path
stroke: #333
fill: none
stroke-width: 1.5px
.operator
fill: red
.output
fill: green
.input
fill: purple
.visual-dl-graph-charts
width inherit
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录