Charts and KPI images for email and Slack
Weekly reports, customer usage summaries and status updates often go where JavaScript charts can’t run: an email, a Slack channel, a PDF, a ticket. A chart image works everywhere. This guide builds a KPI and chart template, then renders it with each report’s numbers, as a stored image or as a URL.
How it works
- A template draws the KPIs and a chart from props. Charts are inline SVG, computed from the numbers in the props, with no chart library.
- Each report sends its numbers as props: the KPI values and the series for the chart.
- The image goes out as a URL in the email or Slack message, or as a file you render with the API and attach.
Step 1: build the template
Start from the Metrics report example in the playground (Templates, then Metrics report). It draws KPIs and a bar chart from a list of numbers. Lists and numbers stay as they are in props:
export const props = {
name: "Acme API",
period: "Nov 10 – Nov 16, 2026",
requests: "2.41M",
requestsDelta: "+12.4% vs last week",
errorRate: "0.08%",
p95: "142 ms",
days: ["M", "T", "W", "T", "F", "S", "S"],
daily: [310, 345, 362, 351, 380, 296, 366],
};
A bar chart is a few lines of SVG:
function Bars({ values }) {
const max = Math.max(...values);
return (
<svg width="700" height="240" viewBox="0 0 700 240">
{values.map((value, i) => {
const height = Math.round((value / max) * 220);
return (
<rect x={i * 100 + 20} y={230 - height} width="60" height={height} rx="8" fill="#6366f1" />
);
})}
</svg>
);
}
Lines work the same way with a <polyline points="…"> built from the values.
Keep series short: a week of days or a year of months renders fast; thousands of
points do not belong in an image.
Step 2: render each report
As a URL in an email or Slack message
Sign a URL with the report’s numbers, the same way as in
Personalized images in emails.
The function from Sign URLs in your code sends lists and numbers as JSON in
the p parameter automatically, so daily arrives as a list of numbers.
In Slack, an image block shows an image from a public URL:
await fetch(process.env.SLACK_WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text: "Weekly API report",
blocks: [
{
type: "image",
image_url: await imageUrl(report),
alt_text: `Requests ${report.requests}, error rate ${report.errorRate}`,
},
],
}),
});
As a file, with the render API
When the image must stay exactly as it was sent, or you attach it to a PDF or a ticket, render it with the API and store or attach the bytes:
const res = await fetch("https://jsximage.com/api/render", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ template: "<template-uid>", props: report }),
});
if (!res.ok) throw new Error((await res.json()).error);
const png = Buffer.from(await res.arrayBuffer());
The API takes props as JSON, so lists and numbers keep their types. Send
options to render the same report in another size, for example a narrow one
for mobile email: see the render API.
Good to know
- One render per report. A signed URL renders the first time it is opened and is cached after that. Every new week’s numbers are a new URL.
- Long URLs. Props go in the URL, up to about 3 KB. A week or a year of values fits easily; for long series, use the render API.
- Accessible text. Put the key numbers in the email text or the
alt_texttoo, for screen readers and clients that block images. - Customer reports. For a report per customer, put only what that customer may see in the props: the URL is public.
Questions? See the docs or email info@jsximage.com.