记录一次echarts 中bar 定时跳跃并显示内容

2023-03-11,,

查看echarts api -----   https://www.echartsjs.com/zh/api.html#echarts

搜索

1.dispatchAction   执行的关键

2.highlight    变换显示的关键

3.tooltip   变幻时 显示提示框的关键

关键代码:

1. myChartSalarypie.setOption({});   设置自己的的option 内容

2. myChartSalarypie.dispatchAction({type: 'downplay',seriesIndex: 0,dataIndex: curIndex});

3.myChartSalarypie.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: curIndex});

4.myChartSalarypie.dispatchAction({
                                        type:'showTip',
                                        seriesIndex:0,
                                        dataIndex:curIndex
                                    });

跳动的完整代码:

if( runFlag !=null )
                                  {
                                       clearInterval(runFlag);
                                       runFlag = null ;
                                  }
                       if(curIndex == null) {
                           myChartSalarypie.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: 0});
                        }
                        else {
                            myChartSalarypie.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: curIndex});
                            myChartSalarypie.dispatchAction({
                                        type:'showTip',
                                        seriesIndex:0,
                                        dataIndex:curIndex
                                    });
                             
                               runFlag = setInterval(function () {
                                    var dataLen = showDate.length;
                                    // 取消高亮
                                    myChartSalarypie.dispatchAction({type: 'downplay',seriesIndex: 0,dataIndex: curIndex});
                                    curIndex = (curIndex + 1) % dataLen;
                                    //设置高亮
                                    myChartSalarypie.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: curIndex});
                                    myChartSalarypie.dispatchAction({
                                        type:'showTip',
                                        seriesIndex:0,
                                        dataIndex:curIndex
                                    });
                                }, 3000);
                                }
                       openRunFlag=false;

记录一次echarts 中bar 定时跳跃并显示内容的相关教程结束。

《记录一次echarts 中bar 定时跳跃并显示内容.doc》

下载本文的Word格式文档,以方便收藏与打印。