Django tag cloud

4 views
Skip to first unread message

Alessandro Ronchi

unread,
Nov 21, 2009, 8:46:45 AM11/21/09
to django...@googlegroups.com
I have a model with with a variable number of objects.

I want to make a tag cloud with font-size to be a proportion of
objects.count() (wich goes from 1 to 150 ).

Obviously I can't use that number in font-size (150pt is too big) and
I have to make a proportion (150 -> 20pt, 1 -> 5pt, 50 ~>10pt and so
on).

How can I accomplish that?

--
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

Carlos Ricardo Santos

unread,
Nov 21, 2009, 10:09:47 AM11/21/09
to django...@googlegroups.com
I used this approach, was explained on "Learning website development with Django book", give a look there:


style.css file:

.tag-cloud-0 { font-size: 100%; } 
.tag-cloud-1 { font-size: 120%; } 
.tag-cloud-2 { font-size: 140%; } 
.tag-cloud-3 { font-size: 160%; } 
.tag-cloud-4 { font-size: 180%; } 
.tag-cloud-5 { font-size: 200%; }

And generated the tag number dynamically counting the objects that has that tag.




2009/11/21 Alessandro Ronchi <alessand...@soasi.com>

--

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=.





--
Cumprimentos,
Carlos Ricardo Santos

Alessandro Ronchi

unread,
Nov 26, 2009, 9:47:55 AM11/26/09
to django...@googlegroups.com


On Sat, Nov 21, 2009 at 4:09 PM, Carlos Ricardo Santos <carlosric...@gmail.com> wrote:
I used this approach, was explained on "Learning website development with Django book", give a look there:


style.css file:

.tag-cloud-0 { font-size: 100%; } 
.tag-cloud-1 { font-size: 120%; } 
.tag-cloud-2 { font-size: 140%; } 
.tag-cloud-3 { font-size: 160%; } 
.tag-cloud-4 { font-size: 180%; } 
.tag-cloud-5 { font-size: 200%; }

And generated the tag number dynamically counting the objects that has that tag.


But in that way I must add some code to the model, wjere I can write exactly the font-size.
I need something similar to widthratio but with a minimum value (or maybe there is a way to make the littler sets not to 0 font-size).

Nick Arnett

unread,
Nov 26, 2009, 4:22:54 PM11/26/09
to django...@googlegroups.com
On Sat, Nov 21, 2009 at 7:09 AM, Carlos Ricardo Santos <carlosric...@gmail.com> wrote:



Obviously I can't use that number in font-size (150pt is too big) and
I have to make a proportion (150 -> 20pt, 1 -> 5pt, 50 ~>10pt and so
on).

How can I accomplish that?


What you need is called data normalization - fitting data to a desired scale - in statistics and analysis.

Here's a general page about normalization:

http://www.qsarworld.com/qsar-statistics-normalization.php

I'd imagine that there's a Python library or module that will do this for you, but it's not hard to write your own.

Nick

Alessandro Ronchi

unread,
Dec 2, 2009, 3:33:27 PM12/2/09
to django...@googlegroups.com
On Thu, Nov 26, 2009 at 10:22 PM, Nick Arnett <nick....@gmail.com> wrote:

> What you need is called data normalization - fitting data to a desired scale
> - in statistics and analysis.
>
> Here's a general page about normalization:
>
> http://www.qsarworld.com/qsar-statistics-normalization.php
>
> I'd imagine that there's a Python library or module that will do this for
> you, but it's not hard to write your own.

I've done a simple custom template tag to have my cloud working :)

--
Alessandro Ronchi

http://www.soasi.com
SOASI - Sviluppo Software e Sistemi Open Source

http://hobbygiochi.com
Hobby & Giochi, l'e-commerce del divertimento
Reply all
Reply to author
Forward
0 new messages