apache / apache/echarts

保存力引导布局graph options 成JSON,重新setOption 报错

Open
#12,357 5 comments 0 reactions 0 assignees View on GitHub
new-feature pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### What problem does this feature solve?
力引导布局完成后,我调用 getOption 方法,得到当前 graph 的 option,保存成 json 文件。然后在另外一个页面用 setOption 把保存的json 传进去,结果出错:

```sh
echarts.js:59368 Uncaught TypeError: Cannot read property '__focusNodeAdjacency' of undefined
at echarts.js:59368
at Graph.graphProto.eachEdge (echarts.js:57587)
at ExtendedClass.render (echarts.js:59365)
at Task.progress (echarts.js:25940)
at doProgress (echarts.js:24831)
at Task.taskProto.perform (echarts.js:24754)
at echarts.js:29844
at ExtendedClass. (echarts.js:22708)
at Array.forEach ()
at each$1 (echarts.js:541)
```

我的目的是,用echarts graph 的 force layout 先布局一次,得到chart option,然后保存好文件。以后每次显示graph 的时候就省去布局的时间了。

或者怎样转换坐标,用force 布局后,得到的layout 是个二维数组,怎么转换成 x y 坐标,然后保存到原始数据中,如果能做,那这个时候的坐标系应该选什么?

谢谢

### What does the proposed API look like?
NA

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.