<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>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#welcome/keydataDetail/<?php echo $key;?>">
                                        <input type="hidden" value="1" name="detail_post" />
                                        <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="detail_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="detail_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><?php echo  $keyName ?? ''?></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 class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>ARPU和ARPPU</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container-AR" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                            <button type="button" class="btn btn-primary" id="all_checked2">全选</button>
                            <button type="button" class="btn btn-primary" id="all_no_checked2">全不选</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer2()">折线图</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer2('column')">柱形图</button>
                        </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-FP" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                        </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">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    var chart1 = null;
    initContainer();
    function initContainer(type = 'line') {
        chart1 = $('#container').highcharts({
            chart: {
                type:type
            },
            title: {
                text: '<?php echo $keyName ?? ''?>'
            },
            subtitle: {
                text: '左坐标轴数量，右坐标轴百分比'
            },
            xAxis: [{
                categories: [<?php echo "'" . implode("','", $dayList) . "'";?>],
                crosshair: true
            }],
            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
            }],
            tooltip: {
                shared: true
            },

            series: [<?php echo $str;?>
            ]
        });
    }

    var chart2 = null;
    initContainer2();
    function initContainer2(type = 'line') {
        chart2 = Highcharts.chart('container-AR', {
            chart: {
                type: type
            },
            title: {
                text: 'ARPU和ARPPU'
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: [<?php echo "'" . implode("','", $dayList) . "'";?>]
            },
            yAxis: {
                title: {
                    text: '数值'
                }
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [<?php echo $str2 ?? '';?>]
        });
    }

    $(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();//隐藏
        })
    })
    $(document).on("click","#all_checked2",function(){
        $(".highcharts-legend-item").each(function(index){
            chart2.series[index].show();//显示
        })
    })
    $(document).on("click","#all_no_checked2",function(){
        $(".highcharts-legend-item").each(function(index){
            chart2.series[index].hide();//隐藏
        })
    })
//    Highcharts.chart('container-FP', {
//        chart: {
//            type: 'line'
//        },
//        title: {
//            text: '首次付费'
//        },
//        subtitle: {
//            text: ''
//        },
//        xAxis: {
//            categories: [<?php //echo "'".implode("','", $dayList)."'";?>//]
//        },
//        yAxis: {
//            title: {
//                text: '数值'
//            }
//        },
//        plotOptions: {
//            line: {
//                dataLabels: {
//                    enabled: true
//                },
//                enableMouseTracking: false
//            }
//        },
//        series: [<?php //echo $str3 ?? '';?>//]
//    });
    $('#container-FP').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: '<?php echo $keyName ?? ''?>'
        },
        subtitle: {
            text: '左坐标轴数量，右坐标轴百分比'
        },
        xAxis: [{
            categories: [<?php echo "'".implode("','", $dayList)."'";?>],
            crosshair: true
        }],
        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
        }],
        tooltip: {
            shared: true
        },

        series: [<?php echo $str3;?>
        ]
    });

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