84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
As shown in the figure, I want to directly obtain the name of each segment of the pie chart in the background and use it as the legend directly, replacing the red "test" at the top. How to get the name of each segment? Thanks!
var myChart = echarts.init(document.getElementById('main')), option = { tooltip: {}, legend: {}, series: [{ name: '访问来源', type: 'pie', radius: '55%', center: ['50%', '60%'], data: [], itemStyle: { emphasis: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' } } }] }; myChart.setOption(option); //以下为ajax获取到的数据 var data = [{ value: 335, name: '直接访问' }, { value: 310, name: '邮件营销' }, { value: 234, name: '联盟广告' }, { value: 135, name: '视频广告' }, { value: 1548, name: '搜索引擎' }], legends = [] data.forEach(function(e, i) { legends.push(e.name) }) myChart.setOption({ legend: { data: legends }, series: [{ data: data }] });