页面树结构
转至元数据结尾
转至元数据起始

提示:本文档的示例代码仅适用于本文档中的示例报表/场景。若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。

1. 示例效果

通过客户端宏,让地图的高亮效果可以循环跳动,如下图所示:

2.操作步骤

  • 步骤一:新建一个空白的自助仪表盘

  • 步骤二:拖入图形 ,选择数据集或业务主题

效果如下:

  • 步骤三:选中图形,右键进入宏管理页

  • 步骤四:在界面新建客户端宏,弹出的新建模块对话框中输入名称,勾选对象为组件、事件为onBeforeRender

  • 步骤五:编写宏代码实现效果

把下面宏代码复制到代码区域;

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)

    
}
示例主要使用的是IEChartsPortlet对象下的getChartInstance方法,点击查看API详情
  • 步骤六:点击 保存,查看效果,需重新打开报表,可看到效果已实现


3. 下载资源

代码资源:migrate (4).xml

  • 无标签