<%@ 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: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({
                series: [{
                    name: '达标率',
                    type: 'liquidFill',
                    data: [],
                    radius: '80%'
                }]
            });

            myChart2.setOption({
                series: [{
                    name: '污水率',
                    type: 'liquidFill',
                    data: [],
                    radius: '80%'
                }]
            });

            myChart3.setOption({
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b}: {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    x: 'left',
                    data:[]
                },
                series: [
                    {
                        name:'访问来源',
                        type:'pie',
                        radius: ['50%', '70%'],
                        avoidLabelOverlap: false,
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                show: true,
                                textStyle: {
                                    fontSize: '30',
                                    fontWeight: 'bold'
                                }
                            }
                        },
                        labelLine: {
                            normal: {
                                show: false
                            }
                        },
                        data:[]
                    }
                ]
            }) ;

            myChart4.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:[]
                    }
                ]
            }) ;

            myChart5.setOption({
                tooltip : {
                    trigger: 'axis',
                    axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                        type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                legend: {
                    data: ['达标水量', '未达标水量']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis:  {
                    type: 'value'
                },
                yAxis: {
                    type: 'category',
                    data: []
                },
                series: [
                    {
                        name: '达标水量',
                        type: 'bar',
                        stack: '总量',
                        label: {
                            normal: {
                                show: true,
                                position: 'insideRight'
                            }
                        },
                        data: []
                    },
                    {
                        name: '未达标水量',
                        type: 'bar',
                        stack: '总量',
                        label: {
                            normal: {
                                show: true,
                                position: 'insideRight'
                            }
                        },
                        data: []
                    }
                ]
            });

        var renderFunc = function () {
            $.get('<%=basePath%>/admin/waterQuality/getWaterqualityHandle.action').done(function (data) {
                // 填入数据
                myChart1.setOption({
                    series: [{
                        // 根据名字对应到相应的系列
                        name: '达标率  ',
                        data: [data]
                    }]
                });
            })
            $.get('<%=basePath%>/admin/waterQuality/getWaterqualityCityHandle.action').done(function (data) {
                // 填入数据
                myChart2.setOption({
                    series: [{
                        // 根据名字对应到相应的系列
                        name: '污水率  ',
                        data: [data]
                    }]
                });
            })
            $.get('<%=basePath%>/admin/waterQuality/getWaterqualitySurface.action').done(function (data) {
                // 填入数据
                myChart3.setOption({
                    legend: {
                        orient: 'vertical',
                        x: 'left',
                        data:data.names
                    },
                    series: [{
                        data:data.values
                    }]
                });
            })
            $.get('<%=basePath%>/admin/waterQuality/getWaterqualityIndustry.action').done(function (data) {
                // 填入数据
                myChart4.setOption({
                    xAxis: {
                        data: data.years
                    },
                    series: [{
                        // 根据名字对应到相应的系列
                        name: '排放量' ,
                        data: data.quantity
                    },{
                        // 根据名字对应到相应的系列
                        name: '达标率' ,
                        data: data.growth
                    }]
                });
            })
            $.get('<%=basePath%>/admin/waterQuality/getWaterqualityFocus.action').done(function (data) {
                // 填入数据
                myChart5.setOption({
                    yAxis: {
                        type: 'category',
                        data: data.regionName
                    },
                    series: [
                        {
                            name: '达标水量',
                            data: data.quantity
                        },
                        {
                            name: '未达标水量',
                            data: data.quantityNo
                        }
                    ]
                });
            })
        };
        renderFunc();
        /*setInterval(renderFunc, 3000);*/
    </script>
</body>
</html>