Charts for Agent Answers: From Markdown Table to Visual
Over MCP, a Fabric Data Agent answers in text and markdown tables. If your app wants charts, it has to draw them. Ask for a fixed answer shape, parse it, pick the chart from the table itself, and draw it by the same rules as every other chart in the app.
In the Fabric portal, a data agent can now answer with a chart. Call the same agent from your own app over MCP and you get text and markdown tables. That gap looks like a limitation. It is actually where the app earns its keep.
Your app knows things the agent does not: your chart conventions, your colours, what the user was looking at when they asked, and the charts already on the screen next to the answer. An answer drawn by those rules reads as part of the app. A pasted-in chart with preset styling reads as a guest. This post is the method I used in my Day of Data app: ask for a shape, parse it, choose the chart from the data, and draw it consistently.
- 5 parts to every answer. Answer, key points, table, chart suggestion, notes. Always in that order, so code knows where to look.
- 3 chart forms cover most answers. A line for months, diverging bars for gaps, ranked bars for everything else.
- 1 click back to the table. Every chart keeps the agent's original table one toggle away. Some readers trust rows more than bars.
From Answer to Chart, Step by Step
Here is the whole idea with one real-shaped answer: a question about key accounts against budget, as the agent returns it, and what the app does with it.
The answer arrives as text
Over MCP, a data agent returns markdown: a headline, a few bullets, a table, and a couple of labelled lines. No chart. Because the agent instructions ask for a fixed shape, the app knows where everything is.
The headline becomes the title
The first sentence is the finding. The app counts the rows behind it and writes the chart title as a sentence: 3 of 5 key accounts are behind budget.
The table is found, and its units read
The parser finds the markdown table, takes the first text column as the labels, and reads the unit from each header. That is how it knows Gap (%) is a percentage and Gap (EUR m) is money.
Clean up before drawing
The Total row stays in the table but leaves the chart, because it would flatten every other bar. The gap column has negative values, so the chart is diverging bars, whatever the agent's own Chart line says.
Draw it the app's way
Red below plan, blue above, labels on the bars, the Notes line as the source. And a toggle back to the table, because some readers trust the numbers more than the bars.
1. Ask for a Shape
Nothing downstream works unless every answer has the same structure. That structure belongs in the agent instructions, in the How to answer section, and it is worth being specific:
Each rule exists because of a specific way charts go wrong:
| Rule | Without it |
|---|---|
| Unit in every header | Code cannot tell a currency column from a percentage, so axes and labels are wrong |
| Sort as the question asks | "Who is furthest behind" draws as an alphabetical list |
| At most 15 rows | A 200-bar chart nobody can read, in a drawer that is 400 pixels wide |
| A Total row | Readers want the total. The chart just has to know to leave it out |
| Answer first, Notes last | No title for the chart, and no source line under it |
One more benefit: this shape is also better for people reading the answer without a chart. The format that code can parse is the same format a busy manager can scan.
2. Parse It
The parser is about 80 lines of TypeScript. It walks the answer line by line and sorts each line into the five parts: markdown table rows become tables, a line starting with Chart: is the suggestion, Notes: is the source line, bullets are key points, and the first remaining sentence is the headline. Agents often bold the template labels ("**Notes**:"), so it strips that first.
The part that needs care is turning cells into numbers. Agents write numbers for people, not for code:
The typographic minus sign is the one that bites. Agents often write −8.2 with a real minus (U+2212), not a hyphen, and a naive parseFloat quietly returns NaN. A column is numeric when at least 80% of its cells parse; the first column that is not numeric becomes the labels.
3. Let the Table Choose the Chart
The agent's Chart: line is a useful hint and a poor command. It is written before the agent sees the shape of its own result, and it varies from run to run. The table, on the other hand, is ground truth. So the app decides from the table and keeps the agent's suggestion as a tie-breaker:
| If the table... | Draw | Because |
|---|---|---|
| has month labels in most rows | A line (or columns, for monthly totals) | Time reads left to right |
| has a gap, variance, growth, or change column with negatives | Diverging bars | Below and above plan are the story |
| anything else | Ranked horizontal bars | Long labels fit, and order is visible |
Three forms sound limiting. In practice they covered nearly every answer from a team of three agents, and the restraint is the point: the reader learns three shapes once, and every answer after that reads instantly. Before charting, drop the Total row, and cap the bars at 15 even if the agent sent more.
4. Draw It by the App's Rules
An answer chart should be indistinguishable from the charts the app already draws. These are the rules that mattered most for answers specifically:
The title is a sentence
"3 of 5 key accounts are behind budget", computed from the rows, not "Gap by key account". The agent's headline usually supplies the sentence; counting the rows makes it exact.
Red below plan, blue above
Diverging bars from a zero line, sorted worst first. Red and blue stay distinguishable for colour-blind readers, which red and green do not.
Label the bars, skip the legend
Values sit on the bars, with a sign for gaps. In a narrow answer panel there is no room for a legend, and no need for one.
Notes become the source line
The agent's Notes say what was counted and for which period. Under the chart, that line is what lets a reader trust it.
The full set of eight chart rules is in the Day of Data write-up, and the repo includes a gallery that draws each chart form from real data, offline, as a reference.
5. Know When Not to Chart
Plenty of good answers should not become charts, and the template makes them easy to detect:
- A single number ("net sales were $9.0bn this year") has no table. Show it as a large figure with the Notes line.
- A clarifying question comes back as one sentence with options. Render the options as buttons that ask again.
- A polite refusal that names another agent is a hand-off. Render it as a button that asks that agent.
- A table that will not parse (two rows, no numeric column, an odd format) falls back to the markdown as written. Never draw a chart you are not sure about.
What About the Agent's Own Charts?
Data agent visualizations went GA at FabCon Europe, so it is fair to ask why an app should draw its own. It depends on where the answer is read:
| Agent visuals | App-drawn charts | |
|---|---|---|
| Where they render | In the Fabric data agent experience | Anywhere your app runs |
| Over MCP or the SDK | Not rendered; the chart specification is in the run steps | Built from the text answer |
| Styling | Preset colours, titles, and labels | Your design system and chart rules |
| Rows charted | Up to 200 | Whatever you decide; 15 reads best |
For people working inside Fabric, the built-in visuals are a real improvement and need no code. For an app, the text answer plus your own drawing is still the better path. If you need the agent's exact choice of chart, the specification in the run steps is an option worth exploring, but the table-first approach keeps working whichever client asks.
Test the Shape Like the Numbers
The format is an interface, so it needs tests like any other interface. After every instruction change, run the parser over the evaluation answers: every multi-row answer must produce a table, every value header must carry a unit, and the Chart and Notes lines must be present. That check slots straight into the agents-as-code pipeline from the previous post, next to the accuracy gate. A correct answer that the app cannot read is still a broken answer.
Further Reading
- Examples in the session repo: the instructions template, sample answers, the parser, and the offline chart gallery
- Get visual responses from a Fabric data agent: Microsoft Learn on the built-in visuals and their limits
- Calling a Fabric Data Agent over MCP: where the text answers come from