Leera IconLeera

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:

Data Shape Summary

TypeExpected Data Shape
line / areatime, value (optional series)
barcategory, value
rangeBarcategory, min, max
rangeAreatime, min, max
pie / donutlabel, value
radialBarlabel, value
scatterx, y (optional series)
bubblex, y, size (optional series)
heatmapx, y, value
candlesticktime, open, high, low, close
boxPlotcategory, min, q1, median, q3, max
radaraxis, value (series)
polarArealabel, value
treemappath (1–3 levels), value
regressionx, 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

  1. Metric + aggregation
  2. Dimension(s)
  3. Time range + granularity
  4. Filters
  5. Chart type
  6. Sorting / limit
  7. Comparison / derived metrics (optional)
  8. 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

  1. Daily orders last 7 days line chart.
  2. Count of orders by day last 7 days line chart include 7-day moving average.
  3. 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.

On this page