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

Cap bar charts

Open dgorissen opened this issue 11 years ago • 6 comments

Im quite surprised to see you can cap row charts but not bar charts? Whats the workaround to tell a bar chart to only show the top k bars (as defined by ordering)?

As an aside: it would also be useful to be able to say "plot as many bars as you can as long as the bar width remains at least 20" (again as defined by ordering). This now requires quite some manual twiddling which I am trying to figure out.

dgorissen avatar Jun 04 '14 11:06 dgorissen

Yes, this is peculiar. My understanding is that this came about because the two charts were written by two different people with different requirements. A lot of dc.js "just happened" in that way, without being planned.

The workaround shouldn't be so bad, but I don't have an example just yet. Use the "fake group" technique described here: https://github.com/dc-js/dc.js/wiki/FAQ#filter-the-data-before-its-charted

If you can contribute an example until this is fixed properly, it would be a great help to everyone. This is frequently requested.

gordonwoodhull avatar Jun 04 '14 12:06 gordonwoodhull

Thanks for the reply @gordonwoodhull . I did see the fake group example and actually tried it in various forms but interestingly never got it to work. It never seemed to actually do anything (not for capping, nor for filtering groups). It was part of the reason I had to abandon my dc usage for a particular project as I was pushing towards a deadline.

However, will be having another shot and will report back here with concrete issues If I can replicate the problems.

dgorissen avatar Jun 07 '14 07:06 dgorissen

Well, it is a horrible hack after all, and it may be more difficult than it sounds to get it working.

There's an interesting question here about what belongs to the chart and what belongs to some prefiltering component. I plan to explore this for 2.1.

gordonwoodhull avatar Jun 07 '14 15:06 gordonwoodhull

Hello i too search for a possibility to limit the numbers of bars in the barchart .... still no chance for doing this? I don't like to use the rowchart in this example ...

AndreasSteibl avatar Jun 28 '18 08:06 AndreasSteibl

Hello I too search for a possibility to limit the numbers of bars in the barchart .Is there a solution to this urgent?

sevilylmz avatar Dec 18 '20 16:12 sevilylmz

Hi @sevilylmz, I checked Stack Overflow but I was surprised not to find an answer.

Would you be so kind as to post a question there, and I will answer promptly? If you can include sample data and code, that would help.

gordonwoodhull avatar Dec 18 '20 20:12 gordonwoodhull