var data1=[12,25,69,78,63,30];
var data2=[120,25,619,78,33,30];
var data3=[112,255,69,748,45,25];
var data4=[102,25,697,789,89,78];
$("#today").on('click',function(){
	$(this).css('color','dodgerblue');
	$(this).siblings('p').css('color','#A9A9A9');
    $.ajax({
        url:'/statistics/getChartInfo',
        dataType:'JSON',
        method:'POST',
		data:{operateType:1},
        success:function (data) {
            var code = data.code;
            if(code=='200'){
                var count1=data.data.info;
                var myArray=new Array()
                for(var i in count1){
                    myArray.push(count1[i]);
                }
                zhexiantu(myArray);
            }else{
                layer.msg('添加失败'+data.msg);
            }
        },
    });
})
$("#weeked").on('click',function(){
	$(this).css('color','dodgerblue');
	$(this).siblings('p').css('color','#A9A9A9');
    $.ajax({
        url:'/statistics/getChartInfo',
        dataType:'JSON',
        method:'POST',
        data:{operateType:2},
        success:function (data) {
            var code = data.code;
            if(code=='200'){
                var count1=data.data.info;
                var myArray=new Array()
                for(var i in count1){
                    myArray.push(count1[i]);
                }
                zhexiantu(myArray);
            }else{
                layer.msg('添加失败'+data.msg);
            }
        },
    });
})
$("#month").on('click',function(){
	$(this).css('color','dodgerblue');
	$(this).siblings('p').css('color','#A9A9A9');
    $.ajax({
        url:'/statistics/getChartInfo',
        dataType:'JSON',
        method:'POST',
        data:{operateType:3},
        success:function (data) {
            var code = data.code;
            if(code=='200'){
                var count1=data.data.info;
                var myArray=new Array()
                for(var i in count1){
                    myArray.push(count1[i]);
                }
                zhexiantu(myArray);
            }else{
                layer.msg('添加失败'+data.msg);
            }
        },
    });
})
$("#year").on('click',function(){
	$(this).css('color','dodgerblue');
	$(this).siblings('p').css('color','#A9A9A9');
    $.ajax({
        url:'/statistics/getChartInfo',
        dataType:'JSON',
        method:'POST',
        data:{operateType:4},
        success:function (data) {
            var code = data.code;
            if(code=='200'){
                var count1=data.data.info;
                var myArray=new Array()
                for(var i in count1){
                    myArray.push(count1[i]);
                }
                zhexiantu(myArray);
            }else{
                layer.msg('添加失败'+data.msg);
            }
        },
    });
})
// 柱状图
function zhexiantu(yData) {
	//初始化
	var myChart = echarts.init(document.getElementById("photo_money"));
	//自适应
	window.onload = myChart.resize;
	//数据配置
	option = {
		grid: {
			left: '3%',
			right: '4%',
			bottom: '3%',
			top: '10%',
			containLabel: true
		},
		xAxis: {
			type: 'category',
            data: ['志愿者总服务次数', '志愿者总数', '志愿者服务总时长', '志愿者团队总数','团队总服务次数','团队总服务时长'],
            axisLabel: {
                interval: 0,    //强制文字产生间隔
                rotate: 0,     //文字逆时针旋转45°
                textStyle: {    //文字样式
                    color: "black",
                    fontSize: 12,
                    fontFamily: 'Microsoft YaHei'
                }
            }

		},
		yAxis: {
			type: 'value'
		},
		series: [{
			data: yData,
			type: 'bar',
			barWidth: 50,
			itemStyle: {
				normal: {
					color: 'dodgerblue'
				}
			},
			label: {
				normal: {
					show: true,
					position: 'top'
				}
			}
		}]
	};
	myChart.setOption(option);
}
$(function(){
    $.ajax({
        url:'/statistics/getChartInfo',
        dataType:'JSON',
        method:'POST',
        data:{operateType:1},
        success:function (data) {
            var code = data.code;
            if(code=='200'){
            	var count1=data.data.info;
                var myArray=new Array()
				for(var i in count1){
                	myArray.push(count1[i]);
				}
                zhexiantu(myArray);
            }else{
                layer.msg('添加失败'+data.msg);
            }
        },
    });
})

