遇到的一個很頭疼的問題,要求坐標軸也跟隨高亮,但是echarts沒有現有的設定可以做出來,就想了一個偏方。記錄一下,代碼如下。
option = { tooltip: { }, legend: { data: ['收入'] }, grid: [{ left: '40', right: '4%', bottom: '3%', containLabel: false, tooltip: { show: true, trigger:'item', } }, { left: '0', right: '4%', bottom: '3%', containLabel: false, tooltip: { trigger: 'axis', axisPointer: { // 坐標軸指示器,坐標軸觸發有效 type: 'shadow' // 默認為直線,可選為:'line' | 'shadow' } }, }], xAxis: [ { type: 'value', gridIndex: 0, }, { type: 'value', gridIndex: 1, } ], yAxis: [ { type: 'category', gridIndex: 0, axisTick: { show: false }, data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] }, { show:false, gridIndex: 1, type: 'category', axisTick: { show: false }, data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] } ], series: [ { name: '收入', type: 'bar', stack: '總量', label: { show: true, position: 'left' }, data: [-120, -132, -101, -134, -190, -230, -210] } ] };