echarts实现环形进度图

//环形进度图
TgsChartsUtil.drawCircleLoadingChart = function(cfg){
    var myChart = TgsChartsUtil.getChart(cfg);

    if(!TgsChartsUtil.isPageLoad()){
        cfg.chartType = "circleLoading";
        TgsChartsUtil.configs.push(cfg);
        TgsChartsUtil.showLoading(myChart, null, 12, TgsChartsUtil.loaddingEffects[3],8);
        return;
    }

    var colorStyleProps = TgsChartsUtil.props['circleLoading']['colorStyle'];
    var colorStyle = null;
    if(cfg.colorStyleByTradeStatus != undefined){
        colorStyle = colorStyleProps[(cfg.colorStyleByTradeStatus=='invest'?'orange':((cfg.colorStyleByTradeStatus=='oping') ? 'blue' : 'gray'))];
    }else if(cfg.colorStyle){
        colorStyle = colorStyleProps[cfg.colorStyle];
    }
    if(!colorStyle){
        colorStyle = colorStyleProps['blue'];
    }

    if(!cfg.width){
        cfg.width = 160;
    }

    var otherStyle = {
        normal : {
            color : colorStyle['otherColor'],
            label : {
                show : false
                //,
                //position : 'center',
                //formatter : '{b}',
                //textStyle: {
                //    baseline : 'bottom'
                //}
            },
            labelLine : {
                show : false
            }
        }
    };

    var valueStyle = {
        normal : {
            color: colorStyle['valueColor'],
            label : {
                show : true,
                position : 'center',
                textStyle: {
                    color : colorStyle['valueColor'],
                    fontSize : cfg.fontSize || 10
                }
            },
            labelLine : {
                show : false
            }
        },
        emphasis: {
            color: colorStyle['valueColor']
        }
    };

    var divisor = cfg.divisor; //除数
    var dividend = cfg.dividend;//被除数
    if(divisor != undefined && dividend != undefined && divisor != 0){
        cfg.data = parseFloat(dividend || 0) / parseFloat(divisor) * 100;
    } else if(cfg.data == undefined || cfg.data == null){
        cfg.data = 0;
    }
    var dv = cfg.data > 100 ? 100 : cfg.data;
    var option = {

        //title : {
        //    text: 'The App World',
        //    subtext: 'from global web index',
        //    x: 'center'
        //},
        toolbox: {
            show : false
        },
        series : [
            {
                type : 'pie',
                center : ['50%', '50%'],
                radius : [cfg.width/2.7, cfg.width/2.16],
                itemGap: 10,
                x: 'center',
                y: 'center',
                data : [
                    {name:Math.floor(cfg.data)+'%', value : dv, itemStyle : valueStyle},
                    {name:'', value : (100 - dv),itemStyle : otherStyle}
                ]
            }
        ]
    };
    myChart.hideLoading();
    myChart.setOption(option);
};

简单调用:

 

TgsChartsUtil.drawCircleLoadingChart({
domId : "loadChart_$!prj.projectId", 
width:54, 
colorStyleByTradeStatus : '$!{prj.prjectStatus}',
dividend : '$!{prj.amount}', 
divisor:'$!{prj.minAmount}'
});

 

抱歉 难得改代码哈

效果:



 

 

 

应用网站,也可以到网站查看具体应用效果:

淘股神 http://www.taogushen.com

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值