(function (H) {
/**
* @todo
* - Handle options for nodes. This can be added as special point items that
* have a flag, isNode, or type: 'node'. It would allow setting specific
* color, className etc. Then these options must be linked by id and used
* when generating the node items.
* - Dynamics (Point.update, setData, addPoint etc).
* - From and to can be null when links enter or exit the diagram.
* - Separate data label and tooltip point formatters for nodes vs links? A
* possible pattern would be to add a point.type, and automate the
* implementation of formatters through the type, for example nodeFormat
* or tooltip.linkFormat. This could be reused for other series types,
* even generic like point.format = 'null' => tooltip.nullFormat.
*/
var defined = H.defined,
each = H.each;
H.seriesType('sankey', 'column', {
colorByPoint: true,
dataLabels: {
enabled: true,
backgroundColor: 'none', // enable padding
crop: false,
formatter: function () {
return this.point.isNode && this.point.id;
// Include data labels for the links like this:
// return this.point.isNode ? this.point.id : this.point.weight;
},
inside: true
},
linkOpacity: 0.5,
nodeWidth: 20,
nodePadding: 10,
showInLegend: false,
states: {
hover: {
linkOpacity: 1
}
},
tooltip: {
followPointer: true,
headerFormat:
'<span style="font-size: 0.85em">{series.name}</span><br/>',
pointFormatter: function () {
if (this.isNode) {
return this.id + ': ' + this.sum();
}
return this.from + ' \u2192 ' + this.to +
': <b>' + this.weight + '</b>';
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.