<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>


<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <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" role="form" method="POST" action="#statistics/login" name="stanpform">
                                        <input type="hidden" name="fromsta_login" value="1">
                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>开始时间</label>
                                                <input type="text" class="form-control datetimepicker" value="<?php if($stime) echo $stime;?>" placeholder="开始时间" name="sta_login_stime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>结束时间</label>
                                                <input type="text" class="form-control datetimepicker" value="<?php if($etime) echo $etime;?>" placeholder="结束时间" name="sta_login_etime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>国家</label>
                                            <input type="text" class="form-control" value="<?php if($address) echo $address;?>" placeholder="国家" name="address" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>用户属性</label>
                                            <select name="userType" class="form-control">
                                                <option value="" <?php if($userType=="") echo "selected";?> >所有</option>
                                                <option value="natural" <?php if($userType=="natural") echo "selected";?> >自然量</option>
                                                <option value="buy" <?php if($userType=="buy") echo "selected";?> >买量</option>
                                            </select>
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>付费等级</label>
                                            <select name="groupId" class="form-control">
                                                <option value="0">所有</option>
                                                <?php
                                                    foreach($groupList as $row){
                                                        echo '<option value="'.$row['id'].'" '.($groupId==$row['id']?'selected':'').' >'.$row['name'].'</option>';
                                                    }
                                                ?>
                                            </select>
                                        </div>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>每日登陆</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                            <button type="button" class="btn btn-primary" id="all_checked1">全选</button>
                            <button type="button" class="btn btn-primary" id="all_no_checked1">全不选</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer()">折线图</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer('column')">柱形图</button>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>
</div>
<!--<script type="text/javascript" src="--><?php //echo base_url().'public/js/chart/chart.js';?><!--"></script>-->
<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" src="<?php echo base_url();?>public/js/highcharts/modules/export-data.js"></script>
<script type="text/javascript">
//设置图表导出格式选项
Highcharts.setOptions({
    lang: {
        printChart: '打印图表',
        downloadJPEG: '下载 JPEG 文件',
        downloadPDF: '下载 PDF   文件',
        downloadPNG: '下载 PNG  文件',
        downloadSVG: '下载 SVG  文件',
        downloadCSV: '下载 CSV  文件',
        downloadXLS: '下载 XLS   文件',
        viewData: '查看数据表格'
    },
    navigation: {
        menuItemStyle: {
            padding: '6px 14px'
        }
    },
    exporting: {
        url: ''
    },
    credits: {
        text: '',
        url: ''
    }
});

    var chart1 = null;
    initContainer();
    function initContainer(type = 'line'){
        chart1 = Highcharts.chart('container', {
            chart: {
                type: type
            },
            title: {
                text: '每日登录'
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: [<?php echo "'".implode("','", $dayList)."'";?>]
            },
            yAxis: [{ // Primary yAxis
                labels: {
                    format: '{value}',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                },
                title: {
                    text: '数值',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                }
            }, { // Secondary yAxis
                title: {
                    text: '百分比',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                },
                labels: {
                    format: '{value} %',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                },
                opposite: true
            }],
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name: '安卓FB每日登陆',
                data: [<?php echo implode(",", $list['af']);?>]
            },{
                name: '安卓游客每日登陆',
                data: [<?php echo implode(",", $list['av']);?>]
            },
            //{
            //    name: '安卓LINE每日登陆',
            //    data: [<?php //echo implode(",", $list['al']);?>//]
            //},
            //    {
            //    name: '华为每日登陆',
            //    data: [<?php //echo implode(",", $list['ah']);?>//]
            //}, {
            //    name: '靠谱每日登陆',
            //    data: [<?php //echo implode(",", $list['ak']);?>//]
            //},{
            //    name: '华为海外每日登陆',
            //    data: [<?php //echo implode(",", $list['hwos']);?>//]
            //},
                {
                name: '苹果FB每日登陆',
                data: [<?php echo implode(",", $list['if']);?>]
            },{
                name: '苹果游客每日登录',
                data: [<?php echo implode(",", $list['iv']);?>]
            },{
                name: 'VIVO每日登陆',
                data: [<?php echo implode(",", $list['vivo_android']);?>]
            },
            //    {
            //    name: '苹果LINE每日登录',
            //    data: [<?php //echo implode(",", $list['il']);?>//]
            //},
                {
                name: '每日登录汇总',
                data: [<?php echo implode(",", $sumList);?>]
            }
            // ,{
            //     name: '每日登录成功率(%)',
            //     data: [<?php echo implode(",", $list['login']);?>],
            //     yAxis: 1,
            //     tooltip: {
            //         valueSuffix: '%'
            //     }
            // }
            ]
        });
    }

    $(document).on("click","#all_checked1",function(){
        $(".highcharts-legend-item").each(function(index){
            chart1.series[index].show();//显示
        })
    })
    $(document).on("click","#all_no_checked1",function(){
        $(".highcharts-legend-item").each(function(index){
            chart1.series[index].hide();//隐藏
        })
    })

    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>