What chart plugins teach you about AI-ready data systems
A new `datasette-charts` release is a good prompt to inspect a bigger pattern: analytics moving closer to the database and into AI-assisted workflows. The hard part is not the chart, it is query shape, provenance, and safe interfaces around natural-language access.
Simon Willison recently noted a new alpha release of datasette-charts, a plugin for plotting data straight from Datasette. The release itself is a small signal. The larger pattern matters more. Teams keep moving analytics closer to the database, then exposing those results through lightweight web layers and AI helpers. When you do this well, you shorten the path from raw records to decisions.
This matters if you build internal tools in Go, AI-assisted data systems, or audit-heavy business software. Charts look simple. The hard part sits under them. Query shape, cache behavior, access control, and prompt boundaries decide whether your system stays fast and trustworthy under real use.
A chart plugin is a useful entry point because it forces you to think about the whole stack. You need structured data, predictable queries, safe defaults, and outputs a human or model can read. If you are building with Go, this is where backend discipline pays off.
Keep the chart layer thin
Treat charts as a view over stable query results. Do not put business logic in the visualization layer. If a chart needs custom grouping, filtering, or derived metrics, compute those earlier.
In practice, this means:
- Write SQL or materialized views for the metric you want to show.
- Keep dimension names stable.
- Normalize timestamps before they hit the chart layer.
- Decide how nulls, outliers, and late-arriving rows get handled.
Thin chart layers are easier to test. They also work better with AI systems. If an LLM needs to explain a chart, you want the chart backed by a query with clear semantics, not a pile of hidden transforms in JavaScript.
A good pattern is to publish a narrow dataset per chart:
select
date(created_at) as day,
count(*) as signups
from users
where created_at >= date('now', '-30 day')
group by 1
order by 1;
The result is easy to chart, easy to cache, and easy to inspect. If your output schema changes every week, your charts and your AI summaries will drift.
Read query shape before you read design
Most chart failures are data access failures in disguise. A pleasant line chart with a bad query turns into latency spikes, lock contention, or high cloud bills.
Inspect query shape first:
- Does the chart issue one query or many.
- Does it scan full tables for each filter change.
- Does it sort large intermediate result sets.
- Does it join wide tables when a pre-aggregated table would do.
- Does it force timestamp conversion at read time on every request.
If you serve analytics from SQLite through a tool like Datasette, you need to be strict about indexes and precomputation. SQLite performs well for many read-heavy workloads, but you still need to respect cardinality and sort cost.
In Go services, measure chart endpoints like any other production API:
- p50, p95, and p99 latency
- rows scanned versus rows returned
- cache hit rate
- concurrent request behavior
- memory allocated per request
If a chart endpoint feeds an AI assistant, add one more metric. Track how often the model asks for regenerated slices of the same data. Repeated near-duplicate queries are a sign you need a summarization cache or a narrower retrieval interface.
Design for AI-readability, not only human readability
Charts are often the last mile for people, but the first mile for AI. A model does not see visual polish the way your users do. It works from underlying values, labels, and surrounding text.
If you want reliable AI-assisted analysis on top of charts, structure the data for machine reading:
- Use explicit units in field names or metadata.
- Keep category labels unambiguous.
- Expose the query timestamp and data freshness.
- Include denominator fields for rates and percentages.
- Publish the filter state alongside the result.
Bad example:
valuetypedate
Better example:
revenue_usdcustomer_segmentbooking_date_utcwindow_daysgenerated_at_utc
This reduces hallucinated explanations. It also helps when you build agentic workflows where a model chooses a chart, drafts a summary, and links back to the source query. The system works best when every output has provenance.
For internal AI tools, store three artifacts together:
- The query or view name.
- The returned data slice.
- The human-facing chart config.
With those three, you get reproducibility. Without them, you get screenshots and vague descriptions.
Put guardrails around natural-language analytics
The moment you let users ask for charts in plain language, you create two problems. Query safety and semantic drift.
Query safety is the obvious one. Do not let a model build unrestricted SQL against live operational tables. Put a constrained interface in front of it.
Useful controls include:
- Read-only roles.
- An allowlist of views.
- Row and column limits.
- Query timeouts.
- Rejection of cross joins and unbounded scans.
- Approval paths for exporting raw records.
Semantic drift is harder. A user asks for churn, revenue, active users, or conversion. Those words often have local definitions. If the model maps them to the wrong query, the chart looks clean and the answer stays wrong.
You need a metrics dictionary. Keep it versioned. Point each term to a specific query or transformation path. Then make the charting layer depend on those definitions, not on free-form prompt interpretation.
This is one area where Go is a good fit. Strong types and explicit interfaces help. You can model allowed metrics, dimensions, and time windows as concrete structs, then compile requests into known query templates.
A small example:
type Metric string
const (
MetricSignups Metric = "signups"
MetricMRR Metric = "mrr_usd"
)
type ChartRequest struct {
Metric Metric
StartDate string
EndDate string
GroupBy string
}
This does not solve analytics by itself. It does reduce the chance of a prompt turning into an expensive or misleading query.
Make provenance visible in the product
A chart without provenance becomes a trust problem during incidents, audits, and executive review. Users need to know where the data came from, when it was generated, and what filters shaped it.
Show this near the chart:
- source table or view name
- generation time
- time zone
- active filters
- last refresh status
- sample size or record count
For AI-generated summaries, include a path back to the underlying dataset. If your system stores only the prose summary, you lose the ability to inspect the evidence later.
This matters even more in mixed AI and human workflows. One user asks for a trend chart. The model writes a sentence. Another user forwards only the sentence. If the sentence is detached from the chart metadata, review gets harder.
A good operational pattern is to assign an immutable identifier to each chart render request. Store the identifier with the query hash, result hash, and config. Then your logs, dashboards, and audit trails refer to the same object.
Where teams go wrong:
- They cache images, but not source data.
- They persist prompts, but not resolved queries.
- They log chart views, but not filter state.
- They allow ad hoc field renames without schema versioning.
Each one breaks traceability.
What to watch next
The interesting shift is not chart plugins by themselves. It is the move toward compact, inspectable analytics stacks where data storage, lightweight publishing, and AI explanation sit close together. Expect more teams to pair simple query-backed charting with natural-language interfaces and retrieval layers.
If you build these systems, keep the fundamentals in place. Stable schemas. Measured queries. Typed request paths. Visible provenance. Those choices decide whether your charts stay useful when your users, or your models, start leaning on them every day.