apyhub
IMAGE PROCESSING · SMART GENERATION

Stacked Bar Chart Generator

What it does

Stacked Bar Chart Generator turns structured series data into a stacked bar chart image or a downloadable chart link. Send a title, a data array, and optional theme or options; get back either a pre-signed URL in data from /link or binary image output from /download.

Each data point includes a name and a values array. Inside each value, you can provide a label, a numeric value, and an optional hex color. You can also set per-bar width and control chart presentation with options such as width, height, spacing, bar_width, canvas_color, background_padding, axis font settings, and title styling.

Use Stacked Bar Chart Generator when you need to compare parts of a whole across categories, such as revenue vs. cost by quarter, traffic sources by month, or budget allocation by team. The theme supports light and dark, making it easier to embed charts in dashboards, reports, or internal tools with different visual styles.

The /link endpoint is useful when you want a shareable image URL, while /download is for retrieving the generated chart directly as a binary file.

▣ ENDPOINT 02 / 02
POST
Generate stacked bar chart image
https://api.eu.apyverse.com/apyhub/generate-stacked-bar-chart/download

QUICKSTART

GUIDE

Quickstart

Generate a stacked bar chart and download it as a binary file.

curl -X POST "https://api.eu.apyverse.com/apyhub/generate-stacked-bar-chart/download" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Quarterly Revenue and Cost",
    "data": [
      {
        "name": "Q1",
        "width": 56,
        "values": [
          { "color": "3B82F6", "label": "Revenue", "value": 100000 },
          { "color": "EF4444", "label": "Cost", "value": 62000 }
        ]
      },
      {
        "name": "Q2",
        "width": 56,
        "values": [
          { "color": "3B82F6", "label": "Revenue", "value": 118000 },
          { "color": "EF4444", "label": "Cost", "value": 69000 }
        ]
      }
    ]
  }'

What you'll get back

Returns a binary file (string with format: "binary"), which is the generated stacked bar chart download.

TRY ITLIVE · 60 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
bar
Alias for data. Use either data or bar, not both.
data*
data-1*
values*
values-1*
6-character hex color without the leading # symbol.
Chart theme.
options
x_axis
Font size in pixels.
6-character hex color without the leading # symbol.
y_axis
Font size in pixels.
6-character hex color without the leading # symbol.
title_style
Padding in pixels.
Font size in pixels.
6-character hex color without the leading # symbol.
6-character hex color without the leading # symbol.

About this endpoint

What it does

Generates and downloads a stacked bar chart image from the chart configuration supplied in the request body. The endpoint returns the rendered image as binary data.

Request Body

ParameterTypeMandatoryDescription
titleStringYesChart title. Must be at least 1 character.
dataObject ArrayYesArray of stacked bar definitions. Each item must include name and values; width is optional.
data[].nameStringYesLabel for the bar group.
data[].widthIntegerNoBar width in pixels. Must be at least 1.
data[].valuesObject ArrayYesStacked segments for the bar group. Each item must include label and value; color is optional.
data[].values[].colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
data[].values[].labelStringYesSegment label.
data[].values[].valueNumberYesSegment value.
barObject ArrayNoAlias for data. Use either data or bar, not both. Each item follows the same shape as data[]. Deprecated.
bar[].nameStringYesLabel for the bar group.
bar[].widthIntegerNoBar width in pixels. Must be at least 1.
bar[].valuesObject ArrayYesStacked segments for the bar group. Each item must include label and value; color is optional.
bar[].values[].colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
bar[].values[].labelStringYesSegment label.
bar[].values[].valueNumberYesSegment value.
themeENUMNoChart theme. Allowed values: light, dark. Default: light.
optionsObjectNoChart rendering options. See nested fields below.
options.widthIntegerNoCanvas width in pixels. Must be at least 1.
options.heightIntegerNoCanvas height in pixels. Must be at least 1.
options.x_axisObjectNoX-axis text styling.
options.x_axis.font_sizeNumberNoFont size in pixels. Must be at least 1.
options.x_axis.font_colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
options.y_axisObjectNoY-axis text styling.
options.y_axis.font_sizeNumberNoFont size in pixels. Must be at least 1.
options.y_axis.font_colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
options.spacingIntegerNoSpace between bars in pixels. Must be at least 0.
options.bar_widthIntegerNoBar width in pixels. Must be at least 1.
options.title_styleObjectNoTitle text styling.
options.title_style.paddingIntegerNoPadding in pixels. Must be at least 0.
options.title_style.font_sizeNumberNoFont size in pixels. Must be at least 1.
options.title_style.font_colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
options.canvas_colorStringNo6-character hex color without the leading # symbol. Must match ^[A-Fa-f0-9]{6}$.
options.background_paddingIntegerNoPadding around the chart in pixels. Must be at least 0.

Response

Returns a binary response containing the generated chart image. The response schema is a single binary string rather than a JSON object.

Notes

The request body defines both data and a deprecated bar alias for the same stacked-bar array; use only one of them, not both. Several styling values are hex colors and must be provided without the leading # symbol.

Query parameters

Name
Type
Description
outputOPTIONAL
string

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.