Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
042f5fbd
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
8
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
042f5fbd
编写于
6月 30, 2020
作者:
W
WeiFeng-mindinsight
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Override zooming function of data map graph, add zooming limit for svg
上级
f803a1bd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
28 deletion
+81
-28
mindinsight/ui/src/views/train-manage/data-map.vue
mindinsight/ui/src/views/train-manage/data-map.vue
+81
-28
未找到文件。
mindinsight/ui/src/views/train-manage/data-map.vue
浏览文件 @
042f5fbd
...
...
@@ -363,41 +363,81 @@ export default {
* Initializing the Zoom Function of a Graph
*/
initZooming
()
{
const
graphDom
=
document
.
querySelector
(
'
#graph0
'
);
const
svgDom
=
document
.
querySelector
(
'
#graph svg
'
);
const
svgRect
=
svgDom
.
getBoundingClientRect
();
const
graphDom
=
document
.
querySelector
(
'
#graph #graph0
'
);
const
graphBox
=
graphDom
.
getBBox
();
const
graphRect
=
graphDom
.
getBoundingClientRect
();
let
graphTransform
=
{};
const
minScale
=
Math
.
min
(
svgRect
.
width
/
2
/
graphRect
.
width
,
svgRect
.
height
/
2
/
graphRect
.
height
,
);
const
padding
=
4
;
const
pointer
=
{
start
:
{
x
:
0
,
y
:
0
,
},
end
:
{
x
:
0
,
y
:
0
,
},
};
const
minDistance
=
50
;
const
pointer
=
{
start
:
{
x
:
0
,
y
:
0
},
end
:
{
x
:
0
,
y
:
0
}};
const
zoom
=
d3
.
zoom
()
.
on
(
'
start
'
,
(
target
)
=>
{
.
on
(
'
start
'
,
()
=>
{
pointer
.
start
.
x
=
event
.
x
;
pointer
.
start
.
y
=
event
.
y
;
})
.
on
(
'
zoom
'
,
(
target
)
=>
{
.
on
(
'
zoom
'
,
()
=>
{
const
transformData
=
this
.
getTransformData
(
graphDom
);
if
(
!
Object
.
keys
(
graphTransform
).
length
)
{
graphTransform
=
{
x
:
transformData
.
translate
[
0
],
y
:
transformData
.
translate
[
1
],
k
:
transformData
.
scale
[
0
],
};
}
let
tempStr
=
''
;
let
change
=
{};
let
scale
=
transformData
.
scale
[
0
];
const
graphRect
=
graphDom
.
getBoundingClientRect
();
const
mapping
=
{
width
:
graphBox
.
width
/
graphRect
.
width
,
height
:
graphBox
.
height
/
graphRect
.
height
,
};
const
transRate
=
graphBox
.
width
/
graphRect
.
width
;
if
(
event
.
type
===
'
mousemove
'
)
{
pointer
.
end
.
x
=
event
.
x
;
pointer
.
end
.
y
=
event
.
y
;
let
tempX
=
pointer
.
end
.
x
-
pointer
.
start
.
x
;
let
tempY
=
pointer
.
end
.
y
-
pointer
.
start
.
y
;
const
paddingTrans
=
Math
.
max
(
(
padding
/
transRate
)
*
scale
,
minDistance
,
);
if
(
graphRect
.
left
+
paddingTrans
+
tempX
>=
svgRect
.
left
+
svgRect
.
width
)
{
tempX
=
Math
.
min
(
tempX
,
0
);
}
if
(
graphRect
.
left
+
graphRect
.
width
-
paddingTrans
+
tempX
<=
svgRect
.
left
)
{
tempX
=
Math
.
max
(
tempX
,
0
);
}
if
(
graphRect
.
top
+
paddingTrans
+
tempY
>=
svgRect
.
top
+
svgRect
.
height
)
{
tempY
=
Math
.
min
(
tempY
,
0
);
}
if
(
graphRect
.
top
+
graphRect
.
height
-
paddingTrans
+
tempY
<=
svgRect
.
top
)
{
tempY
=
Math
.
max
(
tempY
,
0
);
}
change
=
{
x
:
(
pointer
.
end
.
x
-
pointer
.
start
.
x
)
*
mapping
.
width
*
scale
,
y
:
(
pointer
.
end
.
y
-
pointer
.
start
.
y
)
*
mapping
.
height
*
scale
,
x
:
tempX
*
transRate
*
scale
,
y
:
tempY
*
transRate
*
scale
,
};
pointer
.
start
.
x
=
pointer
.
end
.
x
;
pointer
.
start
.
y
=
pointer
.
end
.
y
;
...
...
@@ -408,29 +448,42 @@ export default {
wheelDelta
>
0
?
transformData
.
scale
[
0
]
*
rate
:
transformData
.
scale
[
0
]
/
rate
;
scale
=
Math
.
max
(
this
.
scaleRange
[
0
],
scale
);
scale
=
Math
.
max
(
this
.
scaleRange
[
0
],
scale
,
minScale
);
scale
=
Math
.
min
(
this
.
scaleRange
[
1
],
scale
);
change
=
{
x
:
(
graphRect
.
x
+
padding
/
mapping
.
width
-
event
.
x
)
*
mapping
.
width
*
(
graphRect
.
x
+
padding
/
transRate
-
event
.
x
)
*
transRate
*
(
scale
-
transformData
.
scale
[
0
]),
y
:
(
graphRect
.
bottom
-
padding
/
mapping
.
height
-
event
.
y
)
*
mapping
.
height
*
(
graphRect
.
bottom
-
padding
/
transRate
-
event
.
y
)
*
transRate
*
(
scale
-
transformData
.
scale
[
0
]),
};
}
tempStr
=
`translate(
${
transformData
.
translate
[
0
]
+
change
.
x
}
,
${
transformData
.
translate
[
1
]
+
change
.
y
}
) scale(
${
scale
}
)`
;
graphTransform
=
{
x
:
transformData
.
translate
[
0
]
+
change
.
x
,
y
:
transformData
.
translate
[
1
]
+
change
.
y
,
k
:
scale
,
};
tempStr
=
`translate(
${
graphTransform
.
x
}
,
${
graphTransform
.
y
}
) scale(
${
graphTransform
.
k
}
)`
;
graphDom
.
setAttribute
(
'
transform
'
,
tempStr
);
event
.
stopPropagation
();
event
.
preventDefault
();
});
const
svg
=
d3
.
select
(
'
svg
'
);
const
svg
=
d3
.
select
(
'
#graph
svg
'
);
svg
.
on
(
'
.zoom
'
,
null
);
svg
.
call
(
zoom
);
svg
.
on
(
'
dblclick.zoom
'
,
null
);
svg
.
on
(
'
wheel.zoom
'
,
null
);
const
graph0
=
d3
.
select
(
'
#graph #graph0
'
);
graph0
.
on
(
'
.zoom
'
,
null
);
graph0
.
call
(
zoom
);
},
/**
* Obtains the transform data of a node.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录