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

Better throttling

Open gordonwoodhull opened this issue 11 years ago • 5 comments

As pointed out here: https://groups.google.com/forum/m/#!topic/dc-js-user-group/3AlQht_8Eqs

The current brush throttling is actually a debounce: it prevents more than one brushing event from happening in a time interval, but it also prevents any events from happening while there are events coming in at a higher rate, and then just fires the last one at the end.

What we really want is to fire redraws as fast as we can without them backing up. So we start the first redraw, then throw out all but the last event we get while that's happening, then start the next redraw, etc.

Also see #627: some would prefer having no redraws at all until the end of brushing.

gordonwoodhull avatar Jul 06 '14 07:07 gordonwoodhull

for reference for others reading this thread: Difference between throttle and debounce

Lodash implementation of _.throttle: https://lodash.com/docs#throttle https://github.com/lodash/lodash/blob/master/lodash.src.js#L8438-L8455 https://github.com/lodash/lodash/blob/master/lodash.src.js#L7888

jefffriesen avatar Apr 18 '15 21:04 jefffriesen

@gordonwoodhull - Is there any way to actually make use of promises in dc.js as it stands? I was planning on spending some time on trying to implement something along the lines of Ethan's suggestion here: https://github.com/dc-js/dc.js/issues/627 to address this issue.

But it seems that dc.js isn't setup to support transpiling ES6 to ES5, and I doubt you would want to insert an extra dependency in the library just for this. Any suggestions?

HamsterHuey avatar Jan 25 '18 05:01 HamsterHuey

Hi @HamsterHuey. You don't need transpilation for promises, they are built into all the browsers except IE (and that can be polyfilled). It's only language features like async / await that need to be transpiled.

If you want to apply filters asynchronously as suggested by Ethan, you probably want to supply a filterHandler. I'm not sure how this ties in with brush throttling and would have to give it more thought, but if you come up with any solutions, please post them here.

gordonwoodhull avatar Jan 25 '18 12:01 gordonwoodhull

Thanks @gordonwoodhull . I'll definitely post back if I make any progress on this.

HamsterHuey avatar Jan 26 '18 02:01 HamsterHuey

Just learned about requestidlecallback from the video linked here : https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html

Perhaps there's something that can be done with it?

Frozenlock avatar Aug 27 '18 22:08 Frozenlock