Advertisement
Guest User

Untitled

a guest
Aug 29th, 2011
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <h1>Rapportage uitporteringen</h1>
  2. {literal}
  3. <link href="css/jquery.jqplot.css" type="text/css" rel="stylesheet" media="screen"/>
  4. <script type="text/javascript" src="js/plugins/jqplot.pieRenderer.min.js"></script>
  5. <script type="text/javascript" src="js/plugins/jqplot.barRenderer.min.js"></script>
  6. <script type="text/javascript" src="js/plugins/jqplot.categoryAxisRenderer.min.js"></script>
  7. <script type="text/javascript" src="js/plugins/jqplot.pointLabels.min.js"></script>
  8. <script type="text/javascript">
  9. function get_port_graph(title,month, year, type, elem, chart_type)
  10. {
  11.     // clear the whole thing first!
  12.     var tmpholder = $('#'+elem).find('.options');
  13.     $('#'+elem).html('');
  14.     $('#'+elem).html(tmpholder);
  15.    
  16.    
  17.     $.load_x("nummerloket_outports_ajax.php?get_ports&type=report_per_operator&subtype="+type+"&month="+month+"&chart_type="+chart_type+'&year='+year, '', 'json', false, function(data_get) {
  18.                
  19.     if(data_get == null || data_get.rows == 0)
  20.     {          
  21.        
  22.         setTimeout(function(){ show_dialog('Geen statistieken gevonden');}, 500);          
  23.     }
  24.     else   
  25.     {
  26.    
  27.      
  28.       var data = [];
  29.      
  30.       if(chart_type == 'pie')
  31.       {    
  32.           $.each(data_get.rows, function(key, value)  
  33.           {
  34.               var elem = [];
  35.               elem.push(key,parseInt(value));
  36.               data.push(elem);
  37.        
  38.           });  
  39.        
  40.          $.jqplot (elem, [data],
  41.          {
  42.           seriesDefaults: {
  43.             renderer: jQuery.jqplot.PieRenderer,
  44.             rendererOptions: {          
  45.               fill: true,
  46.               showDataLabels: true,
  47.               sliceMargin: 3,
  48.              
  49.               lineWidth: 2
  50.             }
  51.           },
  52.           title: title,
  53.           legend: { show:true, location: 'e' },
  54.          highlighter: {
  55.            show: true,
  56.            sizeAdjust: 7.5
  57.           },
  58.           cursor: {
  59.            show: false
  60.           }
  61.         }
  62.       );
  63.       }
  64.       else if(chart_type == 'bar') 
  65.       {
  66.          var ticks = [];       
  67.          for(var cn=0; cn < months.length; cn++)
  68.          {
  69.             ticks[cn] = months[cn];
  70.          }
  71.          
  72.          var s1 = [0,0,0,0,0,0,0,0,0,0,0,0];
  73.          $.each(data_get.rows, function(key, value)  
  74.          {
  75.             s1[--key] = value;
  76.          });  
  77.          
  78.         $.jqplot(elem, [s1], {
  79.             seriesDefaults:{
  80.                 renderer:$.jqplot.BarRenderer,
  81.                 rendererOptions: {fillToZero: true},
  82.                 pointLabels: {show: true}
  83.             },
  84.             series:[
  85.                 {label:'Uitporteringen'}
  86.             ],
  87.             legend: {
  88.                 show: true,
  89.                 placement: 'outsideGrid'
  90.             },
  91.             title: title,
  92.             axes: {
  93.  
  94.                 xaxis: {
  95.                     renderer: $.jqplot.CategoryAxisRenderer,
  96.                     ticks: ticks
  97.                 },
  98.                 yaxis: {
  99.                     pad: 0,
  100.                     tickOptions: {formatString: '%d'}
  101.                 }
  102.             }
  103.         });      
  104.       }    
  105.    
  106.      
  107.     }  
  108.     var $options_div = $('#'+elem).find('.options');
  109.    
  110.     $.each($options_div, function(option)
  111.     {
  112.        
  113.     });
  114.    
  115.     $('.jqplot-title').css({'height': '165px'});
  116.     var left = $('#'+elem).find('.jqplot-event-canvas').attr('width').left + 300;
  117.    
  118.    
  119.    
  120.    
  121.     $('#'+elem).append('<div style="left: '+left+ 'px;" class="chart_options">\
  122.     <fieldset class="ui-widget ui-widget-content ui-fieldset"><legend class="ui-widget-header ui-corner-all">Opties</legend>\
  123.     <div id="'+elem+'_options">\
  124.     </fieldset>\
  125.     </div>');  
  126.            
  127.    
  128.     if($options_div)
  129.     {
  130.         $('#'+elem+'_options').append($options_div.html());
  131.         $options_div.hide();
  132.     }
  133.    
  134.     $('#'+elem+'_options').append("<button class=\'savebtn\' onclick=\'export_to_png("+elem+");\' id=\'export_'+$('#'+elem).attr('id')+'\'>Download</button>").find('.savebtn').button({ icons:
  135.                 {
  136.                     primary: "ui-icon-disk"
  137.                 }
  138.           });
  139.      
  140.       $('.option_item').each(function()
  141.         {
  142.             var $cur_val = $(this).val();
  143.             //alert($cur_val.length);
  144.             if($cur_val.length > 0)
  145.             {      
  146.                 var option = $(this).attr('id').split('option_');
  147.                 $('#'+option[1]).val(String($cur_val));    
  148.                 setTimeout(function(){$('#'+option[1]).val(String($cur_val))}, 1000);
  149.                        
  150.             }
  151.          });
  152.    
  153.        
  154.     });
  155. }
  156.  
  157. function year_chart(year)
  158. {
  159.     var d = new Date();
  160.     get_port_graph("Uitporteringen "+year,d.getMonth(), year,'outport', 'chart1', 'bar');      
  161.    
  162. }
  163.  
  164.  
  165. $(function(){
  166.     var d = new Date();
  167.     get_port_graph("Uitporteringen per operator - "+months[d.getMonth()],d.getMonth(),d.getFullYear(),'outport', 'chart2', 'pie');
  168.     year_chart(d.getFullYear());
  169.  
  170.    
  171. });
  172.  
  173.  
  174. </script>
  175.  
  176. {/literal}
  177. <div id="chart1" style="height:300px; width:650px;margin-top: 75px; border: 1px solid #ccc"><div class="options">
  178.     <input type="hidden" value="" id="option_years" class="option_item"/>
  179.     <select id="years" onchange="year_chart(this.value); $('#option_years').val(this.value);">
  180.         <option value="2011">2011</option>
  181.         <option value="2012">2012</option>
  182.         <option value="2013">2013</option>
  183.         <option value="2014">2014</option>
  184.         <option value="2015">2015</option>
  185.     </select>
  186. </div>
  187. </div>
  188. <div id="chart2" style="height:300px; width:650px;margin-top: 75px; border: 1px solid #ccc"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement