---
title: "Before/After Chart API — Two-point range plot | Imejis"
description: "Render before→after comparison images as dumbbell range plots with a named legend and gain/loss coloring, set per API call. Create before/after charts free."
url: "https://www.imejis.io/components/dumbbell/before-after"
---

# Before/After Chart API — Two-point range plot | Imejis

A two-point before→after comparison with a named legend and gain/loss tint.

## Use cases

- Campaign before/after metric cards
- A/B-test result graphics
- Program impact "before → after" visuals

## Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `data` | `object[]` | `[]` | Rows: array of { label, from, to } — one dumbbell per row. |
| `min` | `number` | — | Value-axis minimum (auto-fits when omitted). |
| `max` | `number` | — | Value-axis maximum (auto-fits when omitted). |
| `fromColor` | `color` | `"#94a3b8"` | Color of the "from" dot. |
| `toColor` | `color` | `"#2563eb"` | Color of the "to" dot. |
| `lineColor` | `color` | `"#cbd5e1"` | Connecting bar color. |
| `colorByDirection` | `boolean` | `false` | Tint the connecting bar green/red by direction (to ≥ from). |
| `showValues` | `boolean` | `false` | Print the endpoint values. |
| `valueFormat` | `'number' \| 'compact' \| 'percent' \| 'currency'` | `"number"` | How values are formatted (1,200 / 1.2K / 12% / $1,200). |
| `currencySymbol` | `string` | `"$"` | Symbol used with the 'currency' format. |
| `dotRadius` | `number` (min 0) | `6` | Endpoint dot radius in px. |
| `lineWidth` | `number` (min 0) | `3` | Connecting bar thickness in px. |
| `showAxis` | `boolean` | `true` | Show the value axis. |
| `showGrid` | `boolean` | `true` | Show vertical gridlines. |
| `gridColor` | `color` | `"#e6e6e3"` | Gridline color. |
| `textColor` | `color` | `"#52514e"` | Label and axis text color. |
| `fromLabel` | `string` | — | Legend name for the "from" series (e.g. "2020"). |
| `toLabel` | `string` | — | Legend name for the "to" series (e.g. "2024"). |
| `showLegend` | `boolean` | `false` | Show the from/to legend. |
| `opacity` | `number` | `1` | Overall component opacity from 0 (transparent) to 1 (opaque). |
| `borderWidth` | `number` | `0` | Border thickness in pixels around the component. |
| `borderColor` | `color` | `"transparent"` | Border color (any CSS color). |
| `borderStyle` | `'solid' \| 'dashed' \| 'dotted' \| 'double' \| 'none'` | `"solid"` | Border line style. |
| `borderRadius` | `number` | `0` | Corner radius in pixels. |
| `boxShadow` | `string` | — | CSS box-shadow applied to the component, e.g. "0 4px 6px rgba(0,0,0,0.1)". |

## Design JSON (this variant)

```json
{
  "title": "Dumbbell sample",
  "description": "Region revenue, Q1 → Q2",
  "dimensions": {
    "width": 800,
    "height": 420
  },
  "background": {
    "color": "#ffffff"
  },
  "components": [
    {
      "id": "sample-dumbbell",
      "key": "change",
      "type": "dumbbell",
      "position": {
        "x": 120,
        "y": 60
      },
      "rotation": 0,
      "size": {
        "width": 560,
        "height": 300
      },
      "dynamic": true,
      "properties": {
        "data": [
          {
            "label": "North",
            "from": 120,
            "to": 180
          },
          {
            "label": "South",
            "from": 90,
            "to": 140
          },
          {
            "label": "East",
            "from": 160,
            "to": 150
          },
          {
            "label": "West",
            "from": 70,
            "to": 130
          }
        ],
        "fromColor": "#94a3b8",
        "toColor": "#2563eb",
        "colorByDirection": true,
        "showValues": true,
        "fromLabel": "Before",
        "toLabel": "After",
        "showLegend": true,
        "valueFormat": "compact",
        "showAxis": true,
        "showGrid": true,
        "opacity": 1
      }
    }
  ]
}
```

## Examples

### Conversion lift after redesign

Three funnel steps improving after a redesign, in percent.

API overrides that reproduce this example:

```json
{
  "change.colorByDirection": true,
  "change.showValues": true,
  "change.fromLabel": "Before",
  "change.toLabel": "After",
  "change.showLegend": true,
  "change.data": [
    {
      "label": "Signup",
      "from": 42,
      "to": 58
    },
    {
      "label": "Activate",
      "from": 25,
      "to": 39
    },
    {
      "label": "Paid",
      "from": 8,
      "to": 14
    }
  ],
  "change.valueFormat": "percent"
}
```

### Load time before/after

Page load times dropping after optimization (lower is better).

API overrides that reproduce this example:

```json
{
  "change.colorByDirection": false,
  "change.showValues": true,
  "change.fromLabel": "Before",
  "change.toLabel": "After",
  "change.showLegend": true,
  "change.data": [
    {
      "label": "Home",
      "from": 3.4,
      "to": 1.2
    },
    {
      "label": "Product",
      "from": 4.1,
      "to": 1.8
    },
    {
      "label": "Checkout",
      "from": 5.2,
      "to": 2.1
    }
  ],
  "change.toColor": "#16a34a",
  "change.fromColor": "#dc2626"
}
```

## API overrides

Push fresh rows per render with '<key>.data' (or just '<key>') as [{ label, from, to }]; colors, labels and format are overridable too.

Flat override payload (`key.property` addressing) with the sample design's current values — send only the keys you want to change:

```json
{
  "change.data": [
    {
      "label": "North",
      "from": 120,
      "to": 180
    },
    {
      "label": "South",
      "from": 90,
      "to": 140
    },
    {
      "label": "East",
      "from": 160,
      "to": 150
    },
    {
      "label": "West",
      "from": 70,
      "to": 130
    }
  ],
  "change.fromColor": "#94a3b8",
  "change.toColor": "#2563eb",
  "change.colorByDirection": true,
  "change.showValues": true,
  "change.fromLabel": "Q1",
  "change.toLabel": "Q2",
  "change.showLegend": true,
  "change.valueFormat": "compact",
  "change.showAxis": true,
  "change.showGrid": true,
  "change.opacity": 1
}
```

```bash
curl --location 'https://render.imejis.io/v1/{{YOUR_DESIGN_ID}}' \
--header 'dma-api-key: {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
    "change.data": [
        {
            "label": "North",
            "from": 120,
            "to": 180
        },
        {
            "label": "South",
            "from": 90,
            "to": 140
        },
        {
            "label": "East",
            "from": 160,
            "to": 150
        },
        {
            "label": "West",
            "from": 70,
            "to": 130
        }
    ],
    "change.fromColor": "#94a3b8",
    "change.toColor": "#2563eb",
    "change.colorByDirection": true,
    "change.showValues": true,
    "change.fromLabel": "Q1",
    "change.toLabel": "Q2",
    "change.showLegend": true,
    "change.valueFormat": "compact",
    "change.showAxis": true,
    "change.showGrid": true,
    "change.opacity": 1
}'
```

`{{YOUR_DESIGN_ID}}` and `{{YOUR_API_KEY}}` are placeholders: first create
the design in your account (paste the sample design JSON above into the
editor at https://app.imejis.io, or create it programmatically via the
imejis MCP server's `create_design` + `update_design` tools), then render
it with the design's id and one of your API keys.

Agents: the MCP server at https://api.imejis.io/api/mcp exposes this same
catalog as structured data via the `list_component_types` tool (property
kinds, allowed values, bounds, ready-to-use sample designs).

## Related

- [Dumbbell component](https://www.imejis.io/components/dumbbell.md) — full reference and FAQs
- [Dark](https://www.imejis.io/components/dumbbell/dark.md) — Light dots on a dark canvas for social cards.
