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/05/21 03:31:51 UTC

[GitHub] [incubator-echarts] huangzigeng opened a new issue #12677: 饼图-传入数据后 是否可以返回每个数据的百分比

huangzigeng opened a new issue #12677:
URL: https://github.com/apache/incubator-echarts/issues/12677


   饼图中  传入数据后  每个数据在饼图中都占有一个面积  这个面积是按百分比来的,那么可以在实例中获取到这个百分比不


----------------------------------------------------------------
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] plainheart edited a comment on issue #12677: 饼图-传入数据后 是否可以返回每个数据的百分比

Posted by GitBox <gi...@apache.org>.
plainheart edited a comment on issue #12677:
URL: https://github.com/apache/incubator-echarts/issues/12677#issuecomment-631886102


   没有提供直接的API可以获取,不过要是真想获取也能计算得到。
   1、直接拿自己的原始数据,计算百分比。
   2、获取到你想要获取百分比的pie系列实例,根据其`layout`中的`angle`计算出对应角度,再除以`360`可以算出百分比。
   ```js
     var model = chart.getModel();
     // 根据索引获取系列,或者也可以根据名称、类型等获取
     var pieSeries = model.getSeriesByIndex(0); // getSeriesByName/getSeriesByType
     // 传入你想要获取的数据项索引,可以得到该数据项的Layout
     var itemLayout = b.getData().getItemLayout(0);
     // layout中有我们所需的angle数值,这是一个弧度值,可转换为角度除以360计算百分比
     // 或者直接除以 2*Math.PI计算百分比
     var percent = itemLayout.angle / (2 * Math.PI); // 或者180 / Math.PI * itemLayout.angle / 360
   ```


----------------------------------------------------------------
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] plainheart commented on issue #12677: 饼图-传入数据后 是否可以返回每个数据的百分比

Posted by GitBox <gi...@apache.org>.
plainheart commented on issue #12677:
URL: https://github.com/apache/incubator-echarts/issues/12677#issuecomment-631886102


   没有提供直接的API可以获取,不过要是真想获取也能计算得到。
   1、直接拿自己的原始数据,计算百分比。
   2、获取到你想要获取百分比的pie系列实例,根据其`layout`中的`angle`计算出对应角度,再除以`360`可以算出百分比。
   ```js
     var model = chart.getModel();
     // 根据索引获取系列,或者也可以根据名称、类型等获取
     var pieSeries = model.getSeriesByIndex(0); // getSeriesByName/getSeriesByType
     // 传入你想要获取的数据项索引,可以得到该数据项的Layout
     var itemLayout = b.getData().getItemLayout(0);
     // layout中有我们所需的angle数值,这是一个弧度值,可转换为角度除以360计算百分比
     // 或者直接除以 2*Math.PI计算百分比
     var percent = itemLayout.angle / (2 * Math.PI); // 或者180 / Math.PI * itemLayout.angle
   ```


----------------------------------------------------------------
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] quillblue commented on issue #12677: 饼图-传入数据后 是否可以返回每个数据的百分比

Posted by GitBox <gi...@apache.org>.
quillblue commented on issue #12677:
URL: https://github.com/apache/incubator-echarts/issues/12677#issuecomment-631885460


   如果需要在饼图上显示百分比,可以通过tooltip或是label的`formatter`中设置[https://echarts.apache.org/examples/zh/editor.html?c=pie-nest](https://echarts.apache.org/examples/zh/editor.html?c=pie-nest) 
   
   如果仅需要获得百分比以供JS中其他计算使用,可以自己实现。
   
   如果是有其他的需求,请通过[Issue Helper](https://ecomfe.github.io/?lang=zh-cn)提交符合要求的Issue。
   


----------------------------------------------------------------
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] plainheart edited a comment on issue #12677: 饼图-传入数据后 是否可以返回每个数据的百分比

Posted by GitBox <gi...@apache.org>.
plainheart edited a comment on issue #12677:
URL: https://github.com/apache/incubator-echarts/issues/12677#issuecomment-631886102


   没有提供直接的API可以获取,不过要是真想获取也能计算得到。
   1、直接拿自己的原始数据,计算百分比。
   2、获取到你想要获取百分比的pie系列实例,根据其`layout`中的`angle`计算出对应角度,再除以`360`可以算出百分比。
   ```js
     var model = chart.getModel();
     // 根据索引获取系列,或者也可以根据名称、类型等获取
     var pieSeries = model.getSeriesByIndex(0); // getSeriesByName/getSeriesByType
     // 传入你想要获取的数据项索引,可以得到该数据项的Layout
     var itemLayout = pieSeries.getData().getItemLayout(0);
     // layout中有我们所需的angle数值,这是一个弧度值,可转换为角度除以360计算百分比
     // 或者直接除以 2*Math.PI计算百分比
     var percent = itemLayout.angle / (2 * Math.PI); // 或者180 / Math.PI * itemLayout.angle / 360
   ```


----------------------------------------------------------------
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