Dc.js - Listening to Chart Group Rendering

I am trying to refactor some kind of custom d3 code that I wrote to display a series of diagrams driven by cross filters by typing dc.js.

My main problem is that I have some types of diagrams that are not supported by dc.js (like Sunburst Partition ), and I'm trying to figure out how to render them in conjunction with the dc.js diagram group.

Filtering one chart dc.js automatically displays / redraws all other charts belonging to the same chartGroup . Is it possible to somehow connect to this global re-render event so that I can re-draw non-dc diagrams at the same time?

I understand that on every single chart there are listeners, for example. chart.on("postRender", function(chart){...}) , but there seems to be no way to intercept a group of charts. Is there a good scheme by which this can be achieved?

+5
source share
1 answer

The β€œright” way to do this is to register your chart in the dc registry using dc.registerChart

https://github.com/dc-js/dc.js/blob/master/src/core.js#L91

Unfortunately, this material is not currently documented, but there is indeed a fairly easy connection. You just need to implement .redraw() and .render() on some object (diagram or wrapper) and pass it as the first argument.

Put it in the same group (second argument) as the diagrams to which it should answer.

render () creates dom elements from scratch, and redraw () updates them when data changes.

It looks like you might also need to implement the .filterAll() dummy, but this is an oversight.

I added a problem to document this stuff:

https://github.com/dc-js/dc.js/issues/676

Please comment here or here if you have any problems.

EDIT: This is now documented thanks to Jasmine Hegman. See diagram documentation for documentation .

+8
source

Source: https://habr.com/ru/post/1200460/


All Articles