<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">
        <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 " href="#shop/payDistributed/2" role="button">充值曲线</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#shop/payDistributed/1" role="button">充值分布 - 柱形图</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#shop/payDistributed/3" role="button">充值分布 - 饼图</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#shop/payDistributed/4" role="button">充值分布 - 时间累计</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#shop/payDistributed/5" role="button">钻石消耗 - 柱形图</a>
                        </div>
                    </div>
                </div>
            </section>
        </aside>
        <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="/#shop/payDistributed/4">
										<input type="hidden" name="fromsta_np" 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_np_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_np_etime" />
                                        </div>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
 
            <div class="col-sm-6">
                <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>
                </aside>
            </div>
            
            <div class="col-sm-6">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>充值分析归类</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="containerSum" style="min-width: 310px; height: 600px; margin: 0 auto"></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">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
	
	/*
	// 创建渐变色
	Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function (color) {
		return {
			radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
			stops: [
				[0, color],
				[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
			]
		};
	});
	*/
	

		
		// 构建图表
		var chart = Highcharts.chart('container',{
			title: {
				text: '充值总值<?php echo array_sum($shopPercent);?>'
			},
			tooltip: {
				pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
			},
			plotOptions: {
				pie: {
					allowPointSelect: true,
					cursor: 'pointer',
					dataLabels: {
						enabled: true,
						format: '<b>{point.name}</b>: {point.percentage:.1f} %',
						style: {
							color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
						},
						connectorColor: 'silver'
					}
				}
			},
			series: [{
				type: 'pie',
				name: '商品充值占比',
				data: [
					<?php
						foreach($shopPercent as $p_k => $p_v){
					?>
					{
						name: '<?php echo $good[$p_k]; ?>',
						sliced: true,
						selected: true,
						y:<?php echo $p_v / array_sum($shopPercent); ?>
					},
					<?php
						}
					?>
				]
			}]
		});
		
		// 构建图表
		var chartSum = Highcharts.chart('containerSum',{
			title: {
				text: '充值总值<?php echo array_sum($shopPercentSum);?>'
			},
			tooltip: {
				pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
			},
			plotOptions: {
				pie: {
					allowPointSelect: true,
					cursor: 'pointer',
					dataLabels: {
						enabled: true,
						format: '<b>{point.name}</b>: {point.percentage:.1f} %',
						style: {
							color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
						},
						connectorColor: 'silver'
					}
				}
			},
			series: [{
				type: 'pie',
				name: '商品充值占比',
				data: [
					<?php
						foreach($shopPercentSum as $p_k => $p_v){
					?>
					{
						name: '<?php echo $goodsSum[$p_k]; ?>',
						sliced: true,
						selected: true,
						y:<?php echo $p_v / array_sum($shopPercentSum); ?>
					},
					<?php
						}
					?>
				]
			}]
		});
	
</script>
