<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<style type="text/css">
    .col-xs-5ths {
        border: solid lightgray 1px;
        width: 16.66%;
        float:left;
        border-left:none;
        text-align: center;
        height: 110px;
        border-bottom: none;
    }
    .col-xs-5ths:first-child {
        border-left:solid lightgray 1px;
    }
    .header-data {
        font-size: 35px;
        font-weight: 500;
    }
    .col-xs-5ths label {
        font-weight: 500;
        font-size: 18px;
        margin-bottom: 0;
        margin-top:10px;
    }
    .second-row > .col-xs-5ths {
        border-bottom: solid lightgray 1px;
    }
    .section-first {
        margin-left: 15px;
        margin-right: 15px;
    }
    .chart-pos {
        margin-right: -65%;
    }

    @media screen and (max-width:700px) {
        .col-xs-5ths {
            position: relative;
        }
        .col-xs-5ths label {
            font-size: 1rem;
        }

        .header-data {
            font-size: 1.5rem;
            font-weight: bold;
            margin-top: 1rem;
        }

        .chart-pos {
            position: absolute;
            bottom: 9%;
        }
    }
</style>
<div class="content_wrapper">
    <div class="container-fluid">
        <aside>
            <header><i class="fa fa-fw fa-file"></i>排行榜</header>
            <section>
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-12">
                            <a style="margin:5px;" class="btn btn-primary active" href="#rank/index" role="button">总排行榜</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#rank/day" role="button">每日排行榜</a>
                        </div>
                    </div>
                </div>
            </section>
        </aside>
        <aside>
            <header><i class="fa fa-fw fa-file"></i>查询</header>
            <section>
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-12">
                            <form class="form-inline" method="POST" action="/#rank/day">
                                <span class="gap"></span>
                                <div class="form-group">
                                    <label>时间: </label>
                                    <input type="text" class="form-control datetimepicker" value="<?php echo $day;?>" placeholder="开始时间" id="day" name="day" />
                                </div>
                                <button type="button" onclick="to()" class="btn btn-primary">查询</button>
                            </form>
                        </div>
                    </div>
                </div>
            </section>
        </aside>
        <div class="row">
            <!--
            <div class="col-sm-6">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <aside>
                                        <section>
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div id="money"></div>
                                                </div>
                                            </div>
                                        </section>
                                    </aside>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
            <div class="col-sm-6">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <aside>
                                        <section>
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div id="spins"></div>
                                                </div>
                                            </div>
                                        </section>
                                    </aside>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
            -->
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <aside>
                                        <section>
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div id="level"></div>
                                                </div>
                                            </div>
                                        </section>
                                    </aside>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/highcharts.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/modules/exporting.js"></script>
<script type="text/javascript">
    function to(){

        window.location.href = "/#rank/day/"+$('#day').val();
    }
    ////选择日期
    //$('.datetimepicker').datepicker({
    //    language:'zh-CN',
    //    format:'yyyymmdd',
    //    zIndexOffset:906  //控制z-index
    //});
    //$("#money").css("height",($("#money").height() + 500 ) + "px");
    //$("#money").css("width",$("#money").width() + "px");
    //Highcharts.chart('money', {
    //    chart: {
    //        type: 'bar'
    //    },
    //    title: {
    //        text: '金币消耗排行榜'
    //    },
    //    subtitle: {
    //        text: "(*)表示付费用户"
    //    },
    //    xAxis: {
    //        categories: ["<?php echo implode('","',array_keys($money)); ?>"],
    //        title: {
    //            text: null
    //        }
    //    },
    //    yAxis: {
    //        min: 0,
    //        title: {
    //            text: '',
    //            align: 'high'
    //        },
    //        labels: {
    //            overflow: 'justify'
    //        }
    //    },
    //    tooltip: {
    //        valueSuffix: ''
    //    },
    //    plotOptions: {
    //        bar: {
    //            dataLabels: {
    //                enabled: true,
    //                allowOverlap: true // 允许数据标签重叠
    //            }
    //        }
    //    },
    //    legend: {
    //        layout: 'vertical',
    //        align: 'right',
    //        verticalAlign: 'top',
    //        x: -40,
    //        y: 100,
    //        floating: true,
    //        borderWidth: 1,
    //        backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
    //        shadow: true
    //    },
    //    series: [{
    //        name: '金币',
    //        data: [<?php echo implode(',',array_values($money)); ?>],
    //        events: {
    //            click: function(event) {
    //                var uid = this.data[event.point.x].category;
    //            	uid = uid.replace( /\(\*\)/g, '');
    //                window.open("#user/index/"+uid,"_blank");
    //            }
    //        }
    //    }]
    //}, function(chart) { // 图表渲染完毕后的回调函数
    //    var xAxis = chart.xAxis[0];
    //    console.log(xAxis);
    //    Highcharts.addEvent(xAxis.axisGroup.element, 'click', function(e) {
    //        //触发Y轴标题点击事件，以下忽略
    //        console.log(e)
    //    });
    //});
    //$("#spins").css("height",($("#spins").height() + 500) + "px");
    //$("#spins").css("width",$("#spins").width() + "px");
    //Highcharts.chart('spins', {
    //    chart: {
    //        type: 'bar'
    //    },
    //    title: {
    //        text: '能量消耗排行榜'
    //    },
    //    subtitle: {
    //        text: "(*)表示付费用户"
    //    },
    //    xAxis: {
    //        categories: ["<?php echo implode('","',array_keys($spins)); ?>"],
    //        title: {
    //            text: null
    //        }
    //    },
    //    yAxis: {
    //        min: 0,
    //        title: {
    //            text: '',
    //            align: 'high'
    //        },
    //        labels: {
    //            overflow: 'justify'
    //        }
    //    },
    //    plotOptions: {
    //        bar: {
    //            dataLabels: {
    //                enabled: true,
    //                allowOverlap: true // 允许数据标签重叠
    //            }
    //        }
    //    },
    //    legend: {
    //        layout: 'vertical',
    //        align: 'right',
    //        verticalAlign: 'top',
    //        x: -40,
    //        y: 100,
    //        floating: true,
    //        borderWidth: 1,
    //        backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
    //        shadow: true
    //    },
    //    series: [{
    //        name: '能量',
    //        data: [<?php echo implode(',',array_values($spins)); ?>],
    //        events: {
    //            click: function(event) {
    //            	var uid = this.data[event.point.x].category;
    //            	uid = uid.replace( /\(\*\)/g, '');
    //                window.open("#user/index/"+uid,"_blank");
    //            }
    //        }
    //    }]
    //});

    $("#level").css("height",($("#level").height() + 500) + "px");
    $("#level").css("width",$("#level").width() + "px");
    Highcharts.chart('level', {
        chart: {
            type: 'bar'
        },
        title: {
            text: '关卡升级排行榜'
        },
        subtitle: {
            text: "(*)表示付费用户"
        },
        xAxis: {
            categories: ["<?php echo implode('","',array_keys($level)); ?>"],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true,
                    allowOverlap: true // 允许数据标签重叠
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        series: [{
            name: '关卡',
            data: [<?php echo implode(',',array_values($level)); ?>],
            events: {
                click: function(event) {
                	var uid = this.data[event.point.x].category;
                	uid = uid.replace( /\(\*\)/g, '');
                    window.open("#user/index/"+uid,"_blank");
                }
            }
        }]
    });

</script>
