D3.js DC.js |如何触发D3更新?

D3.js DC.js |如何触发D3更新?,d3.js,dc.js,D3.js,Dc.js,我正在使用一些D3代码来整理我的DC盒形图,例如,将圆。离群值半径变小,在每个盒形图后面插入一个矩形,并附加一个悬停标题 这在页面加载时效果很好。我希望它也能用于过滤。它适用于一种过滤,而不是另一种过滤 我在同一个仪表板上有一个直方图,使用.brushOn(true),我有一个事件,可以正确更新过滤器上的箱线图: .on("filtered", function(obj){ update(); }); 这段代码调用了下面的函数,它调用了另外两个函数:(1)updateFactorFields2

我正在使用一些D3代码来整理我的DC盒形图,例如,将圆。离群值半径变小,在每个盒形图后面插入一个矩形,并附加一个悬停标题

这在页面加载时效果很好。我希望它也能用于过滤。它适用于一种过滤,而不是另一种过滤

我在同一个仪表板上有一个直方图,使用.brushOn(true),我有一个事件,可以正确更新过滤器上的箱线图:

.on("filtered", function(obj){ update(); });
这段代码调用了下面的函数,它调用了另外两个函数:(1)updateFactorFields2,它通过fakegroup更新箱线图后面的数据,并且似乎可以工作。(2)整洁的盒子图,这就是问题所在

function update() {

  var grps = window.grps;//an array holding my crossfilter groups
  var dims = window.dims; //an array holding CF dimensions

  updateFactorFields2(grps[0]);

  factorBox.render();//factorBox is my DC boxplot chart

  tidyBoxPlots('postRender');

}
tidyBoxPlots也会更新.title,但是下面的代码就足够了。tidyBoxPlots在最终由histChart.on(“filtered”,…)触发时起作用

但是,当由以下事件触发时,tidyBoxPlots不工作,即使调用了update(),并且updateFactorFields工作:

$("[id='filterDropdown']").on('change',function(e,p){
        if (p.selected) {
          var tempIndex = filters[0].indexOf(e.target.id);
          filters[6][tempIndex].push(p.selected);//store this filter
          filters[5][tempIndex].filterFunction(function(d){ return filters[6][tempIndex].indexOf(d)!=-1; });//filter the dimension stored in filters[5] by the array values stored in filters[6]
          update();//calls update() fine

        }
我很确定问题在于我使用的事件类型,因为我以前在这方面遇到过麻烦。所以我尝试了大部分,如果不是全部,但没有乐趣:

我在下拉列表中使用selected.js,因此使用jquery

有人能帮忙吗


感谢有相同问题的其他人:问题是获取正确的事件类型,并在相对于dc.renderAll()的正确位置调用update()

谢谢你的跟进。正确的事件类型是什么?它只是postRender,但在调用.render()之后,我必须交换一些代码行才能获得它
$("[id='filterDropdown']").on('change',function(e,p){
        if (p.selected) {
          var tempIndex = filters[0].indexOf(e.target.id);
          filters[6][tempIndex].push(p.selected);//store this filter
          filters[5][tempIndex].filterFunction(function(d){ return filters[6][tempIndex].indexOf(d)!=-1; });//filter the dimension stored in filters[5] by the array values stored in filters[6]
          update();//calls update() fine

        }