美文网首页前端技术js
echarts 时间轴修改

echarts 时间轴修改

作者: igor_d140 | 来源:发表于2018-10-23 23:48 被阅读33次
    <!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>
    

    相关文章

      网友评论

        本文标题:echarts 时间轴修改

        本文链接:https://www.haomeiwen.com/subject/oxwzzftx.html