dc.js icon indicating copy to clipboard operation
dc.js copied to clipboard

Suggestion for faster dc.filterAll()

Open ehansis opened this issue 9 years ago • 2 comments

I have built a dashboard with ~10 graphs and lots of data (which, unfortunately, I cannot share). Calling dc.filterAll() on it is pretty slow, taking 10-15 seconds. The default implementation of dc.filterAll() calls .filterAll() on each chart. Is there a reason why this couldn't be limited only to charts that actually have filters set? In my use cases, this typically applies only to a few charts. The following version works much quicker for me:

    function myFilterAll() {
        var charts = dc.chartRegistry.list();
        for (var i = 0; i < charts.length; ++i) {
            if (charts[i].hasFilter()) {
                charts[i].filterAll();
            }
        }
    }

I'm on dc.js version 2.1.4 (but the code for dc.filterAll() seems to be identical in the current 2.1.8).

ehansis avatar Jul 19 '17 07:07 ehansis

I'm surprised that crossfilter doesn't notice when filterAll is a no-op, but after briefly scanning the code I am pretty sure it does not.

That would be the best place to fix this. However, I'd certainly take a pull request for dc.js with the above logic. Thank you!

gordonwoodhull avatar Jul 19 '17 14:07 gordonwoodhull

OK, just submitted a PR.

My changes of the tests are a bit shaky - I haven't worked with this toolset before. Tests pass, but they are not overly smart.

ehansis avatar Jul 24 '17 20:07 ehansis