Created
September 11, 2012 13:57
-
-
Save perryn/3698687 to your computer and use it in GitHub Desktop.
twitter chart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <body> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> | |
| <script src="http://code.highcharts.com/highcharts.js"></script> | |
| <script src="http://code.highcharts.com/modules/exporting.js"></script> | |
| <div id="container" style="min-width: 400px; height: 700px; margin: 0 auto"></div> | |
| <script> | |
| $(document).ready(function(){ | |
| twitter_ids = [ | |
| "perrynfowler", | |
| "matthewcashmore", | |
| // ADD TWITTER IDS HERE | |
| ]; | |
| items = []; | |
| chart = new Highcharts.Chart({ | |
| chart: { | |
| renderTo: 'container', | |
| type: 'column', | |
| margin: [ 50, 50, 100, 80] | |
| }, | |
| title: { | |
| text: 'Number of Followers' | |
| }, | |
| xAxis: { | |
| categories: twitter_ids, | |
| labels: { | |
| rotation: -45, | |
| align: 'right', | |
| style: { | |
| fontSize: '13px', | |
| fontFamily: 'Verdana, sans-serif' | |
| } | |
| } | |
| }, | |
| yAxis: { | |
| min: 0, | |
| title: { | |
| text: 'Followers' | |
| } | |
| }, | |
| legend: { | |
| enabled: false | |
| }, | |
| tooltip: { | |
| formatter: function() { | |
| return '<b>'+ this.x +'</b><br/>'+ | |
| Highcharts.numberFormat(this.y, 0) + | |
| ' followers'; | |
| } | |
| }, | |
| series: [{ | |
| name: 'Followers', | |
| data: items, | |
| dataLabels: { | |
| enabled: true, | |
| rotation: -90, | |
| color: '#FFFFFF', | |
| align: 'right', | |
| x: -3, | |
| y: 10, | |
| formatter: function() { | |
| return this.y; | |
| }, | |
| style: { | |
| fontSize: '13px', | |
| fontFamily: 'Verdana, sans-serif' | |
| } | |
| } | |
| }] | |
| }); | |
| $.each(twitter_ids, function(index, id) { | |
| $.getJSON('http://api.twitter.com/1/users/lookup.json?screen_name=' + id, function(data) { | |
| chart.series[0].addPoint({x:index, y:data[0]['followers_count']}); | |
| }).error(function(data) { alert("error talking to twitter. Done more than 150 lookups per hour?"); }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment