You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/03/31 11:24:30 UTC

[GitHub] [incubator-echarts] travis1111 opened a new issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

travis1111 opened a new issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357
 
 
   ### 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.<anonymous> (echarts.js:22708)
       at Array.forEach (<anonymous>)
       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
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pumpkindev removed a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
pumpkindev removed a comment on issue #12357:
URL: https://github.com/apache/echarts/issues/12357#issuecomment-840338090


   @100pah 我这边也是想达到楼主这种效果,
   当布局完毕后,获取坐标,重新setOption()加坐标进去并且将layout设置为none,graph会整体放大大概1.2倍的样子,不知道哪里出问题了(width,height都没变动,echarts版本是5.0.2)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] travis1111 commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
travis1111 commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-609446415
 
 
   谢谢!但是有两个问题
   
   1. 这个layout 跟viewport 有很大关系,比如我第一次layout完后,存了数据,然后把浏览器窗口大小改变一下,再load 进去,graph 的比例就不一样了,像是被压扁了一样。
   
   2. 另外一个办法我想到的就是用convertToPixel 存当前canvas 大小及像素点,然后重新load 的时候根据新的屏幕大小,调整像素位置,然后在convertFromPixel 写成layout。可以第一步就不对,我用下面的方法返回的跟送进去的一样:
   
   ```sh
   var obj = chart.convertToPixel({seriesIndex:0},[958.004150390625, 349.3768310546875]);
   console.log(obj);
   ```
   
   返回还是
   
   ```sh
   958.004150390625, 349.3768310546875
   ```
   
   是我用错了吗?
   我的 `coordinateSystem` 没有设定。设定任何其他的都不对。`layout` 是 `force`。
   
   谢谢

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-608617538
 
 
   当前还并不能通过 getOption 获得布局好的结果。
   私有 api 可以获取这些值,如:
   ```js
   var layout = [];
   var privateData = chart.getModel().getSeries()[0].getData();
   for (var i = 0; i < privateData.count(); i++) {
       layout.push(privateData.getItemLayout(i));
   }
   ```
   但是这些私有 api 只能在当前版本中使用,后续版本可能会改变。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-608617538
 
 
   当前还并不能通过 getOption 获得布局好的结果。
   私有 api 可以获取这些值,如:
   ```js
   var layout = [];
   var privateData = mm.getModel().getSeries()[0].getData();
   for (var i = 0; i < privateData.count(); i++) {
       layout.push(privateData.getItemLayout(i));
   }
   ```
   但是这些私有 api 只能在当前版本中使用,后续版本可能会改变。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] echarts-bot[bot] commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-606567605
 
 
   Hi! We've received your issue and please be patient to get responded. 🎉
   The average response time is expected to be within one day for weekdays.
   
   In the meanwhile, please make sure that **you have posted enough image to demo your request**. You may also check out the [API](http://echarts.apache.org/api.html) and [chart option](http://echarts.apache.org/option.html) to get the answer.
   
   If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.
   
   If you are interested in the project, you may also subscribe our [mail list](https://echarts.apache.org/en/maillist.html).
   
   Have a nice day! 🍵

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-609448258
 
 
   `convertToPixel` 的输入是 “数据” ,输出是 pixel。
   但是 [958.004150390625, 349.3768310546875] 本身就是 pixel。
   
   可能要适应浏览器尺寸,只能是,获取 layout 值的阶段,
   也获取当时的 chart 的 width & height。
   使用 layout 画 chart 前,如果 chart 的  width & height 与“获取 layout 值时” 不同,
   就把 layout 值根据新  width & height 更改一下。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pumpkindev commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
pumpkindev commented on issue #12357:
URL: https://github.com/apache/echarts/issues/12357#issuecomment-840338090


   @100pah 我这边也是想达到楼主这种效果,
   当布局完毕后,获取坐标,重新setOption()加坐标进去并且将layout设置为none,graph会整体放大大概1.2倍的样子,不知道哪里出问题了(width,height都没变动,echarts版本是5.0.2)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-609421552
 
 
   这是一个用上面方法提取 layout 数据的例子。
   
   ```html
   <html>
   <head>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1" />
       <script src="https://cdn.jsdelivr.net/npm/echarts@4.7.0/dist/echarts.min.js"></script>
   </head>
   <body>
       <style>
           html, body {
               width: 100%;
               height: 100%;
               margin: 0;
               padding: 0;
           }
           button {
               font-size: 20px;
           }
           #main0 {
               height: 350px;
           }
           #main1 {
               height: 350px;
           }
       </style>
   
   
       <div id="main0"></div>
       <div>
           <button id="retrieve">Retrieve layout data and render with the layout data</button>
       </div>
       <div id="main1"></div>
   
   
   
       <script>
   
           var _myChart0 = echarts.init(document.getElementById('main0'));
   
           var _graphData = {
               "nodes": [
                   {"id": "0", "name": "Myriel"},
                   {"id": "1", "name": "Napoleon"},
                   {"id": "2", "name": "MlleBaptistine"},
                   {"id": "3", "name": "MmeMagloire"},
                   {"id": "4", "name": "CountessDeLo"},
                   {"id": "5", "name": "Geborand"},
                   {"id": "6", "name": "Champtercier"},
                   {"id": "7", "name": "Cravatte"},
                   {"id": "8", "name": "Count"},
                   {"id": "9", "name": "OldMan"},
                   {"id": "10", "name": "Labarre"},
                   {"id": "11", "name": "Valjean"},
                   {"id": "12", "name": "Marguerite"},
                   {"id": "13", "name": "MmeDeR"},
                   {"id": "14", "name": "Isabeau"},
                   {"id": "15", "name": "Gervais"},
                   {"id": "16", "name": "Tholomyes"},
                   {"id": "17", "name": "Listolier"},
                   {"id": "18", "name": "Fameuil"},
                   {"id": "19", "name": "Blacheville"},
                   {"id": "20", "name": "Favourite"},
                   {"id": "21", "name": "Dahlia"},
                   {"id": "22", "name": "Zephine"},
                   {"id": "23", "name": "Fantine"},
                   {"id": "24", "name": "MmeThenardier"},
                   {"id": "25", "name": "Thenardier"},
                   {"id": "26", "name": "Cosette"},
                   {"id": "27", "name": "Javert"},
                   {"id": "28", "name": "Fauchelevent"},
                   {"id": "29", "name": "Bamatabois"},
                   {"id": "30", "name": "Perpetue"},
                   {"id": "31", "name": "Simplice"},
                   {"id": "32", "name": "Scaufflaire"},
                   {"id": "33", "name": "Woman1"},
                   {"id": "34", "name": "Judge"},
                   {"id": "35", "name": "Champmathieu"},
                   {"id": "36", "name": "Brevet"},
                   {"id": "37", "name": "Chenildieu"},
                   {"id": "38", "name": "Cochepaille"},
                   {"id": "39", "name": "Pontmercy"},
                   {"id": "40", "name": "Boulatruelle"},
                   {"id": "41", "name": "Eponine"},
                   {"id": "42", "name": "Anzelma"},
                   {"id": "43", "name": "Woman2"},
                   {"id": "44", "name": "MotherInnocent"},
                   {"id": "45", "name": "Gribier"},
                   {"id": "46", "name": "Jondrette"},
                   {"id": "47", "name": "MmeBurgon"},
                   {"id": "48", "name": "Gavroche"},
                   {"id": "49", "name": "Gillenormand"},
                   {"id": "50", "name": "Magnon"},
                   {"id": "51", "name": "MlleGillenormand"},
                   {"id": "52", "name": "MmePontmercy"},
                   {"id": "53", "name": "MlleVaubois"},
                   {"id": "54", "name": "LtGillenormand"},
                   {"id": "55", "name": "Marius"},
                   {"id": "56", "name": "BaronessT"},
                   {"id": "57", "name": "Mabeuf"},
                   {"id": "58", "name": "Enjolras"},
                   {"id": "59", "name": "Combeferre"},
                   {"id": "60", "name": "Prouvaire"},
                   {"id": "61", "name": "Feuilly"},
                   {"id": "62", "name": "Courfeyrac"},
                   {"id": "63", "name": "Bahorel"},
                   {"id": "64", "name": "Bossuet"},
                   {"id": "65", "name": "Joly"},
                   {"id": "66", "name": "Grantaire"},
                   {"id": "67", "name": "MotherPlutarch"},
                   {"id": "68", "name": "Gueulemer"},
                   {"id": "69", "name": "Babet"},
                   {"id": "70", "name": "Claquesous"},
                   {"id": "71", "name": "Montparnasse"},
                   {"id": "72", "name": "Toussaint"},
                   {"id": "73", "name": "Child1"},
                   {"id": "74", "name": "Child2"},
                   {"id": "75", "name": "Brujon"},
                   {"id": "76", "name": "MmeHucheloup"}
               ],
               "links": [
                   {"source": "1", "target": "0"},
                   {"source": "2", "target": "0"},
                   {"source": "3", "target": "0"},
                   {"source": "3", "target": "2"},
                   {"source": "4", "target": "0"},
                   {"source": "5", "target": "0"},
                   {"source": "6", "target": "0"},
                   {"source": "7", "target": "0"},
                   {"source": "8", "target": "0"},
                   {"source": "9", "target": "0"},
                   {"source": "11", "target": "0"},
                   {"source": "11", "target": "2"},
                   {"source": "11", "target": "3"},
                   {"source": "11", "target": "10"},
                   {"source": "12", "target": "11"},
                   {"source": "13", "target": "11"},
                   {"source": "14", "target": "11"},
                   {"source": "15", "target": "11"},
                   {"source": "17", "target": "16"},
                   {"source": "18", "target": "16"},
                   {"source": "18", "target": "17"},
                   {"source": "19", "target": "16"},
                   {"source": "19", "target": "17"},
                   {"source": "19", "target": "18"},
                   {"source": "20", "target": "16"},
                   {"source": "20", "target": "17"},
                   {"source": "20", "target": "18"},
                   {"source": "20", "target": "19"},
                   {"source": "21", "target": "16"},
                   {"source": "21", "target": "17"},
                   {"source": "21", "target": "18"},
                   {"source": "21", "target": "19"},
                   {"source": "21", "target": "20"},
                   {"source": "22", "target": "16"},
                   {"source": "22", "target": "17"},
                   {"source": "22", "target": "18"},
                   {"source": "22", "target": "19"},
                   {"source": "22", "target": "20"},
                   {"source": "22", "target": "21"},
                   {"source": "23", "target": "11"},
                   {"source": "23", "target": "12"},
                   {"source": "23", "target": "16"},
                   {"source": "23", "target": "17"},
                   {"source": "23", "target": "18"},
                   {"source": "23", "target": "19"},
                   {"source": "23", "target": "20"},
                   {"source": "23", "target": "21"},
                   {"source": "23", "target": "22"},
                   {"source": "24", "target": "11"},
                   {"source": "24", "target": "23"},
                   {"source": "25", "target": "11"},
                   {"source": "25", "target": "23"},
                   {"source": "25", "target": "24"},
                   {"source": "26", "target": "11"},
                   {"source": "26", "target": "16"},
                   {"source": "26", "target": "24"},
                   {"source": "26", "target": "25"},
                   {"source": "27", "target": "11"},
                   {"source": "27", "target": "23"},
                   {"source": "27", "target": "24"},
                   {"source": "27", "target": "25"},
                   {"source": "27", "target": "26"},
                   {"source": "28", "target": "11"},
                   {"source": "28", "target": "27"},
                   {"source": "29", "target": "11"},
                   {"source": "29", "target": "23"},
                   {"source": "29", "target": "27"},
                   {"source": "30", "target": "23"},
                   {"source": "31", "target": "11"},
                   {"source": "31", "target": "23"},
                   {"source": "31", "target": "27"},
                   {"source": "31", "target": "30"},
                   {"source": "32", "target": "11"},
                   {"source": "33", "target": "11"},
                   {"source": "33", "target": "27"},
                   {"source": "34", "target": "11"},
                   {"source": "34", "target": "29"},
                   {"source": "35", "target": "11"},
                   {"source": "35", "target": "29"},
                   {"source": "35", "target": "34"},
                   {"source": "36", "target": "11"},
                   {"source": "36", "target": "29"},
                   {"source": "36", "target": "34"},
                   {"source": "36", "target": "35"},
                   {"source": "37", "target": "11"},
                   {"source": "37", "target": "29"},
                   {"source": "37", "target": "34"},
                   {"source": "37", "target": "35"},
                   {"source": "37", "target": "36"},
                   {"source": "38", "target": "11"},
                   {"source": "38", "target": "29"},
                   {"source": "38", "target": "34"},
                   {"source": "38", "target": "35"},
                   {"source": "38", "target": "36"},
                   {"source": "38", "target": "37"},
                   {"source": "39", "target": "25"},
                   {"source": "40", "target": "25"},
                   {"source": "41", "target": "24"},
                   {"source": "41", "target": "25"},
                   {"source": "42", "target": "24"},
                   {"source": "42", "target": "25"},
                   {"source": "42", "target": "41"},
                   {"source": "43", "target": "11"},
                   {"source": "43", "target": "26"},
                   {"source": "43", "target": "27"},
                   {"source": "44", "target": "11"},
                   {"source": "44", "target": "28"},
                   {"source": "45", "target": "28"},
                   {"source": "47", "target": "46"},
                   {"source": "48", "target": "11"},
                   {"source": "48", "target": "25"},
                   {"source": "48", "target": "27"},
                   {"source": "48", "target": "47"},
                   {"source": "49", "target": "11"},
                   {"source": "49", "target": "26"},
                   {"source": "50", "target": "24"},
                   {"source": "50", "target": "49"},
                   {"source": "51", "target": "11"},
                   {"source": "51", "target": "26"},
                   {"source": "51", "target": "49"},
                   {"source": "52", "target": "39"},
                   {"source": "52", "target": "51"},
                   {"source": "53", "target": "51"},
                   {"source": "54", "target": "26"},
                   {"source": "54", "target": "49"},
                   {"source": "54", "target": "51"},
                   {"source": "55", "target": "11"},
                   {"source": "55", "target": "16"},
                   {"source": "55", "target": "25"},
                   {"source": "55", "target": "26"},
                   {"source": "55", "target": "39"},
                   {"source": "55", "target": "41"},
                   {"source": "55", "target": "48"},
                   {"source": "55", "target": "49"},
                   {"source": "55", "target": "51"},
                   {"source": "55", "target": "54"},
                   {"source": "56", "target": "49"},
                   {"source": "56", "target": "55"},
                   {"source": "57", "target": "41"},
                   {"source": "57", "target": "48"},
                   {"source": "57", "target": "55"},
                   {"source": "58", "target": "11"},
                   {"source": "58", "target": "27"},
                   {"source": "58", "target": "48"},
                   {"source": "58", "target": "55"},
                   {"source": "58", "target": "57"},
                   {"source": "59", "target": "48"},
                   {"source": "59", "target": "55"},
                   {"source": "59", "target": "57"},
                   {"source": "59", "target": "58"},
                   {"source": "60", "target": "48"},
                   {"source": "60", "target": "58"},
                   {"source": "60", "target": "59"},
                   {"source": "61", "target": "48"},
                   {"source": "61", "target": "55"},
                   {"source": "61", "target": "57"},
                   {"source": "61", "target": "58"},
                   {"source": "61", "target": "59"},
                   {"source": "61", "target": "60"},
                   {"source": "62", "target": "41"},
                   {"source": "62", "target": "48"},
                   {"source": "62", "target": "55"},
                   {"source": "62", "target": "57"},
                   {"source": "62", "target": "58"},
                   {"source": "62", "target": "59"},
                   {"source": "62", "target": "60"},
                   {"source": "62", "target": "61"},
                   {"source": "63", "target": "48"},
                   {"source": "63", "target": "55"},
                   {"source": "63", "target": "57"},
                   {"source": "63", "target": "58"},
                   {"source": "63", "target": "59"},
                   {"source": "63", "target": "60"},
                   {"source": "63", "target": "61"},
                   {"source": "63", "target": "62"},
                   {"source": "64", "target": "11"},
                   {"source": "64", "target": "48"},
                   {"source": "64", "target": "55"},
                   {"source": "64", "target": "57"},
                   {"source": "64", "target": "58"},
                   {"source": "64", "target": "59"},
                   {"source": "64", "target": "60"},
                   {"source": "64", "target": "61"},
                   {"source": "64", "target": "62"},
                   {"source": "64", "target": "63"},
                   {"source": "65", "target": "48"},
                   {"source": "65", "target": "55"},
                   {"source": "65", "target": "57"},
                   {"source": "65", "target": "58"},
                   {"source": "65", "target": "59"},
                   {"source": "65", "target": "60"},
                   {"source": "65", "target": "61"},
                   {"source": "65", "target": "62"},
                   {"source": "65", "target": "63"},
                   {"source": "65", "target": "64"},
                   {"source": "66", "target": "48"},
                   {"source": "66", "target": "58"},
                   {"source": "66", "target": "59"},
                   {"source": "66", "target": "60"},
                   {"source": "66", "target": "61"},
                   {"source": "66", "target": "62"},
                   {"source": "66", "target": "63"},
                   {"source": "66", "target": "64"},
                   {"source": "66", "target": "65"},
                   {"source": "67", "target": "57"},
                   {"source": "68", "target": "11"},
                   {"source": "68", "target": "24"},
                   {"source": "68", "target": "25"},
                   {"source": "68", "target": "27"},
                   {"source": "68", "target": "41"},
                   {"source": "68", "target": "48"},
                   {"source": "69", "target": "11"},
                   {"source": "69", "target": "24"},
                   {"source": "69", "target": "25"},
                   {"source": "69", "target": "27"},
                   {"source": "69", "target": "41"},
                   {"source": "69", "target": "48"},
                   {"source": "69", "target": "68"},
                   {"source": "70", "target": "11"},
                   {"source": "70", "target": "24"},
                   {"source": "70", "target": "25"},
                   {"source": "70", "target": "27"},
                   {"source": "70", "target": "41"},
                   {"source": "70", "target": "58"},
                   {"source": "70", "target": "68"},
                   {"source": "70", "target": "69"},
                   {"source": "71", "target": "11"},
                   {"source": "71", "target": "25"},
                   {"source": "71", "target": "27"},
                   {"source": "71", "target": "41"},
                   {"source": "71", "target": "48"},
                   {"source": "71", "target": "68"},
                   {"source": "71", "target": "69"},
                   {"source": "71", "target": "70"},
                   {"source": "72", "target": "11"},
                   {"source": "72", "target": "26"},
                   {"source": "72", "target": "27"},
                   {"source": "73", "target": "48"},
                   {"source": "74", "target": "48"},
                   {"source": "74", "target": "73"},
                   {"source": "75", "target": "25"},
                   {"source": "75", "target": "41"},
                   {"source": "75", "target": "48"},
                   {"source": "75", "target": "68"},
                   {"source": "75", "target": "69"},
                   {"source": "75", "target": "70"},
                   {"source": "75", "target": "71"},
                   {"source": "76", "target": "48"},
                   {"source": "76", "target": "58"},
                   {"source": "76", "target": "62"},
                   {"source": "76", "target": "63"},
                   {"source": "76", "target": "64"},
                   {"source": "76", "target": "65"},
                   {"source": "76", "target": "66"}
               ]
           };
   
           _graphData.nodes.forEach(function (node) {
               node.draggable = true;
           });
           var option0 = {
               tooltip: {},
               animation: false,
               series: [{
                   name: 'Les Miserables',
                   type: 'graph',
                   layout: 'force',
                   symbolSize: 10,
                   data: _graphData.nodes,
                   links: _graphData.links,
                   roam: true,
                   focusNodeAdjacency: true,
                   label: {
                       position: 'right'
                   },
                   force: {
                       repulsion: 100
                   }
               }]
           };
   
           _myChart0.setOption(option0);
   
       </script>
   
   
   
       <script>
   
           var retrieveBtn = document.getElementById('retrieve');
           retrieveBtn.onclick = function () {
               var layoutMap = retrieveLayoutData(_myChart0);
               renderWithLayoutMap(layoutMap);
           }
   
           function retrieveLayoutData(chart) {
               var layoutMap = {};
               var privateData = chart.getModel().getSeries()[0].getData();
               for (var i = 0; i < privateData.count(); i++) {
                   var point = privateData.getItemLayout(i);
                   var id = privateData.getId(i);
                   layoutMap[id] = {
                       id: id,
                       name: privateData.getName(i),
                       x: point[0],
                       y: point[1]
                   };
               }
               return layoutMap;
           }
   
           function renderWithLayoutMap(layoutMap) {
   
               var links = _graphData.links;
               // Set x, y to the original nodes:
               var nodes = _graphData.nodes.map(function (originNode) {
                   var layoutInfo = layoutMap[originNode.id];
                   return {
                       id: originNode.id,
                       name: originNode.name,
                       x: layoutInfo.x,
                       y: layoutInfo.y
                   };
               });
   
               // Render chart.
               var option = {
                   title: {
                       text: 'Les Miserables',
                       subtext: 'Default layout',
                       top: 'bottom',
                       left: 'right'
                   },
                   tooltip: {},
                   series : [
                       {
                           name: 'Les Miserables',
                           type: 'graph',
                           data: nodes,
                           links: links,
                           symbolSize: 10,
                           roam: true,
                           focusNodeAdjacency: true,
                           label: {
                               position: 'right'
                           },
                           force: {
                               repulsion: 100
                           }
                       }
                   ]
               };
   
               var myChart1 = echarts.init(document.getElementById('main1'));
               myChart1.setOption(option);
           }
   
       </script>
   
   </body>
   </html>
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah edited a comment on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-609448258
 
 
   
   可能要适应浏览器尺寸,只能是,获取 layout 值的阶段,
   也获取当时的 chart 的 width & height。
   使用 layout 画 chart 前,如果 chart 的  width & height 与“获取 layout 值时” 不同,
   就把 layout 值根据新  width & height 更改一下。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] 100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错

Posted by GitBox <gi...@apache.org>.
100pah commented on issue #12357: 保存力引导布局graph options 成JSON,重新setOption 报错
URL: https://github.com/apache/incubator-echarts/issues/12357#issuecomment-609448258
 
 
   `convertToPixel` 的输入是 “数据” ,输出是 pixel。
   但是 [958.004150390625, 349.3768310546875] 本身就是 pixel。
   
   可能要适应浏览器尺寸,只能是,获取 layout 值的阶段,
   也获取当时的 chart 的比例。
   使用 layout 画 chart 前,如果 chart 比例与“获取 layout 值时” 不同,
   就把 layout 值根据新比例更改一下。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org