Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
a6ec53ce
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看板
未验证
提交
a6ec53ce
编写于
3月 23, 2018
作者:
D
daminglu
提交者:
GitHub
3月 23, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1st PR on Interactive Graph 0.0.3 (#338)
上级
3afc5b2d
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
930 addition
and
128 deletion
+930
-128
frontend/mock/data/plugin/graphs/graph.js
frontend/mock/data/plugin/graphs/graph.js
+681
-1
frontend/package.json
frontend/package.json
+3
-0
frontend/src/graph/ui/Chart.vue
frontend/src/graph/ui/Chart.vue
+246
-127
未找到文件。
frontend/mock/data/plugin/graphs/graph.js
浏览文件 @
a6ec53ce
此差异已折叠。
点击以展开。
frontend/package.json
浏览文件 @
a6ec53ce
...
...
@@ -14,7 +14,10 @@
"dependencies"
:
{
"axios"
:
"^0.16.1"
,
"csshint"
:
"^0.3.3"
,
"cytoscape"
:
"^3.2.11"
,
"cytoscape-dagre"
:
"^2.2.0"
,
"d3-format"
:
"^1.2.1"
,
"dagre"
:
"^0.8.2"
,
"echarts"
:
"^3.8.5"
,
"file-saver"
:
"^1.3.3"
,
"htmlcs"
:
"^0.4.1"
,
...
...
frontend/src/graph/ui/Chart.vue
浏览文件 @
a6ec53ce
<
template
>
<div
class=
"visual-dl-graph-charts"
>
<div
v-if=
"graphUrl"
class=
"visual-dl-img-box"
>
<div
class=
"small-img-box"
>
<img
class=
"small-img"
ref=
"small_img"
width=
"30"
:src=
"graphUrl"
/>
<div
class=
"screen-handler"
ref=
"screen_handler"
></div>
</div>
<img
class=
"draggable"
ref=
"draggable"
:width=
"computedWidth"
:src=
"graphUrl"
/>
</div>
<div
id=
"container"
class=
"cy draggable"
ref=
"draggable"
></div>
</div>
</
template
>
<
script
>
// libs
import
echarts
from
'
echarts
'
;
import
{
dragMovelHandler
,
tansformElement
,
relativeMove
}
from
'
./dragHelper
'
;
// service
import
{
getPluginGraphsGraph
}
from
'
../../service
'
;
// https://github.com/taye/interact.js
import
interact
from
'
interactjs
'
;
export
default
{
props
:
[
'
fitScreen
'
,
'
download
'
,
'
scale
'
],
computed
:
{
computedWidth
()
{
let
scale
=
this
.
scale
;
return
Math
.
floor
(
scale
*
2
*
700
);
}
},
data
()
{
return
{
width
:
800
,
height
:
600
,
graphUrl
:
''
,
};
},
watch
:
{
fitScreen
:
function
(
val
)
{
this
.
clearDragedTransform
(
this
.
getBigImgEl
());
this
.
clearDragedTransform
(
this
.
getSmallImgDragHandler
());
},
download
:
function
(
val
)
{
let
aEl
=
document
.
createElement
(
'
a
'
);
aEl
.
href
=
this
.
graphUrl
;
aEl
.
download
=
'
graph.png
'
;
aEl
.
click
();
}
},
mounted
()
{
this
.
getOriginChartsData
();
},
methods
:
{
createChart
()
{
let
el
=
this
.
el
.
getElementsByClassName
(
'
visual-dl-chart-box
'
)[
0
];
this
.
myChart
=
echarts
.
init
(
el
);
},
// libs
import
echarts
from
'
echarts
'
;
import
{
dragMovelHandler
,
tansformElement
,
relativeMove
}
from
'
./dragHelper
'
;
// service
import
{
getPluginGraphsGraph
}
from
'
../../service
'
;
// https://github.com/taye/interact.js
import
interact
from
'
interactjs
'
;
import
cytoscape
from
'
cytoscape
'
;
import
dagre
from
'
cytoscape-dagre
'
;
initChartOption
(
data
)
{
this
.
setChartOptions
(
data
);
export
default
{
props
:
[
'
fitScreen
'
,
'
download
'
,
'
scale
'
],
computed
:
{
computedWidth
()
{
let
scale
=
this
.
scale
;
return
Math
.
floor
(
scale
*
2
*
700
);
}
},
setChartOptions
(
data
)
{
this
.
myChart
.
setOption
(
data
);
data
()
{
return
{
myCY
:
null
,
width
:
800
,
height
:
600
,
graphUrl
:
''
,
};
},
getOriginChartsData
()
{
getPluginGraphsGraph
().
then
(({
status
,
data
})
=>
{
if
(
status
===
0
&&
data
.
url
)
{
this
.
graphUrl
=
data
.
url
this
.
addDragEventForImg
();
watch
:
{
fitScreen
:
function
(
val
)
{
this
.
clearDragedTransform
(
this
.
getBigImgEl
());
this
.
clearDragedTransform
(
this
.
getSmallImgDragHandler
());
},
download
:
function
(
val
)
{
if
(
this
.
myCY
)
{
let
aEl
=
document
.
createElement
(
'
a
'
);
aEl
.
href
=
this
.
myCY
.
png
();
aEl
.
download
=
'
graph.png
'
;
aEl
.
click
();
}
}
);
}
},
mounted
()
{
var
that
=
this
;
this
.
getOriginChartsData
();
cytoscape
.
use
(
dagre
);
getPluginGraphsGraph
().
then
(({
errno
,
data
})
=>
{
clearDragedTransform
(
dragImgEl
)
{
dragImgEl
.
style
.
transform
=
'
none
'
;
dragImgEl
.
setAttribute
(
'
data-x
'
,
0
);
dragImgEl
.
setAttribute
(
'
data-y
'
,
0
);
},
var
raw_data
=
data
.
data
;
var
data
=
raw_data
;
getBigImgEl
()
{
return
this
.
$refs
.
draggable
},
var
graph_data
=
{
nodes
:
[],
edges
:
[]
};
getSmallImgEl
()
{
return
this
.
$refs
.
small_img
},
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
);
}
getSmallImgDragHandler
()
{
return
this
.
$refs
.
screen_handler
},
for
(
var
i
=
0
;
i
<
data
.
edges
.
length
;
++
i
)
{
var
source
=
data
.
edges
[
i
].
source
;
var
target
=
data
.
edges
[
i
].
target
;
if
(
node_names
.
includes
(
source
)
===
false
)
{
graph_data
.
nodes
.
push
({
data
:
{
id
:
source
,
node_data
:
source
}
});
node_names
.
push
(
source
);
}
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
;
}
graph_data
.
nodes
.
push
({
data
:
{
id
:
target
,
node_data
:
node_data
}
});
node_names
.
push
(
target
);
}
addDragEventForImg
()
{
let
that
=
this
;
// target elements with the "draggable" class
interact
(
'
.draggable
'
).
draggable
({
// enable inertial throwing
inertia
:
true
,
autoScroll
:
true
,
// call this function on every dragmove event
onmove
(
event
)
{
dragMovelHandler
(
event
,
(
target
,
x
,
y
)
=>
{
tansformElement
(
target
,
x
,
y
);
// compute the proportional value
let
triggerEl
=
that
.
getBigImgEl
();
let
relativeEl
=
that
.
getSmallImgDragHandler
();
relativeMove
({
triggerEl
,
x
,
y
},
relativeEl
);
graph_data
.
edges
.
push
({
data
:
{
source
:
source
,
target
:
target
}
});
}
});
interact
(
'
.screen-handler
'
).
draggable
({
// enable inertial throwing
inertia
:
true
,
autoScroll
:
true
,
restrict
:
{
restriction
:
'
parent
'
,
endOnly
:
false
,
elementRect
:
{
top
:
0
,
left
:
0
,
bottom
:
1
,
right
:
1
// >> cy
var
cy
=
cytoscape
({
container
:
document
.
getElementById
(
'
container
'
),
boxSelectionEnabled
:
false
,
autounselectify
:
true
,
layout
:
{
name
:
'
dagre
'
},
style
:
[
{
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
'
}
}
],
elements
:
graph_data
,
});
this
.
myCY
=
cy
;
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
'
);
}
},
// call this function on every dragmove event
onmove
(
event
)
{
dragMovelHandler
(
event
,
(
target
,
x
,
y
)
=>
{
tansformElement
(
target
,
x
,
y
);
// compute the proportional value
let
triggerEl
=
that
.
getSmallImgEl
();
let
relativeEl
=
that
.
getBigImgEl
();
relativeMove
({
triggerEl
,
x
,
y
},
relativeEl
);
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
'
);
}
}
});
}
}
);
});
},
methods
:
{
createChart
()
{
let
el
=
this
.
el
.
getElementsByClassName
(
'
visual-dl-chart-box
'
)[
0
];
this
.
myChart
=
echarts
.
init
(
el
);
},
initChartOption
(
data
)
{
this
.
setChartOptions
(
data
);
},
setChartOptions
(
data
)
{
this
.
myChart
.
setOption
(
data
);
},
getOriginChartsData
()
{
getPluginGraphsGraph
().
then
(({
status
,
data
})
=>
{
if
(
status
===
0
&&
data
.
url
)
{
this
.
graphUrl
=
data
.
url
;
this
.
addDragEventForImg
();
}
});
},
clearDragedTransform
(
dragImgEl
)
{
dragImgEl
.
style
.
transform
=
'
none
'
;
dragImgEl
.
setAttribute
(
'
data-x
'
,
0
);
dragImgEl
.
setAttribute
(
'
data-y
'
,
0
);
},
getBigImgEl
()
{
return
this
.
$refs
.
draggable
},
getSmallImgEl
()
{
return
this
.
$refs
.
small_img
},
getSmallImgDragHandler
()
{
return
this
.
$refs
.
screen_handler
},
addDragEventForImg
()
{
let
that
=
this
;
// target elements with the "draggable" class
interact
(
'
.draggable
'
).
draggable
({
// enable inertial throwing
inertia
:
true
,
autoScroll
:
true
,
// call this function on every dragmove event
onmove
(
event
)
{
dragMovelHandler
(
event
,
(
target
,
x
,
y
)
=>
{
tansformElement
(
target
,
x
,
y
);
// compute the proportional value
let
triggerEl
=
that
.
getBigImgEl
();
let
relativeEl
=
that
.
getSmallImgDragHandler
();
relativeMove
({
triggerEl
,
x
,
y
},
relativeEl
);
});
}
});
interact
(
'
.screen-handler
'
).
draggable
({
// enable inertial throwing
inertia
:
true
,
autoScroll
:
true
,
restrict
:
{
restriction
:
'
parent
'
,
endOnly
:
false
,
elementRect
:
{
top
:
0
,
left
:
0
,
bottom
:
1
,
right
:
1
}
},
// call this function on every dragmove event
onmove
(
event
)
{
dragMovelHandler
(
event
,
(
target
,
x
,
y
)
=>
{
tansformElement
(
target
,
x
,
y
);
// compute the proportional value
let
triggerEl
=
that
.
getSmallImgEl
();
let
relativeEl
=
that
.
getBigImgEl
();
relativeMove
({
triggerEl
,
x
,
y
},
relativeEl
);
});
}
});
}
}
}
};
};
</
script
>
<
style
lang=
"stylus"
>
.cy
height: 100%
width: 70%
position: absolute
top: 0px
left: 0px
.visual-dl-graph-charts
width
90%
width
inherit
margin 0 auto
margin-bottom 20px
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录