交叉过滤器过滤器不过滤(dc.js) [英] Crossfilter filters not filtering (dc.js)

查看:193
本文介绍了交叉过滤器过滤器不过滤(dc.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





以下是最相关的代码:

  var userDimension = data.dimension(function(d){return d.user;})filter(['John','Paul']); 
var totalSalesByUser = userDimension.group();
var pieChartUserSales = dc.pieChart(#pie-chart-sales-by-user);
pieChartUserSales
.width(150).height(150)
.dimension(userDimension)
.group(totalSalesByUser);

dc.renderAll();

饼图看起来和过滤器一样,没有过滤器,但我要找的效果是

解决方案

Crossfilter过滤器不适用于定义在与过滤器相同的尺寸。创建第二个维度并对其进行过滤。



这是一个更新的示例。还要注意,你定义的过滤器不会做你可能意味着它,所以我改变了一个过滤器只有保罗和约翰的函数: http://jsbin.com/yugakire/1/edit


I'm trying to use filters in crossfilter, but nope.

Here's the JSBin

Here's the most relevant code:

var userDimension = data.dimension(function(d) {return d.user;}).filter(['John', 'Paul']);
var totalSalesByUser = userDimension.group();
var pieChartUserSales = dc.pieChart("#pie-chart-sales-by-user");
pieChartUserSales
  .width(150).height(150)
  .dimension(userDimension)
  .group(totalSalesByUser); 

dc.renderAll();

The pie chart looks the same with and without the filter, but the effect I'm looking for is narrowing it down to the items where John or Paul is the user.

解决方案

Crossfilter filters don't apply to groups defined on the same dimension as the filter. Create a second dimension and filter on that.

Here's an updated example. Also note that the filter you defined doesn't do what you probably meant it to do, so I changed that to a function that filters to only Paul and John: http://jsbin.com/yugakire/1/edit

这篇关于交叉过滤器过滤器不过滤(dc.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆