Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f2247c65
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2247c65
编写于
3月 12, 2018
作者:
J
Jose Ivan Vargas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use graph width to determine tick number
上级
0e2a3543
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
3 addition
and
36 deletion
+3
-36
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+0
-9
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+3
-18
spec/javascripts/datetime_utility_spec.js
spec/javascripts/datetime_utility_spec.js
+0
-9
未找到文件。
app/assets/javascripts/lib/utils/datetime_utility.js
浏览文件 @
f2247c65
...
...
@@ -291,15 +291,6 @@ export const getTimeframeWindow = (length, date) => {
return
timeframe
;
};
/**
* Returns the time difference between two dates in minutes
*
* @param {Date} dateStart
* @param {Date} dateEnd
*/
export
const
timeDifferenceMinutes
=
(
dateStart
,
dateEnd
)
=>
(
dateEnd
-
dateStart
)
/
1000
/
60
;
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
utils
=
{
...(
window
.
gl
.
utils
||
{}),
...
...
app/assets/javascripts/monitoring/components/graph.vue
浏览文件 @
f2247c65
<
script
>
import
{
scaleLinear
,
scaleTime
}
from
'
d3-scale
'
;
import
{
axisLeft
,
axisBottom
}
from
'
d3-axis
'
;
import
{
max
,
extent
,
min
}
from
'
d3-array
'
;
import
{
max
,
extent
}
from
'
d3-array
'
;
import
{
select
}
from
'
d3-selection
'
;
import
{
timeMinute
}
from
'
d3-time
'
;
import
{
timeDifferenceMinutes
}
from
'
~/lib/utils/datetime_utility
'
;
import
GraphLegend
from
'
./graph/legend.vue
'
;
import
GraphFlag
from
'
./graph/flag.vue
'
;
import
GraphDeployment
from
'
./graph/deployment.vue
'
;
...
...
@@ -16,7 +14,7 @@
import
createTimeSeries
from
'
../utils/multiple_time_series
'
;
import
bp
from
'
../../breakpoints
'
;
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
min
,
extent
,
select
,
timeMinute
};
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
extent
,
select
};
export
default
{
components
:
{
...
...
@@ -208,23 +206,10 @@
const
allValues
=
this
.
timeSeries
.
reduce
((
all
,
{
values
})
=>
all
.
concat
(
values
),
[]);
axisXScale
.
domain
(
d3
.
extent
(
allValues
,
d
=>
d
.
time
));
axisYScale
.
domain
([
0
,
d3
.
max
(
allValues
.
map
(
d
=>
d
.
value
))]);
// time difference
const
dateEnd
=
d3
.
max
(
allValues
.
map
(
d
=>
d
.
time
));
const
dateStart
=
d3
.
min
(
allValues
.
map
(
d
=>
d
.
time
));
const
timeDifference
=
timeDifferenceMinutes
(
dateStart
,
dateEnd
);
let
timeTicks
;
if
(
timeDifference
>
90
)
{
timeTicks
=
60
;
}
else
if
(
timeDifference
>
45
&&
timeDifference
<=
90
)
{
timeTicks
=
30
;
}
else
if
(
timeDifference
<=
45
)
{
timeTicks
=
15
;
}
const
xAxis
=
d3
.
axisBottom
()
.
scale
(
axisXScale
)
.
ticks
(
d3
.
timeMinute
.
every
(
timeTicks
)
)
.
ticks
(
this
.
graphWidth
/
120
)
.
tickFormat
(
timeScaleFormat
);
const
yAxis
=
d3
.
axisLeft
()
...
...
spec/javascripts/datetime_utility_spec.js
浏览文件 @
f2247c65
...
...
@@ -170,12 +170,3 @@ describe('getTimeframeWindow', () => {
});
});
});
describe
(
'
timeDifferenceMinutes
'
,
()
=>
{
it
(
'
returns the time difference between two dates in minutes
'
,
()
=>
{
const
dateStart
=
new
Date
(
'
2018-03-08 12:00:00
'
);
const
dateEnd
=
new
Date
(
'
2018-03-08 13:00:00
'
);
expect
(
datetimeUtility
.
timeDifferenceMinutes
(
dateStart
,
dateEnd
)).
toEqual
(
60
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录