This example follows the site-wide theme, language and data.

A conversation, not a screenshot

A mock chat with no model behind it. Click a slice of the donut and watch the click become the next message, then the next chart.

The loop, end to end

  1. The assistant answers with a donut spec. ChartFromSpec draws it inside the bubble with chrome="bare".
  2. A click on a slice calls onIntent with a typed ChartIntent.
  3. intentToPrompt turns it into one line. Your app sends it as the next user message and the model replies with the next chart.
tsx
import { ChartFromSpec, intentToPrompt } from 'em-kit';
import type { ChartSpec } from 'em-kit';

type Props = {
  message: { text: string; spec?: ChartSpec };
  sendMessage: (text: string) => void;
};

export function AssistantMessage({ message, sendMessage }: Props) {
  return (
    <div className="bubble">
      <p>{message.text}</p>
      {message.spec && (
        <ChartFromSpec
          spec={message.spec}
          chrome="bare"
          height={260}
          onIntent={(intent) => sendMessage(intentToPrompt(intent))}
        />
      )}
    </div>
  );
}
Last intent received

Click a slice in the chat to see the object your handler receives.

Analytics assistantMock conversation · data is local

How did revenue split by region last quarter?

North America led last quarter with $421K, 36% of $1.2M. Click a slice to dig in.

Try your own spec

Paste whatever a model might send. Valid specs render with the real components; wrong ones still render something visible. The quickest way to test your prompts: copy the tool input from your logs and drop it in. Setting up the tool and the system prompt is covered in the charts from a model guide.

Example specs
chrome
Valid JSON

Edit the spec and the chart updates as you type. Try changing "chart" or removing a field.

Revenue by region

Last quarter

Intent log

Click a slice, bar, point or table row. Each click is one ChartIntent, followed by the line intentToPrompt would send to the model.