wtorek, 16 września 2008

Pięć minut tu jest i już hakuje (odwrotna chmura etykiet) / He's been here for five minutes and he's already hacking (reversed label cloud)

Zachciało mi się chmury tagów (tu nazywanej chmurą etykiet), ale odwrotnej. To oznacza, że rozmiar czcionki rzadziej używanych elementów jest większy niż częściej używanych i vice versa.
Znalazłem zwykłą, pod tym adresem.
Jak dla mnie kod był nieco pokomplikowany i dawno nie miałem styczności z ECMAScript'em więc poszło mi nieco mozolnie. Jednak wystarczyło tylko zmienić linijkę:

var m=(b-a)/Math.log(x),v=Math.floor(Math.log(i)*m+a)

na

var m=(b-a)/Math.log(x),v=200/(Math.floor(Math.log(i)*m+a))

Wartość 200 została wyznaczona empirycznie (bo mi się wykres ładnie ułożył ;p).

--- English ---

I've always wanted a tag cloud (here named a label cloud), but reversed. This means that the less used categories font size is larger rather than smaller and vice versa.
I've found a normal one under this address.
As for me the code was somewhat complicated and I've had no contact with ECMAScript for a long time so the process went a bit slowly. But it was only needet to change the line:

var m=(b-a)/Math.log(x),v=Math.floor(Math.log(i)*m+a)

to

var m=(b-a)/Math.log(x),v=200/(Math.floor(Math.log(i)*m+a))

The value of 200 was empiricaly appointed (because the graph looked nicely ;p).

Brak komentarzy: