Browse DevX
Sign up for e-mail newsletters from DevX


Make Your Java Data More Useful with Treemap Visualization : Page 3

Using visualizations such as pie charts and bar graphs to present data is nothing new. But what happens when you've got more data points than a pie chart can render? Enter the treemap! Use JTreemap to create your own Java Treemap application and render any data you like.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Building a Treemap Application with JTreemap
The JTreemap project makes it very simple to build a treemap. Indeed, if you structure your XML according to the DTD that is provided, the application will automatically render a treemap for you.

This XML format is very straightforward, and consists of a nested tree of data which the data item nodes containing a value, a weight and a label. An example of the XML is shown in the code below. The full XML document is available here.

<?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE root SYSTEM "TreeMap.dtd" > <root> <label>World</label> <branch> <label>Populations</label> <branch> <label>Western Europe</label> <item> <label>England</label> <weight>50</weight> <value>2</value> </item> . . </branch> <branch> <label>Americas</label> <item> <label>USA</label> <weight>300.0</weight> <value>11.0</value> </item> <item> <label>Canada</label> <weight>22.0</weight> <value>-5.0</value> </item> </branch> </branch> </root>

Figure 4: This shows JTreemap's visualization of population data.

Figure 4 shows what happens when the application is run with the above data. The visualization draws a treemap with boxes representing the size of the population of the country (specified using the 'weight' node), colors representing the delta of the population (specified using the 'value' node) and a label associated with the country (specified using the label node).

Visualization Equals Data Simplification
This method is an incredibly useful way of looking at data. It allows for a much better overview of complex data than you get with traditional visualizations. The JTreemap Applet provides an easy way to implement this technology. Use the basics you have gleaned here to explore the next level and add value to your data applications.

Laurence Moroney is a freelance enterprise architect who specializes in designing and implementing service-oriented applications and environments using .NET, J2EE, or (preferably) both. He has authored books on .NET and Web services security, and more than 30 professional articles. A former Wall Street architect, and security analyst, he also dabbles in journalism, reporting for professional sports. You can find his blog at http://www.philotic.com/blog.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date