鍍金池/ 問答/HTML5  Python  C++  HTML/ ECharts的儀表盤刻度 浮點(diǎn)數(shù)取整 問題,在線等 急!!!!!

ECharts的儀表盤刻度 浮點(diǎn)數(shù)取整 問題,在線等 急!!!!!

圖片描述

1.如圖儀表盤刻度怎么取整?;

2,這是實(shí)現(xiàn)邏輯代碼:

//TAT

var rounds = document.querySelector('div.round');
var _watchHtml = '';

this._valueDatas.forEach(function (value,index,array) {
    value = eval('('+ value +')');
    console.log(value)

    var maxTat = value.c3text;  //總值 100
    var fwcTat = value.c4text;  //警報值 60
    var difTat = (maxTat - fwcTat);  //安全值 100-60 = 40
    var colors = difTat/maxTat;
    var _valueLengths = value.c3text.length;


    _watchHtml += '<div class="watchBox"><div class="watch w'+index+'"></div></div>'
    var wat=document.createElement('div');
    wat.setAttribute('class','watchBox');
    wat.innerHTML='<div class="watch w'+index+'"></div>';
   // rounds.innerHTML = _watchHtml;
    rounds.appendChild(wat)



    //儀表盤配置參數(shù)
    var watch = echarts.init(document.querySelector('.w'+index));
    var option = {
        toolbox: {
            show: false
        },
        tooltip: {
            formatter: "{a} <br/> : {c}%"
        },
        textStyle: {
            fontSize: 8,
        },
        series: [
            {
                type: 'gauge',
                radius: '100%',
                clockwise: true,
                splitNumber: _valueLengths,
                center: [110, 90],
                min: 0,
                max: value.c3text,
                detail: {
                    formatter: '{value}min',
                    fontSize: 10,
                    offsetCenter: ['0%','60%']
                },
                data: [{value: difTat}],
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: [
                            [colors,'#29b6f6'],
                            [fwcTat/maxTat,'#ffa726'],
                            [100,'#f44336'],
                        ]
                    }
                },
                splitLine: {
                    show: false
                },
                axisLabel: {
                    distance: 5,
                    fontSize: 10,
                },
                pointer: {
                    show: true,
                    length: '60%',
                    width: 5,
                }
            }
        ]
    }
    watch.setOption(option);
})
回答
編輯回答
妖妖

我有用過這個,你不要用他那個數(shù)據(jù)來平均等分,而是用另一種方法,比如你的有9份,有3種顏色,那就是分成3份,我目前知道的就這樣解決,我也沒有找到整數(shù)的api??傊阋昧硪环N方法給他搞成整數(shù)。

2018年3月30日 23:37
編輯回答
舊酒館

自己寫個方法,調(diào)用

2017年2月7日 05:28
編輯回答
糖豆豆
axisLabel: {
                    distance: 5,
                    fontSize: 10,
                      formatter: function(v){
                          return v.toFixed(0);
                    },
                },
2017年10月15日 09:28