简体   繁体   中英

How to prevent my crossfilter from selecting nothing - dc.js

I'm working on a project using dc.js and I don't want the crossfilter to render unless data is selected. Currently, it is possible to do something like this 在此输入图像描述

Is there a way to avoid this from happening? I want at least one bar to have to be selected to crossfilter.

I found the answer. you need to add the following two lines to your bar chart:

.round(dc.round.floor)
.alwaysUseRounding(true)

If your bar chart has the property .centerBar(true), you should use the following instead:

.round(function(n) { return Math.floor(n) + 0.5 })
.alwaysUseRounding(true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM