diff --git a/packages/flint-mcp/ui/src/BoardView.tsx b/packages/flint-mcp/ui/src/BoardView.tsx index 0b7871e7..627da14b 100644 --- a/packages/flint-mcp/ui/src/BoardView.tsx +++ b/packages/flint-mcp/ui/src/BoardView.tsx @@ -44,6 +44,7 @@ import { boardPng } from './board-export'; import { SelectionChips, chipText, impliedParts, partText } from './selection-chips'; import { ViewSwitch, useCellViews, useChartTable, type CellView } from './chart-table-view'; import { ActionButton, ThemeControl } from './controls'; +import { usePageScroll } from './page-scroll'; import { LINK_LAYER, conditionUpdates, gestureParts, shownFields, type ChartLink, type LinkCondition, type LinkSpec } from 'flint-chart/interactive'; export interface BoardChart { @@ -733,16 +734,8 @@ export function BoardView({ app, initial, hostContext }: { app: App; initial: Bo document.documentElement.style.background = style.background; document.body.style.background = style.background; }, [style.background]); - // Inline, the card is sized to the board, so the page never scrolls. A scrollbar would appear while the - // host catches up with a new height, narrow the board, lay every chart out again, and change the height - // again. In a pane the host sets the height, so a taller board scrolls, with its gutter kept so the - // scrollbar never narrows it. const paned = hostContext?.displayMode === 'fullscreen' || hostContext?.displayMode === 'pip'; - useEffect(() => { - document.documentElement.style.overflow = paned ? 'hidden auto' : 'hidden'; - document.documentElement.style.scrollbarGutter = paned ? 'stable' : ''; - document.body.style.overflow = paned ? 'visible' : 'hidden'; - }, [paned]); + usePageScroll(hostContext, paned); const byId = useMemo(() => new Map(charts.map((chart) => [chart.id, chart])), [charts]); const grid = draft ?? board.grid; diff --git a/packages/flint-mcp/ui/src/ChartView.tsx b/packages/flint-mcp/ui/src/ChartView.tsx index 90e8da11..80107d9a 100644 --- a/packages/flint-mcp/ui/src/ChartView.tsx +++ b/packages/flint-mcp/ui/src/ChartView.tsx @@ -25,6 +25,7 @@ import { chartIconFor } from './chart-icons'; import { SelectionChips, chipText, impliedParts, partText, type SelectionChip } from './selection-chips'; import { VIEW_SWITCH_LABEL, ViewSwitchIcon, useChartTable, type CellView } from './chart-table-view'; import { tablePng } from './table-export'; +import { usePageScroll } from './page-scroll'; import { conditionUpdates, selectionParts, type LinkCondition } from 'flint-chart/interactive'; import { chartContext, chartView, type ChartGesture } from '../../src/chart-context'; import { @@ -611,16 +612,9 @@ export function ChartView({ app, shown, hostContext }: { app: App; shown: Board; }, []); useEffect(() => () => chartBoxObserver.current?.disconnect(), []); - // Inline, the card is sized to the chart, so the page never scrolls: a scrollbar shown while the host - // catches up with a new height would narrow the chart and lay it out again. In a pane the host sets - // the height and the chart is laid out for what the pane leaves it; the page scrolls only past that, - // with its gutter kept so the scrollbar never narrows the chart. + // In a pane the host sets the height and the chart is laid out for what the pane leaves it. const paned = hostContext?.displayMode === 'fullscreen' || hostContext?.displayMode === 'pip'; - useEffect(() => { - document.documentElement.style.overflow = paned ? 'hidden auto' : 'hidden'; - document.documentElement.style.scrollbarGutter = paned ? 'stable' : ''; - document.body.style.overflow = paned ? 'visible' : 'hidden'; - }, [paned]); + usePageScroll(hostContext, paned); // Re-seed when a new tool input arrives from the host. useEffect(() => setCurrent(input), [input]); diff --git a/packages/flint-mcp/ui/src/page-scroll.ts b/packages/flint-mcp/ui/src/page-scroll.ts new file mode 100644 index 00000000..c46c41eb --- /dev/null +++ b/packages/flint-mcp/ui/src/page-scroll.ts @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { useEffect, useState } from 'react'; +import type { McpUiHostContext } from '@modelcontextprotocol/ext-apps'; + +/** The tallest the host will draw the card inline, if it says. */ +function hostMaxHeight(hostContext?: McpUiHostContext): number | undefined { + const dims = hostContext?.containerDimensions as { height?: number; maxHeight?: number } | undefined; + const cap = dims?.maxHeight ?? dims?.height; + return typeof cap === 'number' && Number.isFinite(cap) && cap > 0 ? cap : undefined; +} + +/** How far a scrolling page must shrink below the cap before it stops scrolling, so the gutter cannot flip it back and forth. */ +const HYSTERESIS = 16; + +/** + * Whether the page scrolls. Inline, the card is sized to the page, so it never does: a scrollbar would + * appear while the host catches up with a new height, narrow the content, lay it out again, and change + * the height again. A host that stops growing the card at a height (VS Code: 75% of its window) says so + * in `containerDimensions.maxHeight`; a page taller than that scrolls, or its bottom is cut off. In a pane + * the host sets the height, so the page scrolls past it. A scrolling page keeps its gutter so the + * scrollbar never narrows it. + */ +export function usePageScroll(hostContext: McpUiHostContext | undefined, paned: boolean): void { + const cap = paned ? undefined : hostMaxHeight(hostContext); + const [over, setOver] = useState(false); + useEffect(() => { + if (cap === undefined || typeof ResizeObserver === 'undefined') { + setOver(false); + return; + } + const read = () => { + const height = document.body.scrollHeight; + setOver((prev) => (prev ? height > cap - HYSTERESIS : height > cap + 1)); + }; + read(); + const observer = new ResizeObserver(read); + observer.observe(document.body); + return () => observer.disconnect(); + }, [cap]); + + const scrolls = paned || over; + useEffect(() => { + document.documentElement.style.overflow = scrolls ? 'hidden auto' : 'hidden'; + document.documentElement.style.scrollbarGutter = scrolls ? 'stable' : ''; + document.body.style.overflow = scrolls ? 'visible' : 'hidden'; + }, [scrolls]); +} diff --git a/site/src/components/PromptBlock.tsx b/site/src/components/PromptBlock.tsx new file mode 100644 index 00000000..270ae288 --- /dev/null +++ b/site/src/components/PromptBlock.tsx @@ -0,0 +1,77 @@ +import { useState, type CSSProperties } from 'react'; +import { useTranslation } from 'react-i18next'; +import { siteTheme } from '../shared/theme'; + +const HAIRLINE = 'rgba(0, 0, 0, 0.10)'; + +/** + * A monospace block of text. With `copyable`, it is a prompt the reader pastes into their agent, with a + * copy button over its top-right corner. + */ +export function PromptBlock({ children, copyable = false }: { children: string; copyable?: boolean }) { + const { t } = useTranslation(); + const [copied, setCopied] = useState(false); + + async function copy() { + await navigator.clipboard.writeText(children); + setCopied(true); + window.setTimeout(() => setCopied(false), 1600); + } + + return ( +
+ {copyable ? ( + + ) : null} +
{children}
+
+ ); +} + +const wrapStyle: CSSProperties = { + margin: '4px 0 8px', + border: `1px solid ${HAIRLINE}`, + borderRadius: 8, + background: 'rgba(0,0,0,0.025)', + overflow: 'auto', + position: 'relative', +}; + +const preStyle: CSSProperties = { + margin: 0, + padding: '14px 16px', + fontFamily: siteTheme.fontMono, + fontSize: 13, + lineHeight: 1.6, + color: siteTheme.text, +}; + +const preCopyableStyle: CSSProperties = { + paddingRight: 128, +}; + +const copyButtonStyle: CSSProperties = { + position: 'absolute', + top: 8, + right: 8, + display: 'inline-flex', + alignItems: 'center', + gap: 6, + border: `1px solid rgba(0, 102, 204, 0.24)`, + borderRadius: 7, + background: 'rgba(0, 102, 204, 0.08)', + color: siteTheme.accent, + fontFamily: siteTheme.fontSans, + fontSize: 12.5, + fontWeight: 600, + padding: '5px 10px', + cursor: 'pointer', +}; + +const copyIconStyle: CSSProperties = { + fontSize: 13, + lineHeight: 1, +}; diff --git a/site/src/global.css b/site/src/global.css index 460010ed..b42230ca 100644 --- a/site/src/global.css +++ b/site/src/global.css @@ -130,4 +130,18 @@ input[type='range'].site-range:focus-visible { margin-left: auto; flex-shrink: 0; } -} \ No newline at end of file +} +/* A copyable prompt: the copy button floats over the block's top-right corner, beside the short first line. */ +.prompt-block-copyable pre { + padding: 14px 14px 12px !important; + font-size: 12px !important; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +@media (max-width: 520px) { + /* Too narrow for the button beside the first line: it keeps a row of its own. */ + .prompt-block-copyable pre { + padding-top: 42px !important; + } +} diff --git a/site/src/i18n/messages/en.json b/site/src/i18n/messages/en.json index f980c8c3..5c5c1de2 100644 --- a/site/src/i18n/messages/en.json +++ b/site/src/i18n/messages/en.json @@ -400,6 +400,11 @@ "ctaMcp": "Get MCP Server", "ctaGithub": "Visit GitHub", "ctaDocs": "Read the docs", + "tryIt": { + "title": "Try it now", + "body": "Copy this prompt into your AI agent, such as GitHub Copilot, Claude Code, Cursor or Codex. It adds the Flint MCP server and draws your first chart.", + "manual": "Wondering about the experience? Check out the MCP server." + }, "news": { "title": "Updates", "video": "Video", @@ -444,11 +449,12 @@ "howItWorksBody": "A Flint spec consists of the data, semantic types, the chart spec, and optional theme and interaction specs. Instead of relying on complex user-side logic to glue them together, the compiler does the heavy lifting: it resolves each part against the others and composes a complete backend-native spec (shown here in Vega-Lite), filling in the necessary low-level details, and renders a good-looking, interactive chart.", "overviewAlt": "Flint workflow: an agent infers a dataSpec from a raw table, a short chartSpec is written, and Flint compiles it into a faceted line chart, then a grouped bar, waterfall, heatmap, and sunburst as the spec is edited.", "leadBefore": "Flint is a visualization intermediate language that lets", - "leadHighlight1": "AI agents reliably create expressive, good-looking and interactive charts from simple, human-editable chart specs", + "leadHighlight1": "AI agents reliably create expressive, good-looking and interactive charts from simple, human-editable specs", "leadStop": ". ", - "leadAvailability": "It is available as an MCP server for everyday use with your agent, and as an npm library for building interactive applications.", - "leadHighlight2": "Flint supports {{chartTypes}} chart types across {{backends}} rendering backends through one unified interface, with {{themes}} themes and {{presets}} interaction presets", - "leadAfter": "To create bespoke visualizations, you can design custom themes in the Theme Lab and build advanced interactions with the Flint API.", + "leadInsight": "The key design is to disentangle the visual, style and interaction logic that low-level chart libraries mix together: you or your agents describe each in a short semantic spec, and the compiler composes them.", + "leadAvailability": "Use it as an MCP server with your agent, or as an npm library for building interactive applications.", + "leadHighlight2": "Flint supports {{chartTypes}} chart types across {{backends}} rendering backends, {{themes}} themes and {{presets}} interaction presets", + "leadAfter": "For bespoke visualizations, design your own themes in the Theme Lab and build advanced interactions with the Flint API. ", "backendRosterLabel": "Backends", "themeRosterLabel": "Themes", "interactionRosterLabel": "Interactions", @@ -565,6 +571,8 @@ "leadBefore": "Install flint-chart-mcp as a", "leadMcpLink": "Model Context Protocol", "leadAfter": "server and your agent can create interactive charts or author reusable visual themes. By default it opens an interactive Flint chart view; it can also return static artifacts and guide agents through a formal ThemeSpec.", + "copyPrompt": "Copy prompt", + "copied": "Copied", "quickStart": "Quick start:", "quickStartBody": "paste this setup request into your agent and let it configure Flint for the current project. For manual setup, see", "installConfigure": "install & configure", diff --git a/site/src/i18n/messages/zh-CN.json b/site/src/i18n/messages/zh-CN.json index 582589a8..ee222ca6 100644 --- a/site/src/i18n/messages/zh-CN.json +++ b/site/src/i18n/messages/zh-CN.json @@ -400,6 +400,11 @@ "ctaMcp": "使用 MCP 服务器", "ctaGithub": "访问 GitHub", "ctaDocs": "阅读文档", + "tryIt": { + "title": "立即试用", + "body": "把这段提示词复制到你的 AI 智能体(如 GitHub Copilot、Claude Code、Cursor 或 Codex)。它会添加 Flint MCP 服务器,并画出你的第一张图表。", + "manual": "想了解使用体验?请查看 MCP 服务器页面。" + }, "news": { "title": "更新", "video": "视频", @@ -444,11 +449,12 @@ "howItWorksBody": "一份 Flint 规范由数据、语义类型、图表规范,以及可选的主题和交互规范组成。无需在使用方编写复杂逻辑把它们拼接起来,编译器会完成繁重的工作:它将各部分相互解析,组合出完整的后端原生规范(此处以 Vega-Lite 为例),补全必要的底层细节,并渲染出美观、可交互的图表。", "overviewAlt": "Flint 工作流:智能体从原始表格推断 dataSpec,编写简短的 chartSpec,Flint 将其编译为按地区展示的折线图;随后在编辑规范时依次得到分组柱状图、瀑布图、热力图与旭日图。", "leadBefore": "Flint 是一种可视化中间语言,帮助", - "leadHighlight1": "AI 智能体从简洁、可人工编辑的图表规范出发,稳定生成表现力强、观感出色且可交互的图表", + "leadHighlight1": "AI 智能体从简洁、可人工编辑的规范出发,稳定生成表现力强、观感出色且可交互的图表", "leadStop": "。", - "leadAvailability": "你可以通过 MCP 服务器在日常工作中配合智能体使用它,也可以用 npm 库构建交互式应用。", - "leadHighlight2": "Flint 通过统一接口,在 {{backends}} 种渲染后端上支持 {{chartTypes}} 种图表类型,并提供 {{themes}} 套主题和 {{presets}} 种交互预设", - "leadAfter": "如需定制可视化,可以在主题实验室中设计自定义主题,并用 Flint API 构建高级交互。", + "leadInsight": "其核心设计是把底层图表库中混在一起的视觉逻辑、样式逻辑和交互逻辑解耦:你或你的智能体分别用简短的语义规范描述它们,由编译器将它们组合起来。", + "leadAvailability": "你可以把它作为 MCP 服务器配合智能体使用,也可以作为 npm 库构建交互式应用。", + "leadHighlight2": "Flint 在 {{backends}} 种渲染后端上支持 {{chartTypes}} 种图表类型,并提供 {{themes}} 套主题和 {{presets}} 种交互预设", + "leadAfter": "如需定制可视化,可以在主题实验室中设计自己的主题,并用 Flint API 构建高级交互。", "backendRosterLabel": "渲染后端", "themeRosterLabel": "主题", "interactionRosterLabel": "交互", @@ -565,6 +571,8 @@ "leadBefore": "将 flint-chart-mcp 配置为", "leadMcpLink": "Model Context Protocol", "leadAfter": "服务器后,智能体既能创建交互式图表,也能编写可复用的视觉主题。Flint 默认打开可交互的图表视图;也可以导出静态结果,并引导智能体通过正式的 ThemeSpec 定义视觉设计。", + "copyPrompt": "复制提示词", + "copied": "已复制", "quickStart": "让 AI 智能体帮你配置:", "quickStartBody": "把下面这段请求发给智能体即可。若想手动配置,请参阅", "installConfigure": "安装与配置", diff --git a/site/src/routes/Landing.tsx b/site/src/routes/Landing.tsx index d5e08ede..8d3c0341 100644 --- a/site/src/routes/Landing.tsx +++ b/site/src/routes/Landing.tsx @@ -12,6 +12,9 @@ import { ScaleToFit } from '../components/ScaleToFit'; import { GalleryOptionsBar, ThemeControl } from '../components/GalleryOptionsBar'; import { SpecPipelineFigure } from '../components/SpecPipelineFigure'; import { CodeBlock } from '../components/CodeBlock'; +import { PromptBlock } from '../components/PromptBlock'; +import { MCP_SETUP_PROMPT } from '../shared/mcp-setup'; +import { Zap } from 'lucide-react'; import stringify from 'json-stringify-pretty-compact'; import { testCaseToFlintSummary, testCaseToAssemblyInput, withHouse, withHouseId } from '../shared/test-case-utils'; import { buildPanelModel, withoutEchoedOverrides } from '../shared/chart-options'; @@ -64,7 +67,7 @@ export function Landing() {
{/* ---- Hero ------------------------------------------------------ */} -
+
@@ -80,13 +83,7 @@ export function Landing() { {t('landing.leadBefore')}{' '} {t('landing.leadHighlight1')} {t('landing.leadStop')} - , - npm: , - }} - /> + {t('landing.leadInsight')}

{t('landing.leadHighlight2', { @@ -103,6 +100,13 @@ export function Landing() { advanced: , }} /> + , + npm: , + }} + />

@@ -218,6 +222,26 @@ export function Landing() { {/* ---- Interactive example: spec -> chart --------------------- */} + {/* ---- Try it now: a prompt the reader pastes into their agent -- */} +
+
+

+

+

{t('landing.tryIt.body')}

+

+ }} + /> +

+
+
+ {MCP_SETUP_PROMPT} +
+
+ {/* ---- News ---------------------------------------------------- */}

{t('landing.news.title')}

@@ -1787,6 +1811,55 @@ const howItWorksSectionStyle: CSSProperties = { paddingBottom: 48, }; +const tryItSectionStyle: CSSProperties = { + ...sectionStyle, + display: 'grid', + gridTemplateColumns: 'minmax(0, 300px) minmax(0, 1fr)', + gap: 32, + alignItems: 'start', + paddingTop: 20, + paddingBottom: 28, +}; + +const tryItTextColStyle: CSSProperties = { + display: 'grid', + gap: 8, +}; + +const tryItHeadingStyle: CSSProperties = { + display: 'flex', + alignItems: 'center', + gap: 8, + margin: 0, + fontSize: 22, + lineHeight: 1.3, + fontWeight: 650, +}; + +const tryItIconStyle: CSSProperties = { + flex: '0 0 auto', + color: '#b26a00', +}; + +const tryItBodyStyle: CSSProperties = { + margin: 0, + color: siteTheme.text, + fontSize: 14.5, + lineHeight: 1.6, +}; + +const tryItNoteStyle: CSSProperties = { + margin: 0, + color: siteTheme.textMuted, + fontSize: 13, + lineHeight: 1.55, +}; + +const tryItPromptColStyle: CSSProperties = { + minWidth: 0, + background: PAPER, +}; + const newsSectionStyle: CSSProperties = { ...sectionStyle, display: 'grid', @@ -2246,6 +2319,11 @@ const landingInteractiveStyles = ` } @media (max-width: 640px) { + .landing-try-it { + grid-template-columns: minmax(0, 1fr) !important; + gap: 14px !important; + } + .landing-backend-roster-label { flex-basis: 100%; margin-right: 0 !important; diff --git a/site/src/routes/McpExperience.tsx b/site/src/routes/McpExperience.tsx index 024fc442..995c2458 100644 --- a/site/src/routes/McpExperience.tsx +++ b/site/src/routes/McpExperience.tsx @@ -48,6 +48,29 @@ export function McpExperience() { ); } +/** One of the introduction's two chat turns, without its heading: the talk deck shows them one to a slide. */ +export function McpChatTurn({ kind }: { kind: 'chart' | 'board' }) { + const { t } = useTranslation(); + useMcpStyles(SCOPE); + useHostPage(); + return ( + <> + + + {kind === 'chart' ? ( + } + /> + ) : ( + } + /> + )} + + + ); +} + /** The step-by-step stories, one chart and then a board, each a chat drawn with the real MCP cards. */ export function McpExperienceStories() { useMcpStyles(SCOPE); @@ -62,11 +85,11 @@ export function McpExperienceStories() { } /** One ask and what the agent produces, in a chat window that grows to hold it. */ -function SimpleStory({ heading, children }: { heading: string; children: ReactNode }) { +function SimpleStory({ heading, children }: { heading?: string; children: ReactNode }) { const { t } = useTranslation(); return ( -
-

{heading}

+
+ {heading &&

{heading}

}
diff --git a/site/src/routes/McpServer.tsx b/site/src/routes/McpServer.tsx index daf23b0c..4723553b 100644 --- a/site/src/routes/McpServer.tsx +++ b/site/src/routes/McpServer.tsx @@ -1,14 +1,13 @@ -import { useState } from 'react'; import type { CSSProperties, ReactNode } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { SiteNavBar, MicrosoftDisclosures } from '../components/SiteShell'; import { LocaleLink } from '../i18n/LocaleLink'; import { GITHUB_REPO, siteTheme } from '../shared/theme'; +import { MCP_SETUP_PROMPT } from '../shared/mcp-setup'; +import { PromptBlock } from '../components/PromptBlock'; import chartPreview from '../assets/mcp-chart-preview.svg'; import { McpExperience } from './McpExperience'; -const HOSTED_MCP_URL = 'https://flint.data-formulator.ai/mcp'; - const SURFACE_GROUPS = [ { key: 'chart', tools: ['validate_chart', 'show'] }, { key: 'board', tools: ['validate_board', 'show'] }, @@ -26,7 +25,6 @@ export function McpServer() { return (
-
@@ -57,9 +55,7 @@ export function McpServer() { .

-
- {setupPrompt} -
+ {MCP_SETUP_PROMPT}

- {clientConfig} + {clientConfig}

@@ -139,7 +135,7 @@ export function McpServer() {

- {disableFileReferenceConfig} + {disableFileReferenceConfig} {/* ---- Next ------------------------------------------------- */} @@ -286,36 +282,6 @@ function SurfaceCard(props: { title: string; desc: string; tools: readonly strin ); } -function CodeBlock({ children, copyable = false }: { children: string; copyable?: boolean }) { - const [copied, setCopied] = useState(false); - - async function copyCode() { - await navigator.clipboard.writeText(children); - setCopied(true); - window.setTimeout(() => setCopied(false), 1600); - } - - return ( -
- {copyable ? ( - - ) : null} -
{children}
-
- ); -} - -const setupPrompt = `Help me set up Flint as an MCP server named "flint"! - -1. Add it to my client config, using whichever option my client supports: - - a local (stdio) server: npx -y flint-chart-mcp - - the hosted server over HTTP: ${HOSTED_MCP_URL} -2. Verify the setup by listing the available Flint chart types. -3. Show me a fun first chart: how many moons each planet has, in a Flint theme you like.`; - const clientConfig = `{ "mcpServers": { "flint": { @@ -349,22 +315,7 @@ const GRID_LINE = 'rgba(0, 0, 0, 0.02)'; const READING_WIDTH = 880; -const interactiveStyles = ` - /* The copy button floats over the block's top-right corner, beside the short first line. */ - .mcp-setup-grid pre { - padding: 14px 14px 12px !important; - font-size: 12px !important; - white-space: pre-wrap; - overflow-wrap: anywhere; - } - @media (max-width: 520px) { - /* Too narrow for the button beside the first line: it keeps a row of its own. */ - .mcp-setup-grid pre { - padding-top: 42px !important; - } - } -`; const pageStyle: CSSProperties = { minHeight: '100vh', @@ -856,53 +807,6 @@ const cardDescStyle: CSSProperties = { margin: 0, }; -/* ---- code blocks ---- */ - -const codeBlockWrapStyle: CSSProperties = { - margin: '4px 0 8px', - border: `1px solid ${HAIRLINE}`, - borderRadius: 8, - background: 'rgba(0,0,0,0.025)', - overflow: 'auto', - position: 'relative', -}; - -const codeBlockStyle: CSSProperties = { - margin: 0, - padding: '14px 16px', - fontFamily: siteTheme.fontMono, - fontSize: 13, - lineHeight: 1.6, - color: siteTheme.text, -}; - -const codeBlockCopyableStyle: CSSProperties = { - paddingRight: 128, -}; - -const copyButtonStyle: CSSProperties = { - position: 'absolute', - top: 8, - right: 8, - display: 'inline-flex', - alignItems: 'center', - gap: 6, - border: `1px solid rgba(0, 102, 204, 0.24)`, - borderRadius: 7, - background: 'rgba(0, 102, 204, 0.08)', - color: siteTheme.accent, - fontFamily: siteTheme.fontSans, - fontSize: 12.5, - fontWeight: 600, - padding: '5px 10px', - cursor: 'pointer', -}; - -const copyIconStyle: CSSProperties = { - fontSize: 13, - lineHeight: 1, -}; - /* ---- next actions ---- */ const nextRowStyle: CSSProperties = { diff --git a/site/src/routes/mcp-experience-data.ts b/site/src/routes/mcp-experience-data.ts index 7802911d..a8407cd0 100644 --- a/site/src/routes/mcp-experience-data.ts +++ b/site/src/routes/mcp-experience-data.ts @@ -80,7 +80,7 @@ const coffeeByCountry: ChartAssemblyInput = { chart_spec: { chartType: 'Line Chart', encodings: { x: { field: 'Year' }, y: { field: 'Bags' }, color: { field: 'Country' } }, - title: 'Asia is learning to love coffee', + title: "Asia's love for coffee has grown", // Wider than tall: the card holds 480px of chart, and the legend takes two rows above the plot. baseSize: { width: 520, height: 280 }, subtitle: 'Coffee consumed in each country, million 60-kg bags, 2005–2025', diff --git a/site/src/shared/mcp-setup.ts b/site/src/shared/mcp-setup.ts new file mode 100644 index 00000000..afbedb12 --- /dev/null +++ b/site/src/shared/mcp-setup.ts @@ -0,0 +1,11 @@ +/** The hosted Flint MCP endpoint, for clients that connect over HTTP. */ +export const HOSTED_MCP_URL = 'https://flint.data-formulator.ai/mcp'; + +/** A request a reader pastes into their agent: it sets Flint up as an MCP server and draws a first chart. */ +export const MCP_SETUP_PROMPT = `Help me set up Flint as an MCP server named "flint"! + +1. Add it to my client config, using whichever option my client supports: + - a local (stdio) server: npx -y flint-chart-mcp + - the hosted server over HTTP: ${HOSTED_MCP_URL} +2. Verify the setup by listing the available Flint chart types. +3. Show me a fun first chart: how many moons each planet has, in a Flint theme you like.`; diff --git a/site/src/talk/data.ts b/site/src/talk/data.ts index 0367f0b2..ff4f597d 100644 --- a/site/src/talk/data.ts +++ b/site/src/talk/data.ts @@ -182,7 +182,7 @@ const layoutStep = (): Spec => ({ color: { aggregate: 'sum', field: 'newUsers', type: 'quantitative', title: 'Net new users', scale: { scheme: 'redblue', domainMid: 0 }, - legend: { format: '~s', orient: 'top', direction: 'horizontal', gradientLength: 180 }, + legend: { format: '~s' }, }, }, }); diff --git a/site/src/talk/parts.tsx b/site/src/talk/parts.tsx index fc3bd9a7..a4fd619c 100644 --- a/site/src/talk/parts.tsx +++ b/site/src/talk/parts.tsx @@ -4,6 +4,7 @@ import { FlintChart } from 'flint-chart/react'; import { ScaleToFit } from '../components/ScaleToFit'; import { VegaLiteView } from '../components/VegaLiteView'; import { SKETCHES } from './sketches'; +import { C, ellipse } from './sketch'; import minimaps from './specs/minimaps.json'; /** A live Flint chart laid out for its box: the compiler sizes it to the room, nothing spills. */ @@ -26,6 +27,80 @@ export function VegaLite({ spec }: { spec: unknown }) { ); } +export type Flaw = { role: 'x-axis' | 'y-axis' | 'legend' | 'marks'; label: string }; + +/** + * A Vega-Lite chart with its problems circled in red, hand-drawn over the parts Vega names (an axis, + * the legend, the marks), each with a short label. The rings follow the chart as it scales. + */ +export function FlawedVegaLite({ spec, flaws }: { spec: unknown; flaws: Flaw[] }) { + // Each ring carries its number; the labels are listed as text beside the chart (see FlawList). + const host = useRef(null); + const canvasRef = useRef(null); + useEffect(() => { + const el = host.current, canvas = canvasRef.current; + if (!el || !canvas) return; + let ready = false; + const draw = () => { + const svg = el.querySelector('svg.marks, svg'); + const w = el.clientWidth, h = el.clientHeight; + if (!ready || !svg || !w || !h) return; + const hb = el.getBoundingClientRect(), k = hb.width / w || 1; + const dpr = Math.max(2, window.devicePixelRatio * 1.5); + canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr); + const ctx = canvas.getContext('2d')!; + ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, w, h); + const axes = [...svg.querySelectorAll('.role-axis')].map((g) => g.getBoundingClientRect()); + const pick = (role: Flaw['role']): DOMRect | undefined => { + if (role === 'legend') return svg.querySelector('.role-legend')?.getBoundingClientRect(); + if (role === 'marks') return svg.querySelector('.role-mark')?.getBoundingClientRect(); + // The x axis is the wide one, the y axis the tall one. + const sorted = [...axes].sort((a, b) => (role === 'x-axis' ? b.width / b.height - a.width / a.height : b.height / b.width - a.height / a.width)); + return sorted[0]; + }; + flaws.forEach((flaw, i) => { + const r = pick(flaw.role); + if (!r) return; + const x = (r.left - hb.left) / k, y = (r.top - hb.top) / k, bw = r.width / k, bh = r.height / k; + const cx = x + bw / 2, cy = y + bh / 2; + ellipse(ctx, cx, cy, bw / 2 + 12, bh / 2 + 10, { w: 3, color: C.red, seed: 3000 + i * 7 }); + // A numbered badge on the ring's upper left; the slide lists what each number means. + const rx = bw / 2 + 12, ry = bh / 2 + 10; + const bx = Math.min(Math.max(cx - rx * 0.72, 16), w - 16), by = Math.min(Math.max(cy - ry * 0.72, 16), h - 16); + ctx.save(); + ctx.fillStyle = C.red; ctx.beginPath(); ctx.arc(bx, by, 15, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#fff'; ctx.font = "700 18px Inter, system-ui, sans-serif"; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; + ctx.fillText(String(i + 1), bx, by + 1); + ctx.restore(); + }); + canvas.dataset.drawn = 'true'; + }; + void document.fonts.load("700 20px 'Kalam'").then(() => { ready = true; draw(); }); + const ro = new ResizeObserver(draw); + ro.observe(el); + const mo = new MutationObserver(() => requestAnimationFrame(draw)); + mo.observe(el, { childList: true, subtree: true }); + return () => { ro.disconnect(); mo.disconnect(); }; + }, [flaws]); + return ( +
+ + + + +
+ ); +} + +/** The numbered problems a FlawedVegaLite circles, as readable text. */ +export function FlawList({ flaws }: { flaws: Flaw[] }) { + return ( +
    + {flaws.map((flaw, i) =>
  1. {i + 1}{flaw.label}
  2. )} +
+ ); +} + /** A site demo laid out at `width`, scaled to fit its box. Flint's pointer handling follows the scale. */ export function Demo({ width, children }: { width: number; children: ReactNode }) { return ( diff --git a/site/src/talk/sketch.ts b/site/src/talk/sketch.ts index b35239b9..20ef0bf9 100644 --- a/site/src/talk/sketch.ts +++ b/site/src/talk/sketch.ts @@ -167,9 +167,11 @@ export function card(ctx: Ctx, x: number, y: number, w: number, h: number, o: { rect(ctx, x, y, w, h, { w: o.w ?? 3, color: o.color ?? C.ink, seed: o.seed || 0 }); } -export type FontKind = 'hand' | 'handBold' | 'mono'; +export type FontKind = 'hand' | 'handBold' | 'mono' | 'sans'; export function font(size: number, kind: FontKind = 'hand'): string { if (kind === 'mono') return `500 ${size}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`; + // The deck's own type, for sentences that sit in a sketch but should read as text. + if (kind === 'sans') return `400 ${size}px 'Inter Variable', Inter, system-ui, sans-serif`; return `${kind === 'handBold' ? 700 : 400} ${size}px 'Kalam'`; } diff --git a/site/src/talk/sketches.ts b/site/src/talk/sketches.ts index 0139ac06..7bf24acb 100644 --- a/site/src/talk/sketches.ts +++ b/site/src/talk/sketches.ts @@ -180,7 +180,7 @@ export const SKETCHES: Record = { // the two limits, shared by every row for (const [x, label] of [[base, 'base size'], [most, 'the most it may stretch']] as [number, string][]) { for (let y = 70; y < 620; y += 26) line(ctx, X(x), Y(y), X(x), Y(y + 12), { w: S(2), color: C.soft, seed: x + y, taper: false }); - text(ctx, label, X(x), Y(52), { size: S(22), color: C.ink2, align: 'center', maxWidth: S(220) }); + text(ctx, label, X(x), Y(52), { size: S(21), kind: 'sans', color: C.ink2, align: 'center', maxWidth: S(220) }); } const rows: { y: number; n: number; wall: number; say: string; extra?: string }[] = [ { y: 110, n: 4, wall: base, say: 'A few items: bands widen, and the plot keeps its size.' }, @@ -188,7 +188,7 @@ export const SKETCHES: Record = { { y: 490, n: 18, wall: most, say: 'Too many: bands at their thinnest, the plot at its limit.', extra: 'the rest scroll into view' }, ]; rows.forEach(({ y, n, wall, say, extra }, r) => { - text(ctx, say, X(20), Y(y + 40), { size: S(26), color: C.ink, maxWidth: S(470), maxLines: 2 }); + text(ctx, say, X(20), Y(y + 40), { size: S(25), kind: 'sans', color: C.ink, maxWidth: S(470), maxLines: 2, lineHeight: 1.3 }); // the axis box rect(ctx, X(x0), Y(y), S(wall - x0), S(100), { w: 3, color: C.ink, seed: 400 + r }); // bands and the springs between them @@ -204,11 +204,11 @@ export const SKETCHES: Record = { } if (r === 1) { arrow(ctx, X(wall + 6), Y(y + 30), X(wall + 76), Y(y + 30), { w: S(3.5), color: C.meaning, seed: 470, head: S(13) }); - text(ctx, 'the data pushes out', X(wall + 84), Y(y + 38), { size: S(22), color: C.meaning, maxWidth: S(1430 - wall - 84) }); + text(ctx, 'the data pushes out', X(wall + 84), Y(y + 38), { size: S(21), kind: 'sans', color: C.meaning, maxWidth: S(1430 - wall - 84) }); arrow(ctx, X(most + 70), Y(y + 78), X(wall + 10), Y(y + 78), { w: S(3.5), color: C.look, seed: 471, head: S(13) }); - text(ctx, 'the canvas pushes back', X(most - 150), Y(y + 128), { size: S(22), color: C.look, maxWidth: S(330) }); + text(ctx, 'the canvas pushes back', X(most - 150), Y(y + 128), { size: S(21), kind: 'sans', color: C.look, maxWidth: S(330) }); } - if (extra) text(ctx, extra, X(most + 16), Y(y + 58), { size: S(21), color: C.ink2, maxWidth: S(1430 - most - 16), maxLines: 3 }); + if (extra) text(ctx, extra, X(most + 16), Y(y + 58), { size: S(20), kind: 'sans', color: C.ink2, maxWidth: S(1430 - most - 16), maxLines: 3 }); }); }, @@ -395,30 +395,54 @@ Object.assign(SKETCHES, { typesHow(ctx: Ctx, w: number, h: number) { pipeline(ctx, w, h, [ { title: 'Data + types', draw: (b, x) => { - mono(ctx, b, 'period newUsers', x + 40, 152, { size: 22, color: C.ink2 }); - line(ctx, b.X(x + 36), b.Y(166), b.X(x + 364), b.Y(166), { w: b.S(2), color: C.soft, seed: 501 }); + // The raw rows, on a soft grey wash: just numbers so far. + washRect(ctx, b.X(x + 26), b.Y(124), b.S(348), b.S(176), C.soft, { alpha: 0.22, seed: 500 }); + rect(ctx, b.X(x + 26), b.Y(124), b.S(348), b.S(176), { w: b.S(1.5), color: C.soft, seed: 504 }); + mono(ctx, b, 'period newUsers', x + 40, 156, { size: 22, color: C.ink2 }); + line(ctx, b.X(x + 36), b.Y(170), b.X(x + 364), b.Y(170), { w: b.S(2), color: C.soft, seed: 501 }); [['202101', '5948'], ['202101', '-1086'], ['…', '…']].forEach(([p, v], i) => { - mono(ctx, b, p, x + 40, 206 + i * 40, { size: 22 }); - mono(ctx, b, v.padStart(8), x + 196, 206 + i * 40, { size: 22, color: v.startsWith('-') ? C.red : C.ink }); + mono(ctx, b, p, x + 40, 210 + i * 36, { size: 22 }); + mono(ctx, b, v.padStart(8), x + 196, 210 + i * 36, { size: 22, color: v.startsWith('-') ? C.red : C.ink }); + }); + ellipse(ctx, b.X(x + 80), b.Y(203), b.S(58), b.S(22), { w: b.S(2.5), color: C.amber, seed: 502 }); + // The semantic types, highlighted in blue: the part the agent adds. + washRect(ctx, b.X(x + 26), b.Y(326), b.S(348), b.S(232), C.meaning, { alpha: 0.2, seed: 505 }); + rect(ctx, b.X(x + 26), b.Y(326), b.S(348), b.S(232), { w: b.S(2.5), color: C.meaning, seed: 506 }); + text(ctx, '+ semantic types', b.X(x + 44), b.Y(370), { size: b.S(28), kind: 'handBold', color: C.meaning, maxWidth: b.S(320), maxLines: 1 }); + [['period', 'YearMonth'], ['game', 'Category'], ['newUsers', 'Profit']].forEach(([f, t], i) => { + const y = 424 + i * 46; + mono(ctx, b, `${f}:`, x + 44, y, { size: 22, color: C.ink2 }); + text(ctx, t, b.X(x + 44 + (f.length + 2) * 13.6), b.Y(y), { size: b.S(23), kind: 'mono', color: C.meaning, maxWidth: b.S(200), maxLines: 1 }); + line(ctx, b.X(x + 44 + (f.length + 2) * 13.6), b.Y(y + 6), b.X(x + 44 + (f.length + 2) * 13.6 + t.length * 13.8), b.Y(y + 6), { w: b.S(2.5), color: C.meaning, seed: 507 + i }); }); - ellipse(ctx, b.X(x + 80), b.Y(199), b.S(58), b.S(22), { w: b.S(2.5), color: C.amber, seed: 502 }); - line(ctx, b.X(x + 30), b.Y(318), b.X(x + 370), b.Y(318), { w: b.S(2), color: C.soft, seed: 503 }); - text(ctx, '+ semantic types', b.X(x + 40), b.Y(366), { size: b.S(28), kind: 'handBold', color: C.meaning, maxWidth: b.S(330), maxLines: 1 }); - ['period: YearMonth', 'game: Category', 'newUsers: Profit'].forEach((m, i) => mono(ctx, b, m, x + 40, 420 + i * 48, { size: 23, color: C.meaning })); } }, - { title: 'Compiler decides', draw: (b, x) => { - chip(ctx, b, x + 24, 180, 'parse', C.blue, '202101 is Jan 2021', 511); - chip(ctx, b, x + 24, 258, 'time axis', C.teal, 'a tick each half year', 513); - chip(ctx, b, x + 24, 336, 'diverge', C.red, 'colors split at 0', 515); - chip(ctx, b, x + 24, 414, 'sum', C.amber, '4 regions, 1 cell', 517); - chip(ctx, b, x + 24, 492, 'fit', C.purple, 'cells sized to fit', 519); + { title: 'What it means', draw: (b, x) => { + chip(ctx, b, x + 24, 200, 'parse', C.blue, '202101 is Jan 2021', 511); + chip(ctx, b, x + 24, 300, 'sum', C.amber, '4 regions, 1 cell', 513); + chip(ctx, b, x + 24, 400, 'diverge', C.red, 'colors split at 0', 515); + chip(ctx, b, x + 24, 500, 'format', C.teal, 'Jan 2021, -1.1k', 517); } }, - { title: 'Chart', draw: (b, x) => { - miniHeatmap(ctx, b.X(x + 40), b.Y(160), b.S(320), b.S(250), { rows: 6, cols: 10, seed: 31, palette: DEFAULT_DIVERGING, frame: false }); - line(ctx, b.X(x + 40), b.Y(430), b.X(x + 360), b.Y(430), { w: b.S(2.5), color: C.ink, seed: 521 }); - ['2021', '2023', '2025'].forEach((t, i) => text(ctx, t, b.X(x + 60 + i * 140), b.Y(474), { size: b.S(26), color: C.ink2, align: 'center', maxWidth: b.S(90) })); + { title: 'Layout', draw: (b, x) => { + // The data pushes the plot out; the canvas pushes back: a dashed canvas around a plot that stretched. + rect(ctx, b.X(x + 30), b.Y(150), b.S(340), b.S(260), { w: b.S(2), color: C.soft, seed: 521 }); + miniHeatmap(ctx, b.X(x + 60), b.Y(176), b.S(290), b.S(170), { rows: 6, cols: 12, seed: 31, palette: DEFAULT_DIVERGING, frame: false }); + arrow(ctx, b.X(x + 205), b.Y(370), b.X(x + 345), b.Y(370), { w: b.S(2.5), color: C.purple, seed: 522, head: b.S(10) }); + arrow(ctx, b.X(x + 205), b.Y(370), b.X(x + 65), b.Y(370), { w: b.S(2.5), color: C.purple, seed: 523, head: b.S(10) }); + ['2021', '2023', '2025'].forEach((t, i) => text(ctx, t, b.X(x + 80 + i * 120), b.Y(398), { size: b.S(20), color: C.ink2, align: 'center', maxWidth: b.S(80) })); + chip(ctx, b, x + 24, 470, 'fit', C.purple, 'cells sized to the canvas', 524); + chip(ctx, b, x + 24, 540, 'ticks', C.teal, 'one label a year', 526); + } }, + { title: 'Any backend', draw: (b, x) => { + const libs: [string, string][] = [['Vega-Lite', C.blue], ['ECharts', C.red], ['Chart.js', C.amber], ['Plotly', C.teal], ['Excel', C.green]]; + libs.forEach(([name, color], i) => { + const y = 150 + i * 84; + washRect(ctx, b.X(x + 30), b.Y(y), b.S(340), b.S(62), color, { alpha: 0.18, seed: 531 + i }); + rect(ctx, b.X(x + 30), b.Y(y), b.S(340), b.S(62), { w: b.S(2), color, seed: 541 + i }); + miniHeatmap(ctx, b.X(x + 42), b.Y(y + 10), b.S(96), b.S(42), { rows: 3, cols: 6, seed: 31 + i, palette: DEFAULT_DIVERGING, frame: false }); + text(ctx, name, b.X(x + 160), b.Y(y + 42), { size: b.S(26), kind: 'handBold', maxWidth: b.S(200), maxLines: 1 }); + }); } }, - ], [{ label: 'compiler' }, { label: 'renders' }], [140, 800, 1460]); + ], [{ label: 'compiler' }, { label: 'compiler' }, { label: 'compiles to' }]); }, /** B, how it works: an unthemed chart, the theme spec, what the compiler decides for this chart, the result. */ @@ -576,44 +600,198 @@ Object.assign(SKETCHES, { }); Object.assign(SKETCHES, { - /** A.1: what each semantic type in the spec sets off, as a small decision tree per field. */ + /** + * A.1: what each semantic type sets off, as a small tree per field. The type boxes and connectors are + * drawn; the branch text is set over them as HTML (see TYPE_TREE in slides.tsx), on the same 1000 × 720 frame. + */ typesTree(ctx: Ctx, w: number, h: number) { const s = Math.min(w / 1000, h / 720); const X = (v: number) => v * s + (w - 1000 * s) / 2, Y = (v: number) => v * s + (h - 720 * s) / 2, S = (v: number) => v * s; - type Leaf = { y: number; text: string; mono?: boolean; color?: string }; - const roots: { cy: number; label: string; leaves: Leaf[] }[] = [ - { cy: 140, label: 'period: YearMonth', leaves: [ - { y: 62, text: 'try the month formats, in order' }, - { y: 112, text: '202101 · 2021-01 · 01/2021 · Jan 2021 · 2021M01', mono: true, color: C.ink2 }, - { y: 168, text: '202101 → Jan 2021', mono: true, color: C.green }, - { y: 226, text: 'draw a time axis, labelled by year' }, - ] }, - { cy: 380, label: 'game: Category', leaves: [ - { y: 338, text: 'no order of its own: keep the data’s order' }, - { y: 410, text: 'one row each, names wrapped to fit' }, - ] }, - { cy: 592, label: 'newUsers: Profit', leaves: [ - { y: 520, text: 'it adds up: sum the four regions' }, - { y: 590, text: 'it can go negative: colors diverge at 0' }, - { y: 660, text: 'same reach on both sides of 0' }, - ] }, - ]; - roots.forEach((r, i) => { + TYPE_TREE.forEach((r, i) => { card(ctx, X(10), Y(r.cy - 40), S(300), S(80), { seed: 1000 + i * 9, color: C.meaning, w: 3 }); text(ctx, r.label, X(160), Y(r.cy + 9), { size: S(25), kind: 'mono', color: C.meaning, align: 'center', maxWidth: S(280), maxLines: 1 }); r.leaves.forEach((l, j) => { - const indent = l.mono ? 40 : 0; if (!l.mono) { - stroke(ctx, [[X(312), Y(r.cy)], [X(345), Y((r.cy + l.y - 8) / 2)], [X(372), Y(l.y - 8)]], { w: S(2.2), color: C.ink2, seed: 1003 + i * 9 + j }); - dot(ctx, X(380), Y(l.y - 8), S(5), C.ink2, { seed: 1030 + i * 9 + j }); + stroke(ctx, [[X(312), Y(r.cy)], [X(345), Y((r.cy + l.y) / 2)], [X(372), Y(l.y)]], { w: S(2.2), color: C.ink2, seed: 1003 + i * 9 + j }); + dot(ctx, X(380), Y(l.y), S(5), C.ink2, { seed: 1030 + i * 9 + j }); } else { - line(ctx, X(398), Y(l.y - 40), X(398), Y(l.y - 8), { w: S(2), color: C.soft, seed: 1050 + i * 9 + j }); - line(ctx, X(398), Y(l.y - 8), X(422), Y(l.y - 8), { w: S(2), color: C.soft, seed: 1060 + i * 9 + j }); + line(ctx, X(398), Y(l.y - 32), X(398), Y(l.y), { w: S(2), color: C.soft, seed: 1050 + i * 9 + j }); + line(ctx, X(398), Y(l.y), X(422), Y(l.y), { w: S(2), color: C.soft, seed: 1060 + i * 9 + j }); } - text(ctx, l.text, X(396 + indent), Y(l.y), l.mono - ? { size: S(21), kind: 'mono', color: l.color, maxWidth: S(560), maxLines: 1 } - : { size: S(29), color: l.color ?? C.ink, maxWidth: S(600), maxLines: 1 }); }); }); }, }); + +// What each semantic type sets off; `y` is the middle of a leaf's line on the 1000 × 720 frame. +export type TypeLeaf = { y: number; text: string; mono?: boolean; tone?: 'muted' | 'good' }; +export const TYPE_TREE: { cy: number; label: string; leaves: TypeLeaf[] }[] = [ + { cy: 140, label: 'period: YearMonth', leaves: [ + { y: 54, text: 'Try the month formats, in order' }, + { y: 104, text: '202101 · 2021-01 · 01/2021 · Jan 2021 · 2021M01', mono: true, tone: 'muted' }, + { y: 160, text: '202101 → Jan 2021', mono: true, tone: 'good' }, + { y: 218, text: 'Draw a time axis, labelled by year' }, + ] }, + { cy: 380, label: 'game: Category', leaves: [ + { y: 330, text: "No order of its own: keep the data's order" }, + { y: 402, text: 'One row each, names wrapped to fit' }, + ] }, + { cy: 592, label: 'newUsers: Profit', leaves: [ + { y: 512, text: 'It adds up: sum the four regions' }, + { y: 582, text: 'It can go negative: colors diverge at 0' }, + { y: 652, text: 'Same reach on both sides of 0' }, + ] }, +]; + +// ---------------------------------------------------------------- section A: the vocabulary of semantic types +const TYPE_GROUPS: { group: string; color: string; types: string[]; x: number; y: number; w: number }[] = [ + // Placed by hand on a 1500 × 560 board: three columns, the bigger groups first. + { group: 'Time units', color: C.blue, x: 20, y: 20, w: 470, types: ['Year', 'Quarter', 'Month', 'Week', 'Day', 'Hour', 'YearMonth', 'YearQuarter', 'YearWeek', 'Decade', 'Duration'] }, + { group: 'Points in time', color: C.blue, x: 20, y: 330, w: 470, types: ['DateTime', 'Date', 'Time', 'Timestamp'] }, + { group: 'Measures', color: C.amber, x: 515, y: 20, w: 470, types: ['Quantity', 'Count', 'Amount', 'Price', 'Percentage', 'Temperature'] }, + { group: 'Signed measures', color: C.red, x: 515, y: 255, w: 470, types: ['Profit', 'PercentageChange', 'Sentiment', 'Correlation'] }, + { group: 'Ordered numbers', color: C.green, x: 515, y: 440, w: 470, types: ['Rank', 'Score', 'ID'] }, + { group: 'Places', color: C.teal, x: 1010, y: 20, w: 470, types: ['Country', 'State', 'City', 'Region', 'Address', 'ZipCode', 'Latitude', 'Longitude'] }, + { group: 'Categories', color: C.purple, x: 1010, y: 310, w: 470, types: ['Category', 'Name', 'Status', 'Boolean', 'Direction', 'Range'] }, +]; + +Object.assign(SKETCHES, { + /** The semantic types, each family a hand-drawn group with its types as chips, laid out by hand. */ + typeCloud(ctx: Ctx, w: number, h: number) { + const s = Math.min(w / 1500, h / 560); + const X = (v: number) => v * s + (w - 1500 * s) / 2, Y = (v: number) => v * s + (h - 560 * s) / 2, S = (v: number) => v * s; + const CHIP_H = 40, GAP = 10, PAD = 22, FS = 20; + TYPE_GROUPS.forEach((g, gi) => { + // Lay the chips out in rows first, so the group's outline fits them. + ctx.save(); ctx.font = `500 ${S(FS)}px ui-monospace, 'SF Mono', Menlo, monospace`; + const widths = g.types.map((t) => ctx.measureText(t).width / s + 26); + ctx.restore(); + const rows: { t: string; w: number; x: number }[][] = [[]]; + let cx = 0; + g.types.forEach((t, i) => { + if (cx > 0 && cx + widths[i] > g.w - PAD * 2) { rows.push([]); cx = 0; } + rows[rows.length - 1].push({ t, w: widths[i], x: cx }); + cx += widths[i] + GAP; + }); + const gh = 62 + rows.length * (CHIP_H + GAP) + 8; + washRect(ctx, X(g.x), Y(g.y), S(g.w), S(gh), g.color, { alpha: 0.13, seed: 2000 + gi }); + rect(ctx, X(g.x), Y(g.y), S(g.w), S(gh), { w: S(2.5), color: g.color, seed: 2010 + gi }); + text(ctx, g.group, X(g.x + PAD), Y(g.y + 40), { size: S(27), kind: 'handBold', color: g.color, maxWidth: S(g.w - PAD * 2), maxLines: 1 }); + rows.forEach((row, ri) => row.forEach((c, ci) => { + const x = g.x + PAD + c.x, y = g.y + 58 + ri * (CHIP_H + GAP); + card(ctx, X(x), Y(y), S(c.w), S(CHIP_H), { seed: 2100 + gi * 40 + ri * 10 + ci, color: g.color, fill: '#ffffff', w: 1.6 }); + text(ctx, c.t, X(x + c.w / 2), Y(y + CHIP_H / 2 + 7), { size: S(FS), kind: 'mono', color: C.ink, align: 'center', maxWidth: S(c.w - 8), maxLines: 1 }); + })); + }); + }, +}); + +// ---------------------------------------------------------------- act 4: three ways to use Flint + +type TrioPanel = (ctx: Ctx, b: Board, x: number, py: number) => void; + +/** + * Three hand-drawn windows side by side. With `focus`, the other two fade back and that one is circled + * in `ring`; the slide prints the labels underneath as text. + */ +function trio(panels: TrioPanel[], seed: number, focus?: number, ring: string = C.red): Draw { + return (ctx, w, h) => { + const s = Math.min(w / 1500, h / 410); + const b: Board = { X: (v) => v * s + (w - 1500 * s) / 2, Y: (v) => v * s + (h - 410 * s) / 2, S: (v) => v * s }; + const { X, Y, S } = b; + const PW = 420, PH = 330, xs = [45, 540, 1035], py = 40; + xs.forEach((x, i) => { + const k = seed + i * 100; + card(ctx, X(x), Y(py), S(PW), S(PH), { seed: k, color: C.ink, fill: C.paper, w: 2.5 }); + line(ctx, X(x), Y(py + 34), X(x + PW), Y(py + 34), { w: S(2), color: C.soft, seed: k + 1 }); + [0, 1, 2].forEach((j) => dot(ctx, X(x + 20 + j * 18), Y(py + 17), S(5), [C.red, C.amber, C.green][j], { seed: k + 2 + j })); + panels[i](ctx, b, x, py); + }); + if (focus !== undefined) { + ctx.save(); + ctx.fillStyle = 'rgba(255, 255, 255, 0.66)'; + xs.forEach((x, i) => { if (i !== focus) ctx.fillRect(X(x - 20), Y(0), S(PW + 40), S(410)); }); + ctx.restore(); + ellipse(ctx, X(xs[focus] + PW / 2), Y(py + PH / 2), S(PW / 2 + 30), S(PH / 2 + 26), { w: S(5), color: ring, seed: seed + 900 + focus }); + } + }; +} + +// The three ways to use Flint: a chat with a chart card in the reply; an app with a table linked to a +// chart; a theme's swatches and typeface carried onto three charts. +const USE_PANELS: TrioPanel[] = [ + (ctx, { X, Y, S }, x, py) => { + washRect(ctx, X(x + 150), Y(py + 52), S(250), S(46), C.blue, { alpha: 0.22, seed: 1106 }); + line(ctx, X(x + 166), Y(py + 70), X(x + 376), Y(py + 70), { w: S(3), color: C.blue, seed: 1107 }); + line(ctx, X(x + 166), Y(py + 84), X(x + 320), Y(py + 84), { w: S(3), color: C.blue, seed: 1108 }); + dot(ctx, X(x + 32), Y(py + 128), S(12), C.ink, { seed: 1109 }); + card(ctx, X(x + 54), Y(py + 116), S(346), S(196), { seed: 1110, color: C.soft, fill: '#ffffff', w: 2 }); + miniLines(ctx, X(x + 74), Y(py + 140), S(306), S(150), { seed: 1111, series: 3 }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, '', X(x + 20), Y(py + 66), { size: S(22), kind: 'mono', color: C.meaning, maxWidth: S(220), maxLines: 1 }); + rect(ctx, X(x + 20), Y(py + 86), S(150), S(220), { w: S(2), color: C.soft, seed: 1201 }); + for (let i = 0; i < 6; i++) { + line(ctx, X(x + 32), Y(py + 112 + i * 32), X(x + 158), Y(py + 112 + i * 32), { w: S(i === 2 ? 4 : 2), color: i === 2 ? C.amber : C.soft, seed: 1202 + i }); + } + card(ctx, X(x + 196), Y(py + 86), S(204), S(220), { seed: 1210, color: C.soft, fill: '#ffffff', w: 2 }); + miniBars(ctx, X(x + 212), Y(py + 110), S(172), S(180), { seed: 1211, bars: 5, color: [C.soft, C.soft, C.amber, C.soft, C.soft] }); + arrow(ctx, X(x + 162), Y(py + 176), X(x + 252), Y(py + 176), { w: S(3), color: C.amber, seed: 1212, head: S(12) }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, 'Aa', X(x + 28), Y(py + 100), { size: S(48), kind: 'handBold', color: C.ink, maxWidth: S(90), maxLines: 1 }); + ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d'].forEach((c, i) => dot(ctx, X(x + 140 + i * 52), Y(py + 82), S(17), c, { seed: 1301 + i })); + const pal = ['#1f3b73', '#1b998b', '#e3a72f']; + [0, 1, 2].forEach((i) => { + const cx = x + 22 + i * 132; + card(ctx, X(cx), Y(py + 136), S(118), S(170), { seed: 1310 + i * 3, color: C.soft, fill: '#ffffff', w: 2 }); + if (i === 0) miniBars(ctx, X(cx + 12), Y(py + 160), S(94), S(130), { seed: 1320, bars: 4, color: pal[0] }); + if (i === 1) miniLines(ctx, X(cx + 10), Y(py + 160), S(98), S(130), { seed: 1321, series: 2, colors: pal }); + if (i === 2) miniHeatmap(ctx, X(cx + 12), Y(py + 164), S(94), S(118), { rows: 4, cols: 4, seed: 1322, palette: pal, frame: false }); + }); + }, +]; + +// The three specs: semantic types that become a chart; a theme that turns a plain chart into a house +// chart; a click that arrives as an event naming the data. +const SPEC_PANELS: TrioPanel[] = [ + (ctx, { X, Y, S }, x, py) => { + ['"period": "YearMonth"', '"game": "Category"', '"newUsers": "Profit"'].forEach((t, i) => + text(ctx, t, X(x + 24), Y(py + 72 + i * 32), { size: S(21), kind: 'mono', color: C.meaning, maxWidth: S(370), maxLines: 1 })); + miniHeatmap(ctx, X(x + 40), Y(py + 178), S(340), S(110), { rows: 4, cols: 10, seed: 1511, palette: DEFAULT_DIVERGING, frame: false }); + line(ctx, X(x + 40), Y(py + 298), X(x + 380), Y(py + 298), { w: S(2), color: C.ink, seed: 1512 }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, '"theme_spec": "economist"', X(x + 24), Y(py + 72), { size: S(21), kind: 'mono', color: C.look, maxWidth: S(370), maxLines: 1 }); + card(ctx, X(x + 20), Y(py + 104), S(160), S(200), { seed: 1601, color: C.soft, fill: '#ffffff', w: 2 }); + miniBars(ctx, X(x + 34), Y(py + 140), S(132), S(150), { seed: 1602, bars: 4, color: '#a7adb2' }); + arrow(ctx, X(x + 188), Y(py + 204), X(x + 232), Y(py + 204), { w: S(3), color: C.look, seed: 1603, head: S(12) }); + card(ctx, X(x + 240), Y(py + 104), S(160), S(200), { seed: 1604, color: C.soft, fill: '#ffffff', w: 2 }); + washRect(ctx, X(x + 254), Y(py + 118), S(30), S(9), '#e3120b', { alpha: 0.95, seed: 1605 }); + miniBars(ctx, X(x + 254), Y(py + 140), S(132), S(150), { seed: 1602, bars: 4, color: '#006ba2' }); + }, + (ctx, { X, Y, S }, x, py) => { + const pts: [number, number, number][] = [[50, 250, 9], [80, 200, 12], [110, 230, 8], [140, 150, 14], [170, 180, 10], [200, 110, 11], [120, 280, 8], [60, 120, 9]]; + rect(ctx, X(x + 20), Y(py + 56), S(210), S(250), { w: S(2), color: C.soft, seed: 1701 }); + pts.forEach(([px, pyy, r], i) => dot(ctx, X(x + px), Y(py + pyy), S(r), i === 3 ? C.behavior : C.soft, { seed: 1702 + i })); + ellipse(ctx, X(x + 140), Y(py + 150), S(22), S(22), { w: S(2.5), color: C.amber, seed: 1711 }); + arrow(ctx, X(x + 236), Y(py + 180), X(x + 262), Y(py + 180), { w: S(3), color: C.behavior, seed: 1712, head: S(10) }); + card(ctx, X(x + 268), Y(py + 116), S(136), S(130), { seed: 1713, color: C.behavior, fill: '#ffffff', w: 2.5 }); + text(ctx, 'click', X(x + 280), Y(py + 152), { size: S(19), kind: 'mono', color: C.ink2, maxWidth: S(116), maxLines: 1 }); + text(ctx, 'Country:', X(x + 280), Y(py + 188), { size: S(19), kind: 'mono', color: C.ink, maxWidth: S(116), maxLines: 1 }); + text(ctx, '"Japan"', X(x + 280), Y(py + 222), { size: S(19), kind: 'mono', color: C.behavior, maxWidth: S(116), maxLines: 1 }); + }, +]; + +const SPEC_RINGS = [C.meaning, C.look, C.behavior]; + +Object.assign(SKETCHES, { + useCases: trio(USE_PANELS, 1100), + useCase1: trio(USE_PANELS, 1100, 0), + useCase2: trio(USE_PANELS, 1100, 1), + useCase3: trio(USE_PANELS, 1100, 2), + specs: trio(SPEC_PANELS, 1500), + spec1: trio(SPEC_PANELS, 1500, 0, SPEC_RINGS[0]), + spec2: trio(SPEC_PANELS, 1500, 1, SPEC_RINGS[1]), + spec3: trio(SPEC_PANELS, 1500, 2, SPEC_RINGS[2]), +}); diff --git a/site/src/talk/slides.tsx b/site/src/talk/slides.tsx index bcfc8dce..f3b36b30 100644 --- a/site/src/talk/slides.tsx +++ b/site/src/talk/slides.tsx @@ -1,22 +1,23 @@ import type { ReactNode } from 'react'; import type { ChartAssemblyInput, ThemeSpec } from 'flint-chart'; import { THEME_PRESETS } from 'flint-chart'; +import { TYPE_TREE } from './sketches'; import { SizingPlayground } from '../components/SizingPlayground'; import { ThemeExplorer } from './ThemeExplorer'; import { WorldCupScorersDemo } from '../playground/WorldCupScorersDemo'; -import { CountryTableStage } from '../playground/ExternalToChartLab'; +import { CarOriginTableStage, CountryTableStage } from '../playground/ExternalToChartLab'; +import { McpChatTurn } from '../routes/McpExperience'; import { GlobeWarmingStage } from '../playground/GlobeWarmingStage'; import { RetailDrilldownStage } from '../playground/RetailDrilldownStage'; import { YouDrawItStage } from '../playground/YouDrawItStage'; import { ArticleSection } from '../playground/InteractiveDataReportLab'; import { TIME_USE } from '../playground/interactive-data-report-content'; -import { InteractionDashboardLab } from '../playground/InteractionDashboardLab'; import { FLINT_BASE, LONG_ROWS, TYPES_FLINT, typesCompiled, CARS, flintInput, flintShown, linkedYears, PICKED_GAME, PICKED_ROWS, STEPS, VL, foodLines, gameBars, heatmap, lineByType, penguins, picked, withData, type FlintState, } from './data'; import { - Chart, Code, Demo, FitTable, Stable, MINIMAPS, Minimap, Sketch, VegaLite, fullLayout, lineDiff, plainLayout, specLayout, stepLayout, textRows, + Chart, Code, Demo, FitTable, FlawList, FlawedVegaLite, Stable, MINIMAPS, Minimap, Sketch, VegaLite, fullLayout, type Flaw, lineDiff, plainLayout, specLayout, stepLayout, textRows, type CodeRow, type CodeSource, } from './parts'; import glue from './specs/vl-final-glue.txt?raw'; @@ -39,9 +40,9 @@ const Cell = ({ caption, children, framed }: { caption?: string; children: React ); /** One step of the traditional way: the code and chart before, then the code and chart after. */ -const Step = ({ before, beforeSpec, after, afterSpec, note }: { before: CodeSource; beforeSpec: unknown; after: CodeSource; afterSpec: unknown; note?: ReactNode }) => (<> +const Step = ({ before, beforeSpec, after, afterSpec, note, flaws }: { before: CodeSource; beforeSpec: unknown; after: CodeSource; afterSpec: unknown; note?: ReactNode; flaws?: Flaw[] }) => (<>
-
+
{flaws ? : }
→
@@ -64,18 +65,25 @@ const DIFF = { }; const GLUE_LINES = glue.trimEnd().split('\n').length; -/** A playful theme an agent might write from a one-line prompt; the slide shows this exact object. */ -const FUN_THEME = { - extends: 'cartoon', - id: 'theme-park', - label: 'Theme park', +/** What is wrong with the raw chart, circled on it. */ +const RAW_FLAWS: Flaw[] = [ + { role: 'marks', label: 'The chart runs far too wide for the page.' }, + { role: 'x-axis', label: 'Months show as raw numbers like 202101.' }, + { role: 'legend', label: 'Losses and gains share one color ramp, with no midpoint at zero.' }, +]; + +/** A brand theme an agent might write from a short style guide; the slide shows this exact object. */ +const BRAND_THEME = { + extends: 'swiss', + id: 'northwind', + label: 'Northwind', ink: { - surface: { source: 'house', canvas: '#fdf6ff', plot: '#fdf6ff' }, - series: { categorical: ['#ff6fb5', '#4cb8ff', '#ffc93c', '#9b6cff', '#38d39f', '#ff8a5c'] }, - accent: '#ff6fb5', + text: { primary: '#14213d', secondary: '#4a5568' }, + series: { single: '#1f3b73', categorical: ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d', '#5b8e7d'] }, + accent: '#1b998b', }, - type: { headline: { family: "'Chalkboard SE', 'Comic Neue', cursive", weight: 'bold' } }, - marks: { cornerRadius: 12, strokeWeight: 5 }, + type: { headline: { family: "Georgia, 'Times New Roman', serif", weight: 'bold' } }, + structure: { grid: { measure: 'quiet', category: 'omit' } }, } as unknown as ThemeSpec; const PRESETS: { caption: string; spec: ChartAssemblyInput }[] = [ @@ -109,6 +117,59 @@ const TLDR_SPEC = `{ // After the Flint version: one request at a time, each starting where the last one left off. const FLINT_W = 52; +/** + * The type tree: the drawn boxes and connectors from the sketch, with the branch text set over them in + * the deck's own type. Both sit on the same 1000 × 720 frame, so the text stays on its line at any size. + */ +const TypeTree = () => ( +
+
+ + {TYPE_TREE.flatMap((r) => r.leaves).map((l) => ( + + {l.text} + + ))} +
+
+); + +/** The three use cases, labelled under the sketch's three panels. */ +const USE_CASES = [ + { title: 'Explore data', short: 'A chart or a dashboard, right in your chat.', long: 'Ask, and a live chart or dashboard opens in your chat through the Flint MCP server.' }, + { title: 'Build apps', short: 'Flint as a component in your app.', long: 'Your coding agent writes Flint into the app as a component and wires it to the rest of the page.' }, + { title: 'Design', short: 'One theme for every chart.', long: 'Write your house style once as a theme, and every chart in every library follows it.' }, +]; + +/** The three specs, labelled under the sketch's three panels, each in its section color. */ +const SPECS = [ + { title: 'The chart spec', short: 'What the data means.', long: 'Semantic types and a layout engine take care of what the data means.', color: '#2f6db5' }, + { title: 'The theme spec', short: 'How it looks.', long: 'A formal specification of style, written once for every chart.', color: '#e8954a' }, + { title: 'The interaction spec', short: 'How it behaves.', long: 'Semantic events and update operators describe how a chart behaves.', color: '#d9534f' }, +]; + +/** + * A three-panel sketch with readable labels under its panels. With `focus`, the sketch circles that + * panel, its label is spelled out, and the other two fade back. + */ +const Trio = ({ sketch, items, focus }: { + sketch: string; items: { title: string; short: string; long: string; color?: string }[]; focus?: number; +}) => ( +
+
+
+ {items.map((u, i) => ( +
+

{i + 1}. {u.title}

+

{focus === i ? u.long : u.short}

+
+ ))} +
+
+); +const UseCases = ({ focus }: { focus?: number }) => ; + /** The "draw your guess" demo's interaction, condensed: a trigger, and a handler that answers with an update. */ const BESPOKE_ROWS: CodeRow[] = [ { text: 'const draw: CanvasInteractionDef = {', hot: true }, @@ -152,16 +213,6 @@ const APP_ROWS: CodeRow[] = [ { text: '' }, ]; -/** The semantic types Flint knows, from its type registry, grouped as the registry groups them. */ -const SEMANTIC_TYPES: [string, string][] = [ - ['Points in time', 'DateTime, Date, Time, Timestamp'], - ['Time units', 'Year, Quarter, Month, Week, Day, Hour, YearMonth, YearQuarter, YearWeek, Decade, Duration'], - ['Measures', 'Quantity, Count, Amount, Price, Percentage, Temperature'], - ['Signed measures', 'Profit, PercentageChange, Sentiment, Correlation'], - ['Ordered numbers', 'Rank, Score, ID'], - ['Places', 'Country, State, City, Region, Address, ZipCode, Latitude, Longitude'], - ['Categories', 'Category, Name, Status, Boolean, Direction, Range'], -]; /** The parts of the real "economist" preset that the theme slides talk about. */ const ECON = (THEME_PRESETS as Record }>).economist.spec; @@ -236,7 +287,7 @@ export const SLIDES: SlideDef[] = [ { id: 'title', kind: 'title', render: () => (<>

Flint: a visualization language for the AI era

-

Chenglong Wang, Yuwei Xiao, Kecheng Lu, Yunhai Wang, Alper Sarikaya, Michel Galley, Chris Quirk, Jianfeng Gao
Deep Learning Group, Microsoft Research

+

microsoft.github.io/flint-chart

@@ -247,7 +298,7 @@ export const SLIDES: SlideDef[] = [ { id: 'tldr', render: () => (<> -

Flint in short

+

Conclusion

Flint is a visualization language for AI agents to reliably create polished data visualizations. The agent writes a short, simple spec, and Flint's compiler takes care of the rest.

@@ -268,15 +319,10 @@ export const SLIDES: SlideDef[] = [ }, // ======================================================== Act 1 - { - id: 'act1', kind: 'section', render: () => (<> -

Authoring a chart the traditional way

-

We'll build one chart with a declarative grammar, Vega-Lite, step by step.

- ), - }, { id: 'ideal', render: () => (<> -

Ideally, a chart is a few lines that are easy to change

+

Authoring with Vega-Lite

+

Ideally, a chart is a few lines that are easy to change.

@@ -294,7 +340,7 @@ export const SLIDES: SlideDef[] = [ }, { id: 'reality', render: () => (<> -

In reality, our charts ask for more

+

Let's try a slightly more complicated example

Task: "Make a heatmap of net new users by game and month for our report page, in The Economist style, and let me click a game to highlight it next to our table."

@@ -302,30 +348,26 @@ export const SLIDES: SlideDef[] = [ rows={LONG_ROWS.map((r) => [r.game, r.region, r.period.replace('-', ''), r.newUsers])} />

Rows: 60 months × 24 games × 4 regions = 5,760.

-
- - -
+
), }, { - id: 'attempt-1', render: () => (<> -

Attempt one: plug the data in, and it breaks

- The same few lines give a valid spec and a wrong chart. To fix it we parse 202101 into a date, sum the four regions in each cell, and centre the colours on zero, adding {DIFF.parse.plus} lines.} - /> + id: 'broken', render: () => (<> +

Plug the data in, and the chart breaks

+
+ + +
), }, { - id: 'attempt-2', render: () => (<> -

Attempt two: five years of months need a new layout

+ id: 'attempt-1', render: () => (<> +

Let's fix parsing and layout

Sixty months crowd the axis with Jan to Dec five times over. We widen the chart, label each year once, give long game names room, and move the legend to the top. That adds {DIFF.layout.plus} lines and changes {DIFF.layout.minus}.} + before={ROWS.raw} beforeSpec={withData(STEPS.raw)} + after={stepLayout(STEPS.layout, STEPS.raw)} afterSpec={withData(STEPS.layout)} + note={<>Parse 202101 into a date, sum the four regions, centre the colours on zero, then widen the chart and label each year once: {lineDiff(STEPS.raw, STEPS.layout).plus} lines.} /> ), }, @@ -333,7 +375,7 @@ export const SLIDES: SlideDef[] = [ id: 'theme-vl', render: () => (<>

Making it look like The Economist is mostly new work

Fonts and axes go into the config, the house colours into the encoding, and the red tab, headline, and source line become extra views placed by hand. The spec grows by {DIFF.theme.plus} lines.} /> @@ -362,7 +404,7 @@ export const SLIDES: SlideDef[] = [
-

A click filters the table and a picker selects a game. These {GLUE_LINES} lines talk in signal names and internal stores, not in terms of the data.

+

{GLUE_LINES} lines, all in signal names.

), }, { @@ -391,16 +433,10 @@ export const SLIDES: SlideDef[] = [ ), }, - // ======================================================== Act 2 - { - id: 'act2', kind: 'section', render: () => (<> -

Just let an AI agent do it?

-

Today we would hand this to an agent. It can do it, but then we notice five problems.

- ), - }, + // Act 1, continued: handing it to an agent { id: 'five-problems', render: () => (<> -

Five problems with letting the agent write it all

+

Just let an AI agent do it? Five problems show up

    @@ -416,23 +452,16 @@ export const SLIDES: SlideDef[] = [ { id: 'root-cause', render: () => (<>

    The root cause is the language

    -
    -
    -

    Low-level configuration ties together what the data means, how the chart looks, and how it behaves. Every change ripples into the others.

    -

    "The logic depends on coordinates, pixels, and SVG paths, all tangled together. So the agent reasons, writes, debugs, and goes around again, and still hands you something fragile."

    -
    -
    -
    +
    ), }, // ======================================================== Act 3 { id: 'lifting', render: () => (<> -

    Flint is a language for AI agents that disentangles visual and interaction logic

    +

    Flint is a language for AI agents that disentangles visual and interaction logic

    -

    You and your agent work with the high-level specs, without losing control. The compiler takes care of data parsing, layout, events, design tokens, and the dependencies between them.

    ), }, @@ -443,7 +472,6 @@ export const SLIDES: SlideDef[] = [
    -

    A few lines on the raw data, with the same look. Click a game to try it.

), @@ -453,34 +481,34 @@ export const SLIDES: SlideDef[] = [ // Section A { - id: 'sec-a', kind: 'section', render: () => (<> -
-

The chart spec

-

Semantic types and a layout engine take care of what the data means.

+ id: 'sec-a', render: () => (<> +

1. The chart spec

+ ), }, + { id: 'a-how', render: () => (<>

Semantic types: say what the data means, and the compiler does the rest

) }, { id: 'a-what', render: () => (<> -

Say what each field means, and the compiler does the rest

+

What each type decides for this chart

-
-
+
+ +

Semantic types decide data processing, axes, and colors, so the compiler can infer the low-level configuration reliably, without heuristics.

+
+
), }, - { id: 'a-how', render: () => (<>

How it works: from what the data means to the chart

) }, { id: 'a-vl', render: () => (<>

And this is what the compiler wrote in Vega-Lite

-

The Flint spec, on the raw rows.

→
-

What the compiler wrote in Vega-Lite because of the three types.

), @@ -489,11 +517,7 @@ export const SLIDES: SlideDef[] = [ id: 'a-types', render: () => (<>

Semantic types: a small vocabulary with a lot behind it

- - - {SEMANTIC_TYPES.map(([family, types]) => )} - -
{family}{types}
+

Agents are really good at this. Saying that a column is a month, a profit, or a country is just reading the data, and it is far easier than writing parsing, scale, and format code.

), @@ -503,7 +527,6 @@ export const SLIDES: SlideDef[] = [

The layout engine: the data pushes out, the canvas pushes back

-

Each item is a spring that wants its own room, and the canvas is a stiffer spring that resists growing. The plot settles where the two balance, never past the most it may stretch.

), }, @@ -524,7 +547,6 @@ export const SLIDES: SlideDef[] = [

One spec, five rendering libraries

-

Each library structures its parameters differently. The same chart spec compiles to all of them.