Skip to content

Commit

Permalink
Merge pull request #7 from ajrbyers/master
Browse files Browse the repository at this point in the history
Tweaked js to use foreignObject for icons in SVG.
  • Loading branch information
norlab authored May 15, 2018
2 parents 5b10285 + a26587e commit 20af6ec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions paperbuzzviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function PaperbuzzViz(options) {
.data(sources)
.enter().append("rect")
.attr("fill", "#CECCCC")
.attr("height", "100")
.attr("height", "200")
.attr("width", "100%")
.attr("x", "0")
.attr("y", "0");
Expand Down Expand Up @@ -113,12 +113,20 @@ function PaperbuzzViz(options) {
.attr("class", "miniViz-text")
.text(calculateYears(pub_date) + ' year(s)');

miniViz.append("text")

var total = 0;
for (i = 0; i < data.altmetrics_sources.length; i++) {

var x = 10;
var y = 100 * (i + 1);

miniViz.append("foreignObject")
.attr("class", "miniViz-count")
.attr("id", function(d, i) { return "miniViz-count-" + data.altmetrics_sources[i].source_id; })
.attr("x", "100")
.attr("y", "50")
.attr("x", x)
.attr("y", y)
.html(function(d, i) { return '<i class="icon-' + data.altmetrics_sources[i].source_id + '"></i>' + " "; });
}


}
Expand Down

0 comments on commit 20af6ec

Please sign in to comment.