Rowchart select only a single bar in dc.js / crossfilter?

雨燕双飞 提交于 2019-12-01 06:47:12

Ethan's answer is almost there. It's likely unintentional, but dc.js doesn't appear to use the return value for addFilterHandler, so you'll have to modify the filters parameter for it to work, like so:

myChart.addFilterHandler(function (filters, filter) {
    filters.length = 0; // empty the array
    filters.push(filter);
    return filters;
});

This works great as long as your chart doesn't use cap (e.g. a pie chart with limited slices), as this handler prevents the others group from working. I've yet to come up with a satisfactory solution for that case, unfortunately.

I assume you'll want addFilterHandler - https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#dc.baseMixin+addFilterHandler

You'd probably want to do the following, but it's untested.

myChart.addFilterHander(function (filters, filter) {
    return [filter];
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!