首页 > 其他分享 >echarts饼图,半圈半圆,百分比显示

echarts饼图,半圈半圆,百分比显示

时间:2022-08-23 15:16:16浏览次数:68  
标签:scale name color value 半圈 var 半圆 data echarts

var data = [{
    value: 24.5,//正确率的百分比
    name: '高等教育学'
}, {
    value: 89,
    name: '高等教育心理学'
}, {
    value: 38,
    name: '综合学科'
}];

var a = 0;
var scale = 1;
var borderColor = '#021421';
for (var i = 0; i < data.length; i++) {
    a += data[i].value;
}
data.push({
    value: a,
    name: '',
    itemStyle: {
        normal: {
            color: 'none'
        }
    }
});
var rich = {
    yellow: {
        color: "#ffc72b",
        fontSize: 19 * scale,
        padding: [5, 4]
    },
    circle: {
        backgroundColor: "#ffc72b",
        width: 7 * scale,
        align: 'left',
        height: 7 * scale,
        borderRadius: 7 * scale
    },
    green: {
        color: "rgba(63,255,234,0.5)",
        fontSize: 19 * scale,
        padding: [6, 0]
    },
    tip: {
        color: "#ffc72b",
        fontSize: 40 * scale,
        padding: [15, 4]
    },
    white: {
        color: "#fff",
        align: 'center',
        fontSize: 21 * scale,
        padding: [10, 0]
    },
    hr: {
        borderColor: '#06405a',
        width: '100%',
        borderWidth: 0.5,
        height: 0
    }
}
console.log(data);
option = {
    legend: {
        formatter: function(name) {
            var sum = 0; //各科正确率总和
            var averagePercent; //综合正确率
            data.forEach(function(value, index, array) {
                if (index < (data.length - 1)) {
                    sum += value.value;
                }
            });
            averagePercent = (sum / (data.length - 1)).toFixed(2);
            return '{tip|' + averagePercent + '%}\n{hr|}\n{white|' + '综合正确率' + '}\n{hr|}';
        },
        data: [data[0].name],
        // data: ['高等教育学'],
        itemGap: 50,
        left: '0',
        top: '0',
        icon: 'none',
        textStyle: {
            color: "#fff",
            fontSize: 16 * scale,
            rich: rich
        },
    },
    backgroundColor: "#021421",
    color: ['#176265', '#28a59e', '#3fffea'],
    series: [{
        name: '访问来源',
        type: 'pie',
        startAngle: -180,
        hoverAnimation: false,
        radius: ['78%', '55%'],
        center: ['50%', '88%'],
        data: data,
        label: {
            normal: {
                formatter: function(params, ticket, callback) {
                    if (data.length !== (params.dataIndex + 1)) {
                        return '{yellow|' + params.value + '%}\n{circle|}\n{green|' + params.name + '}';
                    }
                },
                color: "rgba(63,255,234,0.5)",
                rich: rich
            }
        },
        // markLine: {
        //     label:{
        //         normal:{
        //             position:'start',
        //         }
        //     },
        //     lineStyle:{
        //         normal:{
        //             color:"#fff"
        //         }
        //     }
        // },
        labelLine: {
            normal: {
                length: 80 * scale,
            }
        },
        itemStyle: {
            normal: {
                borderColor: borderColor,
                borderWidth: 4 * scale,
            },
            // emphasis: {
            //     shadowBlur: 10,
            //     shadowOffsetX: 0,
            //     shadowColor: 'rgba(0, 0, 0, 0.5)'
            // }
        }
    }]
};

 

 

标签:scale,name,color,value,半圈,var,半圆,data,echarts
From: https://www.cnblogs.com/facenano/p/16616199.html

相关文章

  • echarts刻度盘,半圈半圆,百分比
    vardemoData={name:'城镇化率',value:60,};option={backgroundColor:'#222939',title:{text:'{num|'+demoData.value+'%}'......
  • echarts异形图水滴图,百分比显示,波浪水球
    varvalue=0.45;varvalue1=0.76;vardata=[value,value1];varoption={backgroundColor:'#0F224C',title:[{text:'本......
  • echarts饼图,完整圆形,百分比显示
    option={tooltip:{trigger:'item',formatter:"{a}<br/>{b}:{c}({d}%)"},color:['#8fc31f','#f35833','......
  • echarts环形饼图,完整圆形,百分比分值
    varscale=1;varechartData=[{value:21,name:'市场签约1'},{value:38,name:'市场签约2'},{value:35,name:'市场签约3'},......
  • echarts 数据的各种格式
    数据集数据集(dataset)是专门用来管理数据的组件。虽然每个系列都可以在series.data中设置数据,但是从ECharts4支持数据集开始,更推荐使用数据集来管理数据。因为这样......
  • ECharts 中的样式简介
    ECharts中的样式简介本文主要是大略概述,用哪些方法,可以在ApacheEChartsTM中设置样式,改变图形元素或者文字的颜色、明暗、大小等。为了让表述更通俗易懂,我们在这里用......
  • echarts 图表容器及大小
    图表容器及大小在快速上手中,我们介绍了初始化ECharts的接口echarts.init。API文档中详细介绍了参数的具体含义,建议理解后再阅读本文。下面,我们就常见的几种使用场景,......
  • 学习:python pyecharts数据可视化
    pyecharts数据可视化pyecharts是一个用于生成Echarts图标的类库Echarts是百度开源的一个数据可视化的Js库用Echarts生成的图可视化效果非常棒 新版v1和老版本......
  • 在vue中使用echarts
    1.引入echarts先通过npm安装echartsnpmrunecharts--save2.在main.js中import*asechartsfrom'echarts';Vue.prototype.$echarts=echarts3.在.vue文件中(包括......
  • echarts存在两个series时,tooltip限制仅显示一个
    应用场景       如图,当需要用类似装饰时,需要有两个轴,两组数据,但是tooltip中应该仅显示一组。 解决方法     在option下先设置一个全局的tool......