Leera Charts
How to write effective prompts that Leera can translate into SQL to generate accurate visualizations.
Leera converts natural‑language prompts into SQL, executes the query, then formats the result into a chart. Good prompts describe: metric(s), dimension(s), filters, time range, aggregation, chart intent, comparison (optional), sorting, limits, and granularity.
Chart Guides
See dedicated guides for each chart type:
- Line
- Area
- Bar
- Range Bar
- Range Area
- Pie
- Donut
- Radial Bar
- Scatter
- Bubble
- Heatmap
- Candlestick
- Box Plot
- Radar
- Polar Area
- Treemap
- Regression (Scatter)
Data Shape Summary
| Type | Expected Data Shape |
|---|---|
| line / area | time, value (optional series) |
| bar | category, value |
| rangeBar | category, min, max |
| rangeArea | time, min, max |
| pie / donut | label, value |
| radialBar | label, value |
| scatter | x, y (optional series) |
| bubble | x, y, size (optional series) |
| heatmap | x, y, value |
| candlestick | time, open, high, low, close |
| boxPlot | category, min, q1, median, q3, max |
| radar | axis, value (series) |
| polarArea | label, value |
| treemap | path (1–3 levels), value |
| regression | x, y |
Prompt Structure
Template: Show [AGGREGATION] [METRIC] by [DIMENSION] for [TIME RANGE] filtered by [CONDITION] as a [CHART TYPE] sorted by [ORDER] limit [N].
Minimal example: Daily active users last 30 days as line chart.
Core Elements
- Metric & aggregation
- Dimension(s) & granularity
- Time range
- Filters
- Chart type (state explicitly)
- Sorting & limit
- Comparison / derived metrics (optional)
- Formatting (currency, %)
Good vs Weak Prompts
Good: Show monthly sum of revenue and cost for the last 12 months line chart include previous year comparison.
Weak: Revenue over time.
Good: Top 10 product categories by total orders in the last 90 days bar chart exclude category = 'Misc'.
Weak: Orders by category.
Multi-Series & Derived
Explicitly list metrics and formulas: Show daily sum of revenue, cost, and profit (revenue - cost) last 60 days line chart.
Filters
Be explicit: region in (US, CA, UK) and channel = 'web' exclude test accounts (email like '%@test.%').
Chart Selection (Quick)
Trend → line/area
Ranking → bar
Distribution → boxPlot
Composition (few categories) → pie/donut/polarArea
Correlation → scatter/bubble
Hierarchy → treemap
Ranges → rangeBar/rangeArea
Financial OHLC → candlestick
Matrix → heatmap
Comparisons
Monthly recurring revenue last 12 months with previous year same month comparison line chart and % change.
Avoid Ambiguity
Instead of Sales last quarter → Sum of gross_sales USD last calendar quarter by week line chart.
Anti-Patterns
- Vague intent
- Mixed unrelated intents
- Missing aggregation
- Overloaded with too many series
Checklist
- Metric + aggregation
- Dimension(s)
- Time range + granularity
- Filters
- Chart type
- Sorting / limit
- Comparison / derived metrics (optional)
- Formatting needs
Troubleshooting
Empty result → relax filters / confirm time range.
Wrong chart → state chart type.
Aggregation off → include aggregation keyword.
Too many categories → limit top N or group Others.
Sample Advanced Prompt
Show weekly sum of revenue, cost, and profit (revenue - cost) for the last 26 weeks with previous 26-week average as a reference line line chart sort by week ascending.
Minimal to Rich Progression
- Daily orders last 7 days line chart.
- Count of orders by day last 7 days line chart include 7-day moving average.
- Count of orders by day last 7 days line chart exclude status = 'cancelled' include 7-day moving average and previous week comparison.
Summary
Clear, structured, specific language → better SQL → accurate charts.