czt
2 天以前 51faf3e9c3c613e7fb12db6c88356946f2429e0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var layer;
var form;
var curCamera;
 
layui.use(['layer'], function () {
    form = layui.form;
    layer = layui.layer;
 
    // 调色板切换事件
    document.querySelectorAll('.palette-item').forEach(item => {
        item.addEventListener('click', function() {
            document.querySelectorAll('.palette-item').forEach(i => {
                i.classList.remove('active');
            });
            this.classList.add('active');
            const paletteName = this.textContent.trim();
            layer.msg(`已切换至${paletteName}调色板`, {icon: 1, time: 1000});
        });
    });
 
 
    //选择摄像头后触发的事件
    const cameraSelect = document.getElementById('select-camera');
    cameraSelect.addEventListener('change', function() {
        const selectedCamera = this.value;
        //console.log("--------------"+selectedCamera);
        video(selectedCamera);
 
        // 更新温度走势图
        // updateEchartsTemp(selectedCamera);
    });
 
 
    // 初始化ECharts温度走势图
    initEchartsTemp();
 
});
 
/**
 * 视频播放
 * @param selectId
 */
function video(selectId) {
    //从列表中获取摄像头信息
    curCamera = listCamera.find(camera => camera.id === selectId);
    if (!curCamera) { layer.msg('没有获取到当前摄像头信息……', {icon: 1, time: 1200});}
 
 
}
 
/**
 * 更新温度走势图
 * @param selectId
 */
function updateEchartsTemp(selectId) {
    var data = {
        cameraId: selectId
    };
    $.ajax({
        type: 'POST',
        url: "/security/infrared/chart-data",
        dataType: 'JSON',
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            //layer.msg("信息更新完成!!");
        },
        error: function (result) {
           // layer.msg(result.msg);
        }
    });
}
 
// 初始化ECharts温度走势图
function initEchartsTemp() {
    // 初始化ECharts温度走势图
    var temperatureChartDom = document.getElementById('temperatureChart');
    var temperatureChart = echarts.init(temperatureChartDom);
 
    // 图表配置项
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        legend: {
            data: ['数量 (KG)'],
            top: 0
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                boundaryGap: false,
                data: ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06', '12-07']
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '数量 (KG)',
                min: 0,
                max: 3000000,
                axisLabel: {
                    formatter: '{value} KG'
                }
            }
        ],
        series: [
            {
                name: '数量 (KG)',
                type: 'line',
                smooth: true,
                lineStyle: {
                    width: 2,
                    color: '#0f3460'
                },
                areaStyle: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                        { offset: 0, color: 'rgba(15, 52, 96, 0.3)' },
                        { offset: 1, color: 'rgba(15, 52, 96, 0.05)' }
                    ])
                },
                data: [2560000, 2510000, 2540000, 2530000, 2490000, 2610000, 2570000]
            }
        ]
    };
    // 渲染图表
    option && temperatureChart.setOption(option);
    // 窗口大小变化时调整图表大小
    window.addEventListener('resize', function() {
        temperatureChart.resize();
    });
}