This project has moved and is read-only. For the latest updates, please go here.

Tag Cloud Example using FlickNet.dll

Topics: Developer Forum
Sep 27, 2006 at 7:19 PM
I'm thinking this might be better for the wiki, but since I cannot add a page there I thought I would post my code here in case anyone else wants to do this. This may not be the best way to approach this so comments/criticisms are certainly welcome.

' This subroutine populates a lable control called lblTags

Private Sub PopulateTags()

Dim tagList As Tag() = myFlickr.TagsGetListUserPopular(myFlickrId)
Dim eachTag As Tag

Dim intMaxPopularity As Integer = 0
Dim intMinPopularity As Integer = 100000 'seed value

'Find Min and Max Values
For Each eachTag In tagList
If eachTag.Count > intMaxPopularity Then intMaxPopularity = eachTag.Count
If eachTag.Count < intMinPopularity Then intMinPopularity = eachTag.Count

For Each eachTag In tagList
'Dim tagItem as Tag = myFlickr.
Me.lblTags.Text = Me.lblTags.Text & "<a href='default.aspx?query=" & eachTag.TagName & "&query_type=tags' class='" & GetTagSize(eachTag.Count, intMinPopularity, intMaxPopularity) & "'>" & eachTag.TagName & "</a> "

Me.lblTags.Text = "<div id='tags'>" & Me.lblTags.Text & "</div>"
End Sub

' This Function returns the css class (defined elsewhere) for the individual tag

Private Function GetTagSize(ByVal intTagCount As Integer, ByVal intMin As Integer, ByVal intMax As Integer) As String

Dim intFontBlock As Integer = CType(((intMax - intMin) / 6), Integer)

Select Case intTagCount
Case 0 To intFontBlock
Return "tagsize1"
Case intFontBlock To (intFontBlock * 2)
Return "tagsize2"
Case (intFontBlock * 2) To (intFontBlock * 3)
Return "tagsize3"
Case (intFontBlock * 3) To (intFontBlock * 4)
Return "tagsize4"
Case (intFontBlock * 4) To (intFontBlock * 5)
Return "tagsize5"
Case (intFontBlock * 5) To (intFontBlock * 6)
Return "tagsize6"
Case Else
Return "tagsize7"
End Select

End Function