Advertisement
Guest User

Untitled

a guest
Sep 11th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.65 KB | None | 0 0
  1. <?php
  2.  
  3.         //graphdata1,2,3,4,5 contain all the appropriate data but removed for privacy.
  4.  
  5.         $title1 = "Total Calls";
  6.         $size1 = sizeof($graphdata1);
  7.        
  8.         $title2 = "Impressions";
  9.         $size2 = sizeof($graphdata2);
  10.        
  11.         $title3 = "Clicks";
  12.         $size3 = sizeof($graphdata3);
  13.        
  14.         $title4 = "Media Cost (£)";
  15.         $size4 = sizeof($graphdata4);
  16.        
  17.         $title5 = "Unanswered Calls";
  18.         $size5 = sizeof($graphdata5);
  19.        
  20.         $color = "0F9DDD";
  21.         $width = "500";
  22.         $height = "300";
  23.        
  24.         ?>
  25.        
  26.        
  27.         <html>
  28.   <head>
  29.   <!--Load the AJAX API-->
  30.     <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  31.     <script type="text/javascript">
  32.       // Load the Visualization API and the piechart package.
  33.       google.load('visualization', '1.0', {'packages':['corechart']});
  34.       // Set a callback to run when the Google Visualization API is loaded.
  35.       google.setOnLoadCallback(drawChart);
  36.       // Callback that creates and populates a data table,
  37.       // instantiates the pie chart, passes in the data and
  38.       // draws it.
  39.      
  40.       function drawChart() {
  41.           drawChart1();
  42.           drawChart2();
  43.           drawChart3();
  44.           drawChart4();
  45.           drawChart5();
  46.  
  47.       }
  48.      
  49.      
  50.       function drawChart1() {
  51.  
  52.         // Create the data table.
  53.         var data = new google.visualization.DataTable();
  54.         data.addColumn('string', 'Client');
  55.         data.addColumn('number', 'Total Calls');
  56.         data.addRows([
  57.  
  58.         <?php
  59.         for($x=0;$x<$size1-1;$x++) {
  60.        
  61.             echo "['".$graphdata1[$x][0]."', ".$graphdata1[$x][1]."],";
  62.        
  63.         }
  64.        
  65.         echo "['".$graphdata1[$size1-1][0]."', ".$graphdata1[$size1-1][1]."]";
  66.         echo "]);";
  67.    
  68.    
  69.         ?>
  70.        
  71.         // Set chart options
  72.         var options1 = {'title':'<?php echo $title1; ?>',
  73.                        'width':<?php echo $width; ?>,
  74.                        'height':<?php echo $height; ?>,
  75.                        'legend': { position: 'none' },
  76.                        'colors': ['<?php echo $color; ?>'],
  77.                        'fontName': 'Myriad Web Pro',
  78.                        'chma' : '20,15,20,20',
  79.                        'chartArea': { left: 150, width: 400}
  80.                    
  81.                        
  82.                        };
  83.  
  84.         // Instantiate and draw our chart, passing in some options.
  85.         var chart1 = new google.visualization.BarChart(document.getElementById('1g'));
  86.         chart1.draw(data, options1);
  87.       }
  88.      
  89.      
  90.      
  91.        function drawChart2() {
  92.  
  93.         // Create the data table.
  94.         var data = new google.visualization.DataTable();
  95.         data.addColumn('string', 'Client');
  96.         data.addColumn('number', 'Impressions');
  97.         data.addRows([
  98.  
  99.         <?php
  100.         for($x=0;$x<$size2-1;$x++) {
  101.        
  102.             echo "['".$graphdata2[$x][0]."', ".$graphdata2[$x][1]."],";
  103.        
  104.         }
  105.        
  106.         echo "['".$graphdata2[$size2-1][0]."', ".$graphdata2[$size2-1][1]."]";
  107.         echo "]);";
  108.    
  109.    
  110.         ?>
  111.        
  112.         // Set chart options
  113.         var options2 = {'title':'<?php echo $title2; ?>',
  114.                        'width':<?php echo $width; ?>,
  115.                        'height':<?php echo $height; ?>,
  116.                        'legend': { position: 'none' },
  117.                        'colors': ['<?php echo $color; ?>'],
  118.                        'fontName': 'Myriad Web Pro',
  119.                        'chma' : '20,15,20,20',
  120.                        'chartArea': { left: 150, width: 400}
  121.                    
  122.                        
  123.                        };
  124.  
  125.         // Instantiate and draw our chart, passing in some options.
  126.         var chart2 = new google.visualization.BarChart(document.getElementById('2g'));
  127.         chart2.draw(data, options2);
  128.       }
  129.      
  130.  
  131.      
  132.                function drawChart3() {
  133.  
  134.         // Create the data table.
  135.         var data = new google.visualization.DataTable();
  136.         data.addColumn('string', 'Client');
  137.         data.addColumn('number', 'Clicks');
  138.         data.addRows([
  139.  
  140.         <?php
  141.         for($x=0;$x<$size3-1;$x++) {
  142.        
  143.             echo "['".$graphdata3[$x][0]."', ".$graphdata3[$x][1]."],";
  144.        
  145.         }
  146.        
  147.         echo "['".$graphdata3[$size3-1][0]."', ".$graphdata3[$size3-1][1]."]";
  148.         echo "]);";
  149.    
  150.    
  151.         ?>
  152.        
  153.         // Set chart options
  154.         var options3 = {'title':'<?php echo $title3; ?>',
  155.                        'width':<?php echo $width; ?>,
  156.                        'height':<?php echo $height; ?>,
  157.                        'legend': { position: 'none' },
  158.                        'colors': ['<?php echo $color; ?>'],
  159.                        'fontName': 'Myriad Web Pro',
  160.                        'chma' : '20,15,20,20',
  161.                        'chartArea': { left: 150, width: 400}
  162.                    
  163.                        
  164.                        };
  165.  
  166.         // Instantiate and draw our chart, passing in some options.
  167.         var chart3 = new google.visualization.BarChart(document.getElementById('3g'));
  168.         chart3.draw(data, options3);
  169.       }
  170.      
  171.      
  172.                function drawChart4() {
  173.  
  174.         // Create the data table.
  175.         var data = new google.visualization.DataTable();
  176.         data.addColumn('string', 'Client');
  177.         data.addColumn('number', 'Media Cost');
  178.         data.addRows([
  179.  
  180.         <?php
  181.         for($x=0;$x<$size4-1;$x++) {
  182.        
  183.             echo "['".$graphdata4[$x][0]."', ".$graphdata4[$x][1]."],";
  184.        
  185.         }
  186.        
  187.         echo "['".$graphdata4[$size4-1][0]."', ".$graphdata4[$size4-1][1]."]";
  188.         echo "]);";
  189.    
  190.    
  191.         ?>
  192.         var formatter = new google.visualization.NumberFormat({
  193.             prefix: '£'
  194.         });
  195.         formatter.format(data,1);
  196.        
  197.         // Set chart options
  198.         var options4 = {'title':'<?php echo $title4; ?>',
  199.                        'width':<?php echo $width; ?>,
  200.                        'height':<?php echo $height; ?>,
  201.                        'legend': { position: 'none' },
  202.                        'colors': ['<?php echo $color; ?>'],
  203.                        'fontName': 'Myriad Web Pro',
  204.                        'chma' : '20,15,20,20',
  205.                        'chartArea': { left: 150, width: 400}
  206.                    
  207.                        
  208.                        };
  209.  
  210.         // Instantiate and draw our chart, passing in some options.
  211.         var chart4 = new google.visualization.BarChart(document.getElementById('4g'));
  212.         chart4.draw(data, options4);
  213.       }
  214.      
  215.      
  216.                function drawChart5() {
  217.  
  218.         // Create the data table.
  219.         var data = new google.visualization.DataTable();
  220.         data.addColumn('string', 'Client');
  221.         data.addColumn('number', 'Unanswered Calls');
  222.         data.addRows([
  223.  
  224.         <?php
  225.         for($x=0;$x<$size5-1;$x++) {
  226.        
  227.             echo "['".$graphdata5[$x][0]."', ".$graphdata5[$x][1]."],";
  228.        
  229.         }
  230.        
  231.         echo "['".$graphdata5[$size5-1][0]."', ".$graphdata5[$size5-1][1]."]";
  232.         echo "]);";
  233.    
  234.    
  235.         ?>
  236.        
  237.         // Set chart options
  238.         var options5 = {'title':'<?php echo $title5; ?>',
  239.                        'width':<?php echo $width; ?>,
  240.                        'height':<?php echo $height; ?>,
  241.                        'legend': { position: 'none' },
  242.                        'colors': ['<?php echo $color; ?>'],
  243.                        'fontName': 'Myriad Web Pro',
  244.                        'chma' : '20,15,20,20',
  245.                        'chartArea': { left: 150, width: 400}
  246.                    
  247.                        
  248.                        };
  249.  
  250.         // Instantiate and draw our chart, passing in some options.
  251.         var chart5 = new google.visualization.BarChart(document.getElementById('5g'));
  252.         chart5.draw(data, options5);
  253.       }
  254.      
  255.  
  256.     </script>
  257.   </head>
  258.  
  259.   <body style="background:transparent">
  260.     <!--Div that will hold the pie chart-->
  261.     <div id="1"><div id="1g"></div></div>
  262.     <div id="2"><div id="2g"></div></div>
  263.     <div id="3"><div id="3g"></div></div>
  264.     <div id="4"><div id="4g"></div></div>
  265.     <div id="5"><div id="5g"></div></div>
  266.  
  267.   </body>
  268. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement