AnyChart Treemap drillChange current event out of sync with getDrilldownPath

ぐ巨炮叔叔 提交于 2019-12-25 03:44:14

问题


With Anychart 8.3+ I am using the TreeMap chart.listen('drillChange') listener to obtain a clicked element's information.

Note: I needed to use e.current.get('name') as shown in an example, instead of e.currentTarget as per Treemap listen() documentation. However the getDrillDownPath() value seems to be one event-click behind. Why is this?

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
});

Below is a link to sample code, showing the undefined e.currentTarget, the defined e.current.get('name'), and the drilldown path value being one step behind.

https://playground.anychart.com/AeI6bUhK/7

Thanks in advance!


回答1:


The e.currentTarget is the default field which in some context can be undefined. The getDrillDownPath() function returns the path to the current level. The current level you can get from e.current.get('name'). So, for your purpose the full path you can get like this:

  chart.title("Treemap: Interactivity (Drillchange)" +
    "<br><br>Path: " + text + "\\" + e.current.get('name')
  );


来源:https://stackoverflow.com/questions/54017423/anychart-treemap-drillchange-current-event-out-of-sync-with-getdrilldownpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!