How to Make a Sunburst Chart with ChatGPT

Cody Schneider8 min read

A sunburst chart is one of the best ways to visualize hierarchical data, letting you see the parts that make up a whole across multiple levels. While building one used to require deep spreadsheet skills or specialized software, you can now create a detailed sunburst chart in minutes just by asking ChatGPT. This guide will walk you through exactly how to prepare your data, write the right prompts, and generate a polished chart to illustrate your data's structure.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

What Exactly is a Sunburst Chart?

Think of a sunburst chart as a next-level pie chart. While a standard pie chart shows proportions of a whole for a single category, a sunburst chart displays how those proportions are broken down into sub-categories using concentric rings. The center circle represents the total, and each ring moving outward shows a deeper level of the hierarchy.

Each ring is sliced to represent its proportion of the parent slice in the ring inside it. This makes it incredibly effective for understanding compositions. For example, you can see not only that "Electronics" are 40% of your total sales (the inner ring), but also that "Smartphones" make up 60% of those electronics sales (the next ring out).

When to Use a Sunburst Chart

Sunburst charts aren't for every dataset. They shine when you have a clear hierarchical relationship and want to show how a central value is distributed among its descendants. Here are a few ideal use cases:

  • Sales data: Visualizing sales by Product Category > Sub-Category > Individual Product.
  • Organizational structures: Illustrating headcount distribution by Division > Department > Team.
  • Budget breakdowns: Showing how a total budget is allocated by Department > Project > Expense Type.
  • Website traffic analysis: Breaking down user demographics by Continent > Country > City.

One watch-out: they can become cluttered and hard to read if you have too many categories at any single level or go more than three or four levels deep. For very complex hierarchies, a different visualization like a treemap might be a better fit.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Preparing Your Data for ChatGPT

Success with any AI data analysis tool starts with well-structured data. ChatGPT's Advanced Data Analysis feature (available to Plus subscribers) is powerful, but it's not a mind-reader. To get a useful sunburst chart, you need to provide your data in a clean, logical format that clearly defines the hierarchy.

The best format is a simple table, like one you'd have in a CSV or an Excel spreadsheet. Each column should represent a level in your hierarchy, and the final column should contain the numerical value that determines the size of each slice.

Imagine you run an online store and want to visualize your sales data. Your table structure should look like this:

Category, Subcategory, Product, Sales

Here's a small example of what the data would look like in a CSV file:

Category,Subcategory,Product,Sales Electronics,Smartphones,iPhone 15,95000 Electronics,Smartphones,Galaxy S24,82000 Electronics,Laptops,MacBook Pro,125000 Electronics,Laptops,Dell XPS 15,110000 Apparel,T-Shirts,Graphic Tee,15000 Apparel,T-Shirts,Plain White Tee,22000 Apparel,Hoodies,Zip-Up Hoodie,35000 Home Goods,Kitchen,Coffee Maker,18000 Home Goods,Kitchen,Blender,12000

Why This Structure Works

  • It's Unambiguous: Each row clearly defines a path from the highest level (Category) down to the lowest (Product) along with its corresponding value (Sales).
  • It's Machine-Readable: The AI can easily parse this structure to understand the parent-child relationships it needs to build the chart's rings.
  • It's Simple: You don't need complex pivots or nested JSON. A straightforward flat file is all it takes.

Before you start, take a minute to clean up your data in Excel or Google Sheets. Check for typos, make sure your naming is consistent (e.g., "Electronics" vs. "electronic"), and save it as a simple CSV or .xlsx file.

How to Create Your Chart: A Step-by-Step Guide

Once your data is prepped and saved, you're ready to create your visualization. This process relies on ChatGPT's "Advanced Data Analysis" capability, which lets it write and execute Python code on your behalf. This feature is exclusive to ChatGPT Plus subscribers.

Step 1: Start a New Chat and Enable Advanced Data Analysis

Log in to ChatGPT. If you're using GPT-4, the Advanced Data Analysis model is typically enabled by default. You can tell it's ready when you see a small paperclip icon to the left of the message box, which is used for uploading files.

Step 2: Upload Your Data File

Click the paperclip icon and select the CSV or Excel file you prepared earlier. ChatGPT will take a moment to upload and process it. Once it's done, it will confirm that the file is ready for analysis.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Step 3: Write Your Prompt

This is where the magic happens. Your prompt tells the AI what to do with your file. The more specific you are, the better the result will be. Start with a direct instruction.

A good starting prompt is:

Using the uploaded file, create a sunburst chart to visualize sales. The hierarchy should follow the columns in this order: Category, Subcategory, and then Product. The size of each segment should be determined by the 'Sales' column.

ChatGPT will interpret your request, write Python code (likely using a library like Plotly), execute it, and then display the resulting chart directly in the chat interface.

Step 4: Review and Refine Your Chart

The first chart the AI generates is rarely perfect. This is where the conversational nature of ChatGPT becomes powerful. You can ask for modifications in plain English. Treat it as if you're giving feedback to a data analyst.

Here are some common refinement prompts:

  • Adjusting Colors: This looks good, but can you change the color palette to blues and greens?
  • Adding a Title: Please add the title 'Quarterly Sales Breakdown by Product'.
  • Modifying Labels: Can you make the text on the outer ring larger so it's easier to read?
  • Changing Levels: Generate a new version of the chart that only shows Category and Subcategory. Leave out the Product level.
  • Focusing on Specific Segments: Regenerate the plot, but only include data from the 'Electronics' category.

Each time you send a new prompt, ChatGPT will remember the context and apply your changes, producing a revised chart. Keep iterating until it looks exactly the way you want.

Common Pitfalls and How to Solve Them

While this process is straightforward, you can run into a few common snags. Here's what to look out for.

1. Errors Caused by Unstructured Data

If you upload a file with merged cells, empty rows, or an inconsistent hierarchical structure, ChatGPT will get confused and likely return an error.

The Fix: Always go back to raw, tidy data. One row per entry, one column per hierarchy level, and one column for the value. Stick to the clean CSV format described above for the most reliable results.

2. Getting a "Generic" or Wrong Chart

If your prompt is too vague, like "Visualize my data," the AI might guess and give you a bar chart or a different type of visualization.

The Fix: Be explicit in your prompt. Always state the chart type ("sunburst chart"), the hierarchy ("the levels are Category, then Subcategory..."), and the value column ("use the 'Sales' column to determine size").

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

3. The Chart is Unreadable and Overcrowded

If your data is too granular — for instance, hundreds of products within a single subcategory — the outer ring of your sunburst chart will become a cramped, illegible mess of tiny slivers.

The Fix: Simplify your data before you create the chart. You could group smaller categories into an "Other" category or simply ask ChatGPT to visualize a higher level of the hierarchy. A prompt like, "Show me the sunburst for Category and Subcategory only" can instantly make the chart cleaner.

Realize the Limitations: Static vs. Live Data

It's important to remember that ChatGPT produces a static image of a chart (like a .png file). You can't hover over segments for details, click to dive deeper, or connect it to a live data source. It's a snapshot in time based on the file you uploaded.

For one-off presentations or reports, this is perfectly fine. But it's not a solution for ongoing business intelligence where you need a dashboard that updates automatically as your data changes.

Final Thoughts

Sunburst charts are an excellent tool for visualizing hierarchical data, and using ChatGPT significantly lowers the barrier to creating them. By focusing on proper data preparation and writing clear, specific prompts, you can move from a raw spreadsheet to an insightful visualization in a matter of minutes, without writing a single line of code yourself.

While creating static charts from CSVs is a huge step forward, the next challenge is connecting your analysis to live business data without the constant cycle of exporting and uploading files. To solve this, we built Graphed to connect directly to your data sources like Google Analytics, Shopify, or Salesforce and allows you to create real-time, interactive dashboards using the same simple, natural language approach. It's designed to give you instant answers from your live data, so your insights are always up to date.

Related Articles