function draw() {

	var from =document.getElementById("chart_report_from").value;
	var to =document.getElementById("chart_report_to").value;
	
    
	var class_id =$("#chart_class_id").val();
	var group_id=$("#chart_group_id").val();
	var classification_id=$("#chart_classification_id").val();

	var elem = document.getElementById('chart_');
	elem.style.visibility = 'visible';

	$.ajax({
		type : 'GET',
		url : 'create/draw/'+ class_id +"/"+group_id+"/"+classification_id +"/"+from+"/"+to,
		/*data : {
			'_token' : $('meta[name="csrf-token"]').attr('content')
		},
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		  },*/
		
		   
		success : function(data) {

			console.log("data.mains_", data.mains_);
			$('#draw_chart_').empty();
			var mains = data.mains_ ;
			//['Spotify', 34],
			var arr=[];


			for (var i = 0; i < mains.length; ++i) {
				var sub_arr = [];
				sub_arr[0] = mains[i].waste.name ;
				sub_arr[1] = mains[i].sum;
				arr[i] = sub_arr;

            var name = mains[i].waste.name ;
			var  sum = mains[i].sum; 
			if( mains[i].waste.unit == 'كجم') {
				$("table").find('tbody').append("<tr><td style='width:100px'>"+name+"</td> <td style='width:50px'> "+ sum +"</td> <td style='width:50px'></td></tr>");
			}else {
				$("table").find('tbody').append("<tr><td style='width:100px'>"+name+"</td> <td style='width:50px'></td> <td style='width:50px'>"+ sum +"</td></tr>");	
			}		
			}
	  
			
		console.log(data.supplier_);
		var supplier_name = data.supplier_.name;
		var class_name = data.class_.name;
		var group_name = data.group_.name;
		var classification_name = data.classification_.name;
		var from = data.from;
		var to = data.to;
		var title2 = supplier_name +" | "+class_name + " | "+group_name+" | "+classification_name+" |  الفترة من "+from+" الي  "+to + " | Chart-Report" ;
		document.getElementById("title_1").innerHTML = "تـقـريـر"; 
		document.getElementById("title_2").innerHTML = title2;

		
		





	  var data = anychart.data.set( arr );
	  // create a pie chart with the data
	  var chart = anychart.pie(data)
	  // set the chart radius making a donut chart
	  chart.innerRadius('55%');
	  //chart.legend(false);
	  chart.title('')
	  chart.container('container');
	  chart.draw();

	  


		},
		error : function(request, status, error) {
			console.log(error);
		}
	});
  
		 
	}

