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.

Default outputno styling parameters
Bar chart with default styling

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:

Styledcolors=4F46E5&bg=FFFFFF&bg2=EEF2FF&bgStyle=dots&bgStyleColor=C7D2FE&borderRadius=16
Bar chart with a gradient background, dot pattern and rounded corners
GET
/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.

ParameterTypeDefaultWhat it does
bgstring#FFFFFFA hex color with or without #, or transparent. Overrides the theme background
bg2string-A second hex color: the background becomes a top-to-bottom gradient
bgOpacitynumber10 to 1. Fades the background only; the chart content stays opaque
bgStylestringnonenone, dots, grid or snow
bgStyleColorstring#94A3B8Hex 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

Light surfacebg=FFFFFF&bg2=EEF2FF&bgStyle=dots&bgStyleColor=C7D2FE
Light chart with a gradient and dots

Snow, for something quieter than a grid

Snow patternbg=F8FAFC&bgStyle=snow&bgStyleColor=CBD5E1
Chart with a snow background pattern

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.

Dark theme with a gridtheme=dark&bg=0B1220&bg2=172554&bgStyle=grid&bgStyleColor=334155
Line chart on a dark navy background

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.

Transparent over a patterned cardtheme=dark&bg=transparent
Chart with a transparent background over a patterned card

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.

White at 65% over a brand colorbg=FFFFFF&bgOpacity=0.65
Chart with a semi-transparent white background over a gradient

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.

Two brand colors, stacked barscolors=0EA5E9,F97316&bg=F8FAFC
Stacked bar chart with two brand colors
sunset theme, warm backgroundtheme=sunset&bg=FFF7ED&bg2=FFEDD5
Donut chart with the sunset theme
ocean theme, cool backgroundtheme=ocean&bg=F0F9FF&bg2=E0F2FE
Area chart with the ocean theme

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.

ParameterUse it for
titleA short label inside the image. Leave it out when the page already has a heading above the chart
borderRadiusRounding the chart area, 0 to 32. Match the container: cards at 16px look right with 16
showValuesfalse removes the numbers. Use it for trends and dashboards where the axis is enough
legendfalse hides the legend. A single-series chart rarely needs one
lineWidth1 to 5. Thicker for presentation, thinner for dense data
pointStylecircle, square, star, emoji or none
namesSeries 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:

Clean linelineWidth=4&pointStyle=none&showValues=false&bg2=F1F5F9
Clean line chart with no data labels

What changes by chart type

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.

Same flowchart, two surfacesoptions: bgColor, nodeColor, strokeColor, textColor
Light flowchart
bgColor=#F8FAFC
nodeColor=#FFFFFF
strokeColor=#4F46E5
Dark flowchart with orange links
bgColor=#0B1220
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.

GET
/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

GET
/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

GET
/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

GET
/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

GET
/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.