Heatmap DC.js-如何手动过滤多个项目 [英] Heatmap DC.js - how to filter multiple items manually
问题描述
我正在使用dc.js处理热图.在页面加载期间,我想手动过滤热图.
I'm working on a heatmap chart using dc.js. During the page loads, i want to manually filter the heatmap.
例如,如果使用此heatmap.filter("30,0");进行过滤,它在页面加载时有效.但是当我尝试使用.filter()函数过滤多个值时,它没有起作用.
For example, if it filter using this heatmap.filter("30,0"); it works when the page loads. but when i try to filter multiple values using the .filter() function, it didnt work.
我只是为了测试而尝试这样做.
I tried doing this just for testing.
var test = [];
test.push("30,0");
test.push("40,2");
heatmapChart.filter(test);
虽然它只有一个项目才可以工作,但是如果我添加另一个数组项目,则图表会中断.是否有手动过滤多个项目的特定方法?
Though it works if its only one item, but if i add another array item, the chart breaks. Is there a specific way to filter multiple items manually?
推荐答案
是的,但是这里和那里之间有些怪异.
Yes, but there are a few layers of weird between here and there.
First, the actual filter items are constructed using dc.filters.TwoDimensionalFilter - I think your comma separated strings are only working by accident.
第二,图表已经覆盖了 .filter()
,因此,如果要获取可以处理多个项目的基本版本,则需要调用 chart._filter()
.
Second, the chart has already overridden .filter()
so if you want to get at the base version which can handle multiple items, you need to call chart._filter()
instead.
最后,也是最奇怪的是,对多个项目进行过滤的语法是提供一个包含单个过滤器项目数组的数组.
Finally, and weirdest of all, the syntax for filtering on multiple items is to supply an array containing a single array of filter items.
将所有这些放在一起,
var ff = [dc.filters.TwoDimensionalFilter([0,2008]),
dc.filters.TwoDimensionalFilter([3,1994]),
dc.filters.TwoDimensionalFilter([9,2000])];
heatmapChart._filter([ff]);
与热图过滤示例一起使用.注意过滤器数组的数组!
works with the heatmap filtering example. Note the array of array of filters!
这篇关于Heatmap DC.js-如何手动过滤多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!