
<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">
                                    <a style="margin:5px;" class="btn btn-success <?php if($type == ''){echo 'active';}?>" href="#statistics/cardSta/<?php echo $uid;?>" role="button">全部</a>
                                    <a style="margin:5px;" class="btn btn-success <?php if($type == 'cardGold'){echo 'active';}?>" href="#statistics/cardSta/<?php echo empty($uid)?0:$uid;?>/cardGold" 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" role="form" method="post" action="">
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>用户UID:</label>
                                            <input type="text" class="form-control" placeholder="用户UID" name="userid" id="userid" value="<?php echo $uid ?? '';?>">
                                        </div>
                                        <span class="gap"></span>
                                        <button type="button" class="btn btn-primary" id="submitButton">查询</button>

                                        <button type="button" class="btn btn-success" id="exportAllData">导出存量数据</button>
                                        <button type="button" class="btn btn-success" id="exportAllData2">导出用户量数据</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: 600px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>
                    <?php if(empty($uid)){ ?>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container2" style="min-width: 310px; height: 600px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>

                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container3" style="min-width: 310px; height: 600px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>
                    <?php }     ?>
                </aside>
            </div>
        </div>
    </div>
</div>
</div>
<!--<script type="text/javascript" src="--><?php //echo base_url();?><!--public/js/highcharts/highcharts.js"></script>-->
<script src="https://code.highcharts.com.cn/highstock/highstock.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.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">
    $('#submitButton').click(function () {
        var uid = $('#userid').val();
        if(uid == ""){
            window.location.href = '#statistics/cardSta/0/<?php echo $type; ?>'
        }else if(uid > 100000){
            window.location.href = '#statistics/cardSta/'+ uid + "/<?php echo $type; ?>";
        }
    });

    $(document).on("click","#exportAllData",function(){
        window.location.href = '/Export/cardSta/<?php echo empty($uid)?0:$uid; ?>/<?php echo empty($type)?'card':$type; ?>/1';
    });

    $(document).on("click","#exportAllData2",function(){
        window.location.href = '/Export/cardSta/<?php echo empty($uid)?0:$uid; ?>/<?php echo empty($type)?'card':$type; ?>';
    });

    //设置图表导出格式选项
    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: ''
        }
    });

    $('#container').highcharts( {
        chart: {
            type: 'column',
            zoomType: 'x'
        },
        title: {
            text: '存量'
        },
        xAxis: {
            type: 'category',
            labels: {
                rotation: -45  // 设置轴标签旋转角度
            },
            scrollbar: {
                enabled: true
            },
            min: 0,
            max: 70,
        },
        yAxis: {
            min: 0,
            title: {
                text: '存量(张)'
            },
            scrollbar: {
                enabled: true
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '：</b><br/>' + this.point.y + '张<br/><b>卡片信息：</b><br/>星级：'+this.series.userOptions.data[this.point.x][2]+'<br/></b>解锁等级：'+this.series.userOptions.data[this.point.x][3]
                    +'<br/></b>卡片ID：'+this.series.userOptions.data[this.point.x][4]
                    +'<br/></b>卡片名称：'+this.series.userOptions.data[this.point.x][5];
            }
        },
        series: [{
            name: '存量',
            data: [
                <?php foreach ($data['card'] as $k => $row){
                $row['ci_name_zh'] = (str_replace(["\n","\\n","\r","
                    "],"",$row['ci_name_zh']));
                    echo "['".$row['ci_name_zh']."[".$k."]"."',{$row['num']},{$row['ci_star_rank']},{$row['ci_lockRank']},{$k},'{$row['ci_name_zh']}'],";
                } ?>
            ],
            // dataLabels: {
            //     enabled: true,
            //     rotation: -90,
            //     color: '#FFFFFF',
            //     align: 'right',
            //     format: '{point.y}', // :.1f 为保留 1 位小数
            //     y: 10
            // }
        }]
    });

    <?php if(empty($uid)){ ?>

    Highcharts.chart('container2', {
        chart: {
            type: 'column'
        },
        title: {
            text: '拥有用户'
        },
        xAxis: {
            type: 'category',
            labels: {
                rotation: -45  // 设置轴标签旋转角度
            },
            scrollbar: {
                enabled: true
            },
            min: 0,
            max: 70,
        },
        yAxis: {
            min: 0,
            title: {
                text: '用户量(张)'
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '：</b><br/>' + this.point.y + '个<br/><b>卡片信息：</b><br/>星级：'+this.series.userOptions.data[this.point.x][2]+'<br/></b>解锁等级：'+this.series.userOptions.data[this.point.x][3]
                    +'<br/></b>卡片ID：'+this.series.userOptions.data[this.point.x][4]
                    +'<br/></b>卡片名称：'+this.series.userOptions.data[this.point.x][5];
            }
        },
        series: [{
            name: '用户量',
            data: [
                <?php foreach ($data['card'] as $k => $row){
                	echo "['".$row['ci_name_zh']."[".$k."]"."',{$row['owner']},{$row['ci_star_rank']},{$row['ci_lockRank']},{$k},'{$row['ci_name_zh']}'],";
                } ?>
            ],
            // dataLabels: {
            //     enabled: true,
            //     rotation: -90,
            //     color: '#FFFFFF',
            //     align: 'right',
            //     format: '{point.y}', // :.1f 为保留 1 位小数
            //     y: 10
            // }
        }]
    });

    Highcharts.chart('container3', {
        chart: {
            type: 'column'
        },
        title: {
            text: '进度分布'
        },
        xAxis: {
            type: 'category',
            labels: {
                rotation: 0  // 设置轴标签旋转角度
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '进度分布'
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name+'</b><br/>' + this.point.y + '个'
            }
        },
        series: [{
            name: '进度',
            data: [
                <?php foreach ($data['group'] as $key=>$row){
                    echo "[{$key},{$row}],";
                } ?>
            ],
            dataLabels: {
                enabled: true,
                rotation: -90,
                color: '#FFFFFF',
                align: 'right',
                format: '{point.y}', // :.1f 为保留 1 位小数
                y: 10
            }
        }]
    });
    <?php } ?>
</script>