通过客户端宏,让地图的高亮效果可以循环跳动,如下图所示:
2.操作步骤
- 步骤一:新建一个空白的自助仪表盘
- 步骤二:拖入图形 ,选择数据集或业务主题
效果如下:
- 步骤三:选中图形,右键进入宏管理页
- 步骤四:在界面新建客户端宏,弹出的新建模块对话框中输入名称,勾选对象为组件、事件为onBeforeRender
- 步骤五:编写宏代码实现效果
把下面宏代码复制到代码区域;
代码块 | ||||
---|---|---|---|---|
| ||||
// 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) |
- 步骤六:点击 保存,查看效果,需重新打开报表,可看到效果已实现