该宏示例在 V10.5上 验证通过 本文档的示例代码仅适用于本文档中的示例报表/场景。若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。 |
仪表盘根据文本类型的筛选器备选值(备选值需在宏代码中设置)进行轮播,可以通过菜单工具栏中的“开始轮播”、“暂停轮播”以及“停止轮播”按钮控制轮播。
该宏示例需注意的事项如下:
|
① 在仪表盘中任意位置右键进入“宏管理”界面
② 进入宏管理界面,新建宏,在弹出的新建模块对话框中输入名称,勾选对象为“仪表盘”,事件为“onRender(每次渲染完成后)”。
③ 宏示例“筛选器备选值轮播”主要使用的是
把下面宏代码复制到代码区域:
function main(page: IPage) { const portlet: IFilterPortlet = page.getPortletsByTitle('年份')[0] as IFilterPortlet; let pageMenu = page.getPageToolbar() setTimeout(() => { pageMenu.addButton({ icon: 'sx-icon-liked icon-16', tooltip: '开启轮播', color: '#0f0', handler: function () { launchCarousel(portlet); } }, 1) pageMenu.addButton({ icon: 'sx-icon-liked icon-16', tooltip: '暂停轮播', color: 'yellow', handler: function () { portlet.pauseCarousel(); } }, 1) pageMenu.addButton({ icon: 'sx-icon-liked icon-16', tooltip: '停止轮播', color: 'red', handler: function () { portlet.turnOffCarousel(); } }, 1) }, 1000) //launchCarousel(portlet) } function launchCarousel(portlet: IFilterPortlet) { // 筛选器类型为日期与文本时,则需要在宏代码中配置轮播的参数值。 const standByValues: Array<IStandByValue> = [ { value: '2016年' }, { value: '2017年' }, { value: '2018年' }, { value: '2019年' } ] let options: ICarouselOptions = { timeout: 1.5, infinite: true, standByValues }; portlet.turnOnCarousel(options); } |