javascript - 通过单击元素打开 icCube 仪表板(带参数)
问题描述
如何在打开另一个仪表板的 icCube 仪表板上设置事件?(并通过选择参数)
解决方案
icCube 帮助我提出了一个类似的请求,以允许“在单击图表中的行/列时钻取 URL”问题。您可以修改它以设置 URL 以打开另一个仪表板。
以下设置打开一个新的浏览器选项卡,谷歌搜索图表中单击的行和年份过滤器的设置:
脚步:
- 在图表中定义一个或多个 On Click 事件,例如:On Row Click --> event:"country";
- 在例如 Year 上定义一个 MDX 过滤器,称它为:“year”;
- 在 Widget JS Hooks 中,设置“On Send Event”;
- 添加并修改以下代码(此代码使用您的参数打开 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”。
推荐阅读
- html - 无法在 Angular 6 中更改标签的高度和颜色
- python - 在 tkinter 中获取用户输入失败
- android - 从 Android Auto 获取某些信息
- python - 使用 Django Signals post_save 错误“save() 禁止以防止数据丢失做 unsave 相关对象 ''myModel.”
- php - PHP - 防止用户玩弄 url GET 变量
- python - 尝试读取大型网站文件数据时出现 MemoryError 异常
- c# - 如何在 EMGUCV 中使用 Facemarker?
- c# - 如何使用 Excel-DNA 循环遍历 Excel 中的一系列单元格来构建 UDF?
- java - 解组嵌套的 XML 标记
- android - 在同一活动中将数据片段传递给片段