Adding FontAwesome icons to a D3 graph

You need to use the proper Unicode inside a normal text element, and then set the font-family to “FontAwesome” like this: node.append(‘text’) .attr(‘font-family’, ‘FontAwesome’) .attr(‘font-size’, function(d) { return d.size+’em’} ) .text(function(d) { return ‘\uf118’ }); This exact code will render an “icon-smile” icon. The unicodes for all FontAwesome icons can be found here: http://fortawesome.github.io/Font-Awesome/cheatsheet/ Be … Read more

Can you insert a line break in text when using d3.js? [duplicate]

Since you already know where you want to break the text, you could consider just adding separate elements. .append(“text”) .attr(“dy”, “0em”) .text(“line 1”) // “line 1” or whatever value you want to add here. And then for the second line, just add an offset .append(“text”) .attr(“dy”, “1em”) // you can vary how far apart it … Read more

What is ‘d3.svg.axis()’ in d3 version 4?

The D3 v4 API is here. According to the changelog: D3 4.0 provides default styles and shorter syntax. In place of d3.svg.axis and axis.orient, D3 4.0 now provides four constructors for each orientation: d3.axisTop, d3.axisRight, d3.axisBottom, d3.axisLeft. Therefore, those lines should be: var xAxis = d3.axisBottom(xRange).tickFormat(function(d){ return d.x;}); var yAxis = d3.axisLeft(yRange); PS: I’m assuming … Read more

How to get coordinates of an svg element?

The element.getBoundingClientRect() method will return the proper coordinates of an element relative to the viewport regardless of whether the svg has been scaled and/or translated. See this question and answer. While getBBox() works for an untransformed space, if scale and translation have been applied to the layout then it will no longer be accurate. The … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)