Skip to content

tweak: support comparison in ai charts#8836

Merged
djbarnwal merged 1 commit intomainfrom
tweak/create-chart-comparisons
Feb 17, 2026
Merged

tweak: support comparison in ai charts#8836
djbarnwal merged 1 commit intomainfrom
tweak/create-chart-comparisons

Conversation

@djbarnwal
Copy link
Member

Add support for comparison time range in some the AI generated charts

Part of https://linear.app/rilldata/issue/APP-725/ai-improve-analyst-agents-visualization-logic

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped PR. The comparison plumbing leverages the existing CartesianChartProvider infrastructure (dual measures with __prev suffix, Vega transforms) — no new rendering code needed. The prompt examples and validation logic are thorough.

Schema nit — add required to comparison_time_range object

charts_json_schema.go — The comparison_time_range object doesn't declare "required": ["start", "end"]. The Go handler validates this server-side so it won't cause a runtime bug, but having the schema match the actual contract helps the LLM produce correct output. Currently the schema would accept {"comparison_time_range": {}} as valid.

"comparison_time_range": {
  "type": "object",
  "properties": { ... },
  "required": ["start", "end"],
  "description": "..."
}

Follow-ups (non-blocking):

  • Explore link drops comparisonChartContainer.svelte:120 hardcodes showTimeComparison: false. Now that AI charts can have comparison, clicking "Open in Explore" loses it. Pre-existing but newly relevant.
  • area_chart exclusion — Area uses CartesianChartProvider like line/bar, so comparison likely works. If the exclusion is deliberate (overlapping fills?), a brief comment in the prompt explaining why would help the LLM avoid suggesting workarounds.
  • Evals — The create_chart prompt is getting rich enough that eval coverage would be valuable. Tests asserting the LLM produces valid specs for key patterns (comparison bar chart, invalid chart type + comparison rejected, etc.) would catch prompt regressions early.

ericpgreen2

This comment was marked as duplicate.

@djbarnwal djbarnwal merged commit 60dcf65 into main Feb 17, 2026
22 of 24 checks passed
@djbarnwal djbarnwal deleted the tweak/create-chart-comparisons branch February 17, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants