December 10, 2007
Tag Clouds: Usability and MathSource Data
As input for a tag cloud, you need a dataset consisting of at least three columns:
The weight in the dataset often represents some frequencythe number of times a text is used as a search term, or the number of items sold of a product. However, the weight is not always an integer value. You can also consider, say, election results consisting of political parties and their percentages, earthquakes and their intensity, or movie stars and their IQ. In fact, there is technically little difference between tag clouds, histograms, line graphs, and pie charts. (I wouldn't be surprised to find the tag cloud as just another type of standard chart in Excel 2010.)
While constructing the source data for a tag cloud, you can impose restrictions on the raw data in the system in three ways:
Eventually, you will create one or more functions that resemble Listing One. Your architecture for data access is hopefully more sophisticated than this simple example. But if you separate the construction of source data from the remaining functional layers of the tag cloud, then you already have a better design than the average tag cloud example found on the Internet.
Public Function GetWriters(ByVal maxCount As Integer, _
ByVal ignoreNoise As Boolean, ByVal fromDate As DateTime, _
ByVal toDate As DateTime) As DataTable
Dim query As String = String.Format( _
"SELECT * FROM (SELECT TOP {0} ID, Text, " & _
"Count FROM Writers ORDER BY Count DESC) sub " & _
"ORDER BY Text ASC", maxCount)
'TODO: also filter on ignoreNoise, fromDate and toDate
Dim adapter As New SqlDataAdapter(query, _ConnectionString)
Dim table As New DataTable
adapter.Fill(table)
Return table
End Function
Listing One
|
|
||||||||||||||||||||||||||||||
|
|
|
|