.elasticX(true) doesn't work dc.js

旧城冷巷雨未停 提交于 2019-12-06 15:10:10

I think you mean the elastic is not kicking in when the chart is filtered.

This is because crossfilter still returns bins if they are empty - they just have value zero. So dc.js still detects the domain of all the bins, including the empty ones.

What you can do is use a fake group to remove the empty bins

function remove_empty_bins(source_group) {
    return {
        all:function () {
            return source_group.all().filter(function(d) {
                return d.value != 0;
            });
        }
    };
}


var filtered_group = remove_empty_bins(group);

chart.dimension(dim)
    .group(filtered_group)
    ...

Then dc.js will detect only the domain of non zero values. More details in the FAQ.

You have to apply this to all groups that make up the chart.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!