echarts 时间轴修改
2018-10-23 本文已影响33人
igor_d140
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
// 间隔1分钟输出
const timeset = count => {
let result = []
for (let i = 0; i < count; i++) {
if (count === 24) {
result.push(i + ':')
} else {
let j = i
if (j < 10) j = '0' + j
result.push(j + '')
}
}
return result
}
// 间隔n分钟输出
const minset = (count, n) => {
let result = []
for (let i = 0; i < count; i += n) {
let j = i
if (j < 10) j = '0' + j
result.push(j + '')
}
return result
}
// 输出时间数组
const timeline2arr = () => {
//hours
let hour2arr = timeset(24),
// minutes
min2arr = timeset(60),
// min2arr = minset(60, 5),
//time2arr
time2arr = hour2arr.map(h => min2arr.map(m => h + m)).reduce((prev, next) => prev.concat(next))
return time2arr
}
// const data = JSON.stringify(timeline2arr())
// debugger
console.log(timeline2arr())
</script>
</body>
</html>