echarts-魔改

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>

<body>
    <div id="app" v-cloak>
      <div id="day" style="height: 22vh;"></div>
     <div>
</body>
<script>
    new Vue({
        el: '#app',
        // 获取
        data() {
            return {
            }
        },
        mounted() {
            this.IsPC()
            if (this.IsPC() == true) {
                this.flag = true
            } else {
                this.flag = false
            }
            this.getDayDataList()
            this.getMonthDataList()
        },
        methods: {
            IsPC() {
                var userAgentInfo = navigator.userAgent;
                var Agents = ["Android", "iPhone",
                    "SymbianOS", "Windows Phone",
                    "iPad", "iPod"
                ];
                var flag = true;
                for (var v = 0; v < Agents.length; v++) {
                    if (userAgentInfo.indexOf(Agents[v]) > 0) {
                        flag = false;
                        break;
                    }
                }
                return flag;
            },

            drawDayTotalSleep(data, value, c) {

                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('day1'))
                var aa = 'Awake'
                var bb = 'Light'
                var cc = 'Deep'
                var days = ['Deep', 'Light', 'Awake',];
                if (data.length != 0) {
                    data = data.map(function (item) {
                        return [item[0], item[1], item[2] || '-'];
                    });

                    if (data[data.length - 1][2] == 3) {
                        data.pop()
                    }
                }

                // 绘制图表
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '5%',
                        left: '2%',
                        right: '5%',
                        bottom: '1%',
                        containLabel: true
                    },
                    legend: {
                        // orient: 'vertical',
                        icon: "circle",
                        x: '60%',
                        y: "center",
                        data: ['Awake', 'Light', 'Deep'],
                        itemGap: 40,
                        selectedMode: false,
                        textStyle: {
                            color: '#ffffff',

                        }
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'line',
                        },
                        // formatter:'{c}%'
                        formatter(params) {
                            var a = '<div><p>' + params[0].name + '</p></div>'
                            for (var i = 0; i < params.length; i++) {
                                if (params[i].value[2] == 1) {
                                    params[i].value[2] = aa
                                }
                                if (params[i].value[2] == 2) {
                                    params[i].value[2] = bb
                                }
                                if (params[i].value[2] == 3) {
                                    params[i].value[2] = cc
                                }
                                a += '<p>' + params[i].marker + params[i].value[2] + '</p>';
                            }
                            return a;
                        }
                    },

                    animation: false,

                    xAxis: {
                        type: 'category',
                        data: value,
                        show: this.sleepStageDisFlag,
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: true,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    yAxis: [{
                        type: 'category',
                        data: days,
                        show: this.sleepStageDisFlag,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: true,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                type: 'dashed',
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    {
                        type: 'category',
                        data: days,
                        show: this.sleepStageDisFlag,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'dashed'
                            }
                        },
                        axisLabel: {
                            show:false,
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: true,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                type: 'dashed',
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    }],
                    visualMap: {
                        min: 1,
                        max: 3,
                        show: false,
                        calculable: false,
                        orient: 'horizontal',

                        left: 'center',
                        bottom: '10%',
                        //自定义热力图颜色
                        inRange: {
                            color: ['#6B5CAD', '#4197B5', '#AFB3C0']
                        }
                    },
                    series: [{
                        name: 'Punch Card',
                        type: 'heatmap',
                        barWidth: '50',
                        data: data,
                    },
             ]
                });
            },
            // 
            drawHeartRate(a, b, c) {
               
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('day2'))
                // 绘制图表
                let sleepStr1 = 'Asleep'
               let sleepStr2 = 'Asleep'
               let awakeStr = 'Awake'
               if(this.commonChartsTomorrowSleepTime == ''){
                sleepStr1 = ''
               }  
               if(this.commonChartsSleepTime == ''){
                sleepStr2 = ''
               } if(this.commonChartsWakeTime == ''){
                awakeStr = ''
               }     
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '15%',
                        left: '4%',
                        right: '1%',
                        bottom: '1%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'dotted'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                        data: a

                    },
                    yAxis: {
                        type: 'value',
                        minInterval: 1,
                        show:!c,
                        min:0,
                        max:100,
                        // boundaryGap : [ 0, 0.1 ],
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#AFB3C0"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },
                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'none',
                        },
                        renderMode: 'html', // 浮层的渲染模式,默认以 'html 即额外的 DOM 节点展示 tooltip;
                        backgroundColor: ' #525466', // 提示框浮层的背景颜色。
                        // formatter:'{c}%'
                        formatter(params) {
                            var a = ''
                            for (var i = 0; i < params.length; i++) {
                                a += '<p>'+ params[i].value + '</p>';
                            }
                            return a;
                        }
                    },
                    series: [{
                        name: '销量',
                        type: 'line',
                        symbol: "none",
                        itemStyle: {
                            normal: {
                                color: '#fff',
                                lineStyle: {
                                    color: 'rgba(208, 77, 77, 0.75)'
                                }
                            }
                        },
                        areaStyle: {
                            opacity: 0.8,
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(208, 77, 77, 0.75)'
                            }, {
                                offset: 1,
                                color: 'rgba(208, 77, 77, 0)'
                            }])
                        },
                        data: b
                    },
                    {
                        name: '平行于y轴的趋势线',
                        type: 'line',
                        markLine: {
                            lineStyle: {
                                width: 1,
                                color: 'gray',
                            },
                            name: 'aa',
                            symbol: 'none',
                            data: [[
                                { coord: [b[0], 0] },
                                { coord: [b[b.length-1], 100] }//如何获取grid上侧最大值,目前是写死的
                            ], [
                                { coord: [a[a.length - 1], 0] },
                                { coord: [a[a.length - 1], 100] }
                            ],
                            [
                                { coord: [this.mob_total_timeflag2, 0] ,name:this.mob_total_timeflag2},
                                { coord: [this.mob_total_timeflag2, 100],name:this.mob_total_timeflag2 }
                            ],
                            [
                                { coord: [this.commonChartsWakeTime, 0], name: awakeStr  + '\n' + this.commonChartsWakeTime },
                                { coord: [this.commonChartsWakeTime, 100] }
                            ],
                            [
                                { coord: [this.commonChartsSleepTime, 0], name:sleepStr2  + '\n' + this.commonChartsSleepTime },
                                { coord: [this.commonChartsSleepTime, 100] }
                            ],
                            // [
                            //     { coord: [this.commonChartsTomorrowSleepTime, 0], name:sleepStr1  + '\n' + this.commonChartsTomorrowSleepTime },
                            //     { coord: [this.commonChartsTomorrowSleepTime, 100] }
                            // ],
                        ]
                        }
                    }
                    ]
                });
            }
            
            drawRespirtoryRate(a, b, c) {
                // console.log(a,b)
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('day3'))
                // 绘制图表
                let sleepStr1 = 'Asleep'
               let sleepStr2 = 'Asleep'
               let awakeStr = 'Awake'
               if(this.commonChartsTomorrowSleepTime == ''){
                sleepStr1 = ''
               }  
               if(this.commonChartsSleepTime == ''){
                sleepStr2 = ''
               } if(this.commonChartsWakeTime == ''){
                awakeStr = ''
               }     
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '15%',
                        left: '6%',
                        right: '1%',
                        bottom: '1%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'dotted'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                        data: a

                    },
                    yAxis: {
                        type: 'value',
                        show:!c,
                        min:0,
                        max:25,
                        minInterval: 1,
                        // boundaryGap : [ 0, 0.1 ],
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#AFB3C0"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },
                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'none',
                        },
                        renderMode: 'html', // 浮层的渲染模式,默认以 'html 即额外的 DOM 节点展示 tooltip;
                        backgroundColor: ' #525466', // 提示框浮层的背景颜色。
                        // formatter:'{c}%'
                        formatter(params) {
                            var a = ''
                            for (var i = 0; i < params.length; i++) {
                                a += '<p>'+ params[i].value
                                     + '</p>';
                            }
                            return a;
                        }
                    },
                    series: [{
                        name: '销量',
                        type: 'line',
                        symbol: "none",
                        itemStyle: {
                            normal: {
                                color: '#fff',
                                lineStyle: {
                                    color: 'rgba(45, 92, 180, 0.75)'
                                }
                            }
                        },
                        areaStyle: {
                            opacity: 0.8,
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(45, 92, 180, 0.75)'
                            }, {
                                offset: 1,
                                color: 'rgba(45, 92, 180, 0)'
                            }])
                        },
                        data: b
                    },
                    {
                        name: '平行于y轴的趋势线',
                        type: 'line',
                        markLine: {
                            lineStyle: {
                                width: 1,
                                color: 'gray',
                            },
                            name: 'aa',
                            symbol: 'none',
                            data: [[
                                { coord: [b[0], 0] },
                                { coord: [b[b.length-1], 25] }//如何获取grid上侧最大值,目前是写死的
                            ], [
                                { coord: [a[a.length - 1], 0] },
                                { coord: [a[a.length - 1], 25] }
                            ],
                         [
                                { coord: [this.mob_total_timeflag2, 0] ,name:this.mob_total_timeflag2},
                                { coord: [this.mob_total_timeflag2, 25],name:this.mob_total_timeflag2 }
                            ],
                            [
                                { coord: [this.commonChartsWakeTime, 0], name: awakeStr+ '\n' + this.commonChartsWakeTime },
                                { coord: [this.commonChartsWakeTime, 25] }
                            ],
                            [
                                { coord: [this.commonChartsSleepTime, 0], name:sleepStr2  + '\n' + this.commonChartsSleepTime },
                                { coord: [this.commonChartsSleepTime, 25] }
                            ],
                            // [
                            //     { coord: [this.commonChartsTomorrowSleepTime, 0], name:sleepStr1  + '\n' + this.commonChartsTomorrowSleepTime },
                            //     { coord: [this.commonChartsTomorrowSleepTime, 25] }
                            // ],
                        ]
                        }
                    }
                ]
                });
            },

            drawMovement(a, b, c) {
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('day4'))
                // 绘制图表
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '15%',
                        left: '6%',
                        right: '1%',
                        bottom: '1%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'dotted'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                        data: a

                    },
                    yAxis: {
                        type: 'value',
                        minInterval: 1,
                       min:0,
                       max:25,
                       show:!c,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#AFB3C0"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },
                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'line',
                        },
                        // formatter:'{c}%'
                        formatter(params) {
                            var a = '<div><p>' + params[0].name + '</p></div>'
                            for (var i = 0; i < params.length; i++) {
                                a += '<p>' + params[i].marker + params[i].value + '</p>';
                            }
                            return a;
                        }
                    },
                    series: [{
                        name: '销量',
                        type: 'line',
                        symbol: "none",
                        itemStyle: {
                            normal: {
                                color: '#fff',
                                lineStyle: {
                                    color: 'rgba(245, 175, 0, 0.75)'
                                }
                            }
                        },
                        areaStyle: {
                            opacity: 0.8,
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(245, 175, 0, 0.75)'
                            }, {
                                offset: 1,
                                color: 'rgba(245, 175, 0, 0)'
                            }])
                        },
                        data: b
                    },
                    {
                        name: '平行于y轴的趋势线',
                        type: 'line',
                        markLine: {
                            lineStyle: {
                                width: 1,
                                color: '#6D7188',
                            },
                            name: 'aa',
                            symbol: 'none',
                            data: [[
                                { coord: [b[0], 0] },
                                { coord: [b[b.length-1], 25] }//如何获取grid上侧最大值,目前是写死的
                            ], [
                                { coord: [a[a.length - 1], 0] },
                                { coord: [a[a.length - 1], 25] }
                            ]]
                        }
                    }
                ]
                });
            },
            // 日报 打鼾干预
            drawAntiSnore(a, b, c) {
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('day5'))

                // 绘制图表
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        height:'80%',
                        top:'5%',
                        left: '5%',
                        right: '5%',
                        bottom: '2%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        data: a,
                        axisLabel: {
                            // formatter: function shijiantime(times) {
                            //     var timearr = times.replace(" ", ":").replace(/\:/g, "-").split("-");
                            //     var timestr = timearr[3] + ":" + timearr[4] + ""
                            //     return timestr
                            // },
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },

                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    yAxis: {
                        type: 'value',
                        min: 0,
                        max:5,
                        show:!c,
                        interval: 1,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            show: false,
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    series: [{
                        type: "k",
                        barMaxWidth: 5,
                        itemStyle: {
                            normal: {
                                color: '#4197B5',
                                barBorderRadius: [40, 10, 10, 10],
                                borderColor: "none"
                            }
                        },
                        data: b,
                        showBackground: true,

                    },
                    // {
                    //     name: '平行于y轴的趋势线',
                    //     type: 'line',
                    //     markLine: {
                    //         lineStyle: {
                    //             width: 1,
                    //             color: '#6D7188',
                    //         },
                    //         name: 'aa',
                    //         symbol: 'none',
                    //         data: [[
                    //             { coord: [a[0], 0] },
                    //             { coord: [a[0], 5] }//如何获取grid上侧最大值,目前是写死的
                    //         ], [
                    //             { coord: [a[a.length - 1], 0] },
                    //             { coord: [a[a.length - 1], 5] }
                    //         ]]
                    //     }
                    // }
                ]
                });
            },
            //  饼图        
            drawMonthlySleepQuality(a, b, c) {
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('month1'))
                // 绘制图表
                myChart.setOption({
                    tooltip: {
                        trigger: 'item'
                    },
                    grid: {
                        top: '1%',
                        left: '1%',
                        right: '1%',
                        bottom: '1%',
                        containLabel: true
                    },
                    series: [
                        {
                            // name: '访问来源',
                            type: 'pie',
                            radius: ['40%', '70%'],
                            avoidLabelOverlap: false,
                            radius: ["45%", "60%"],
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: true,
                                    fontSize: '20',
                                    fontWeight: 'bold'
                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                { value: a, name: 'Deep', itemStyle: { color: '#6B5CAD' } },
                                { value: b, name: 'Light', itemStyle: { color: '#4197B5' } },
                                { value: c, name: 'Awale', itemStyle: { color: '#AFB3C0' } },
                            ]
                        }
                    ]
                });
            },
            // 月报 起来和入睡时间
            drawWakeAndFallTime(a, b, c) {
                let myChart = echarts.init(document.getElementById('month2'))
                var cc = this.fall_clone
                var dd = this.wake_clone
                function ChangeHourMinutestr(str) {

                    if (str > 1440 && str != 0) {
                        str = str - 1440

                        if (str !== "0" && str !== "" && str !== null) {
                            return ((Math.floor(str / 60)).toString().length < 2 ? "0" + (Math.floor(str / 60)).toString() :
                                (Math.floor(str / 60)).toString()) + ":" + ((str % 60).toString().length < 2 ? "0" + (str % 60).toString() : (str % 60).toString());

                        } else {
                            return "";
                        }
                    } else {
                        if (str !== "0" && str !== "" && str !== null) {
                            return ((Math.floor(str / 60)).toString().length < 2 ? "0" + (Math.floor(str / 60)).toString() :
                                (Math.floor(str / 60)).toString()) + ":" + ((str % 60).toString().length < 2 ? "0" + (str % 60).toString() : (str % 60).toString());

                        } else {
                            return "";
                        }
                    }

                }
                function ChangeStrToMinutes(str) {
                    console.log(str)
                    var arrminutes = str.split(":");
                    if (arrminutes.length == 2) {
                        var minutes = parseInt(arrminutes[0]) * 60 + parseInt(arrminutes[1]);
                        return minutes;
                    } else {
                        return 0;
                    }
                }
                var aa = this.avgSleepTime
                var bb = this.avgWakeTime

                var ech_avg_sleep_time;
                var ech_avg_wake_time = ChangeStrToMinutes(this.avgWakeTime)
                if (ChangeStrToMinutes(this.avgSleepTime) < 720) {
                    ech_avg_sleep_time = ChangeStrToMinutes(this.avgSleepTime) + 1440
                    console.log('1')
                } else {
                    ech_avg_sleep_time = ChangeStrToMinutes(this.avgSleepTime)
                    console.log('2')
                }
                // 绘制图表
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '10%',
                        left: '4%',
                        right: '15%',
                        bottom: '1%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        interval: 2,
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            // onZero: true,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                        data: a,
                    },

                    yAxis: {
                        type: 'value',
                        // inverse: true,
                        scale: false,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            formatter: function (value, index) {
                                // if (value > 1440) {
                                //     value = value - 1440

                                //     return ChangeHourMinutestr(value)
                                // }
                                return ChangeHourMinutestr(value)

                            },
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'line',
                            crossStyle: {
                                color: '#B3BCE3'
                            }

                        },
                        formatter(params) {
                            var a = '<div><p>' + params[0].name + '</p></div>'
                            for (let i = 0; i < params.length; i++) {
                                // console.log(params[i])
                                if (!isNaN(params[i].value[2])) {
                                    a += '<p>' + params[i].marker + cc + " : " + ChangeHourMinutestr(params[i].value[2] + "") + '</p>' + '<p>' + params[i].marker + dd + " : " + ChangeHourMinutestr((params[i].value[1]) + "") + '</p>';
                                }
                            }
                            return a;
                        }
                    },
                    series: [{
                        type: 'k',
                        markLine: {
                            symbol: "none",
                            data: [{
                                silent: true, //鼠标悬停事件  true没有,false有
                                lineStyle: { //警戒线的样式  ,虚实  颜色
                                    type: "dashed",
                                    color: "#52EEFF",
                                },
                                label: {
                                    position: 'end',
                                    formatter: `${aa}`,
                                    color: "#D8D8DB",
                                    fontSize: '12'
                                },
                                yAxis: ech_avg_sleep_time

                            }, {

                                silent: true,
                                lineStyle: {
                                    type: "dashed",

                                    color: "#FFAD67",
                                },
                                label: {
                                    position: 'end',
                                    color: "#D8D8DB",
                                    formatter: `${bb}`,
                                    fontSize: '12'
                                },
                                yAxis: ech_avg_wake_time

                            }]
                        },
                        barMaxWidth: 3.5,
                        itemStyle: {
                            borderColor: "none",
                            color: '#8877D1',
                            emphasis: {
                            }
                        },
                        lineStyle: {
                            normal: {
                                opacity: 1,
                            }
                        },
                        data: b,
                    }]
                });
            },
            // 月报 心率
            drawMonthHeartRate(a, b, c) {
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('month3'))
                // 绘制图表
                myChart.setOption({
                    title: {
                        show: c,
                        text: 'No Data',
                        left: 'center',
                        top: 'center',
                        textStyle: {
                            color: '#fff',
                            fontSize: 14,
                            fontWeight: 400
                        }
                    },
                    grid: {
                        top: '10%',
                        left: '6%',
                        right: '7%',
                        bottom: '1%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'dotted'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#D8D8DB"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },

                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                        data: a

                    },
                    yAxis: {
                        type: 'value',
                        minInterval: 20,
                        // boundaryGap : [ 0, 0.1 ],
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: '#666870',
                                width: 1,
                                type: 'solid'
                            }
                        },
                        axisLabel: {
                            textStyle: {
                                color: "#AFB3C0"
                            }
                        },
                        axisLine: {
                            show: false,
                            axisTick: {
                                show: false
                            },
                            lineStyle: {
                                color: '#666870 ',
                                width: 1, //这里是为了突出显示加上的  
                            }
                        },
                    },
                    tooltip: {
                        // 触发器
                        trigger: "axis",
                        axisPointer: {
                            type: 'line',
                        },
                        // formatter:'{c}%'
                        formatter(params) {
                            var a = '<div><p>' + params[0].name + '</p></div>'
                            for (var i = 0; i < params.length; i++) {
                                a += '<p>' + params[i].marker + params[i].value + '</p>';
                            }
                            return a;
                        }
                    },
                    series: [{
                        name: '销量',
                        type: 'line',
                        symbol: 'none',
                        itemStyle: {
                            normal: {
                                color: '#fff',
                                lineStyle: {
                                    color: 'rgba(208, 77, 77, 0.75)'
                                }
                            }
                        },
                        areaStyle: {
                            opacity: 0.8,
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(208, 77, 77, 0.75)'
                            }, {
                                offset: 1,
                                color: 'rgba(208, 77, 77, 0)'
                            }])
                        },
                        data: b
                    }]
                });
            },
         
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值