| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 | {% extends "index.html" %}{% block title %}振動監控{% endblock %}{% block head %}{{ super() }}{% endblock %}{% block body %}    <div id="headlth_indicator">        <div id="curr_health" style="width: 300px;height:300px;float:right"></div>        <div id="pred_health" style="width: 300px;height:300px;float:right"></div>            </div>    <div id="history_record" style="width: 600px;height:600px;float:right"></div>     <script>        var curr_health = echarts.init(document.getElementById("curr_health"));        var pred_health = echarts.init(document.getElementById("pred_health"));        var history_record = echarts.init(document.getElementById("history_record"));        let date = transform_time_to_string(new Date());        fetch(`/health?date=${date}`)            .then(function(response) {                return response.json();            })            .then(function(myJson) {                console.log(myJson);                option = {                    series: [{                        type: 'gauge',                        startAngle: 180,                        endAngle: 0,                        min: 0,                        max: 1,                        splitNumber: 8,                        axisLine: {                            lineStyle: {                                width: 6,                                color: [                                    [0.25, '#FF6E76'],                                    [0.5, '#FDDD60'],                                    // [0.75, '#58D9F9'],                                    [1, '#7CFFB2']                                ]                            }                        },                        pointer: {                            icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',                            length: '70%',                            width: 5,                            offsetCenter: [0, '-60%'],                            itemStyle: {                                color: 'auto'                            }                        },                        axisTick: {                            length: 12,                            lineStyle: {                                color: 'auto',                                width: 2                            }                        },                        splitLine: {                            length: 20,                            lineStyle: {                                color: 'auto',                                width: 5                            }                        },                        axisLabel: {                            color: '#464646',                            fontSize: 20,                            distance: -60,                            formatter: function (value) {                                if (value === 1) {                                    return '100';                                }                                // else if (value === 0.625) {                                //     return '中';                                // }                                else if (value === 0.5) {                                    return '50';                                }                                else if (value === 0.3) {                                    return '30';                                }                            }                        },                        title: {                            offsetCenter: [0, '-20%'],                            fontSize: 30                        },                        detail: {                            fontSize: 15,                            offsetCenter: [0, '+20%'],                            valueAnimation: true,                            formatter: function (value) {                                return '目前健康指標: ' + Math.round(value * 100) + '分';                                // return '目前健康指標'                            },                            color: 'auto'                        },                        data: [{                            value: myJson['curr_health'],                            name: ''                        }]                    }]                };                pred_health.setOption(option);                option = {                    series: [{                        type: 'gauge',                        startAngle: 180,                        endAngle: 0,                        min: 0,                        max: 1,                        splitNumber: 8,                        axisLine: {                            lineStyle: {                                width: 6,                                color: [                                    [0.25, '#FF6E76'],                                    [0.5, '#FDDD60'],                                    // [0.75, '#58D9F9'],                                    [1, '#7CFFB2']                                ]                            }                        },                        pointer: {                            icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',                            length: '70%',                            width: 5,                            offsetCenter: [0, '-60%'],                            itemStyle: {                                color: 'auto'                            }                        },                        axisTick: {                            length: 12,                            lineStyle: {                                color: 'auto',                                width: 2                            }                        },                        splitLine: {                            length: 20,                            lineStyle: {                                color: 'auto',                                width: 5                            }                        },                        axisLabel: {                            color: '#464646',                            fontSize: 20,                            distance: -60,                            formatter: function (value) {                                if (value === 1) {                                    return '100';                                }                                // else if (value === 0.625) {                                //     return '中';                                // }                                else if (value === 0.5) {                                    return '50';                                }                                else if (value === 0.3) {                                    return '30';                                }                            }                        },                        title: {                            offsetCenter: [0, '-20%'],                            fontSize: 30                        },                        detail: {                            fontSize: 15,                            offsetCenter: [0, '20%'],                            valueAnimation: true,                            formatter: function (value) {                                return '預測健康指標: ' + Math.round(value * 100) + '分';                                // return '目前健康指標'                            },                            color: 'auto'                        },                        data: [{                            value: myJson['pred_health'],                            name: ''                        }]                    }]                };                curr_health.setOption(option);            });                    fetch(`/history_data?time_end=${date}`)            .then(function(response) {                return response.json();            })            .then(function(myJson) {                console.log(myJson);                option = {                    // color: ['#80FFA5', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'],                    title: {                        text: '歷史紀錄圖表'                    },                    tooltip: {                        trigger: 'axis',                        axisPointer: {                            type: 'cross',                            label: {                                backgroundColor: '#6a7985'                            }                        }                    },                    legend: {                        data: ['RPM_1X', 'RPM_2X', 'RPM_3X', 'RPM_4X', 'RPM_5X', 'RPM_6X', 'RPM_7X', 'RPM_8X', 'Gear_1X', 'Gear_2X', 'Gear_3X','Gear_4X']                    },                    toolbox: {                        feature: {                            saveAsImage: {}                        }                    },                    grid: {                        left: '3%',                        right: '4%',                        bottom: '3%',                        containLabel: true                    },                    xAxis: [                        {                            type: 'category',                            boundaryGap: false,                            data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00']                        }                    ],                    yAxis: [                        {                            type: 'value'                        }                    ],                    series: [                        {                            name: 'RPM_1X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_1X']                        },                        {                            name: 'RPM_2X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_2X']                        },                        {                            name: 'RPM_3X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_3X']                        },                        {                            name: 'RPM_4X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_4X']                        },                        {                            name: 'RPM_5X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_5X']                        },                        {                            name: 'RPM_6X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_6X']                        },                        {                            name: 'RPM_7X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_7X']                        },                        {                            name: 'RPM_8X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['RPM_1X']                        },                        {                            name: 'Gear_1X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['Gear_1X']                        },                        {                            name: 'Gear_2X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['Gear_2X']                        },                        {                            name: 'Gear_3X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['Gear_3X']                        },                        {                            name: 'Gear_4X',                            type: 'line',                            stack: '总量',                            smooth: true,                            lineStyle: {                                width: 0                            },                            showSymbol: false,                            areaStyle: {                                opacity: 0.8,                                // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{                                //     offset: 0,                                //     color: 'rgba(128, 255, 165)'                                // }, {                                //     offset: 1,                                //     color: 'rgba(1, 191, 236)'                                // }])                            },                            emphasis: {                                focus: 'series'                            },                            data: myJson['curr_history']['Gear_4X']                        }                    ]                };                history_record.setOption(option);            });                                    </script>{% endblock %}
 |