Viktor
Viktor

Reputation: 1487

How to get the node's coordinates after force layout in Apache ECharts?

I use Apache Echarts which is a great library to display my graph but it has a drawback: if using force layout then I can't organize the nodes, after I dragged one of them in to a different position, the force layout moves it back to its original position.

I read several blog post and a possible (only one?) solution can be to leave the force layout to display the graph, then use 'none' layout and set the coordinates of 'force' layout to each nodes.
To do that I should be able to get the coordinates of the nodes after the 'force' layout displayed them. and then I could set X and Y coordinates and set the layout to 'none'.

Any hint please how can I get the coordinates in Apache Echarts?
Thanks!

Upvotes: 0

Views: 65

Answers (1)

Matthias Mertens
Matthias Mertens

Reputation: 2551

You can find most information about the chart somewhere in the chart object. If you go the the force layout example and log the chart object to the console you can inspect it. For me under _chartsMap there is the graph info called _ec_Les Miserables0_series.graph. Further information about the nodes can be found under _model.dataTask.context.outputData, coordiantes specifically under _itemLayouts corresponding to Items in _nameList.

Note, that the internal API can change at any point without notice.

Upvotes: 0

Related Questions