//来自群友 AAAA钢丝球批发Alive option = { backgroundColor: '#fff', title: { text: '2022收入完成情况分析', top: '17%', textAlign: 'center', left: '49.5%', textStyle: { color: '#262626', fontSize: 18, fontWeight: '600', }, }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { top: '25%', right: '23%' }, grid: { top: '33%', left: '23%', right: '24%', bottom: '28%', containLabel: true }, xAxis: [{ type: 'category', data: ['实际收入', '确保收入', '目标收入', '挑战收入'], axisTick: { show: false, }, splitLine: { show: false, }, axisLine: { show: false, }, axisLabel: { color: 'rgba(73,80,87,0.9)', fontSize: 12, fontWeight: 600, interval: 0, padding: [8, 0, 0, 0] }, }], yAxis: [{ type: 'value', name: '(万元)', nameTextStyle: { color: "rgba(73,80,87,0.9)", fontSize: 12, padding: [0, 0, 6, -60], }, axisLabel: { show: true, textStyle: { color: 'rgba(73,80,87,0.9)', }, padding: 10 }, }], series: [{ name: '对外收入', type: 'bar', emphasis: { focus: 'series' }, barWidth: 20, label: { normal: { show: false, position: "top", formatter: function (data) { return '{a0|' + data.value + '}'; }, rich: { a0: { color: '#5470c6', fontSize: 12, fontFamily: 'DIN', fontWeight: 'bold' }, } }, }, //188.82, 180, 200, 260 data: [{ value: 188.82, label: { show: false } }, { value: 180, label: { show: false } }, { value: 200, label: { show: false } }, { value: 260, label: { show: false } } ] }, ] }; myChart.on("click", (event) => { setTimeout( () => { //先都清空 option.series[0].data.map((item)=>{ item.label.show=false; }) let idx= option.series[0].data.findIndex((e)=>e.value==event.data.value); option.series[0].data[idx].label.show=true; console.log("event",event); myChart.setOption(option,true); }, 10 ) })