Sub topic 7
From Query Results to Charts and Dashboards
Assume you know basic SQL, blockchain activity, and the difference between a token and a protocol. This chapter focuses on the step after writing a query: turning result rows into a useful chart and combining charts into a dashboard.
Start with a result set that has a clear grain
A chart is only as meaningful as the rows behind it. Before choosing a visualization, identify the grain, which is what one row represents. For example, one row might represent one day, one protocol, or one token transfer.
This query returns one row per day. It measures DEX trading volume on Ethereum for the previous 30 days.
SELECT
block_date,
SUM(amount_usd) AS volume_usd
FROM dex.trades
WHERE blockchain = 'ethereum'
AND block_date >= current_date - INTERVAL '30' DAY
GROUP BY 1
ORDER BY 1The block_date column is the time dimension. The volume_usd column is the measure. Since the query groups by date, a line chart can show how volume changes over time.
Check the result before building a chart:
- Are dates sorted?
- Is there one row per expected date?
- Are null values present?
- Is the measure already aggregated?
- Are the units clear, such as USD, tokens, or whole transactions?
If the query returns multiple rows for the same day and the chart expects one, either change the grouping or choose a visualization that supports the extra dimension.
Choose a visualization for the question
Different chart types answer different questions.
| Question | Useful visualization | Important design choice |
|---|---|---|
| How did a metric change over time? | Line chart | Use a real date axis |
| How do categories compare? | Bar chart | Sort by the measure |
| What is the current total? | Counter or single value | Display the time range |
| How do categories contribute to a total? | Stacked bar chart | Limit the number of categories |
| Where are individual events located? | Table | Keep useful identifiers and units |
A line chart is usually better than a pie chart for daily volume. A counter can show the total volume, but it hides daily changes. A table is useful when readers need to inspect exact values or transaction links.
Configure a chart in Dune
In Dune, run the query in the query editor, then use the visualization controls to create a chart from the result columns. Select:
- The chart type.
- The x-axis or dimension column.
- The y-axis or measure column.
- Number formatting, such as currency or abbreviated values.
- A title that states the metric and time range.
A title such as Ethereum DEX volume, last 30 days is more useful than Volume. If the query changes its time range later, update the title or make the range visible in a subtitle.
You can save multiple visualizations for one query. For example, the same result can support a line chart and a table. The chart uses the saved query result, so changing the SQL can change every dependent visualization.
Assemble a dashboard
A dashboard is a collection of visualizations arranged around a specific question. A useful dashboard normally has:
- A small set of headline counters.
- Trend charts for time-based behavior.
- Comparison charts for protocols, chains, or tokens.
- Tables for detailed investigation.
- Text that defines units, sources, and date ranges.
Arrange the page in reading order. Put the question and headline metrics first, trends next, and diagnostic tables last. Avoid adding every chart you can make. Extra tiles make it harder to identify the important signal.
Make dashboards reproducible
Record the source table, filters, aggregation, time zone, and unit conversions. If a dashboard compares DEX volume with token transfers, explain why the metrics are comparable or why they are intentionally different.
Use parameters when viewers need to change a chain, protocol, or date range without editing SQL. A parameterized query can feed several dashboard views while keeping the calculation in one place. Test each allowed parameter value because a filter can produce empty results or change the result grain.
Exercise
A daily volume query returns two rows for some dates because it groups by both block_date and project. Which chart should you use if you want one total value per day, and what SQL change is needed?
Show answer
Use a line chart after removing project from the selected columns and GROUP BY, or aggregate the project rows again by block_date. The result must contain one row per day.