通过客户端宏,让地图的高亮效果可以循环跳动,如下图所示:
效果如下:
把下面宏代码复制到代码区域;
function main(page: IPage, portlet: IEChartsPortlet) { // console.log('portlet: ', portlet) // console.log('chartInstance: ', portlet.getChartInstance()) let options = portlet.getChartOptions() //获取组件对象 let data = options.series[0].data let count = data.length let chartInstance = portlet.getChartInstance() let curIndex = 0 let lastIndex = -1 let interval = setInterval(function () { // 定时器,但是没关 try { // console.log('curIndex: ', curIndex) // console.log('lastIndex: ', lastIndex) if (lastIndex != -1) { chartInstance.dispatchAction({ type: 'downplay', dataIndex: lastIndex }); } chartInstance.dispatchAction({ type: 'highlight', dataIndex: curIndex }); lastIndex = curIndex curIndex++ if (curIndex >= count) { curIndex = 0 } } catch (e) { console.error('e: ', e) clearInterval(interval) } }, 1500) } |
代码资源:migrate (4).xml