在Crossfilter中使用过滤器

sel*_*gsz 6 d3.js crossfilter

我刚开始使用crossfilter和d3.js ...我正在尝试API参考中给出的一些片段...我有以下数据

var payments = crossfilter([
  {date: "2011-11-14T16:17:54Z", quantity: 2, total: 190, tip: 100, type: "tab"},
  {date: "2011-11-14T16:20:19Z", quantity: 2, total: 190, tip: 100, type: "tab"},
  {date: "2011-11-14T16:28:54Z", quantity: 1, total: 300, tip: 200, type: "visa"},
  {date: "2011-11-14T16:30:43Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T16:48:46Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T16:53:41Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T16:54:06Z", quantity: 1, total: 100, tip: 0, type: "cash"},
  {date: "2011-11-14T16:58:03Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T17:07:21Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T17:22:59Z", quantity: 2, total: 90, tip: 0, type: "tab"},
  {date: "2011-11-14T17:25:45Z", quantity: 2, total: 200, tip: 0, type: "cash"},
  {date: "2011-11-14T17:29:52Z", quantity: 1, total: 200, tip: 100, type: "visa"}
]);
Run Code Online (Sandbox Code Playgroud)

我可以通过类型创建维度

var paymentsByTotal = payments.dimension(function(d) { return d.type; });
Run Code Online (Sandbox Code Playgroud)

我的问题是如何过滤字符串数组.我试过了:

paymentsByTotal.filterRange(["cash","visa"]);
Run Code Online (Sandbox Code Playgroud)

但我没有得到预期的结果!

有什么建议?

Hyd*_*der 3

Crossfilter.js 的 master 分支中的源代码没有提供过滤器联合的规定,您必须从Jason Davies 的联合分支获取代码。

然后,您应该能够执行paymentsByTotal.filter("cash","visa");并获得所需的输出。