MCPcopy Index your code
hub / github.com/tdewolff/minify / circularLayout

Function circularLayout

_benchmarks/sample_echarts.js:56822–56862  ·  view source on GitHub ↗

* `basedOn` can be: * 'value': * This layout is not accurate and have same bad case. For example, * if the min value is very smaller than the max value, the nodes * with the min value probably overlap even though there is enough * space to layout them. So we

(seriesModel, basedOn)

Source from the content-addressed store, hash-verified

56820 */
56821
56822 function circularLayout(seriesModel, basedOn) {
56823 var coordSys = seriesModel.coordinateSystem;
56824
56825 if (coordSys && coordSys.type !== 'view') {
56826 return;
56827 }
56828
56829 var rect = coordSys.getBoundingRect();
56830 var nodeData = seriesModel.getData();
56831 var graph = nodeData.graph;
56832 var cx = rect.width / 2 + rect.x;
56833 var cy = rect.height / 2 + rect.y;
56834 var r = Math.min(rect.width, rect.height) / 2;
56835 var count = nodeData.count();
56836 nodeData.setLayout({
56837 cx: cx,
56838 cy: cy
56839 });
56840
56841 if (!count) {
56842 return;
56843 }
56844
56845 _layoutNodesBasedOn[basedOn](seriesModel, graph, nodeData, r, cx, cy, count);
56846
56847 graph.eachEdge(function (edge, index) {
56848 var curveness = retrieve3(edge.getModel().get(['lineStyle', 'curveness']), getCurvenessForEdge(edge, seriesModel, index), 0);
56849 var p1 = clone$1(edge.node1.getLayout());
56850 var p2 = clone$1(edge.node2.getLayout());
56851 var cp1;
56852 var x12 = (p1[0] + p2[0]) / 2;
56853 var y12 = (p1[1] + p2[1]) / 2;
56854
56855 if (+curveness) {
56856 curveness *= 3;
56857 cp1 = [cx * curveness + x12 * (1 - curveness), cy * curveness + y12 * (1 - curveness)];
56858 }
56859
56860 edge.setLayout([p1, p2, cp1]);
56861 });
56862 }
56863 var _layoutNodesBasedOn = {
56864 value: function (seriesModel, graph, nodeData, r, cx, cy, count) {
56865 var angle = 0;

Callers 2

graphCircularLayoutFunction · 0.85
graphForceLayoutFunction · 0.85

Calls 3

retrieve3Function · 0.85
getCurvenessForEdgeFunction · 0.85
clone$1Function · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…