雷达图echarts

  

var height = document.querySelector('#chart-panel').offsetHeight;
var width = document.querySelector('#chart-panel').offsetWidth;
var radiusMax = width >= height ? height : widht;
console.log(width);
var data = {
    title: '雷达图',
    ratioData: [{
            value: '95',
            name: '二电三期'
        },
        {
            value: '90',
            name: '二电二期'
        },
        {
            value: '85',
            name: '二电一期'
        },
        {
            value: '63',
            name: '二电南线'
        },
        {
            value: '48',
            name: '大唐一期'
        },
        {
            value: '35',
            name: '大唐二期'
        }
    ]
};
var indicator = [];
var showData = [];
if (data.title !== undefined) {
    data.ratioData.map(item => {
        indicator.push({
            name: item.name,
            max: 100

        });
        showData.push(Number(item.value));
    });
}

option = {
    // backgroundColor: "#000",
    title: {
        
         text: '热源出力',
        subtext:'345',
        left: 'center',
        top:'46.3%',
        textStyle: {
            color:'#fcaf17',
            fontWeight:'normal',
            fontSize: 18
        },
        subtextStyle:{
            color:'#f47a55',
            fontWeight:'normal',
            fontSize: 16,
            lineHeight:8
        }
    },
    radar: {
        indicator: indicator,
        // shape: "circle",
        center: ["50%", "53%"],
        radius: "85%",
        splitNumber: 5,
        splitArea: {
            areaStyle: {
                color: ['#d1c7b7',"#d9d6c3", '#f6f5ec', '#fffef9', '#fffffb']
            }
        },
        splitLine: {
            show: true,
            lineStyle: {
                opacity: 1,
                color: "#263c5f",
                width: 3,
            }
        },
       
          axisLine: {
            lineStyle: {
                color: '#8f4b4a'
            }
        },
       
        name: {
            show: false,
            //   formatter: '{value}',
            // textStyle: {
            //     color: '#a7a7a7'
            // },
            // fontSize: 20
              
        }
    },
    series: [{
        name: data.title,
        type: "radar",
        symbolSize: 0.1,
        areaStyle: {
            normal: {
                opacity: 1,
                color: new echarts.graphic.RadialGradient(width / 2, height / 2, radiusMax * 0.3, [{
                    offset: 0,
                    color: 'rgb(61, 171, 204,0.2)'
                }, {
                    offset: 1,
                    color: 'rgb(61, 171, 204,1)'
                }], true),
            }
        },
        lineStyle: {
            width: 0,
        },
        label: {
            normal: {
                show: true,
                position: "top",
                formatter: (params) => {
                    let dataIndex = params.data.indexOf(params.value);
                    let rang = `NO.${dataIndex+1}`;
                    let value = `${params.value}%`;
                    let name = indicator[dataIndex].name;
                    let text = '';
                    if (dataIndex < 6) {
                        text = `{value|${value}}{rang|${rang}}{name|${name}}`;
                    } else {
                        text = `{name|${name}}{value|${value}}`;
                    }
                    return text;
                },
                rich: {
                    rang: {
                        color: "#ed1941",
                        fontSize: 13,
                    },
                    value: {
                        color: "#00FFFF",
                        fontWeight: 700,
                        fontSize: 16,
                    },
                    name: {
                        color: "#8f4b38",
                        padding: [0, 5],
                        fontSize: 18
                    }
                }
            }
        },
        data: [showData],
    }]
};

var chart = document.getElementById('chart-panel');
echarts.init(chart);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
雷达是一种用于可视化多个维度数据的表。根据引用\[1\]中的需求,可以通过以下步骤来定制echarts雷达: 1. 去掉背景颜色,调整雷达大小为65%:设置radar对象的center属性为\['50%', '50%'\],radius属性为'65%'。 2. 指示器轴的分割段数为4条:在radar对象中设置splitNumber属性为4。 3. 雷达分割线设为白色半透明0.5:在splitLine对象中设置lineStyle属性的color属性为'rgba(255, 255, 255, 0.5)'。 4. 雷达坐标轴轴线相关设置(竖线):在axisLine对象中设置show属性为true,lineStyle属性的color属性为'rgba(255, 255, 255, 0.5)'。 5. 修饰雷达文字颜色为#4c9bfd:在name对象中设置textStyle属性的color属性为'#4c9bfd'。 6. 修饰区域填充样式:在series对象中设置type属性为'radar',并根据需求设置相应的数据。 根据引用\[2\]中的代码示例,可以参考以下代码来创建echarts雷达: ```javascript var mCharts = echarts.init(document.querySelector('div')); var dataMax = \[ { name: '易用性', max: 100 }, { name: '功能', max: 100 }, { name: '跑分', max: 100 }, { name: '续航', max: 100 }, \]; var option = { radar: { indicator: dataMax, center: \['50%', '50%'\], radius: '65%', splitNumber: 4, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.5)', }, }, axisLine: { show: true, lineStyle: { color: 'rgba(255, 255, 255, 0.5)', }, }, }, series: \[ { type: 'radar', data: \[ { name: '华为手机', value: \[80, 90, 80, 82\] }, { name: '中兴手机', value: \[70, 82, 75, 70\] }, \], }, \], }; mCharts.setOption(option); ``` 如果你想要将雷达最外层的形状改为圆形,可以参考引用\[3\]中的代码示例,在radar对象中设置shape属性为'circle'。 希望以上信息能够帮助到你创建echarts雷达。 #### 引用[.reference_title] - *1* [echarts----雷达](https://blog.csdn.net/grow_/article/details/129561196)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [雷达(用ECharts绘制)](https://blog.csdn.net/YINZHE__/article/details/119791983)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值