plainheart edited a comment on issue #9932: How include % 
URL: 
https://github.com/apache/incubator-echarts/issues/9932#issuecomment-465432458
 
 
   try 
[`tooltip.formatter`](https://echarts.apache.org/option.html#tooltip.formatter) 
for your requirements.
   
   For example:
   ```
   formatter: function(params) {
        var total = 0;
        var renderHtml = [];
        renderHtml.push(params[0].name);
        var len = params.length - 1;
        for (var i = 0; i < len; i++) {
                var item = params[i];
                total += +(item.value); // convert string to number
        }
        for (i = 0; i < len; i++) {
                var item = params[i];
                var percent = (item.value / total * 
100).toFixed(2).toString().replace('.00', '');
                renderHtml.push(item.marker + item.seriesName + ': ' + 
item.value + ' (' + percent + '%)');
        }
        return renderHtml.join('<br>')
   }
   ```
   
![image](https://user-images.githubusercontent.com/26999792/53068840-de7f1800-3514-11e9-8621-9e8da06aa78f.png)
   

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@echarts.apache.org
For additional commands, e-mail: dev-h...@echarts.apache.org

Reply via email to