<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<style>
	.my-btn{position: absolute;right: 20px;top:10px;background-color: #32a3d8;border:0;padding: 7px 10px;color: #fff;}
	.charts-box{width:500px;height:400px;display: inline-block;position: relative;margin-right: 40px;margin-bottom: 40px;}
	.charts-box1{width:1045px;height:400px;display: inline-block;position: relative;margin-right: 40px;margin-bottom: 40px;}
	.select-date{position: absolute;right: 120px;top: 10px;border: 1px solid rgba(0,0,0,.1);padding: 5px 10px;width: 100px;background: url(http://s.iamberry.com/images/select-1.png) 95px center no-repeat;background-size:auto 100%;}
</style>
<title>柱状图统计</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 统计管理 <span class="c-gray en">&gt;</span> 销售统计 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px;background-color: #32a3d8;border: 1px solid #32a3d8;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div>
		<div class="charts-box">
	<div id="container" style="width:500px;height:400px;display: inline-block;">
	</div>
	<button type="button" class="my-btn" id="btn-1">查看折线图</button>
	</div>
	
	<div class="charts-box">
	<div id="container1" style="width:500px;height:400px;display: inline-block;">
	</div>
	<button type="button" class="my-btn" id="btn-2">查看饼状图</button>
	</div>
	
	</div>
	
	<div>
		
	<div class="charts-box1">
	<div id="container2" style="width:1045px;height:400px;display: inline-block;">
	</div>
	<input type="text" value="" placeholder="选择月份" class="select-date" onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM',maxDate:'%y-%M',minDate:'%y-01',onpicked:updateMonthList})" id="select-month" readonly="readonly"/>
	<button type="button" class="my-btn" id="btn-3">查看饼状图</button>
	</div>
	
	<div class="charts-box1">
	<div id="container3" style="width:1045px;height:400px;display: inline-block;">
	</div>
	<button type="button" class="my-btn" id="btn-4">查看饼状图</button>
	</div>
	
	</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/hcharts/Highcharts/5.0.6/js/highcharts.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    var chartType='pie',chartType1='spline',chartType2='spline',chartType3='spline';
	var chart=null;
	var chart1=null;
    var chart2=null;
    var chart3=null;

	//本周
    var week_red_sum2 = 0;
    var week_black_sum2 = 0;
    var week_blue_sum2 = 0;
    var week_sum = 0,week_date = new Array(),week_red = new Array(),week_black = new Array(),week_blue = new Array(),week_num = new Array();

    //上周
    var last_week_red_sum2 = 0;
    var last_week_black_sum2 = 0;
    var last_week_blue_sum2 = 0;
    var last_week_sum = 0,last_week_date = new Array(),last_week_red = new Array(),last_week_black = new Array(),last_week_blue = new Array(),last_week_num = new Array();

    //月
    var month_red_sum2 = 0;
    var month_black_sum2 = 0;
    var month_blue_sum2 = 0;
    var month_sum = 0,month_date = new Array(),month_red = new Array(),month_black = new Array(),month_blue = new Array(),month_num = new Array();

    //年
    var year_red_sum2 = 0;
    var year_black_sum2 = 0;
    var year_blue_sum2 = 0;
    var year_sum = 0,year_date = new Array(),year_red = new Array(),year_black = new Array(),year_blue = new Array(),year_num = new Array();
    $(function () {

		$.ajax({
			url: "/tooth/admin/orderStatistics/select_order_statistics",
			dataType:"json",
			type:"get",
			success: function(data){
				//上周
				var last_week = data.data.listLastWeekNum;
				$.each(last_week, function(i,item){
					last_week_date[i] = valueDate(this.salesDate);
					last_week_red[i] = this.salesRedNum;
					last_week_black[i] = this.salesBlackNum;
					last_week_blue[i] = this.salesBlueNum;
					last_week_num[i] = this.salesNum;
					last_week_sum += this.salesNum;
					last_week_red_sum2 += this.salesRedNum;
					last_week_black_sum2 += this.salesBlackNum;
					last_week_blue_sum2 += this.salesBlueNum;
				});
                last_week_line(last_week_sum,last_week_date,last_week_red,last_week_black,last_week_blue,last_week_num);
				//本周
                var week = data.data.listWeekNum;
                $.each(week, function(i,item){
                    week_date[i] = valueDate(this.salesDate);
                    week_red[i] = this.salesRedNum;
                    week_black[i] = this.salesBlackNum;
                    week_blue[i] = this.salesBlueNum;
                    week_num[i] = this.salesNum;
                    week_sum += this.salesNum;
                    week_red_sum2 += this.salesRedNum;
                    week_black_sum2 += this.salesBlackNum;
                    week_blue_sum2 += this.salesBlueNum;
                });
                week_sector(week_sum,week_red_sum2,week_black_sum2,week_blue_sum2);
                //年统计
				var year = data.data.listYearNum;
                $.each(year, function(i,item){
                    year_date[i] = this.salesMonth;
                    year_red[i] = this.salesRedNum;
                    year_black[i] = this.salesBlackNum;
                    year_blue[i] = this.salesBlueNum;
                    year_num[i] = this.salesNum;
                    year_sum += this.salesNum;
                    year_red_sum2 += this.salesRedNum;
                    year_black_sum2 += this.salesBlackNum;
                    year_blue_sum2 += this.salesBlueNum;
                });
                year_date = valuemonth(year_date);
                year_line(year_sum,year_date,year_red,year_black,year_blue,year_num);

			},
			error:function(data){
				//alert("操作失败，请查看网络是否正常！");
			}
		});

        selectMonthList();
});

    var week_sector = function (week_sum,week_red_sum2,week_black_sum2,week_blue_sum2){
		//第一个图
        chart = new Highcharts.Chart('container', {
            chart: {
                backgroundColor:'#f5f5f5'
            },
            title: {
                text: '本周销售统计'
            },
            subtitle: {
                text: '共销售' + week_sum + '台机器'
            },
            tooltip: {
                pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'WaterO',
                colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                data: [
                    ['红色',week_red_sum2],
                    ['黑色',week_black_sum2],
                    ['蓝色',week_blue_sum2]]
            }]
        });
	}

    //第一个图 按钮点击事件
    $('#btn-1').click(function () {
        chart.destroy ();
        if(chartType=='pie'){
            chartType='spline';
            $(this).text('查看饼状图');
            chart = new Highcharts.Chart('container', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: '本周销售统计'
                },
                subtitle: {
                    text: '共销售' + week_sum + '台机器'
                },
                xAxis: {
                    categories: week_date
                },
                yAxis: {
                    title: {
                        text: '数量'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    pointFormat: '{point.y}台'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: '本周总销量',
                    data: week_num,
                    color:'#fba62e'
                }, {
                    name: '蓝色销量',
                    data: week_blue,
                    color:'#32a3d8'
                }, {
                    name: '红色销量',
                    data: week_red,
                    color:'#f96268'
                }, {
                    name: '黑色销量',
                    data: week_black,
                    color:'#464646'
                }]
            });
        }else{
            chartType='pie';
            $(this).text('查看折线图');
            chart = Highcharts.chart('container', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: '本周销售统计'
                },
                subtitle: {
                    text: '共销售' + week_sum + '台机器'
                },
                tooltip: {
                    pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'WaterO',
                    colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                    data: [
                        ['红色',   week_red_sum2],
                        ['黑色',   week_black_sum2],
                        ['蓝色',   week_blue_sum2]]
                }]
            });
        }
    });

	var last_week_line = function (last_week_sum,last_week_date,last_week_red,last_week_black,last_week_blue,last_week_num) {
        //第二个图
        chart1 = new Highcharts.Chart('container1', {
            chart: {
                backgroundColor:'#f5f5f5'
            },
            title: {
                text: '上周销售统计'
            },
            subtitle: {
                text: '共销售' + last_week_sum + '台机器'
            },
            xAxis: {
                categories: last_week_date
            },
            yAxis: {
                title: {
                    text: '数量'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                pointFormat: '{point.y}台'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: [{
                name: '上周总销量',
                data: last_week_num,
                color:'#fba62e'
            }, {
                name: '蓝色销量',
                data: last_week_blue,
                color:'#32a3d8'
            }, {
                name: '红色销量',
                id: 'berlin',
                data: last_week_red,
                color:'#f96268'
            }, {
                name: '黑色销量',
                data: last_week_black,
                color:'#464646'
            }]
        });
	}

    //第二个图按钮点击事件
    $('#btn-2').click(function () {
        chart1.destroy ();
        if(chartType1=='spline') {
            chartType1 = 'pie';
            $(this).text('查看折线图');
            chart1 = new Highcharts.Chart('container1', {
                chart: {
                    backgroundColor: '#f5f5f5'
                },
                title: {
                    text: '上周销售统计'
                },
                subtitle: {
                    text: '共销售' + last_week_sum + '台机器'
                },
                tooltip: {
                    pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'WaterO',
                    colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                    data: [
                        ['红色', last_week_red_sum2],
                        ['黑色', last_week_black_sum2],
                        ['蓝色', last_week_blue_sum2]]
                }]
            });
        } else {
            chartType1='spline';
            $(this).text('查看饼状图');
            chart1 = Highcharts.chart('container1', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: '上周销售统计'
                },
                subtitle: {
                    text: '共销售' + last_week_sum + '台机器'
                },
                xAxis: {
                    categories: last_week_date
                },
                yAxis: {
                    title: {
                        text: '数量'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    pointFormat: '{point.y}台'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: '本周总销量',
                    data: last_week_num,
                    color:'#fba62e'
                }, {
                    name: '蓝色销量',
                    data: last_week_blue,
                    color:'#32a3d8'
                }, {
                    name: '红色销量',
                    data: last_week_red,
                    color:'#f96268'
                }, {
                    name: '黑色销量',
                    data: last_week_black,
                    color:'#464646'
                }]
            });
		}
    });

	var year_line = function (year_sum,year_date,year_red,year_black,year_blue,year_num) {
        var date=new Date;
        var year=date.getFullYear();
        //第四个图
        chart3 = new Highcharts.Chart('container3', {
            chart: {
                backgroundColor:'#f5f5f5'
            },
            title: {
                text: year + '年销售数量'
            },
            subtitle: {
                text: '共销售' + year_sum + '台机器'
            },
            xAxis: {
                categories: year_date
            },
            yAxis: {
                title: {
                    text: '数量'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                pointFormat: '{point.y}台'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: [{
                name: year + '年总销量',
                data: year_num,
                color:'#fba62e'
            }, {
                name: '蓝色销量',
                data: year_blue,
                color:'#32a3d8'
            }, {
                name: '红色销量',
                data: year_red,
                color:'#f96268'
            }, {
                name: '黑色销量',
                data: year_black,
                color:'#464646'
            }]
        });
	}

    //第四个图按钮点击事件
    $('#btn-4').click(function () {
        var date=new Date;
        var year=date.getFullYear();
        chart3.destroy ();
        if(chartType3=='pie'){
            $(this).text("查看饼状图");
            chartType3='spline';
            chart3 = Highcharts.chart('container3', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: year + '年销售数量'
                },
                subtitle: {
                    text: '共销售' + year_sum + '台机器'
                },
                xAxis: {
                    categories: year_date
                },
                yAxis: {
                    title: {
                        text: '数量'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    pointFormat: '{point.y}台'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: year + '年总销量',
                    data: year_num,
                    color:'#fba62e'
                }, {
                    name: '蓝色销量',
                    data: year_blue,
                    color:'#32a3d8'
                }, {
                    name: '红色销量',
                    data: year_red,
                    color:'#f96268'
                }, {
                    name: '黑色销量',
                    data: year_black,
                    color:'#464646'
                }]
            });
        }else{
            chartType3='pie';
            chart3 = Highcharts.chart('container3', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: year + '年销售数量'
                },
                subtitle: {
                    text: '共销售' + year_sum + '台机器'
                },
                tooltip: {
                    pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'WaterO',
                    colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                    data: [
                        ['红色',   year_red_sum2],
                        ['黑色',   year_black_sum2],
                        ['蓝色',   year_blue_sum2]]
                }]
            });
        }
    });

	function selectMonthList() {
	    var select_month = $('#select-month').val();
	    if (select_month == null || select_month == '') {
            var now = format(new Date());
            $('#select-month').val(now);
            select_month = now;
		}
        var text_month = select_month.substring(5,7);
		var data_month = {
	        "month":select_month
		}

        $.ajax({
            url: "/tooth/admin/orderStatistics/select_order_by_month",
            dataType:"json",
            type:"get",
            data:data_month,
            success: function(data){
                //月
				var month_data = data.data;
				 $.each(month_data, function(i,item){
                     month_date[i] = valueDate(this.salesDate);
                     month_red[i] = this.salesRedNum;
                     month_black[i] = this.salesBlackNum;
                     month_blue[i] = this.salesBlueNum;
                     month_num[i] = this.salesNum;
                     month_sum += this.salesNum;
                     month_red_sum2 += this.salesRedNum;
                     month_black_sum2 += this.salesBlackNum;
                     month_blue_sum2 += this.salesBlueNum;
				 });
                month_line(text_month,month_sum,month_date,month_red,month_black,month_blue,month_num);
            },
            error:function(data){
                //alert("操作失败，请查看网络是否正常！");
            }
        });
	}

	function month_line(text_month,month_sum,month_date,month_red,month_black,month_blue,month_num) {
        //第三个图
        chart2 = new Highcharts.Chart('container2', {
            chart: {
                backgroundColor:'#f5f5f5'
            },
            title: {
                text: text_month + '月销售数量'
            },
            subtitle: {
                text: '共销售' + month_sum + '台机器'
            },
            xAxis: {
                categories: month_date
            },
            yAxis: {
                title: {
                    text: '数量'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                pointFormat: '{point.y}台'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: [{
                name: text_month + '月总销量',
                data: month_num,
                color:'#fba62e'
            }, {
                name: '蓝色销量',
                data: month_blue,
                color:'#32a3d8'
            }, {
                name: '红色销量',
                data: month_red,
                color:'#f96268'
            }, {
                name: '黑色销量',
                data: month_black,
                color:'#464646'
            }]
        });
	}

    //第三个图按钮点击事件
    $('#btn-3').click(function () {
        var select_month = $('#select-month').val();
        var text_month = select_month.substring(5,7);
        chart2.destroy ();
        if(chartType2=='pie'){
            $(this).text("查看饼状图");
            chartType2='spline';
            chart2 = Highcharts.chart('container2', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: text_month + '月销售数量'
                },
                subtitle: {
                    text: '共销售' + month_sum + '台机器'
                },
                xAxis: {
                    categories: month_date
                },
                yAxis: {
                    title: {
                        text: '数量'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    pointFormat: '{point.y}台'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: text_month + '月总销量',
                    data: month_num,
                    color:'#fba62e'
                }, {
                    name: '蓝色销量',
                    data: month_blue,
                    color:'#32a3d8'
                }, {
                    name: '红色销量',
                    data: month_red,
                    color:'#f96268'
                }, {
                    name: '黑色销量',
                    data: month_black,
                    color:'#464646'
                }]
            });
        }else{
            chartType2='pie';
            $(this).text("查看折线图");
            chart2 = Highcharts.chart('container2', {
                chart: {
                    backgroundColor:'#f5f5f5'
                },
                title: {
                    text: text_month + '月销售数量'
                },
                subtitle: {
                    text: '共销售' + month_sum + '台机器'
                },
                tooltip: {
                    pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'WaterO',
                    colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                    data: [
                        ['红色',   month_red_sum2],
                        ['黑色',   month_black_sum2],
                        ['蓝色',   month_blue_sum2]]
                }]
            });
        }

    });

    //选择月份事件请加载my97日期控件（写在回调里头）
    function updateMonthList() {
        var select_month = $('#select-month').val();
        var text_month = select_month.substring(5,7);
        var data_month = {
            "month":select_month
        }
        $.ajax({
            url: "/tooth/admin/orderStatistics/select_order_by_month",
            dataType:"json",
            type:"get",
            data:data_month,
            success: function(data){
                //月
                var month_data = data.data;
                month_sum = 0;
                month_red_sum2 = 0;
                month_black_sum2 = 0;
                month_blue_sum2 = 0;
                month_date = [];
                month_red = [];
                month_black = [];
                month_blue = [];
                month_num = [];
                $.each(month_data, function(i,item){
                    month_date[i] = valueDate(this.salesDate);
                    month_red[i] = this.salesRedNum;
                    month_black[i] = this.salesBlackNum;
                    month_blue[i] = this.salesBlueNum;
                    month_num[i] = this.salesNum;
                    month_sum += this.salesNum;
                    month_red_sum2 += this.salesRedNum;
                    month_black_sum2 += this.salesBlackNum;
                    month_blue_sum2 += this.salesBlueNum;
                });
                if(chartType2=='pie'){
                    chart2.update({
                        chart: {
                            backgroundColor:'#f5f5f5'
                        },
                        title: {
                            text: text_month + '月销售数量'
                        },
                        subtitle: {
                            text: '共销售' + month_sum + '台机器'
                        },
                        tooltip: {
                            pointFormat: '{point.y}台: <b>{point.percentage:.1f}%</b>'
                        },
                        plotOptions: {
                            pie: {
                                allowPointSelect: true,
                                cursor: 'pointer',
                                dataLabels: {
                                    enabled: true,
                                    color: '#000000',
                                    connectorColor: '#000000',
                                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                                }
                            }
                        },
                        series: [{
                            type: 'pie',
                            name: 'WaterO',
                            colors: ['#f96268', '#464646', '#32a3d8', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
                            data: [
                                ['红色',   month_red_sum2],
                                ['黑色',   month_black_sum2],
                                ['蓝色',   month_blue_sum2]]
                        }]
                    });
                }else{
                    chart2.destroy ();
                    chart2 = new Highcharts.Chart('container2', {
                        chart: {
                            backgroundColor:'#f5f5f5'
                        },
                        title: {
                            text: text_month + '月销售数量'
                        },
                        subtitle: {
                            text: '共销售' + month_sum + '台机器'
                        },
                        xAxis: {
                            categories: month_date
                        },
                        yAxis: {
                            title: {
                                text: '数量'
                            },
                            plotLines: [{
                                value: 0,
                                width: 1,
                                color: '#808080'
                            }]
                        },
                        tooltip: {
                            pointFormat: '{point.y}台'
                        },
                        legend: {
                            layout: 'vertical',
                            align: 'right',
                            verticalAlign: 'middle',
                            borderWidth: 0
                        },
                        series: [{
                            name: text_month + '月总销量',
                            data: month_num,
                            color:'#fba62e'
                        }, {
                            name: '蓝色销量',
                            data: month_blue,
                            color:'#32a3d8'
                        }, {
                            name: '红色销量',
                            data: month_red,
                            color:'#f96268'
                        }, {
                            name: '黑色销量',
                            data: month_black,
                            color:'#464646'
                        }]
                    });
                }
            },
            error:function(data){
                alert("操作失败，请查看网络是否正常！");
            }
        });

    };

	function valuemonth(months) {
	    var year_months = new Array();
	    for (var i = 0;i < months.length;i++) {
			switch (months[i]) {
				case "01":year_months[i] = '一月';break;
                case "02":year_months[i] = '二月';break;
                case "03":year_months[i] = '三月';break;
                case "04":year_months[i] = '四月';break;
                case "05":year_months[i] = '五月';break;
                case "06":year_months[i] = '六月';break;
                case "07":year_months[i] = '七月';break;
                case "08":year_months[i] = '八月';break;
                case "09":year_months[i] = '九月';break;
                case "10":year_months[i] = '十月';break;
                case "11":year_months[i] = '十一月';break;
                default:year_months[i] = '十二月';break;
			}
		}
		return year_months;
	}

function valueDate(now) {
    now = new Date(now);
    var month=now.getMonth()+1;
    var date=now.getDate();
    return month+"."+date;
}

    function format(now)   {
        now = new Date(now);
        var   year=now.getFullYear();
        var   month=now.getMonth()+1;
        var   date=now.getDate();
        if (month < 10) {
            month = '0' + month;
		}
        return   year+"-"+month;
    }
</script>
</body>
</html>