$(function(){
     init("polygon","北涵洞1号传感器","../images/bei1.bmp")
     update("polygon1","北涵洞1号传感器","../images/bei1.bmp");
     update("polygon2","北涵洞2号传感器","../images/bei2.bmp");
     update("polygon3","北涵洞3号传感器","../images/bei3.bmp");
     update("polygon4","北涵洞4号传感器","../images/bei4.bmp");
    });
     function init(polygon,title,image,arr) {
            Highcharts.setOptions({
               colors: ['white','#bdeafd', '#FF0000', '#FF0000']
            });
            var polygonchart1 = new Highcharts.Chart({
                chart: {
                    renderTo: polygon,
                    plotBackgroundColor:'#a59152',
                    type: 'areaspline'
                    //plotBackgroundImage: image
                },
                title: {
                    text: title+'位置变化量'
                },
                xAxis: {
                	max:3,
                	min:0,
                    title: {
                        text: null
                    }
                    
                },
                yAxis: {
                    tickInterval: 0.5,
                    max: 3.5,
                    min: 0,
                    title: {
                        rotation: 0,
                        text:null
                    }
                   
                },
                tooltip: {
                    formatter: function () {
                        return  ' <b>位移大小: ' + this.y+ '毫米';
                    }
                },
                credits: {
                    enabled: false
                },
                
                series: [{
		                name: "原始涵洞",
		                type: 'areaspline',
		                data: [{x:0.2,y:0},{x:0.4,y:1.4},{x:0.6,y:2},{x:1.5,y:2.8},{x:2.4,y:2},{x:2.6,y:1.4},{x:2.8,y:0}],
		                dataLabels: {
                          enabled: true,
                          rotation: 0,
                          color: 'black',
                          align: 'center',
                          style: {   
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 3px black'
                          }}},{
                        name: "变化后涵洞",
		                type: 'areaspline',
		                data: arr,
		                color:'#bdeafd',
		                dataLabels: {
                          enabled: true,
                          rotation: 0,
                          color: 'black',
                          align: 'center',
                          x: 0,
                          y: 20,   
                          style: {   
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 3px black'
                          }}}]
            });
        }
        
        function update(polygon,title,image){
         var arr = [];var shuzi = null;
         var rd=parseFloat(Math.random(1)*0.01).toFixed(4);
         switch(polygon){
         case "polygon1": shuzi=2.78;break;
         case "polygon2": shuzi=2.79;break;
         case "polygon3": shuzi=2.78;break;
         case "polygon4": shuzi=2.78;break;
         }
         var rddd = (parseFloat(rd)+parseFloat(shuzi)).toExponential(4);
         arr.push({x:0.2,y:0});
         arr.push({x:0.4,y:1.4});
         arr.push({x:0.6,y:2});
         arr.push({x:1.5,y:parseFloat(rddd)});
         arr.push({x:2.4,y:2});
         arr.push({x:2.6,y:1.4});
         arr.push({x:2.8,y:0});
         init(polygon,title,image,arr);
        };