1 <html> 2 <head> 3 <title>Adoptions in Council and Commission - PreLex example</title> 4 <script type='text/javascript' src='https://www.google.com/jsapi'></script> 5 <script type='text/javascript'> 6 google.load('visualization', '1', {'packages':['annotatedtimeline']}); 7 google.setOnLoadCallback(drawChart); 8 function drawChart() { 9 var data = new google.visualization.DataTable(), 10 chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div')); 11 data.addColumn('date', 'Year'); 12 data.addColumn('number', 'Adoptions in Council'); 13 data.addColumn('string', 'description'); 14 data.addColumn('number', 'Adoptions in Commission'); 15 <?php 16 function loadData($url,$column) { 17 $data = json_decode(file_get_contents($url)); 18 $i = 0; 19 $others = 0; 20 $out = ''; 21 foreach($data as $item) { 22 if ($item->year < 1950 || $item->year > 2011) { 23 continue; 24 } else { 25 if ($column == 2) 26 $out .= " [new Date(".$item->year.",1,1), ".$item->number_of_documents.",null,null],\n"; 27 else if ($column == 4) 28 $out .= " [new Date(".$item->year.",1,1), null, null, ".$item->number_of_documents."],\n"; 29 } 30 } 31 return $out; 32 } 33 34 $out = " data.addRows([\n"; 35 $eurlexUrl = 'http://api.epdb.eu/prelex/year_council/?key=YOUR_API_KEY'; 36 $prelexUrl = 'http://api.epdb.eu/prelex/year_commission/?key=YOUR_API_KEY'; 37 $out .= loadData($eurlexUrl,2); 38 $out .= loadData($prelexUrl,4); 39 $out .= " [new Date(1973,1,1),null,'Enlargement: Denmark, Ireland and United Kingdom',null], 40 [new Date(1981,1,1),null,'Enlargement: Greece',null], 41 [new Date(1986,1,1),null,'Enlargement: Portugal and Spain',null], 42 [new Date(1995,1,1),null,'Enlargement: Austria, Finland and Sweden',null], 43 [new Date(2004,5,1),null,'Enlargement: 10 ECC countries',null], 44 [new Date(2007,1,1),null,'Enlargement: Bulgaria and Romania',null], 45 [new Date(2009,12,1),null,'Lisbon Treaty',null], 46 [new Date(2003,2,1),null,'Treaty of Nice',null], 47 [new Date(1999,5,1),null,'Amsterdam Treaty',null], 48 [new Date(1993,11,1),null,'Maastricht Treaty',null], 49 [new Date(1987,7,1),null,'Single European Act',null], 50 [new Date(1967,7,1),null,'Merger Treaty',null], 51 [new Date(1958,1,1),null,'Treaties of Rome',null], 52 [new Date(2010,2,9),null,'Barrosso II Commission',null], 53 [new Date(2004,11,22),null,'Barrosso I Commission',null], 54 [new Date(1999,9,16),null,'Prodi Commission',null], 55 [new Date(1995,1,23),null,'Santer Commission',null], 56 [new Date(1985,1,null),null,'Delors Commission',null], 57 [new Date(1981,1,12),null,'Thorn Commission',null], 58 [new Date(1977,8,18),null,'Jenkins Commission',null]"; 59 $out .= "\n ]);"; 60 echo $out; 61 ?> 62 63 chart.draw(data, { 64 displayAnnotations: true, 65 displayZoomButtons: false, 66 displayRangeSelector: false, 67 dateFormat: 'yyyy', 68 allowRedraw: true 69 }); 70 } 71 </script> 72 <style type="text/css"> 73 body { background-color:#193F4F; text-align:center;font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 15px } 74 a {color:#fff; } 75 #chart_div { background-color:#fff;color:#333;} 76 #container { background-color:#fff;padding:10px; } 77 #content { width: 920px;margin-left:auto;margin-right:auto; } 78 </style> 79 </head> 80 <body> 81 <div id='content'> 82 <div id='container'> 83 <div id='chart_div' style='width: 900px; height: 400px;'></div> 84 </div> 85 </div> 86 <div style="color:#fff;margin-top:40px;"> 87 This example uses the <a href="http://code.google.com/apis/chart/">Google Chart Tools</a>.<br /> 88 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. 89 The original data source is <a href="http://ec.europa.eu/prelex/apcnet.cfm">PreLex</a>.<br /> 90 You can see the <a href="example05.php.html">PHP source-code</a> used to generate this example, and 91 you can find more <a href="/#examples">examples here</a>. 92 </div> 93 </body> 94 </html>