Histogram from model-data?

I’d like to display some kind of histogram from user-data, but i don’t
really know the approach to do so. I have a model Vote, they belong to
a User (user has_many votes), and each User has a Profile, and in
there i store things like age, location, etc. (user.profile.age or
vote.user.profile.age)

I now have a certain collection of votes from which i want a
histogram, and what i would like to have is for example for the ages a
result like: 0-20 => 15 votes, 21-50 => 10 votes, and 50+ => 2 votes
(the collection would have 27 votes)

how do i set this up?

The basic thing here that i don’t understand is how to use ‘find’ in
such a way that it only returns the votes for which the owner’s
profile gender for example equals ‘m’. I think i have to use :include,
but can’t really figure out the syntax to do so.