Treemap Chart: Definition, How It Works, and When to Use One

By Sriram

Updated on Jul 29, 2026 | 16 min read | 4.22K+ views

Share:

Quick Overview

  • A treemap chart shows part-to-whole data using nested rectangles, where size represents value and color represents category or a second metric.
  • It's called a "treemap" because it maps a tree-like hierarchy onto rectangles instead of branches and nodes.
  • It works best for budgets, portfolios, BI dashboards, and any data with many categories or sub-categories.
  • Avoid it for trends over time, negative values, or datasets with fewer than 5-6 categories.
  • Common fixes include grouping small categories, sorting by value, and using tooltips to handle overlapping labels.

This blog will help us learn what a treemap chart is, how to read one, the different types you can use, when it works best, common problems people run into, and how to build one step by step.

If you want to go beyond the basics and start building real data visualizations, upGrad's Data Science courses can help you build these skills hands-on, from exploratory data analysis to statistical modeling, and open doors across industries that run on data.

What Is a Treemap Chart?

A treemap chart is a way to display hierarchical or part-to-whole data using rectangles of different sizes.

The bigger the rectangle, the bigger its share of the total. This makes treemap charts great for showing proportions across many categories at once, something a regular bar chart struggles to do when you have dozens of items.

Think of a company's total revenue. If you want to show how much each department contributes, a treemap chart divides the whole area into rectangles.

The sales department might take up 40 percent of the space, marketing 25 percent, and so on. You see the entire picture in one glance instead of scrolling through a long list.

Here is what makes a treemap chart different from most other charts:

  • It shows part-to-whole relationships clearly, so you always know what percentage each item represents.
  • It can display hierarchy, meaning categories can have sub-categories nested inside them.
  • It uses space efficiently, so even 50 or 100 categories can fit on one screen.
  • It often uses color as a second layer of information, on top of size.

This part-to-whole framing is really the heart of a treemap chart. Every rectangle only makes sense in relation to the whole area it sits inside. That is what separates it from charts that just compare individual values side by side.

Why Is It Called a "Treemap"?

The name comes from how the chart handles hierarchy, similar to a tree structure in computer science. In a tree diagram, you have a root node that branches into smaller nodes, and those branch into even smaller ones. 

A treemap chart takes that same branching logic but instead of drawing lines and nodes, it maps the tree into nested rectangles.

So a "treemap" is literally a tree structure mapped onto a two-dimensional space. The outer rectangle is the root or the whole. Every rectangle inside it is a branch or category.

 And if that category has sub-categories, you get smaller rectangles nested within it. This is why treemap charts are so useful for multi-level data, like a company's spending broken down by department, then by team, then by project.

The IIM Kozhikode Strategic AI for Business Professionals program in partnership with upGrad is built for turning technical know-how into real business impact. It helps you move from working with data visualization tools to leading AI and data strategy, decisions, and teams at a business level.

How to Create a Treemap Chart

Building a treemap chart follows a similar process across most tools, whether you use Excel, Tableau, Power BI, or a coding library like D3.js or Python's Plotly.

  1. Prepare your data: Organize it into categories and values. If you need hierarchy, structure it as parent and child relationships.
  2. Choose your tool: Pick a charting tool or library that supports treemap charts, based on your skill level and platform.
  3. Map your fields: Assign one field to size (the value) and one to color (either category or a second metric).
  4. Set hierarchy levels: If your data has multiple levels, define the order, like Region, then Country, then City.
  5. Apply sorting: Sort by value so larger categories appear first, improving readability.
  6. Add labels and tooltips: Decide what text appears on each rectangle and what extra details show on hover.
  7. Test with real users: Check if people unfamiliar with the data can understand the chart quickly. Adjust colors, grouping, or sizes if needed.
  8. Review edge cases: Check how the chart handles very small values, missing data, or too many categories, and apply the fixes covered earlier.

Following these steps helps you build a treemap chart that is both accurate and easy to read, regardless of which tool you use.

Data Science Courses to upskill

Explore Data Science Courses for Career Progression

background

Liverpool John Moores University

MS in Data Science

Double Credentials

Master's Degree18 Months

Placement Assistance

Certification6 Months

Treemap Chart Example

Let's say a retail company wants to visualize its yearly sales by product category. Here is sample data:

Category 

Sales (in lakhs) 

Share of Total 

Electronics  450  36% 
Clothing  320  26% 
Home Decor  210  17% 
Groceries  150  12% 
Books  110  9% 

In a treemap chart, this data would appear as five rectangles. Electronics would take up the largest chunk since it has the highest share. 

Books would appear as the smallest rectangle. Each block would likely be colored differently so viewers can tell categories apart instantly.

Now imagine adding a second layer. Under Electronics, you could break it further into Mobiles, Laptops, and Accessories. 

This creates nested rectangles within the Electronics block, showing a treemap chart's real strength: displaying multiple levels of data in a single, compact view.

This kind of example is common in:

  • Retail dashboards showing product category performance.
  • Finance reports breaking down budgets or expenses.
  • Website analytics showing traffic sources and sub-sources.
  • Stock market apps displaying sector-wise or company-wise market cap.

A well-built treemap chart example like this lets a manager understand the entire sales picture in seconds, without reading a single row of a spreadsheet.

How to Read a Treemap Chart

Reading a treemap chart is simple once you know what each visual element means. There are four things to look at: size, color, nesting, and labels.

1. Understanding Rectangle Size (Value Representation)

Size is the primary signal in any treemap chart. The area of each rectangle is directly proportional to its value. A rectangle twice as large as another represents a value twice as big. There is no need to check an axis or a legend for this, the visual size itself tells you the story.

This is different from a bar chart, where you compare bar heights along a fixed scale. In a treemap chart, you are comparing areas, which can sometimes be trickier to judge precisely, but faster to scan overall.

2. Understanding Color (Category or Value Encoding)

Color in a treemap chart usually does one of two jobs:

  • It can represent different categories, so each product line or department gets its own color.
  • It can represent a second numeric value, like growth rate or profit margin, using a color gradient from light to dark or from red to green.

For example, a treemap chart showing stock market performance often uses green for stocks that are up and red for stocks that are down, with the size showing market capitalization.

3. Understanding Nested Rectangles (Hierarchy)

When a treemap chart shows hierarchy, you will notice smaller rectangles grouped inside bigger ones. Each group represents a parent category, and the smaller boxes inside are its children. This lets you drill down mentally, first seeing the big picture, then the details within each section. 

4. Reading Labels

Most treemap charts show a label inside each rectangle, usually the category name and its value or percentage. If a rectangle is too small, labels may be hidden or truncated. Good treemap chart design usually adds a tooltip or hover feature so users can still get exact numbers even when a box is tiny.

How Treemap Charts Work 

Behind every treemap chart is a simple idea: convert data values into space. But the actual math involves a few steps that decide how rectangles are sized, positioned, and arranged.

Data Structure

A treemap chart typically needs data in one of two formats:

  • Flat structure: A simple list of categories and their values, like the sales example above.
  • Hierarchical structure: Data with parent-child relationships, like Region > Country > City, where each level has its own values that add up to the parent.

Most treemap chart tools accept data as a table or a nested JSON-like structure, where each item can optionally contain a list of children.

Here is a simplified way hierarchical data might look:

Level 

Example 

Level 1 (Root)  Total Company Revenue 
Level 2  Department (Sales, Marketing, Ops) 
Level 3  Team within Department 
Level 4  Individual Project or Product 

Squarified Treemap Algorithm

Once the data is in place, the chart needs an algorithm to decide how to divide the space. The most common one used today is the squarified treemap algorithm.

Early treemap charts used a simple slice-and-dice method, which often created long, thin rectangles that were hard to read or compare. The squarified algorithm fixes this by trying to keep every rectangle as close to a square as possible.

Here is roughly how it works:

  • It sorts values from largest to smallest.
  • It groups items into rows or columns based on available space.
  • It adjusts each row's width and height to minimize how "stretched" any rectangle looks.
  • It repeats this for nested levels if hierarchy is involved.

The result is a treemap chart where rectangles are easier to compare visually, since squares and near-squares are simpler for the human eye to judge than long thin strips.

Subscribe to upGrad's Newsletter

Join thousands of learners who receive useful tips

Promise we won't spam!

Types of Treemap Charts

Not every treemap chart looks or works the same way. Depending on the tool and the data, you will come across a few common variations.

1. Standard Treemap

This is the most basic form. It shows one level of categories, each as a single rectangle, with no nesting. It works well when your data has a flat structure, like sales by product category with no sub-categories.

2. Nested / Hierarchical Treemap

This type supports multiple levels of data. You will see big rectangles divided into smaller rectangles, which may be divided further. This is the version most people mean when they talk about a treemap chart being good for hierarchy, since it can show three or four layers of detail in one view.

3. Squarified Treemap

This is not a different chart exactly, but a specific layout method. As explained earlier, it aims to make each rectangle closer to a square shape, improving readability compared to older layout styles. Most modern tools use squarified layouts by default.

4. Slice-and-Dice Treemap

This is the original, simpler algorithm. It divides space by alternating horizontal and vertical cuts, level by level. It is easy to compute but often produces long, thin rectangles, especially with many categories. It is rarely the default choice today but still appears in some legacy tools or specific use cases where strict ordering matters more than visual balance.

Type 

Best For 

Downside 

Standard  Simple, flat data  No hierarchy support 
Nested/Hierarchical  Multi-level data  Can get complex with too many layers 
Squarified  Most general use cases  Slightly harder to compute than slice-and-dice 
Slice-and-Dice  Ordered or sequential data  Rectangles can look thin and uneven 

Treemap Chart vs. Other Chart Types

A treemap chart is not always the right choice. Comparing it with other common chart types helps clarify when to use it.

1. Treemap vs. Bar Chart

A bar chart compares individual values along a common axis, which makes precise comparison easier. A treemap chart sacrifices some precision but fits far more categories into the same space and adds part-to-whole context that a bar chart does not show directly.

2. Treemap vs. Pie Chart

A pie chart also shows part-to-whole data, but it struggles once you have more than five or six slices. A treemap chart handles dozens of categories comfortably and can add hierarchy, which a pie chart cannot do at all.

3. Treemap vs. Sunburst Chart

A sunburst chart shows hierarchy using rings instead of rectangles. It can look more visually appealing for deep hierarchies, but it takes up more space and can be harder to read at a glance. A treemap chart is usually more compact and easier to scan quickly.

4. Treemap vs. Heat Map

A heat map uses color intensity across a grid to show values, usually across two dimensions like time and category. A treemap chart focuses on size for value and color as a secondary layer, making it better suited for part-to-whole data rather than matrix-style comparisons.

Chart Type 

Shows Hierarchy 

Shows Part-to-Whole 

Best Category Count 

Treemap Chart  Yes  Yes  10-100+ 
Bar Chart  No  No  5-20 
Pie Chart  No  Yes  2-6 
Sunburst Chart  Yes  Yes  10-50 
Heat Map  No  No  Varies (matrix based) 

Advantages of Treemap Charts

A treemap chart offers a few clear benefits that explain why it has become popular in dashboards and business reports.

  • Space efficiency: It fits a large number of categories into a small area, something bar charts and pie charts cannot do without becoming cluttered.
  • Instant visual comparison: Since size directly reflects value, viewers can spot the biggest and smallest contributors without reading numbers.
  • Hierarchy support: A treemap chart can display multiple levels of data at once, which helps when you need both a big-picture view and category-level detail.
  • Dual encoding: Using both size and color lets a treemap chart communicate two variables together, like revenue and growth rate.
  • Good for skewed data: When a few categories dominate and many others are small, a treemap chart shows this imbalance naturally, which pie charts often hide.
  • Quick pattern spotting: Because everything sits on one screen, trends like "one department accounts for half the budget" become obvious immediately.

These strengths are exactly why treemap charts show up so often in financial reporting, website analytics, and business intelligence tools. They turn a long list of numbers into a picture that takes seconds to understand.

When Should You Use a Treemap Chart?

A treemap chart works best when your main goal is comparing proportions across many categories, especially when hierarchy is involved.

Best-Fit Scenarios (Financial Data, Budgets, BI Reporting)

Here are situations where a treemap chart genuinely helps:

  • Budget breakdowns: Showing how a total budget splits across departments and sub-departments.
  • Financial portfolios: Displaying asset allocation across sectors, stocks, or fund types.
  • Website or app analytics: Showing traffic by source, then by campaign or page.
  • Business intelligence dashboards: Summarizing large datasets like sales by region, product, and time period.
  • Inventory management: Showing stock levels across categories and sub-categories.

In each case, the data naturally has a whole (total budget, total traffic, total stock) that breaks into meaningful parts. That is exactly the scenario a treemap chart is designed for.

When Not to Use a Treemap

A treemap chart is not always the best fit. Avoid it when:

  • You need to show trends over time. Line charts do this far better.
  • You only have a handful of categories, since a simple bar chart or pie chart will be clearer.
  • Precise, exact value comparison matters more than overall proportion, since judging area differences is harder than judging bar lengths.
  • Your data has negative values, which treemap charts cannot represent well since they rely on positive area.
  • You are presenting to an audience unfamiliar with treemap charts, where a simpler chart type may communicate faster.

Common Treemap Chart Problems

Even a well-designed treemap chart can run into readability issues. Here are the most common problems and practical fixes.

1. Too Many Categories Making the Chart Cluttered

When there are too many small categories, a treemap chart can look like a messy patchwork. Fix this by grouping smaller categories into an "Others" bucket, or by limiting the display to the top 15-20 categories.

2. Small Values Getting Lost or Invisible

Very small values can shrink into rectangles too tiny to see or click. Consider setting a minimum rectangle size, or grouping small values together instead of showing them individually.

3. Overlapping or Unreadable Labels

Labels can overlap or get cut off in smaller rectangles. Use tooltips on hover, shorten label text, or only display labels on rectangles above a certain size threshold.

4. Readability & Accessibility Issues

Relying only on color to distinguish categories can be a problem for color-blind users. Pair color with clear labels, patterns, or borders so the treemap chart remains accessible to everyone.

5. When Proportions Are Hard to Compare

Humans are generally better at comparing lengths than areas. If precise comparison matters, consider pairing your treemap chart with a supporting bar chart or a data table alongside it.

6. Sorting for Clarity (Best Practice)

Always sort categories by value, largest to smallest, before rendering. This simple step makes a treemap chart far easier to scan, since viewers naturally expect the biggest block to stand out first.

7. Better Alternatives for Small Datasets

If you only have three to five categories, skip the treemap chart altogether. A pie chart or a simple bar chart will communicate the same information with less visual complexity.

Conclusion

A treemap chart is one of the most efficient ways to show part-to-whole relationships, especially when your data has many categories or multiple levels of hierarchy. It uses size and color together to help viewers instantly spot what matters most, whether that's a department eating up half the budget or a product category driving most of your sales.

 Once you understand how a treemap chart works and how to read it, it becomes one of the most useful tools for making sense of complex data quickly.

Want to get started with Data Science? Speak with an expert for a free 1:1 counselling session today.

Frequently Asked Questions (FAQs)

1. What is a treemap chart primarily used for?

A treemap chart is primarily used to show part-to-whole relationships across many categories, especially when the data has a hierarchy. It's common in financial reports, budget breakdowns, and business dashboards where you need to compare proportions at a glance rather than read exact figures.

2. How do you read a treemap chart?

You read a treemap chart by looking at rectangle size, which shows value, and color, which usually shows category or a second metric. Nested rectangles indicate sub-categories within a larger group, and labels inside each box give you the exact name or number.

3. How does a treemap indicate value?

A treemap chart indicates value through the area of each rectangle. Bigger rectangles mean bigger values, and this size is calculated proportionally so that all rectangles together represent 100 percent of the total dataset being shown.

4. Why is it called a treemap?

It's called a treemap because it maps a tree-like hierarchical structure onto a two-dimensional space using nested rectangles. Instead of drawing branches and nodes like a traditional tree diagram, it converts each branch into a proportionally sized rectangle.

5. When should I use a treemap chart?

Use a treemap chart when you have many categories, possibly with sub-categories, and want to show how each one contributes to a total. It works especially well for budgets, portfolios, and analytics data where proportions matter more than exact trends.

6. Can a treemap chart show negative values?

No, a standard treemap chart cannot represent negative values well, since it relies on positive area to represent size. If your data includes losses or negative growth, a bar chart or a diverging color scale on another chart type usually works better.

7. Is a treemap chart good for showing trends over time?

Not really. A treemap chart is built for a single snapshot of part-to-whole data, not for showing change across time periods. Line charts or area charts are far better suited for visualizing trends, since they plot data along a continuous timeline.

8. What tools can I use to make a treemap chart?

You can create a treemap chart using Excel, Google Sheets, Tableau, Power BI, or coding libraries like D3.js, Plotly, or Highcharts. Most modern BI and spreadsheet tools now include a built-in treemap chart option under their visualization or insert chart menu.

9. How many categories should a treemap chart display?

A treemap chart works well with anywhere from 10 to 100 categories, though readability starts dropping past 50 unless you group smaller items together. For fewer than 5 to 6 categories, a simpler chart type like a bar chart usually communicates the data more clearly.

10. What's the difference between a treemap chart and a mosaic plot?

A treemap chart shows part-to-whole data using rectangle area, often with hierarchy, while a mosaic plot is typically used in statistics to show relationships between two or more categorical variables using a grid of proportional tiles. Both use rectangles, but their purpose and data structure differ.

11. Why does my treemap chart look cluttered with small boxes?

This usually happens when there are too many low-value categories competing for limited space. Grouping smaller categories into an "Others" bucket, limiting the display to top categories, or setting a minimum rectangle size can make your treemap chart much easier to read.

Sriram

677 articles published

Sriram K is a Senior SEO Executive with a B.Tech in Information Technology from Dr. M.G.R. Educational and Research Institute, Chennai. With over a decade of experience in digital marketing, he specia...

Speak with Data Science Expert

+91

By submitting, I accept the T&C and
Privacy Policy

Start Your Career in Data Science Today

Top Resources

Recommended Programs

IIIT Bangalore logo

The International Institute of Information Technology, Bangalore

Executive Diploma in DS & AI

360° Career Support

Executive Diploma

12 Months

Liverpool John Moores University Logo
bestseller

Liverpool John Moores University

MS in Data Science

Double Credentials

Master's Degree

18 Months

upGrad

Bootcamp

6 Months