Modify title and tooltip of echarts pie chart

Modify the title and font size of the pie chart

Insert picture description here

let option = {
    
    
    title: {
    
    
        text: '单位:千瓦',//标题
        right: 'right',//文字位置
        textStyle: {
    
    //修改字体样式
                fontSize: '14',
                fontWeight: 'normal'
              }
    		},
		  }

Modify tooltip

Insert picture description here

let option = {
    
    
	    title: {
    
    
	        text: '单位:千瓦',
	        right: 'right',
	        textStyle: {
    
    
	                fontSize: '14',
	                fontWeight: 'normal'
	              }
	    },
	    tooltip: {
    
    
	        trigger: 'item',
	        formatter: '{b}(千瓦) : {c} ({d}%)',
	        //{a}表示的名称,即name: '访问来源'
	        //{b}表示 series里data的名称name, name: '搜索引擎'--注意:--可以添加单位
	        //{c}表示 series里data的value,value: 300
	        //{d}表示 series里data的value,所占的百分比,
	        position:[20,40]//  可以 固定位置
	    },
	    legend: {
    
    
	        orient: 'vertical',
	        left: 'left',
	    },
	    series: [
	        {
    
    
	            name: '访问来源',
	            type: 'pie',
	            radius: '50%',
	            data: [
	                {
    
    value: 1048, name: '搜索引擎'},
	                {
    
    value: 735, name: '直接访问'},
	                {
    
    value: 580, name: '邮件营销'},
	                {
    
    value: 484, name: '联盟广告'},
	                {
    
    value: 300, name: '视频广告'}
	            ],
	            emphasis: {
    
    
	                itemStyle: {
    
    
	                    shadowBlur: 10,
	                    shadowOffsetX: 0,
	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
	                }
	            }
	        }
	    ]
};

Guess you like

Origin blog.csdn.net/weixin_45108907/article/details/113517420