Skip to content

feat: add Image-Charts backend (hosted-image-URL render target) - #95

Open
Francois-Guillaume Ribreau (FGRibreau) wants to merge 2 commits into
microsoft:devfrom
FGRibreau:feat/image-charts-backend
Open

feat: add Image-Charts backend (hosted-image-URL render target)#95
Francois-Guillaume Ribreau (FGRibreau) wants to merge 2 commits into
microsoft:devfrom
FGRibreau:feat/image-charts-backend

Conversation

@FGRibreau

Copy link
Copy Markdown

What

Adds an image-charts backend to flint-js that compiles the shared core semantic layer into a single Image-Charts chart URL. That URL is a hosted image that renders server-side and embeds anywhere an <img> works (email, PDF, Slack, Notion, no-code) with no runtime JavaScript. It follows docs/adding-a-backend.md and mirrors the Excel backend, with an inline assembler that returns a declarative artifact ({ type: 'image-charts', url }) instead of a client-side JS spec, and gates chart types to the ones with a faithful mapping.

Why

The existing backends emit a JS spec that a local renderer draws. That leaves out the case where a chart needs to live as a durable, shareable URL (an email, a PDF, a Slack or Notion embed, a no-code image control), where there is no JS runtime and the image has to persist. This backend covers that case by targeting a hosted renderer.

Design / scope

  • Pure and offline. assembleImageCharts builds a string, with no network I/O, no crypto, and no new dependencies. The data reaches Image-Charts only if something later loads the <img>, which is the caller's choice, the same way choosing the Excel backend chooses Office.js. The library keeps its no-I/O property.
  • Free tier only. It emits unsigned URLs (no account/HMAC params). Signed enterprise URLs need a server-side secret, which has no place in a pure compiler function.
  • Reuses the real pipeline. It runs the same Phase 0 semantic resolution and banded-axis overflow filtering as the other backends, then serializes into the Image-Charts query grammar (cht, chd=a:, chs, chxt/chxl, chco, chdl, chm, chtt).
  • Partial coverage by design, like Excel. Bar, grouped bar, stacked bar, line, sparkline, area, scatter, pie, donut, and radar map to a faithful cht. Unsupported types (Boxplot, Sankey, Heatmap, and so on) throw with a clear message.

Tests

  • npm run typecheck, npm run lint, npm run build are clean.
  • npm run test: 947 passed, including 2 new public-API smoke assertions (URL shape, and a throw on unsupported types).
  • A new test-data generator (Image-Charts: Core Templates) exercises the distinct URL param paths.

Disclosure

I maintain Image-Charts, a commercial hosted chart-rendering service. Its free tier (unsigned URLs, watermarked) is what this backend emits. If you would rather not carry a third-party render target in-tree, I am happy to maintain this as an external companion package instead.

Add an `image-charts` backend that compiles the shared core semantic
layer into a single Image-Charts URL. Unlike the JS-spec backends it
emits a permanent hosted-image URL that renders server-side and embeds
anywhere an <img> works (email, PDF, Slack, no-code) with no runtime
JavaScript.

The assembler is pure: it builds a string with no network I/O, no
crypto, and no dependencies, and emits unsigned free-tier URLs only.
It reuses the Phase 0 semantic resolution and banded-axis overflow
filtering, then serializes into the Image-Charts query grammar (cht,
chd=a:, chs, chxt/chxl, chco, chdl, chm, chtt). Coverage is partial by
design, like the Excel backend: bar/line/area/pie/doughnut/radar/
scatter map to a faithful cht; unsupported types throw.

Wire the backend into the src barrel, tsup entries, package exports,
the public-API smoke test, and the test-data generators.
@Chenglong-MS
Chenglong Wang (Chenglong-MS) changed the base branch from main to dev August 14, 2026 06:40
@Chenglong-MS

Copy link
Copy Markdown
Contributor

This is great! Let's add this to the repo. I think we can first merge it to dev, then I'll propose a backend extension folder to host your backend.

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