Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this code available on github?

Alternatively, you have the attention and the publicity, you could turn this into an a revenue producing product, sticking an ad somewhere on the page, and then providing it like a YTMND kind of "fill in the blank" system. At the very least, you could use the Romney thing as a springboard for a viral entry.

At the bottom, stick a "Make a graph for any project" link and commence.

At the very least, this could net you a decent handful of cash for minimal work, and, presumably, you already have the attention. Now take advantage of it before the spotlight moves off you.

Disclaimer: I say all this, not as a marketing type, but just as a geek who's run his own stuff for years, and I see a possibility to make a couple extra bucks with this well done implementation. Maybe it'd turn out to be a waste of time, maybe it'd score you some pizza and beer money every week, or maybe it'd serve as your entry as a "Social analytics" company or whatever. Either way, I think it's worth exploring.



it's just a bit of fun. seeing the tweets roll in is payment enough


> Is this code available on github?

It's in the source code using the google Chart api [https://developers.google.com/chart/interactive/docs/index]

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

      // Load the Visualization API and the piechart package.
      google.load('visualization', '1.0', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(init);

      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawRealtime() {

        var data = google.visualization.arrayToDataTable(headings.concat(likes));

        var options = {
          title: 'Realtime Like Count For Mitt Romney',
          hAxis : {textColor: '#ffffff'},
          colors: ['red','#004411'],
          legend: {position: 'none'}
        };

        var chart = new google.visualization.LineChart(document.getElementById('realtime'));
        chart.draw(data, options);
      }

      function drawHistoric() {

        var data = google.visualization.arrayToDataTable(headings.concat([['1:59pm',12049076],['2:16pm',12048948],['2:30pm',12048820],['2:45pm',12048681],['3:00pm',12048559],['3:15pm',12048421],['3:30pm',12048297],['3:45pm',12048182],['4:00pm',12048077],['4:15pm',12047946],['4:30pm',12047807],['4:45pm',12047660],['5:00pm',12047509],['5:15pm',12047380],['5:30pm',12047247],['5:45pm',12047105],['6:00pm',12046942]]));

        var options = {
          title: 'Recent Like Count For Mitt Romney',
          legend: {position: 'none'}
        };

        var chart = new google.visualization.LineChart(document.getElementById('historic'));
        chart.draw(data, options);
      }

      var headings = [['Time','Likes']];
      var likes = [];

      console.log(headings.concat(likes));

      window.setInterval(fadeAway,1000);

      function init() {
      	drawHistoric();
      	window.setInterval(fetchLikes,1000);
      }

      var start = 0;

      function fetchLikes() {
      	$.getJSON('https://graph.facebook.com/mittromney?fields=likes',function(data){
			console.log(data.likes);
			if(likes.length==0) { data.likes+=10; start=data.likes; } else {
				$("#count").text("-"+(start-data.likes));
			}
			likes.push([new Date().getTime(),data.likes]);
			drawRealtime();
		});
      }

      function fadeAway() {
      	var opa = $("#romney").css('opacity');
      	$("#romney").css('opacity',(opa==0 ? 0 : opa-0.02));
      }

    </script>
It's all in the fetchLikes() that use the JSON api of the facebook graph. It's launched through this : window.setInterval(fetchLikes,1000);

After the graph API has been loaded.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: