Clearing empty positions and ordering dc.js bar chart

458 views Asked by At

I've used a fake group to fix my issue with plotting only top(n) values on a graph. Now I found an other issue that the bar chart shows a few empty positions for those data fields that doesn't come under 'ton(n)', I want to remove them and sort the bars in descending order of their values.

Here is the JSFiddle.

orgHigestBandwidthConsumed.dimension(dimByOrgName)
.group(fakeGroup)
.ordering(function (d) { return -d.value; })

I've tried chart.ordering() to order the bars which didn't work. Can somebody help me fixing this?

enter image description here

1

There are 1 answers

4
Gordon On BEST ANSWER

Since you are specifying the ordinal domain, dc.js will use that instead of calculating it using the existing values and the ordering you specify.

Simply remove the domain and specify the ordering:

.x(d3.scale.ordinal())
.ordering(function(kv) { return -kv.value; })

Fork of your fiddle: http://jsfiddle.net/0p78m8vr/6/