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

stacked barchart legend is upside-down

Open d2a-raudenaerde opened this issue 12 years ago • 3 comments

When stacking barcharts, the 'stacked' units are added from the bottom, for example the first stacked group (stack1) is above the base group (base). In the legend however, the items are added from the top to the bottom, i.e. stack1 is below base. Please keep them in the same order.

d2a-raudenaerde avatar Sep 17 '14 12:09 d2a-raudenaerde

The stack mixin needs a reverse().

_chart.legendables = function () {
    return _stack.map(function (layer, i) {
        return {chart:_chart, name:layer.name, hidden: layer.hidden || false, color:_chart.getColor.call(layer,layer.values,i)};
    }).reverse();
};

d2a-raudenaerde avatar Sep 17 '14 12:09 d2a-raudenaerde

Good idea, thanks.

gordonwoodhull avatar Sep 17 '14 15:09 gordonwoodhull

I don't think it is such a good idea to just reverse the order of labels, although exposing the possibility of sorting them sounds good. Currently, the user has a list of labels in the order of the stacks. When the stacks are passed dynamically, they will be most probably sorted decreasingly (as different groups in a crossfilter dimension usually are), which means that the greatest stack will be at the top of the legend and the user can immediately start interacting with it.

emiguevara avatar Oct 15 '14 13:10 emiguevara