Skip to content

Commit

Permalink
Tweaked js to use foreignObject for icons in SVG.
Browse files Browse the repository at this point in the history
ajrbyers committed May 14, 2018
1 parent 5b10285 commit a26587e
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
@@ -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");
@@ -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>' + " "; });
}


}

0 comments on commit a26587e

Please sign in to comment.