JS in echarts multiple line chart numbers *100 strange appearing decimal

Source: Internet
Author: User

Formatter:function (params){//Data Unit formatting                               varRelval =params[0].name;//x-axis name                                for(vari =0, L =params. length; I < L; i++) {                                    if(params[I].value] {Relval+='<br/>'+params[I].seriesname +' : '+ (params[i].value*100+"%"; }} console.log (params)                               returnRelval; }

This kind of formatter in the data format will appear strange, similar to the problem of 50.000001%

The solution is to cut

For example slice (2,4) Slice the first parameter at the beginning of the cut, the second parameter is cut to the number of a,

Code submission:

Formatterfunction(params) {//Data Unit formatting                               varRelval = Params[0].name;//x-axis name                                for(vari = 0, L = params.length; I < L; i++) {                                    if(params[i].value) {Relval+ = ' <br/> ' + params[i].seriesname + ': ' + (String (params[i].value)). Slice (2,4) + "%"; }} console.log (params)returnRelval; }

JS in echarts multiple line chart numbers *100 strange appearing decimal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.