chainable .data() function · Issue #584 · dc-js/dc.js (original) (raw)

Originally, .data() was intended for pre-processing or filtering data. It takes a group and returns data in the same format as group.all().

However, this does not work if the chart uses .data() internally, because one will override the other.

So the current best way to do this is to create a fake group which wraps the group and implements .all() by fetching the data from the group and then returning its modified version of the data. This works fine and groups can be wrapped multiple times, but it's a bit confusing for new users, and it also looks like an ugly hack until you get used to it.

A simple solution would be to have an internal .data() and an external .data(), but this isn't very elegant and doesn't support the possibility that multiple levels of the chart might want to preprocess the data.

Better to figure out a way to chain them so that (I presume) the client processes the data first, then the base, then the children.