Listening for chart group render

308 views
Skip to first unread message

in...@madebydna.com

unread,
Aug 15, 2014, 11:08:14 PM8/15/14
to dc-js-us...@googlegroups.com

I'm trying to refactor some custom d3 code I wrote to render a series of crossfilter-driven charts by bringing in dc.js.

My main problem is that I have some chart types that are not supported by dc.js (e.g. a Sunburst Partition) and I'm trying to figure out how to render them in conjunction with a dc.js chart group.

Filtering a single dc.js chart will automatically render / redraw all other charts belonging to the same chartGroup. Is it possible to somehow hook into that global group re-render event, so that I can re-draw the non-dc charts at the same time?

I understand that there are listeners on each individual chart, e.g. chart.on("postRender", function(chart){...}) but there doesn't seem to be a way to hook into re-rendering a group of charts. Is there a good pattern by which this could be accomplished?

Any help would be greatly appreciated!

Adam Reynolds

unread,
Aug 16, 2014, 4:05:26 AM8/16/14
to in...@madebydna.com, dc-js-us...@googlegroups.com
The listeners are on individual charts but as the charts work as a group, just use one chart as the 'control' chart and add the trigger to that chart. 

Another option is to pop into the code for  and add the sunburst chart and do a pull request to get the chart into dc.js 2.1 ;)

Andrea Singh

unread,
Aug 16, 2014, 8:12:25 PM8/16/14
to Adam Reynolds, dc-js-us...@googlegroups.com
Thanks, Adam. Using just one of the dc charts as a "control" chart would work of course. First I thought that maybe the "postRedraw" function doesn't get triggered when the control chart itself is filtered, but it does, so no problems there. 

As to incorporating the sunburst chart into the dc library - well, that just seems a bit daunting at the moment ;-)
--
~ Andrea

Gordon Woodhull

unread,
Sep 9, 2014, 5:23:00 PM9/9/14
to Andrea Singh, Adam Reynolds, dc.js user group
Just catching up on my dc.js mail here (returned a week ago).

The better answer is to use the (undocumented) dc.chartRegistry functions, although it certainly will work to have a "control" chart.

Looks like Blair has beat you to incorporating the sunburst chart.  I hope you will try it out and/or help review the code!

Andrea Singh

unread,
Sep 10, 2014, 12:38:57 PM9/10/14
to Gordon Woodhull, Adam Reynolds, dc.js user group
Thanks, Gordon. I just replied to the thread on the sunburst chart. I'll be very happy to try it and look at the code.

By the way, I've been working on my own version which used a custom object that I registered with dc. The dc.registerChart() function worked without issue.
--
~ Andrea

Blair Nilsson

unread,
Sep 11, 2014, 2:40:59 AM9/11/14
to dc-js-us...@googlegroups.com
Do you think an "empty chart" where people can override the renderlet is the way? This seems like a common request.

Blair Nilsson

unread,
Sep 11, 2014, 2:41:01 AM9/11/14
to dc-js-us...@googlegroups.com

Gordon Woodhull

unread,
Sep 11, 2014, 3:29:42 AM9/11/14
to Blair Nilsson, dc-js-us...@googlegroups.com, NORM members' discussion
I could be wrong but I don't think you get enough of the power of d3 in a renderlet to really make the "blank chart" viable. I think it would be hard to do meaningful transitions, and I'm not sure binding data would work right. Renderlets are just a band aid.

By all means try it, if you like.

I think documenting the internal interfaces and providing templates people can fill in, are better ways to make it easy to add charts.

David Saeger

unread,
May 23, 2016, 5:04:36 PM5/23/16
to dc-js user group, gor...@woodhull.com, awjre...@gmail.com
Andrea,

I've been running into a similar problem as the OP and based on this thread I think dc.registerChart() might be the way forward. I was wondering if you had an example of this solution as I've had trouble implementing it. 
Reply all
Reply to author
Forward
0 new messages