Created
December 3, 2013 20:18
-
-
Save repustate/7776799 to your computer and use it in GitHub Desktop.
Insert markers for tweets based on lat/long. Colour coded based on sentiment.
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
d3.json('/media/js/points.json', function(err, json) { | |
svg.select('#points') | |
.selectAll('circle') | |
.data(json) | |
.enter() | |
.append("circle") | |
.attr("r",4) | |
.style('fill-opacity', 0.7) | |
.style('display', function(d) { | |
if (d.dd == base_date.getDate() && d.mm == base_date.getMonth()+1) { | |
return '' | |
} | |
return 'none' | |
}) | |
.style('fill', function(d) { | |
key = d.mm+'-'+d.dd | |
if (!sentiment[key]) { | |
sentiment[key] = {pos:0, neg:0} | |
} | |
if (d.sentiment == 'pos') { | |
sentiment[key]['pos'] += 1 | |
return 'blue' | |
} else { | |
sentiment[key]['neg'] += 1 | |
return 'red' | |
} | |
}) | |
.style('stroke', '#fff') | |
.attr("transform", function(d) {return "translate(" + projection([d.lng, d.lat]) + ")";}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment