mmmdreg
mmmdreg

Reputation: 6608

dc.js cap ordinal bar chart

dc.js has a Cap mixin which allows one to limit the number of groups and display the remainder in an "others" group. How does one access this behavior or exclude the remainder in a bar chart?

I am using a bar chart as I want to show a top 5 with stacked data. For example, the top 10 car manufacturers based on the total of fleet and private sales (in separate stacks). I am using a function to dynamically generate 5 ordinals (i.e. car manufacturers) for the x axis in the order that I want, and the graph generates nearly as expected. However, a separate bar containing the values that don't fit into one of the x values is placed at the start of the graph.

I've added a snapshot of the chart below. Note that I've rotated it with renderlet so it's on its side.

How do I remove the extraneous bar (at the top)?

If not possible, I may contemplate using two row charts side by side with one flipped so that the origin is on the right.

chart

Upvotes: 1

Views: 1776

Answers (1)

Gordon
Gordon

Reputation: 20140

Sigh, the bar chart is not capped, and the row chart is not stacked. Hope to fix that.

That extraneous bar looks... not right.

With capped charts, you can eliminate the "others group" by setting the othersGrouper falsy. With the bar chart you would have to implement a "fake group" using the techniques documented here:

https://github.com/dc-js/dc.js/wiki/FAQ#filter-the-data-before-its-charted

... at least for now.

Upvotes: 3

Related Questions