dc.js/d3.js 有没有办法在 pie/row 图表上获取所有选定的切片、路径等?

dc.js/d3.js Is there a way to get all the selected slices,paths, etc on a pie/row chart?

能够根据此 在 pie/bar 图表上运行点击事件,返回所选路径的 key/value。我只是想知道是否有一种方法可以在这样的点击中获得给定图表的所有选定 path/rect?

基本试过了:

d3.selectAll('g').forEach(function(d) {
   for (var prop in d) {
      if (d[prop].classList !=== undefined && d[prop].classList.contains('selected')) {
          var ( elem in d[prop].children ) {
              // I can see the path element there but have been unable to get at it
              console.log(d[prop].children[elem]);

          }
      }
   }
});

我想要做的是获取路径,以便为页面上所有选定的图表路径获取 d.data.key。

您可能应该查看数据,而不是尝试从 svg 元素对其进行逆向工程。

听起来 chart.filters() 会给你想要的。

http://dc-js.github.io/dc.js/docs/html/dc.baseMixin.html#filters__anchor