Echarts 雷达图指示器名称rich使用示例

1.radar.name.rich

'radar.name': {
    textStyle: {
        color: '#5a4b66'
    },
    formatter: (str) => {
        let obj = _.find(personalityChart, (pc: any) => pc.image === str) || {};
        let percent = obj.percent ? `${Math.round(obj.percent * 100)}%` : '-';
        return `{b|${percent}}  {c|${str}}`;
    },
    rich: {
        b: {
            color: '#F78A89'
        }
    }
},
'**tooltip.formatter': (opts) => {
	let indicator = _.get(opts, 'radar.indicator');
	return (obj) => {
		let {
			name,
			value
		} = obj.data;
		let contentArr = indicator.map((key, inx) => `${key.name}: ${value[inx]}`);
		contentArr.unshift(obj.marker + name);
		return contentArr.join('
'); }; } let personalityChart = [{ "celebrity": "", "celebrity_code": "12345", "id": 17, "image": "人品", "negative": 553, "percent": 0.6545, "positive": 4492, "total": 6018, "x": "人品", "name": "王俊凯", "value": 6018 }, { "celebrity": "", "celebrity_code": "12345", "id": 21, "image": "品味", "negative": 157, "percent": 0.6256, "positive": 2974, "total": 4503, "x": "品味", "name": "王俊凯", "value": 4503 }, { "celebrity": "", "celebrity_code": "12345", "id": 22, "image": "声音", "negative": 3, "percent": 0.9225, "positive": 777, "total": 839, "x": "声音", "name": "王俊凯", "value": 839 }];

percent来自原始数据personalityChart,str来自echarts渲染后数据

在tooltip格式化处理系列名,画图字段为value,效果图:

Echarts 雷达图指示器名称rich使用示例_第1张图片

你可能感兴趣的:(学习总结,Echarts,雷达图)