1 <html>
 2   <head>
 3     <title>Legal acts by author</title>
 4     <script type="text/javascript" src="https://www.google.com/jsapi"></script>
 5     <script type="text/javascript">
 6       google.load("visualization", "1", {packages:["corechart"]});
 7       google.setOnLoadCallback(drawChart);
 8       function drawChart() {
 9         var data = new google.visualization.DataTable(),
10         chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
11 
12         data.addColumn('string', 'Type');
13         data.addColumn('number', 'Number of acts');
14 <?php
15   function loadData($url) {
16     $data = json_decode(file_get_contents($url));
17     $i = 0;
18     $out = '';
19     $others = 0;
20     foreach($data as $item) {
21       if ($item->number_of_documents < 1000) { //we group types with less than 500 acts together
22         $others += $item->number_of_documents;
23       } else {
24         $out .= "        data.setValue($i, 0, '".addslashes($item->form)."');\n";
25         $out .= "        data.setValue($i, 1, ".$item->number_of_documents.");\n";
26         $i++;
27       }
28     }
29     $out .= "        data.setValue($i, 0, 'Other');\n";
30     $out .= "        data.setValue($i, 1, ".$others.");\n";
31     $i++;
32     echo "        data.addRows(".$i.");\n";
33     echo $out;
34   }
35 
36 $url = 'http://api.epdb.eu/eurlex/form/?key=YOUR_API_KEY';
37 loadData($url);
38 ?>
39 
40 
41         chart.draw(data, {
42           width: 900,
43           height: 400,
44           title: 'Acts by type',
45           hAxis: {title: 'Legislative type', titleTextStyle: {color: 'black'}}
46         });
47       }
48     </script>
49     <style type="text/css">
50       body { background-color:#193F4F; text-align:center;font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 15px }
51       a {color:#fff; }
52       #chart_div { background-color:#fff;color:#333;}
53       #container { background-color:#fff;padding:10px; }
54       #content { width: 920px;margin-left:auto;margin-right:auto; }
55     </style>
56   </head>
57   <body>
58     <div id='content'>
59       <div id='container'>
60         <div id='chart_div' style='width:900px;height:400px;'></div>
61       </div>
62     </div>
63 
64     <div style="color:#fff;margin-top:40px;">
65       This example uses the <a href="http://code.google.com/apis/chart/">Google Chart Tools</a>.<br />
66       Data is taken from the <a href="http://api.epdb.eu">API for European Union legislation</a> by <a href="http://www.buhlrasmussen.eu">Buhl & Rasmussen</a> 2011.
67       The original data source is <a href="http://eur-lex.europa.eu/">EUR-Lex</a>.<br />
68       You can see the <a href="example02.php.html">PHP source-code</a> used to generate this example, and
69       you can find more <a href="/#examples">examples here</a>.
70     </div>
71   </body>
72 </html>