JSFiddle - React, Tailwind, and code Playground
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/networkgraph.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container">
<!-- <div id="contextMenu" style="display: none" class="contextMenu">
<div id="contextMenuItem1">Data</div>https://jsfiddle.net/1kors9c8/#run
<div id="contextMenuItem2">Data2</div>
</div> -->
</div>
JavaScript
var H = Highcharts,
extend = H.extend,
pick = H.pick;
H.seriesTypes.networkgraph.prototype.createNode = function(id, userOptions) {
/**
* @private
*/
function findById(nodes, id) {
return H.find(nodes, function(node) {
return node.id === id;
});
}
var node = findById(this.nodes, id),
PointClass = this.pointClass,
options;
if (!node) {
options = this.options.nodes && findById(this.options.nodes, id);
node = (new PointClass()).init(this, extend({
className: 'highcharts-node',
isNode: true,
id: id,
y: 1 // Pass isNull test
}, extend(options, userOptions || {})));
node.linksTo = [];
node.linksFrom = [];
node.formatPrefix = 'node';
node.name = node.name || node.options.id; // for use in formats
// Mass is used in networkgraph:
node.mass = pick(
// Node:
node.options.mass, node.options.marker && node.options.marker.radius,
// Series:
this.options.marker && this.options.marker.radius,
// Default:
4);
/**
* Return the largest sum of either the incoming or outgoing links.
* @private
*/
node.getSum = function() {
var sumTo = 0,
sumFrom = 0;
node.linksTo.forEach(function(link) {
sumTo += link.weight;
});
node.linksFrom.forEach(function(link) {
sumFrom += link.weight;
});
return Math.max(sumTo, sumFrom);
};
/**
* Get the offset in weight values of a point/link.
* @private
*/
node.offset = function(point, coll) {
var offset = 0;
for (var i = 0; i < node[coll].length; i++) {
if (node[coll][i] === point) {
return offset;
}
offset += node[coll][i].weight;
}
};
// Return true if the node has a shape, otherwise all links are
// outgoing.
node.hasShape = function() {
var outgoing = 0;
node.linksTo.forEach(function(link) {
if (link.outgoing) {
...