1.饼图是不能通过grid调整位置的,需要调整series中的
center: [‘50%’, ‘40%’],可以将这两个参数看成坐标x,y,就是饼图的圆心的位置,比如将40%调整为20%,饼图就会往上移动容器高度的20%
2.echarts自动触发显示tooltip,通用的方法(适合饼图,柱形图,折线图...)
这个写在export default上面
var app = { currentIndex: -1};
data(){
screenWidth: document.body.clientWidth}
beforeDestroy() { clearInterval(this.timer); }, watch: { screenWidth(val) { this.screenWidth = val; this.myChart.resize(); } }, beforeDestroy() { clearInterval(this.timer); }, watch: { screenWidth(val) { this.screenWidth = val; this.myChart.resize(); } },
这个写在方法里
getTime() {clearInterval(this.timer);this.timer = setInterval(() => {var dataLen = this.option.series[0].data.length;// 取消之前高亮的图形this.myChart.dispatchAction({type: "downplay",seriesIndex: 0,dataIndex: app.currentIndex});app.currentIndex = (app.currentIndex + 1) % dataLen;console.log("666", dataLen);// 高亮当前图形this.myChart.dispatchAction({type: "highlight",seriesIndex: 0,dataIndex: app.currentIndex});// 显示 tooltipthis.myChart.dispatchAction({type: "showTip",seriesIndex: 0,dataIndex: app.currentIndex});}, 1800);},
handleMouseOver() { clearInterval(this.timer); this.myChart.dispatchAction({ type: "downplay", seriesIndex: 0, dataIndex: app.currentIndex }); },
handleMouseOut() { this.getTime(); },handleMouseOver() { clearInterval(this.timer); this.myChart.dispatchAction({ type: "downplay", seriesIndex: 0, dataIndex: app.currentIndex }); },
handleMouseOut() { this.getTime(); },