<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../../../common/admin/head.jsp"></jsp:include>
    <link  rel="stylesheet" type="text/css" href="<%=basePath%>/resource/css/admin/home/index.css">
</head>
<body>
    <jsp:include page="../../../common/admin/body_pre.jsp">
        <jsp:param name="title" value="${title}"/>
    </jsp:include>
    <div class="row hidden-print">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h2>空气质量</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="javascript:void(0);" >生态环境</a>
                        </li>
                        <li class="active">
                            <strong>空气质量</strong>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <div class="row hidden-print">
        <div class="col-lg-3 col-md-3">
            <div class="ibox shortcut">
                <div class="ibox-title-noline">
                    <span>空气质量指数</span>
                </div>
                <div class="ibox-content-noline">
                    <div id="divChart1" style="width: 100%;height: 400px;"></div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-3">
            <div class="ibox shortcut">
                <div class="ibox-title-noline">
                    <span>全年空气质量状况</span>
                </div>
                <div class="ibox-content-noline">
                    <div id="divChart2" style="width: 100%;height: 400px;"></div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-3">
            <div class="ibox shortcut">
                <div class="ibox-title-noline">
                    <span>机动车尾气排放情况</span>
                </div>
                <div class="ibox-content-noline">
                    <div id="divChart3" style="width: 100%;height: 400px;"></div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-3">
            <div class="ibox shortcut">
                <div class="ibox-title-noline">
                    <span>城市气化率</span>
                </div>
                <div class="ibox-content-noline">
                    <div id="divChart4" style="width: 100%;height: 400px;"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="row hidden-print">
        <div class="col-lg-12 col-md-3">
            <div class="ibox shortcut">
                <div class="ibox-title-noline">
                    <span>重点污染源工业废气排放</span>
                </div>
                <div class="ibox-content-noline">
                    <div id="divChart5" style="width: 100%;height: 400px;"></div>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
    <script type="text/javascript" src="<%=basePath%>/resource/plugins/echarts/echarts-liquidfill.js"></script>
    <script type="text/javascript">
        var myChart1 = echarts.init(document.getElementById('divChart1'));
        var myChart2 = echarts.init(document.getElementById('divChart2'));
        var myChart3 = echarts.init(document.getElementById('divChart3'));
        var myChart4 = echarts.init(document.getElementById('divChart4'));
        var myChart5 = echarts.init(document.getElementById('divChart5'));

            myChart1.setOption( {
                xAxis: {
                    type: 'category',
                    axisLabel: {
                        formatter: '{value}月'
                    },
                    data: []
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: [],
                    type: 'line'
                }]
            });

            myChart2.setOption({
                angleAxis: {
                },
                radiusAxis: {
                    type: 'category',
                    data: ['周一', '周二', '周三', '周四'],
                    z: 10
                },
                polar: {
                },
                series: [{
                    type: 'bar',
                    data: [],
                    coordinateSystem: 'polar',
                    name: '优',
                    stack: 'a'
                }, {
                    type: 'bar',
                    data: [],
                    coordinateSystem: 'polar',
                    name: '轻度污染',
                    stack: 'a'
                }, {
                    type: 'bar',
                    data: [],
                    coordinateSystem: 'polar',
                    name: '重度污染',
                    stack: 'a'
                },{
                    type: 'bar',
                    data: [],
                    coordinateSystem: 'polar',
                    name: '中度污染',
                    stack: 'a'
                },{
                    type: 'bar',
                    data: [],
                    coordinateSystem: 'polar',
                    name: '严重污染',
                    stack: 'a'
                }]
            });

            myChart3.setOption({
                tooltip : {
                    trigger: 'axis',
                    axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                        type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                legend: {
                    data:['排放限制','实际排放']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis : [
                    {
                        type : 'category',
                        data : []
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'排放限制',
                        type:'bar',
                        data:[]
                    },
                    {
                        name:'实际排放',
                        type:'bar',
                        data:[]
                    }
                ]
            }) ;

            myChart4.setOption({
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data:['实际','预测']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: []
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name:'实际',
                        type:'line',
                        stack: '总量',
                        data:[]
                    },
                    {
                        name:'预测',
                        type:'line',
                        stack: '总量',
                        data:[]
                    }
                ]
            }) ;

            myChart5.setOption({
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                toolbox: {
                    feature: {
                        dataView: {show: true, readOnly: false},
                        magicType: {show: true, type: ['line', 'bar']},
                        restore: {show: true},
                        saveAsImage: {show: true}
                    }
                },
                legend: {
                    data:['排放量','达标率']
                },
                xAxis: [
                    {
                        type: 'category',
                        data: [],
                        axisPointer: {
                            type: 'shadow'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '吨',
                        min: 0,
                        max: 250,
                        interval: 50,
                        axisLabel: {
                            formatter: '{value}'
                        }
                    },
                    {
                        type: 'value',
                        name: '百分比',
                        min: 0,
                        max: 25,
                        interval: 5,
                        axisLabel: {
                            formatter: '{value}%'
                        }
                    }
                ],
                series: [
                    {
                        name:'排放量',
                        type:'bar',
                        data:[]
                    },
                    {
                        name:'达标率',
                        type:'line',
                        yAxisIndex: 1,
                        data:[]
                    }
                ]
            });

        var renderFunc = function () {
            $.get('<%=basePath%>/admin/atmosphere/getAtmosphereIndex.action').done(function (data) {
                // 填入数据
                myChart1.setOption({
                    xAxis: {
                        data: data.names
                    },
                    series: [{
                        data: data.values
                    }]
                });
            })
            $.get('<%=basePath%>/admin/atmosphere/getAtmosphereYear.action').done(function (data) {
                // 填入数据
                myChart2.setOption({
                    series: [{
                        data: data.excellents,
                        name: '优'
                    }, {
                        data: data.lights,
                        name: '轻度污染'
                    }, {
                        data: data.severes,
                        name: '重度污染'
                    },{
                        data: data.moderates,
                        name: '中度污染'
                    },{
                        data: data.seriouss,
                        name: '严重污染'
                    }]
                });
            })
            $.get('<%=basePath%>/admin/atmosphere/getAtmosphereEmission.action').done(function (data) {
                // 填入数据
                myChart3.setOption({
                    xAxis : [
                        {
                            type : 'category',
                            data : data.names
                        }
                    ],
                    series : [
                        {
                            name:'排放限制',
                            type:'bar',
                            data:data.limit
                        },
                        {
                            name:'实际排放',
                            type:'bar',
                            data:data.actual
                        }
                    ]
                });
            })
            $.get('<%=basePath%>/admin/atmosphere/getAtmosphereGasification.action').done(function (data) {
                // 填入数据
                myChart4.setOption({
                    xAxis: {
                        type: 'category',
                        data: data.years
                    },
                    series: [
                        {
                            name:'实际',
                            type:'line',
                            stack: '总量',
                            data: data.actualQuality
                        },
                        {
                            name:'预测',
                            type:'line',
                            stack: '总量',
                            data: data.forecastQuality
                        }
                    ]
                });
            })
            $.get('<%=basePath%>/admin/atmosphere/getAtmosphereIndustry.action').done(function (data) {
                // 填入数据
                myChart5.setOption({
                    xAxis: {
                        data: data.years
                    },
                    series: [{
                        // 根据名字对应到相应的系列
                        name: '排放量' ,
                        data: data.discharge
                    },{
                        // 根据名字对应到相应的系列
                        name: '达标率' ,
                        data: data.standard
                    }]
                });
            })
        };
        renderFunc();
        /*setInterval(renderFunc, 3000);*/
    </script>
</body>
</html>