ECharts 雷达图在类目值下面显示数值

需要实现的效果:

 

官网里面的demo显示数值,都是在拐点处:

【解决】

1、只显示类目

 

     <div id="mychart" style="width:300px;height:300px;margin:0 auto;"></div>
        <script>
            var arr1 = [60,73,85,40,60];
            var arr2 = [23,90,23,32,67];
            var mychart =  echarts.init(document.getElementById('mychart'));
            var option = {
                radar: [
                    {
                        indicator: [
                            {text: '品牌', max: 100},
                            {text: '内容', max: 100},
                            {text: '可用性', max: 100},
                            {text: '功能', max: 100},
                            {text: '屏幕', max: 100}
                        ],
                        center: ['50%','54%'],//调整雷达图的位置
                        radius: 80,//半径,可放大放小雷达图
                        axisLine: {//坐标轴线相关设置
                            show: true,
                            lineStyle: {
                                color: 'red'
                            }
                        },
                        splitLine : {
                            show : true,
                            lineStyle : {
                                width : 1,
                                color : 'red' // 图表背景网格线的颜色
                            }
                        },
                        splitArea: {
                            show: false,
                        },
                        name: {
                            rich: {
                                a: {
                                    color: 'red',
                                    lineHeight: 20
                                },
                            },
                            formatter: (a)=>{
                                return `{a|${a}}`
                            }
                        }
                    },
                ],
                series: [
                    {
                        type: 'radar',
                        symbol: 'none',//去掉拐点的圈
                        data: [
                            {
                                value: arr1,
                                name: '某软件',
                                areaStyle: {
                                    normal: {
                                        color: 'blue'
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)"
                                },
                            },{
                                value: arr2,
                                name:'jja',
                                areaStyle: {
                                    normal: {
                                        color: 'red' // 图表中各个图区域的颜色
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)" // 图表中各个图区域的边框线颜色
                                },
                            }
                        ]
                    },
                ]
            };
            mychart.setOption(option);
        </script>

实现效果:

2、实现最简单的数值在类目下

 

<div id="mychart" style="width:300px;height:300px;margin:0 auto;"></div>
        <script>
            var arr1 = [60,73,85,40,60];
            var arr2 = [23,90,23,32,67];
            var mychart =  echarts.init(document.getElementById('mychart'));
            var option = {
                radar: [
                    {
                        indicator: [
                            {text: '品牌', max: 100},
                            {text: '内容', max: 100},
                            {text: '可用性', max: 100},
                            {text: '功能', max: 100},
                            {text: '屏幕', max: 100}
                        ],
                        center: ['50%','54%'],//调整雷达图的位置
                        radius: 80,//半径,可放大放小雷达图
                        axisLine: {//坐标轴线相关设置
                            show: true,
                            lineStyle: {
                                color: 'red'
                            }
                        },
                        splitLine : {
                            show : true,
                            lineStyle : {
                                width : 1,
                                color : 'red' // 图表背景网格线的颜色
                            }
                        },
                        splitArea: {
                            show: false,
                        },
                        name: {
                            rich: {
                                a: {
                                    color: 'red',
                                    lineHeight: 20
                                },
                                b: {
                                    color: '#fff',
                                    align: 'center',
                                    backgroundColor: '#666',
                                    padding: 2,
                                    borderRadius: 4
                                }
                            },
                            formatter: (a,b)=>{
                                return `{a|${a}}\n{b|999}`
                            }
                        }
                    },
                ],
                series: [
                    {
                        type: 'radar',
                        symbol: 'none',//去掉拐点的圈
                        data: [
                            {
                                value: arr1,
                                name: '某软件',
                                areaStyle: {
                                    normal: {
                                        color: 'blue'
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)"
                                },
                            },{
                                value: arr2,
                                name:'jja',
                                areaStyle: {
                                    normal: {
                                        color: 'red' // 图表中各个图区域的颜色
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)" // 图表中各个图区域的边框线颜色
                                },
                            }
                        ]
                    },
                ]
            };
            mychart.setOption(option);
        </script>

 

 

3、实现最终效果

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title></title>
        <script src="js/jquery.min.js"></script>
        <script src="js/echarts.js"></script>
    </head>
    <body>
        <div id="mychart" style="width:300px;height:300px;margin:0 auto;"></div>
        <script>
            var arr1 = [60,73,85,40,60];
            var arr2 = [23,90,23,32,67];
            var mychart =  echarts.init(document.getElementById('mychart'));
            var option = {
                radar: [
                    {
                        indicator: [
                            {text: '品牌', max: 100},
                            {text: '内容', max: 100},
                            {text: '可用性', max: 100},
                            {text: '功能', max: 100},
                            {text: '屏幕', max: 100}
                        ],
                        center: ['50%','54%'],//调整雷达图的位置
                        radius: 80,//半径,可放大放小雷达图
                        axisLine: {//坐标轴线相关设置
                            show: true,
                            lineStyle: {
                                color: 'red'
                            }
                        },
                        splitLine : {
                            show : true,
                            lineStyle : {
                                width : 1,
                                color : 'red' // 图表背景网格线的颜色
                            }
                        },
                        splitArea: {
                            show: false,
                        },
                    },
                ],
                series: [
                    {
                        type: 'radar',
                        symbol: 'none',//去掉拐点的圈
                        data: [
                            {
                                value: arr1,
                                name: '某软件',
                                areaStyle: {
                                    normal: {
                                        color: 'blue'
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)"
                                },
                            },{
                                value: arr2,
                                name:'jja',
                                areaStyle: {
                                    normal: {
                                        color: 'red' // 图表中各个图区域的颜色
                                    }
                                },
                                lineStyle: {
                                    color:"rgba(255,255,255,0)" // 图表中各个图区域的边框线颜色
                                },
                            }
                        ]
                    },
                ]
            };
            mychart.setOption(option);
            var i = -1;
            mychart.setOption({
                  radar: [
                    {
                        name: {
                            rich: {
                                a: {
                                    color: 'red',
                                    lineHeight: 20
                                },
                                b: {
                                    color: '#fff',
                                    align: 'center',
                                    backgroundColor: '#666',
                                    padding: 2,
                                    borderRadius: 4
                                }
                            },
                            formatter: (a,b)=>{
                                i++;
                                return `{a|${a}}\n{b|${arr1[i]}}`
                            }
                        }
                    }
                ]
            })
        </script>
    </body>
</html>

效果:

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yusirxiaer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值