MCPcopy
hub / github.com/tdewolff/minify / graphForceLayout

Function graphForceLayout

_benchmarks/sample_echarts.js:57066–57187  ·  view source on GitHub ↗
(ecModel)

Source from the content-addressed store, hash-verified

57064 }
57065
57066 function graphForceLayout(ecModel) {
57067 ecModel.eachSeriesByType('graph', function (graphSeries) {
57068 var coordSys = graphSeries.coordinateSystem;
57069
57070 if (coordSys && coordSys.type !== 'view') {
57071 return;
57072 }
57073
57074 if (graphSeries.get('layout') === 'force') {
57075 var preservedPoints_1 = graphSeries.preservedPoints || {};
57076 var graph_1 = graphSeries.getGraph();
57077 var nodeData_1 = graph_1.data;
57078 var edgeData = graph_1.edgeData;
57079 var forceModel = graphSeries.getModel('force');
57080 var initLayout = forceModel.get('initLayout');
57081
57082 if (graphSeries.preservedPoints) {
57083 nodeData_1.each(function (idx) {
57084 var id = nodeData_1.getId(idx);
57085 nodeData_1.setItemLayout(idx, preservedPoints_1[id] || [NaN, NaN]);
57086 });
57087 } else if (!initLayout || initLayout === 'none') {
57088 simpleLayout(graphSeries);
57089 } else if (initLayout === 'circular') {
57090 circularLayout(graphSeries, 'value');
57091 }
57092
57093 var nodeDataExtent_1 = nodeData_1.getDataExtent('value');
57094 var edgeDataExtent_1 = edgeData.getDataExtent('value'); // let edgeDataExtent = edgeData.getDataExtent('value');
57095
57096 var repulsion = forceModel.get('repulsion');
57097 var edgeLength = forceModel.get('edgeLength');
57098 var repulsionArr_1 = isArray(repulsion) ? repulsion : [repulsion, repulsion];
57099 var edgeLengthArr_1 = isArray(edgeLength) ? edgeLength : [edgeLength, edgeLength]; // Larger value has smaller length
57100
57101 edgeLengthArr_1 = [edgeLengthArr_1[1], edgeLengthArr_1[0]];
57102 var nodes_1 = nodeData_1.mapArray('value', function (value, idx) {
57103 var point = nodeData_1.getItemLayout(idx);
57104 var rep = linearMap(value, nodeDataExtent_1, repulsionArr_1);
57105
57106 if (isNaN(rep)) {
57107 rep = (repulsionArr_1[0] + repulsionArr_1[1]) / 2;
57108 }
57109
57110 return {
57111 w: rep,
57112 rep: rep,
57113 fixed: nodeData_1.getItemModel(idx).get('fixed'),
57114 p: !point || isNaN(point[0]) || isNaN(point[1]) ? null : point
57115 };
57116 });
57117 var edges = edgeData.mapArray('value', function (value, idx) {
57118 var edge = graph_1.getEdgeByIndex(idx);
57119 var d = linearMap(value, edgeDataExtent_1, edgeLengthArr_1);
57120
57121 if (isNaN(d)) {
57122 d = (edgeLengthArr_1[0] + edgeLengthArr_1[1]) / 2;
57123 }

Callers

nothing calls this directly

Calls 9

simpleLayoutFunction · 0.85
circularLayoutFunction · 0.85
linearMapFunction · 0.85
isNaNFunction · 0.85
retrieve3Function · 0.85
getCurvenessForEdgeFunction · 0.85
forceLayoutFunction · 0.85
isArrayFunction · 0.70
copyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…