首页 > 解决方案 > 通过单击元素打开 icCube 仪表板(带参数)

问题描述

如何在打开另一个仪表板的 icCube 仪表板上设置事件?(并通过选择参数)

标签: javascriptparametersdashboardiccubeiccube-reporting

解决方案


icCube 帮助我提出了一个类似的请求,以允许“在单击图表中的行/列时钻取 URL”问题。您可以修改它以设置 URL 以打开另一个仪表板。

以下设置打开一个新的浏览器选项卡,谷歌搜索图表中单击的行和年份过滤器的设置:

脚步:

  1. 在图表中定义一个或多个 On Click 事件,例如:On Row Click --> event:"country";
  2. 在例如 Year 上定义一个 MDX 过滤器,称它为:“year”;
  3. 在 Widget JS Hooks 中,设置“On Send Event”;
  4. 添加并修改以下代码(此代码使用您的参数打开 Google):
/**
 * Tips:
 * type  - fired event type,
 * event - fired event object (same as first element of args array),
 * args  - list of arguments passed to fireEvent function
 * 
 * Function may return:
 *  - event - will replace first element of args
 *  - args  - will replace whole args array
 *  - false - will cancel event
 */
function(context, $box, type, event, args) {    
  let yearEvent =  context.reportingContext.eventMgr_._eventValues["year"];
  if (!event.isEmptyEvent() && yearEvent && !yearEvent.isEmptyEvent() ) {      
    let win = window.open("https://www.google.com/search?q="+ event.caption() + "+" + yearEvent.caption() , '_blank');
    win.focus();
  }
  return args;
}

结果(测试)

当您单击例如国家“荷兰”时,过滤器设置为“2011”-> google 打开搜索结果为“荷兰 2011”。


推荐阅读