Wednesday, 7 August 2013

Sankey Diagram (D3) - How to use multiple units for link values and how to add notes to mouseover popup box?

Sankey Diagram (D3) - How to use multiple units for link values and how to
add notes to mouseover popup box?

http://bl.ocks.org/d3noob/5028304
Looking at this example, hovering over a link shows the source, the
target, and the value. The value is appended with the variable 'units',
which for this example is "Widgets".
var units = "Widgets";
var formatNumber = d3.format(",.0f"), // zero decimal places
format = function(d) { return formatNumber(d) + " " + units; },
color = d3.scale.category20();
Is there any way of creating classes so that the link between one source
and target is appended with one type of unit and others use different
units? In this example, let's say we wanted the links between "Energy" and
all of its targets to use MWh for its units, but all other links would use
Widgets.
I'd also love to know how to add notes, such as URLs, to the text box that
pops up on mouse hover.

No comments:

Post a Comment