Styling Guide
Here is a chart that is correct in every way. The data is right, the labels are right, and the API returned it in one request. It still looks like it was pasted into the page.
Nothing is broken. The chart has no idea what it is sitting on. It draws its own white rectangle, its own grid, its own palette, and it does that whether the page around it is a light dashboard, a dark report, or a branded email. Next to your own cards and headings, that independence is exactly what looks wrong.
The fix is a short list of request parameters, and every one of them is drawn inside the SVG. That matters more than it sounds: the background, the gradient, the pattern and the colors survive export to PNG, a PDF, an email client, a README, or a screenshot. There is no wrapper CSS to lose and no post-processing step.
Same data, same endpoint, five more parameters:
/chart?type=bar&data=12,19,15,24,30,27&labels=Jan,Feb,Mar,Apr,May,Jun&title=Monthly+signups&colors=4F46E5&bg=FFFFFF&bg2=EEF2FF&bgStyle=dots&bgStyleColor=C7D2FE&borderRadius=16&apikey=YOUR_KEY
The rest of this page is the order to change things in. Each step is one decision, and each one is shown with its own render, so you can stop as soon as the chart looks right for where it lives.
Step 1: give the chart the surface it sits on
Start here, because everything else is judged against the background. A chart on a white card wants a white background. A chart in a dark report wants the exact color of that report, or the rectangle around it becomes a visible seam.
bg takes a hex color with or without #, or the word transparent. Adding bg2 turns the fill into a vertical gradient from bg to bg2, which reads as depth without adding a single element.
| Parameter | Type | Default | What it does |
|---|---|---|---|
| bg | string | #FFFFFF | A hex color with or without #, or transparent. Overrides the theme background |
| bg2 | string | - | A second hex color: the background becomes a top-to-bottom gradient |
| bgOpacity | number | 1 | 0 to 1. Fades the background only; the chart content stays opaque |
| bgStyle | string | none | none, dots, grid or snow |
| bgStyleColor | string | #94A3B8 | Hex color of the pattern |
The background covers the full canvas including the legend strip, and a pattern always sits under the chart, never over it. Keep the pattern color a few steps away from the background so it stays a texture and not a second chart.
A soft gradient with a dot texture
Snow, for something quieter than a grid
A dark chart on a dark page
The dark theme switches the grid, axis and text colors along with the palette, which is the part people usually forget. Set bg to the surface color of the page and bg2 a little lighter.
No background at all
bg=transparent removes the background rectangle and nothing else. Use it when the chart sits on a colored card, a gradient, or an image. The text and grid colors still have to work on that surface, so pair it with a theme that matches the light or dark side.
Partially transparent
bgOpacity between 0 and 1 keeps a light background while the surface behind it shows through. At 0.65 a white background over a brand color reads as frosted glass, and the chart stays readable because only the background fades.
Step 2: pick the colors once, not one at a time
Hand-picked colors drift. One is too bright, the next is too grey, and the fourth clashes with your brand. theme applies a palette that was built to sit together: pastel, vivid, warm, cool, ocean, sunset, forest, mono, retro and dark.
When you do have brand colors, colors takes up to 20 hex values and overrides the theme palette. Two or three is usually enough: a single accent for one series, and one color per series only when the colors carry meaning. Colors cycle when there are fewer of them than items.
Step 3: take things out
Most charts look unfinished because they have too much in them, not too little. Numbers on every bar, a legend for a single series, a title that repeats the heading directly above it: each one is a small cost paid on every read.
| Parameter | Use it for |
|---|---|
| title | A short label inside the image. Leave it out when the page already has a heading above the chart |
| borderRadius | Rounding the chart area, 0 to 32. Match the container: cards at 16px look right with 16 |
| showValues | false removes the numbers. Use it for trends and dashboards where the axis is enough |
| legend | false hides the legend. A single-series chart rarely needs one |
| lineWidth | 1 to 5. Thicker for presentation, thinner for dense data |
| pointStyle | circle, square, star, emoji or none |
| names | Series names, comma separated, instead of Series 1 |
A trend line with the values, the points and the legend removed, on a soft gradient. Nothing is left except the shape of the week, which was the point of the chart:
What changes by chart type
- Bar and stacked bar. One color per series, no more. A gradient background and a corner radius is enough; color every bar differently only when the categories mean something.
- Line and area. Use pointStyle=none past about 15 points, and lineWidth=3 or 4 when the chart is shown large. Area charts read best with a light bg2 in the same hue as the line.
- Pie and donut. A theme palette handles the slice balance. Keep the background quiet, and skip patterns behind a donut hole.
- Radar. Fewer than eight axes. One accent color and showValues=false keeps it readable.
- Scatter. pointSize and pointStyle matter more than the palette. One color per group, not per point.
Flowcharts follow the same rules
The Graph API styles through an options object: bgColor, nodeColor, strokeColor and textColor, plus an optional color on each link. Charts and flowcharts from the same product should share a background and an accent so a page holding both looks like one system.
nodeColor=#FFFFFF
strokeColor=#4F46E5
nodeColor=#172554
strokeColor=#F97316
Custom CSS is the last step, not the first
customCSS injects CSS into the SVG. Reach for it for something the parameters do not cover, such as a font family, and keep it short. Styling that lives in parameters survives every export and every future version of the image; CSS that depends on internal element structure may not.
/chart?type=bar&data=12,19,15,24&theme=dark&customCSS=text%7Bfont-family:Georgia,serif%7D&apikey=YOUR_KEY
Four recipes to start from
Each one looks finished as it is. Replace YOUR_KEY with your API key, and the data with your own.
Dashboard card
/chart?type=bar&data=12,19,15,24,30,27&labels=Jan,Feb,Mar,Apr,May,Jun&colors=4F46E5&bg=FFFFFF&bg2=EEF2FF&bgStyle=dots&bgStyleColor=C7D2FE&borderRadius=16&showValues=false&apikey=YOUR_KEY
Dark report page
/chart?type=line&data=12,19,15,24,30,27&data2=8,11,14,13,20,26&names=Free,Pro&labels=Jan,Feb,Mar,Apr,May,Jun&theme=dark&bg=0B1220&bg2=172554&bgStyle=grid&bgStyleColor=334155&lineWidth=3&apikey=YOUR_KEY
Chart on a colored section
/chart?type=bar&data=12,19,15,24,30,27&labels=Jan,Feb,Mar,Apr,May,Jun&theme=dark&bg=transparent&showValues=false&apikey=YOUR_KEY
Quiet donut for email
/chart?type=donut&data=45,25,20,10&labels=Direct,Search,Social,Email&theme=sunset&bg=FFF7ED&bg2=FFEDD5&legend=false&apikey=YOUR_KEY
Where to go next
Every parameter with its type, range and default is on Customization. The full request reference is the Chart API page, and the flowchart colors are on Graph API.