Page 1 of 1

The more in the category, the bigger the font... [solved]

Posted: Wed Mar 21, 2007 7:54 pm
by Skara
Ok, I want to do something like this...
http://wordpress.org/extend/plugins/tags/

If someone knows where I can find that code, great. If not, I need to figure it out myself. ->


So, the more items that are in a tag/category, the bigger the font.

I'm not quite sure how to go about it. I have about 2000 entries, and the list is growing. I'll probably have around 50 tags or so. Maybe as many as 100.

So, I would like to do something like this...

Code: Select all

$min = 12; //px
$max = 24; //px
// biggest category = 1400
// middle categories...
// smallest category = 5

scale_sizes($categorylist,$min,$max); # <---

// biggest category font size = 24
// middle categories proportionately spaced in size
// smallest category font size = 12
example:

Code: Select all

$categories = array(18,27,36);
#result:
$categoryfontsizes = array(12,18,24);
I just don't know the math behind scaling a range like that.

Posted: Wed Mar 21, 2007 10:21 pm
by feyd
Basic distribution is "somewhat" simple:

Code: Select all

(maximum quantity - minimum quantity) × (maximum size - minimum size) / (current quantity - minimum quantity) + minimum size

Posted: Thu Mar 22, 2007 1:19 am
by Kieran Huggins
I could be mistaken, but isn't wordpress both open source AND in PHP?

Posted: Thu Mar 22, 2007 2:00 am
by dude81
Kieran Huggins wrote:I could be mistaken, but isn't wordpress both open source AND in PHP?
wordpress is an opensource, but the url skara pointed to is wordpress website , and such feature is not avaialble within wordpress.

Posted: Thu Mar 22, 2007 10:04 am
by Skara
feyd wrote:Basic distribution is "somewhat" simple:

Code: Select all

(maximum quantity - minimum quantity) × (maximum size - minimum size) / (current quantity - minimum quantity) + minimum size
well. It is "somewhat" simple, but I never would have figured it out myself. Thanks!

Posted: Thu Mar 22, 2007 10:27 am
by stereofrog
feyd's formula is reverse proportional, to get "more = bigger" proportion, you need something like

Code: Select all

$font_size = ($current_qty - $qty_min) * ($size_max - $size_min) / ($qty_max - $qty_min) + $size_min;

Posted: Thu Mar 22, 2007 11:41 am
by RobertGonzalez
You may also want to search for Tag Clouds, as they are commonly referred to.

Posted: Thu Mar 22, 2007 5:36 pm
by Skara
ah, yeah, I did finally find they were called "tag clouds"

It's all working great now. Thanks.