listener - AnyChart Treemap DrillChange 当前事件与 getDrilldownPath 不同步
问题描述
对于 Anychart 8.3+,我正在使用 TreeMapchart.listen('drillChange')
侦听器来获取单击元素的信息。
注意:我需要按照示例e.current.get('name')
中所示使用,而不是按照 Treemap文档。但是,该值似乎是一个事件单击。为什么是这样?e.currentTarget
listen()
getDrillDownPath()
chart.listen("drillChange", function(e){
// get the drilldown path and convert it to a string
var text = printPath(chart.getDrilldownPath());
// set the chart title
chart.title().useHtml(true);
chart.title("Treemap: Interactivity (Drillchange)" +
"<br><br>currentTarget: " + e.currentTarget +
"<br><br>current.get('name'): " + e.current.get('name') +
"<br><br>Path: " + text
});
下面是示例代码的链接,显示 undefined e.currentTarget
、 definede.current.get('name')
和向下钻取路径值落后一步。
https://playground.anychart.com/AeI6bUhK/7
提前致谢!
解决方案
这e.currentTarget
是在某些情况下可以未定义的默认字段。该getDrillDownPath()
函数返回当前级别的路径。您可以从中获得的当前级别e.current.get('name')
。因此,为了您的目的,您可以获得这样的完整路径:
chart.title("Treemap: Interactivity (Drillchange)" +
"<br><br>Path: " + text + "\\" + e.current.get('name')
);
推荐阅读
- reactjs - react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.createRoo
- java - 无法运行无头 chromedriver
- content-management-system - 合作编辑对鹡鸰的评论?
- r - 如何将同步 R dygraphs 的 x 轴与单双 y 轴对齐?
- java - 如何自定义 Bigbluebutton 模块,如(poll)?
- java - 如何在依赖的 Gradle 项目中使用依赖项中的实现依赖项?
- sql - 如何在更新时将行的副本放入另一个表中?
- java - Spring-boot OncePerRequestFilter - 缓存请求后缺少请求参数
- django - 如何将数据添加到特定用户并显示在特定页面中?
- firebase - 如何管理用户数据